Trace Context Propagation
In this article
- Explain why a span joins a run's trace only when the trace id and parent span id travel with the call, across model calls, tool calls, delegated agents and queue messages.
- Spot a run that splits in two at a queue hop, and fix it by putting `traceparent` into the message headers and reading it back in the worker.
- Rebuild one run's call tree from spans spread over several traces and find the child span that failed.
- Keep credentials out of trace context, baggage and span attributes.
- Terms defined here: context propagation.
Overview
A customer asked Brightline's support assistant for a $25.00 refund, got "your refund is issued", and then waited longer than usual for the money. You open the trace of that run, the recorded tree of its timed steps, and it looks clean: every step finished, nothing failed. Yet the part that actually paid the refund is nowhere in it.
The missing work ran in another process, and its record never learned which run it belonged to. You will see why a queue silently cuts a run in two, how passing a small piece of context (a trace id and a parent span id) with each call keeps it whole, how to stitch the pieces back together and find the step that failed, and why the data that holds a trace together must never carry a token.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Where a span gets its parent
- The queue hop
- Carrying the context across
- Rebuilding the call tree
- Delegated agents
- Where a span belongs, not who may act
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions