Overview
Propagators are used to extract and inject context data across service boundaries. They enable distributed tracing by passing trace context and baggage between services using standard formats like W3C Trace Context.Injector
Injects context into outgoing requests
Extractor
Extracts context from incoming requests
TextMapPropagator
TheTextMapPropagator trait defines the interface for context propagation using string key-value pairs:
Built-in propagators
OpenTelemetry Rust provides several standard propagators:W3C Trace Context
The default propagator implementing the W3C Trace Context specification:W3C Baggage
Propagates baggage according to the W3C Baggage specification:Composite propagator
Combine multiple propagators to support different formats:Jaeger propagator
For Jaeger-specific propagation format, use the separateopentelemetry-jaeger-propagator crate:
Injector and Extractor traits
Injector
TheInjector trait is implemented by carriers that can have context injected into them:
Extractor
TheExtractor trait is implemented by carriers that can have context extracted from them:
HTTP propagation example
Client-side injection
Inject context into HTTP headers:Server-side extraction
Extract context from incoming HTTP headers:Custom propagator
Implement a custom propagator for non-standard formats:Best practices
Always use composite propagator - Combine TraceContext and Baggage propagators to support both trace context and custom attributes.
Related
Context propagation
Learn about context flow
Baggage
Add custom attributes to context