Lesson 6 / 25
Context Propagation
Passing trace IDs between services.
W3C Trace Context headers
For a trace to cross services, the caller must pass the context (trace ID, parent span ID, sampling decision) to the callee. OpenTelemetry uses the W3C Trace Context standard by default: a traceparent HTTP header, plus optional tracestate. Baggage carries additional key-value pairs (such as a tenant ID) across services. Instrumented HTTP clients inject the headers and instrumented servers extract them; for message queues, the context travels in message headers.
The traceparent header
Format: version-traceid-parentid-flags (example from the W3C specification).
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
| | | |
| trace-id (16 bytes, 32 hex) parent span id flags (01 = sampled)
version (8 bytes, 16 hex)
baggage: tenant.id=acme,plan=enterpriseBroken traces usually mean lost context
If traces stop at a service boundary, check that both sides are instrumented and that proxies or queues forward the headers.
Quick check: Which HTTP header carries W3C trace context?
- content-type
- x-request-id
- authorization
- traceparent
Answer
traceparent — tracestate and baggage are optional companions.