Stage 6 · Operate
Tracing Practice
Context Propagation
Propagating W3C traceparent, baggage, and correlation IDs through HTTP, gRPC, and queues.
What Is Context Propagation?
Context propagation is the mechanism that carries trace context across service boundaries. Without it, each service creates an independent trace. With it, all spans from a single request are connected into one trace.
# Without propagation
Service A -> trace-1 (span-1)
Service B -> trace-2 (span-2) # disconnected!
Service C -> trace-3 (span-3) # disconnected!
# With propagation
Service A -> trace-1 (span-1)
Service B -> trace-1 (span-2) # connected via parent
Service C -> trace-1 (span-3) # connected via parentW3C Traceparent
The W3C Trace Context standard defines the traceparent header format. It carries the trace ID, parent span ID, and trace flags. This is the default propagator in OpenTelemetry and the recommended format for all new implementations.
traceparent: 00-abc123def456789a1b2c3d4e5f6a7b8c-d4e5f6a7b8c9-01
# Version: 00
# Trace ID: abc123def456789a1b2c3d4e5f6a7b8c (32 hex chars)
# Parent ID: d4e5f6a7b8c9 (16 hex chars)
# Trace Flags: 01 (sampled)Baggage
Baggage carries key-value pairs across service boundaries. Unlike trace context, baggage is application-defined. Use it to propagate user IDs, tenant IDs, or feature flags. Baggage is sent in the baggage header.
baggage: tenant_id=acme, user_role=admin, feature_flag=new-checkoutHTTP Propagation
HTTP propagation injects trace context into outgoing HTTP headers and extracts it from incoming headers. The OTel SDK handles this automatically for HTTP clients and servers when configured with the correct propagator.
gRPC Propagation
gRPC propagation uses metadata instead of HTTP headers. The OTel SDK provides gRPC interceptors that automatically inject and extract trace context from gRPC metadata.
Messaging Propagation
Message queues (Kafka, RabbitMQ, SQS) require special propagation. Trace context is carried in message headers or attributes. The producer injects context, and the consumer extracts it when processing the message.
# Producer injects traceparent in message headers
# Consumer extracts traceparent from message headers
# OTel Kafka instrumentation handles this automatically
producers:
- topic: orders
header propagation:
enabled: true
consumers:
- topic: orders
header propagation:
enabled: trueBroken propagation is the most common cause of disconnected traces. Verify that every service in the request path properly injects and extracts trace context. Use the trace ID from a known request to confirm end-to-end connectivity.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.