Expand description
W3C Trace Context propagation.
Propagation is default-on and dependency-free — a trace_id shared
across the whole agent tree (ingested from an upstream traceparent or
minted from the run id), threaded into every process’s log lines, the spawn
payload, and outbound MCP _meta. So a single run — supervisor + every
subagent + every tool call — is one correlatable, auditable trace, with no
collector required. Span export (OTLP) is the only otel-gated part.
traceparent = 00-<32-hex trace-id>-<16-hex span-id>-<2-hex flags>.
Structs§
- Trace
Context - A W3C trace context for one process: the shared trace id, this process’s span id, and the sampling flags.
Functions§
- new_
span_ id - A fresh 8-byte (16-hex) span id, unique per call (time ⊕ pid ⊕ counter).
Public so the
otelspan export can mint child span ids under the run trace. - outbound_
traceparent - An outbound
traceparentfor a given trace id with a fresh child span — for stamping onto MCP_meta/ the LLM header so downstream services see this agent as their parent (W3C-correct). - parse
- Parse a
traceparent. ReturnsNonefor any malformed or all-zero (invalid per spec) value. - resolve
- Resolve the trace context for a run: continue an upstream
traceparentif a valid one is supplied (same trace id, fresh span), else mint a fresh trace deterministically from the run id (so retries of a run share a trace id).