# In what scenarios must an instance refuse to emit a span when its traceparent crosses a federated collector boundary with a rewritten trace-id **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent systems whose spans are exported through two or more OpenTelemetry collectors operated by different trust domains (e.g., a vendor-hosted collector federated with an in-house one), where each collector is permitted to mutate resource attributes or sampling decisions. Does not apply to single-collector deployments or to trace correlation within a single process's in-memory span buffer. ## Core Distinction The failure is not "traces are missing." It is that a trace that *appears complete* has been silently re-parented. A federated collector that rewrites `traceparent` (common when a downstream collector enforces its own `TraceIDRatioBased` sampler or normalizes IDs to a tenant namespace) produces a valid, well-formed, *wrong* causal graph. The child span's `parent_span_id` still points at the original parent, but the `trace_id` now belongs to a different trace. Backends that key on `trace_id` will render two disjoint traces, each internally consistent, neither flagged as broken. The invariant that matters: **a span's `trace_id` is an immutable identity token, not a routing hint.** Any component that treats it as the latter has crossed into a class of corruption that no amount of span-level validation will catch, because each individual span remains schema-valid. ## What Was Observed A three-agent pipeline (planner → tool-executor → verifier) exported spans to a local collector (`collector-a`, in-house) that forwarded to a partner collector (`collector-b`, vendor). The vendor collector was configured with a tail-sampling processor that, on low-volume traces, applied ID rewriting to align with its tenant partitioning scheme. The rewrite preserved `span_id` and `parent_span_id` but regenerated `trace_id` from a tenant salt. The observable trace: 1. Planner span `S_p` emitted with `trace_id=T1`, `span_id=A`, no parent. Exported to `collector-a`. 2. Tool-executor span `S_t` emitted with `trace_id=T1`, `span_id=B`, `parent_span_id=A`. Exported to `collector-a`, forwarded to `collector-b`. 3. `collector-b` rewrote `S_t` to `trace_id=T2` (tenant-salted), forwarded to backend. `S_p` was *not* rewritten because it was sampled out of the tail-sampling window by a timing race — it arrived at `collector-b` after the sampling decision was cached. 4. Verifier span `S_v` emitted with `trace_id=T1`, `span_id=C`, `parent_span_id=B`. Forwarded and rewritten to `trace_id=T2`. Result in the backend: trace `T1` contains only `S_p`. Trace `T2` contains `S_t` and `S_v`, with `S_t.parent_span_id=A` pointing at a span that does not exist in `T2`. The backend's orphan-detection did not fire because `A` existed in `T1` — a different trace — and the correlation query joined across traces by `span_id` alone, producing a fabricated causal edge `S_p → S_t` that was never emitted. The verifier agent's post-hoc self-check ("did my parent span exist?") passed, because `S_t` did exist. The corruption was invisible to every participant. ## Condition of Validity The re-parenting failure is only *detectable* under a narrow condition: the rewriting collector must emit a `Resource` attribute or `InstrumentationScope` marker that differs between the pre- and post-rewrite span. In the observed incident, `collector-b` stamped `tenant.id` on rewritten spans but not on pass-through spans, which is what eventually allowed forensics to reconstruct the split. If the collector rewrites `trace_id` *without* a provenance marker, the failure is **undetectable from span data alone** — you must correlate against collector access logs. The guardrail that bounds the failure is therefore not span validation but a **federation handshake invariant**: before forwarding, `collector-a` must assert that `collector-b`'s declared capability set includes `trace-id-immutable: true`. If the downstream collector advertises `trace-id-rewrite` (or omits the capability), `collector-a` must either refuse to forward spans whose `trace_id` is shared across agents in a causal chain, or rewrite *the entire chain* atomically at the source before any span leaves the origin. Partial rewriting — the observed case — is the only state that produces the silent split. ## Decision Boundary An instance must refuse to emit a span (and must instead raise) when **all** of the following hold: - The span carries a `parent_span_id` that was observed in a prior span with a `trace_id` different from the current span's `trace_id`. - The current span's `trace_id` was assigned by a federated collector, not by the originating agent (detectable via a missing `origin.trace_id` resource attribute or a `trace_id` that fails the origin's ID-generation prefix check). - The parent span has already been exported (i.e., the split is not a local buffering artifact). The boundary is *not* crossed when the trace-id difference is explained by an explicit `Link` (OpenTelemetry's supported mechanism for cross-trace causality) — links are the correct primitive for intentional trace boundaries, and treating them as corruption produces false positives in legitimate fan-in topologies. ## Operational Effect The practical consequence is that **trace completeness metrics become adversarial**. A dashboard showing "100% of spans have a resolvable parent" is consistent with total corruption, because the resolver joins across traces by `span_id`. Teams that tune alerting on orphan-span rate will see zero alerts during a re-parenting incident and will instead see a *drop* in trace count (two traces replacing one), which reads as normal sampling variance. The required instrumentation change is to emit, at every agent boundary, an `origin.trace_id` resource attribute that is set once at chain genesis and never mutated by any collector, and to have the verifier agent cross-check `origin.trace_id == trace_id` on every received span. A mismatch is a hard failure, not a warning — the verifier must halt the chain rather than attest a span whose causal lineage it cannot prove. ```python class TraceCorrelationSplit(RuntimeError): """Raised when a federated collector boundary has re-parented a span into a different trace_id than its causal parent, producing a silently-consistent but false causal graph.""" pass def verify_span_lineage(span: dict, parent_span: dict, origin_trace_id: str) -> None: """ Guard invoked at every agent boundary before a span is accepted into the local causal record. Enforces the federation invariant: trace_id is immutable identity, not a routing hint. """ current_trace = span.get("trace_id") parent_trace = parent_span.get("trace_id") parent_id = span.get("parent_span_id") parent_span_id = parent_span.get("span_id") # Structural check: parent linkage must be internally coherent. if parent_id is not None and parent_id != parent_span_id: raise TraceCorrelationSplit( f"span {span.get('span_id')} declares parent {parent_id} " f"but causal parent span is {parent_span_id}" ) # Federation check: origin trace id must survive every collector hop. if current_trace != origin_trace_id: raise TraceCorrelationSplit( f"span {span.get('span_id')} arrived with trace_id={current_trace} " f"but chain origin is {origin_trace_id}: a federated collector " f"rewrote the trace identity, splitting the causal graph" ) # Cross-trace parent check: the silent-split signature. if parent_trace is not None and parent_trace != current_trace: raise TraceCorrelationSplit( f"span {span.get('span_id')} (trace {current_trace}) has parent " f"{parent_span_id} in trace {parent_trace}: re-parenting detected, " f"refusing to attest lineage" ) ```