Span context propagation: connect traces across services safely
When Service A calls Service B, trace and parent-span context must travel with the call so both spans belong to one request flow. OpenTelemetry (OTel) context propagation carries execution context across process and service boundaries, usually through instrumentation libraries. If manual propagation is needed, the sender injects context into a carrier and the receiver validates/extracts it to parent a new child span.
When Service A calls Service B, trace and parent-span context must travel with the call so both spans belong to one request flow. OpenTelemetry (OTel) context propagation carries execution context across process and service boundaries, usually through instrumentation libraries. If manual propagation is needed, the sender injects context into a carrier and the receiver validates/extracts it to parent a new child span.
Context and propagation are different
Context is an object containing values for the current execution flow that correlate signals. Propagation serializes and transports that information across a network or process boundary, then reads it back. When A calls B, A's current span context is propagated and B creates a new span with that remote span as parent. This lets a backend display spans from multiple services as one trace.
The OTel Context specification is stable and Context is immutable. Languages differ in whether current context is implicit or passed explicitly. If the language uses attach/detach scope operations, restore the prior context with the matching token after the work finishes so it does not leak into a later request or task. Check the SDK documentation for language-specific APIs.
Linking a trace over HTTP
OTel's default propagation format uses W3C Trace Context headers. The traceparent header carries a version, trace ID, parent ID (the sender's span ID), and trace flags. Sender instrumentation injects the current context into HTTP headers; receiver instrumentation extracts it and uses it as the parent of the server span. The actual carrier can vary by protocol and configuration.
Frontend activates a server span for the incoming request.
When Frontend calls Product Catalog, HTTP client instrumentation injects the current context into request headers.
Product Catalog server instrumentation extracts the context and starts a new span under the same trace.
The backend groups spans exported by both services by trace ID and shows the request path.
Supported HTTP/RPC instrumentation libraries usually handle this automatically. For an unsupported asynchronous queue or custom transport, use the SDK Propagators API to inject on send and extract on receive. If the protocol has no metadata field, define where metadata is stored and remove it on receipt before processing so it does not interfere with payload interpretation.
Do not confuse baggage with trace context
Trace context contains values needed for trace correlation, such as trace ID, span ID, sampling flags, and trace state. Baggage is a separate store for arbitrary key-value context propagated between services. Baggage is not automatically added to span, metric, or log attributes just because it exists; code must explicitly read it and add selected values to signal attributes.
Baggage can be useful for passing limited classification context learned at request start to downstream calls. However, instrumentation may automatically propagate it with network requests. Never put passwords, API keys, authentication tokens, or personal data in baggage. Review propagator policy at trust boundaries so internal trace IDs or baggage are not sent to untrusted external endpoints.
Trust boundaries and troubleshooting
**Context arriving from outside:** Do not blindly trust client-supplied trace headers. Forged values can corrupt trace relationships or affect parsing. For external requests, ignore or validate/sanitize context according to policy.
**Context leaving the service:** Check whether internal trace/span IDs or baggage could be exposed to third parties; restrict propagation to public endpoints.
**A broken link:** Confirm sender injection and receiver extraction use compatible propagator/protocol settings; check that proxies and queues preserve headers or message metadata; confirm the receiving server span starts from the extracted context.
**Wrong parentage:** Check whether the receiver accidentally created a new root trace instead of using the remote parent. If unrelated requests inherit context, inspect async context restoration after each task.
**Language differences:** SDK APIs, default propagators, and library support vary by language and version even when concepts are shared. Verify the deployed implementation documentation.
Adoption checklist
Check OTel instrumentation and propagation support for the HTTP/RPC client and server libraries you use.
Choose the format and propagator for internal calls, and define separate inject/extract policy at external trust boundaries.
Allow only necessary baggage; prohibit sensitive data. Do not copy baggage into logs or metrics without review.
Send a representative request and verify that frontend and downstream spans share a trace. This article does not claim that this was tested in a particular service.
Sources and scope
OpenTelemetry, [Context propagation](https://opentelemetry.io/docs/concepts/context-propagation/)
OpenTelemetry, [Context specification](https://opentelemetry.io/docs/specs/otel/context/)
OpenTelemetry, [Propagators API](https://opentelemetry.io/docs/specs/otel/context/api-propagators/)
OpenTelemetry, [Baggage](https://opentelemetry.io/docs/concepts/signals/baggage/)
Based on official OpenTelemetry documentation reviewed on 2026-11-19. Covers default W3C Trace Context, Context immutability, Propagators API, and baggage security considerations. Language-specific implementation details and particular message-broker configuration are out of scope.