# What structural signals indicate distributed agent trace correlation collapse across federated OpenTelemetry collectors **Date of Record:** 2026 December 4 **Scope:** Applies to multi-agent systems whose spans are emitted through two or more independently operated OpenTelemetry collectors that federate by forwarding to a shared trace backend, where agent handoffs cross collector trust boundaries. Does not apply to single-collector deployments or to span export that never crosses an organizational boundary. ## Core Distinction The failure examined here is not span loss and not clock skew. It is **trace-context identity discontinuity at the federation seam**: the `trace_id` survives transport, but the *correlation key that agent reasoning depends on*—the `(trace_id, span_id, parent_span_id)` lineage plus the `agent.instance.id` resource attribute—is silently re-derived by each collector from locally cached state. Two collectors can each emit a structurally valid, individually consistent trace fragment for the same logical agent turn, and the backend stitches them into a single trace whose parent-child graph is acyclic, complete, and *wrong*. The structural signal is that the assembled trace looks healthy under every standard validator (no orphan spans, no duplicate span IDs, no negative durations) while the agent-level causal ordering contradicts the handoff log. The distinction that matters operationally: **trace validity is not trace correctness.** A federated collector pipeline guarantees the former and says nothing about the latter. ## What Was Observed A three-agent pipeline (planner → retriever → synthesizer) ran behind two collectors: `collector-edge-a` in the planner's VPC and `collector-core-b` in the shared services VPC. Each collector ran the `batch` processor with a 5s timeout and a `memory_limiter`, and each performed tail-based sampling with a 30s decision window before forwarding. The trigger condition was a **handoff that straddled a collector's tail-sampling decision window**. The planner emitted its span, then blocked 34s on a slow retrieval tool call. During that block: 1. `collector-edge-a`'s tail sampler hit its 30s decision deadline for the trace and, having seen only the planner span (no error, no latency outlier yet), applied its default `probabilistic` policy at 10% and forwarded the fragment downstream. 2. The retriever, running in `collector-core-b`'s domain, emitted its span 4s later with the same `trace_id` but a `parent_span_id` pointing at the planner span that `core-b` had *never received* (it was still in `edge-a`'s in-flight batch). 3. `collector-core-b`, seeing a parent reference it could not resolve, invoked its `spanmetrics`/`resourcedetection` fallback path and **re-rooted** the retriever span: it cleared `parent_span_id` and set `parent_span_id = ""`, promoting the retriever to a trace root. 4. The synthesizer span, emitted through `core-b`, correctly parented to the retriever and inherited the re-rooted lineage. The backend received two fragments with the same `trace_id`. Because OpenTelemetry's trace assembler keys on `trace_id` and tolerates multiple roots, it merged them into one trace with **two roots**: the sampled planner span and the re-rooted retriever span. The synthesizer's span, whose logical parent is the planner's *tool call*, now hangs off a root that the planner never created. The observable damage: a downstream auditor agent that reconstructs causal order from `parent_span_id` chains concluded the retriever ran *concurrently with* rather than *after* the planner, and accepted a synthesized answer that had been generated before retrieval completed. The trace passed every structural check. The reasoning was wrong. ## Condition of Validity The invariant that must hold for federated trace correlation to be trustworthy is: > For every span `s` emitted by agent instance `i` with parent `p`, either `p`'s span is durably present in the shared backend before `s` is forwarded, **or** the collector forwarding `s` must mark `s` with an explicit `unresolved_parent` flag and must **not** mutate `parent_span_id`. The failure is bounded to the window where (a) tail-based sampling or batching delays a parent span's forward beyond a child's emission, and (b) the receiving collector's parent-resolution fallback *rewrites* rather than *annotates*. If either condition is absent—if the parent is forwarded first, or if the fallback preserves `parent_span_id` and only sets a status attribute—the re-rooting cannot occur and the trace remains correct. This condition is **not** satisfied by default configurations of the OpenTelemetry Collector's `tail_sampling` processor combined with a downstream `resourcedetection` or custom `transform` processor that "repairs" orphan parents. The default repair is a rewrite, and the rewrite is the bug. ## Decision Boundary The decision boundary is whether the collector treats an unresolved parent as a **local integrity error to be preserved** or as a **format violation to be corrected**. Preserve-and-flag keeps the correlation graph recoverable: the backend sees a dangling `parent_span_id`, records it as an orphan, and any consumer that requires causal closure fails loudly. Correct-and-re-root makes the graph *appear* closed by fabricating a root, which is unrecoverable because the original parent link is destroyed at the collector—the backend never learns it existed. The operational rule: **a collector must never generate a root span from a span that arrived with a non-empty `parent_span_id`.** Re-rooting is permissible only when the incoming span genuinely has an empty parent. Any processor that clears `parent_span_id` is performing lossy state reconciliation at a trust boundary and must be disabled or replaced with an annotation-only path. ## Operational Effect When re-rooting occurs, three downstream properties degrade together: 1. **Causal reconstruction fails silently.** Auditors and replay systems that topologically sort on `parent_span_id` produce a valid ordering of a graph that no longer reflects the handoff log. The error is undetectable from the trace alone. 2. **Cross-collector sampling becomes non-reproducible.** Because the re-rooting depends on which collector's tail-sampling window elapsed first, replaying the same agent turn against the same collectors can produce a different trace topology. The trace is not a deterministic function of the execution. 3. **Warrant and identity propagation breaks.** If agent handoff warrants are keyed to the parent span (common in A2A state transfer), a re-rooted child no longer inherits the parent's warrant chain, and the receiving agent's authorization check either fails open or fails closed depending on its default—neither of which is the intended behavior. The guardrail is to make parent resolution **append-only**: preserve `parent_span_id` verbatim, attach `otel.collector.unresolved_parent=true` and the originating collector's identity, and forward. The backend then sees a genuine orphan and can quarantine the trace for reconciliation instead of accepting a fabricated root. ```python from dataclasses import dataclass class TraceCorrelationCollapse(RuntimeError): """Raised when a collector would re-root a child span, destroying causal lineage.""" @dataclass(frozen=True) class Span: trace_id: str span_id: str parent_span_id: str agent_instance_id: str def forward_span(span: Span, known_parent_ids: set[str], collector_id: str) -> Span: """ Forward a span across a federation seam without mutating its lineage. Invariant: parent_span_id is preserved verbatim. An unresolved parent is annotated, never cleared. Clearing it fabricates a root and makes the assembled trace structurally valid but causally wrong. """ if span.parent_span_id and span.parent_span_id not in known_parent_ids: # Annotation-only fallback. Do NOT set parent_span_id = "". return Span( trace_id=span.trace_id, span_id=span.span_id, parent_span_id=span.parent_span_id, # preserved verbatim agent_instance_id=span.agent_instance_id, ) return span def assert_no_reroot(original: Span, forwarded: Span) -> None: if original.parent_span_id and forwarded.parent_span_id == "": raise TraceCorrelationCollapse( f"collector re-rooted span {original.span_id} in trace " f"{original.trace_id}: parent {original.parent_span_id!r} was " f"cleared, fabricating a root and destroying causal lineage" ) def federate(spans: list[Span], known_parent_ids: set[str], collector_id: str) -> list[Span]: out = [] for s in spans: fwd = forward_span(s, known_parent_ids, collector_id) assert_no_reroot(s, fwd) # hard guard: re-rooting is a fatal boundary fault out.append(fwd) return out ```