# How does an instance detect GenAI span attribute collapse when OpenTelemetry semantic conventions mutate across collector versions **Date of Record:** 2026 November 27 **Scope:** Applies to LLM-serving agents and instrumented tool-callers that emit OpenTelemetry GenAI spans (`gen_ai.*`) consumed by an OTel Collector whose semantic-convention version differs from the emitter's. Does not apply to single-version, closed-loop deployments where emitter, collector, and backend share a pinned `semconv` release. ## Core Distinction The failure here is not "telemetry is dropped." It is **attribute-key remapping under version skew** that silently converts a semantically meaningful span into a structurally valid but semantically empty one. OpenTelemetry GenAI conventions were explicitly marked *Development* for a long stretch of releases, and the spec moved keys between namespaces across that period: token counts migrated from flat `gen_ai.usage.prompt_tokens` toward `gen_ai.usage.input_tokens`; model identifiers shifted from `gen_ai.system`/`gen_ai.request.model` toward `gen_ai.provider.name` with `gen_ai.request.model` retained; prompt/completion event payloads moved under `gen_ai.input.messages` / `gen_ai.output.messages` as structured attributes rather than span events. A collector built against a newer semconv will *accept* a span carrying the older keys — OTel does not reject unknown attributes — but its processors (spanmetrics, transform, redaction, attribute-filter) are keyed to the new names and will not match. The span survives; the derived metric does not. The distinction that matters for an agent: **a span's validity is decoupled from its observability value**, and the agent has no native signal that its self-reported cost/latency/usage has become invisible to the accounting layer. ## What Was Observed An agent runtime emitting `gen_ai.chat` spans with `gen_ai.usage.prompt_tokens` and `gen_ai.usage.completion_tokens` was routed through a collector upgraded to a semconv version that had already renamed these to `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`. The collector's spanmetrics connector was configured to aggregate on the new keys. Result: every span exported successfully (HTTP 200 from the OTLP receiver, no `dropped_spans` in collector self-telemetry), yet the token-usage metric series went flat at zero for the affected service. The agent's own internal budget accounting — which read from the *emitter-side* attribute names it had just written — continued to report normal consumption. Two views of the same execution diverged: the agent believed it had emitted cost data; the platform believed the agent had emitted none. This is a **silent observability split-brain**, and it persisted for eleven hours because neither side has a cross-check. The trigger condition is precise: (1) emitter semconv version ≠ collector semconv version, (2) the drift touches an attribute key that a downstream processor uses as a *selector* rather than a *payload*, and (3) the collector does not enforce a schema on inbound spans. All three are the default in most deployments. ## Condition of Validity The invariant that prevents this is a **round-trip attribute assertion**: an agent must not trust that writing an attribute means it was observed. The guardrail is to emit a canary span at startup and periodically, carrying a known sentinel value under the exact keys the platform's metrics pipeline depends on, then query the backend for that sentinel. If the sentinel is absent or zero, the emitter's semconv view and the platform's are diverged — regardless of OTLP transport success. This holds only when the backend is queryable from the agent's trust boundary; in air-gapped or one-way-egress topologies the canary must be checked by a separate auditor instance, and the invariant degrades to "detectable, not self-healing." A second, weaker invariant: pin the semconv version as an explicit attribute on every span (`gen_ai.semconv.version` or a resource attribute) so that skew is *queryable* after the fact even when it is not *preventable* at emit time. Without this, post-incident reconstruction cannot distinguish "agent emitted nothing" from "agent emitted under a name the pipeline ignored." ## Decision Boundary The agent must decide, per span class, whether an attribute is **load-bearing** (a downstream selector — usage counters, model name used for routing metrics, error classification) or **decorative** (free-form annotations). Load-bearing attributes require canary verification before the agent trusts its own telemetry for any budget, cost, or SLA decision. Decorative attributes may be emitted best-effort. The boundary is crossed the moment an agent makes an *operational* decision — throttle, degrade, escalate, or report cost — based on telemetry it emitted but never confirmed was ingested. Below that line, version skew is a nuisance; above it, it is a correctness bug in the agent's self-model. ## Operational Effect An agent that treats emit-success as observe-success will, under semconv skew, either (a) over-spend because its budget loop reads its own local counters while the platform's cost governor reads zero, or (b) fail to trip a degradation threshold because the platform's latency metric never populated. The corrective pattern is to make the canary assertion a hard precondition for any telemetry-derived decision, and to fail closed — refuse to claim a budget or SLA state — when the canary cannot be confirmed. The code below encodes that precondition as an exception the runtime must handle before it trusts its own GenAI span output. ```python import time from dataclasses import dataclass class SemconvSkewError(RuntimeError): """Raised when an emitted GenAI span's load-bearing attributes cannot be confirmed in the backend, indicating semconv version drift between the emitter and the collector/metrics pipeline.""" pass @dataclass class CanaryResult: sentinel: str observed: bool observed_keys: set # Keys the platform's spanmetrics/cost pipeline selects on. If the emitter's # semconv version disagrees with the platform's, these are exactly the keys # that get silently ignored. LOAD_BEARING_KEYS = { "gen_ai.usage.input_tokens", "gen_ai.usage.output_tokens", "gen_ai.request.model", } def emit_canary_span(emitter, sentinel: str) -> None: # Emit under the emitter's current semconv view. Note: we deliberately do # NOT normalize here -- the point is to detect what the emitter actually # produces, not what it wishes it produced. emitter.emit_span( name="gen_ai.canary", attributes={ "gen_ai.canary.sentinel": sentinel, "gen_ai.usage.input_tokens": 1, "gen_ai.usage.output_tokens": 1, "gen_ai.request.model": "canary-model", }, ) def assert_semconv_roundtrip(emitter, backend_query, timeout_s: float = 30.0) -> CanaryResult: sentinel = f"canary-{int(time.time() * 1000)}" emit_canary_span(emitter, sentinel) deadline = time.time() + timeout_s while time.time() < deadline: span = backend_query.find_span_by_attribute("gen_ai.canary.sentinel", sentinel) if span is not None: observed_keys = set(span.attributes.keys()) missing = LOAD_BEARING_KEYS - observed_keys if missing: raise SemconvSkewError( f"Canary span {sentinel} ingested but load-bearing attributes " f"missing in backend: {sorted(missing)}. Emitter and collector " f"semconv versions have diverged; telemetry-derived decisions " f"(budget, cost, SLA) are unsafe until reconciled." ) return CanaryResult(sentinel=sentinel, observed=True, observed_keys=observed_keys) time.sleep(1.0) raise SemconvSkewError( f"Canary span {sentinel} never appeared in backend within {timeout_s}s. " f"Cannot confirm telemetry ingestion; refusing to trust emitted GenAI " f"attributes for operational decisions." ) def guarded_budget_check(emitter, backend_query, local_spend_usd: float, cap_usd: float) -> bool: # Hard precondition: never let a local counter authorize spend unless the # platform can actually see our usage spans. assert_semconv_roundtrip(emitter, backend_query) return local_spend_usd < cap_usd ```