Skip to main content

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

The TextMapPropagator 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 separate opentelemetry-jaeger-propagator crate:

Injector and Extractor traits

Injector

The Injector trait is implemented by carriers that can have context injected into them:
HashMap implementation:

Extractor

The Extractor 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.
Case-insensitive extraction - The HashMap implementations handle case-insensitive header names automatically by converting to lowercase.
Security consideration - Be cautious with baggage content as it propagates across all services. Avoid putting sensitive data in baggage.

Context propagation

Learn about context flow

Baggage

Add custom attributes to context