Expand description
Propagating W3C trace context on outbound calls.
TracePropagationInterceptor writes traceparent (and tracestate,
when there is one) onto every request the client sends, taking the value
from an ambient CurrentTrace scope. That indirection is the point: a
client is usually built once and reused for many delegated calls, so a
trace fixed at construction would label every one of them with the first
request’s trace.
§From inside an executor
// `ctx` is the `RequestContext` the server handed the executor. Its
// trace context already names *this* hop's span, so sending it verbatim
// makes the callee a child of this agent.
let Some(trace) = ctx.trace_context().cloned() else {
return delegate(&client, params).await; // caller was not tracing
};
CurrentTrace::scope(trace, delegate(&client, params)).await§Starting one
A chain has to begin somewhere. An agent that is the first hop — nothing
upstream sent it a traceparent — can start a trace with
CurrentTrace::start_root so that every agent below it reports the same
trace id.
This is propagation, not tracing. Nothing here records a span, measures a duration or exports anything; it carries the one identifier that lets whatever does record spans stitch the hops together, including across the Python, JavaScript, Go and Java agents the ITK already runs against.
Structs§
- Current
Trace - The trace the current task is running under.
- Trace
Propagation Interceptor - Writes the ambient
CurrentTraceonto each outbound request.