Skip to main content

cap_external_string

Function cap_external_string 

Source
pub fn cap_external_string(
    field: &'static str,
    raw: String,
    max_bytes: u16,
) -> String
Expand description

Cap an external string at max_bytes (UTF-8-safe boundary), append the …<truncated:N> suffix when the input was clipped, and emit one ObsLabelOversized self-event for telemetry. Returns the (possibly truncated) string. Spec 95 § 3.10 / P2-AH.

Boundary callers (HTTP middleware, bridge field visitor) should run this on every untrusted string before it lands in env.labels or the typed payload.