package propagation

Import Path
	go.opentelemetry.io/otel/propagation (on go.dev)

Dependency Relation
	imports 7 packages, and imported by 3 packages

Involved Source Files baggage.go Package propagation contains OpenTelemetry context propagators. OpenTelemetry propagators are used to extract and inject context data from and into messages exchanged by applications. The propagator supported by this package is the W3C Trace Context encoding (https://www.w3.org/TR/trace-context/), and W3C Baggage (https://www.w3.org/TR/baggage/). propagation.go trace_context.go
Code Examples package main import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" ) func main() { // Create a new composite text map propagator. propagator := propagation.NewCompositeTextMapPropagator( propagation.TraceContext{}, propagation.Baggage{}, ) // Set it as the global text map propagator. otel.SetTextMapPropagator(propagator) }
Package-Level Type Names (total 7)
/* sort by: | */
Baggage is a propagator that supports the W3C Baggage format. This propagates user-defined baggage associated with a trace. The complete specification is defined at https://www.w3.org/TR/baggage/. Extract returns a copy of parent with the baggage from the carrier added. If carrier implements [ValuesGetter] (e.g. [HeaderCarrier]), Values is invoked for multiple values extraction. Otherwise, Get is called. Fields returns the keys who's values are set with Inject. Inject sets baggage key-values from ctx into the carrier. Baggage : TextMapPropagator
HeaderCarrier adapts http.Header to satisfy the TextMapCarrier and ValuesGetter interfaces. Get returns the first value associated with the passed key. Keys lists the keys stored in this carrier. Set stores the key-value pair. Values returns all values associated with the passed key. HeaderCarrier : TextMapCarrier HeaderCarrier : ValuesGetter HeaderCarrier : github.com/redis/go-redis/v9.ConsistentHash
MapCarrier is a TextMapCarrier that uses a map held in memory as a storage medium for propagated key-value pairs. Get returns the value associated with the passed key. Keys lists the keys stored in this carrier. Set stores the key-value pair. MapCarrier : TextMapCarrier MapCarrier : github.com/redis/go-redis/v9.ConsistentHash
TextMapCarrier is the storage medium used by a TextMapPropagator. See ValuesGetter for how a TextMapCarrier can get multiple values for a key. Get returns the value associated with the passed key. Keys lists the keys stored in this carrier. Set stores the key-value pair. HeaderCarrier MapCarrier TextMapCarrier : github.com/redis/go-redis/v9.ConsistentHash func Baggage.Extract(parent context.Context, carrier TextMapCarrier) context.Context func Baggage.Inject(ctx context.Context, carrier TextMapCarrier) func TextMapPropagator.Extract(ctx context.Context, carrier TextMapCarrier) context.Context func TextMapPropagator.Inject(ctx context.Context, carrier TextMapCarrier) func TraceContext.Extract(ctx context.Context, carrier TextMapCarrier) context.Context func TraceContext.Inject(ctx context.Context, carrier TextMapCarrier)
TextMapPropagator propagates cross-cutting concerns as key-value text pairs within a carrier that travels in-band across process boundaries. Extract reads cross-cutting concerns from the carrier into a Context. Implementations may check if the carrier implements ValuesGetter, to support extraction of multiple values per key. Fields returns the keys whose values are set with Inject. Inject set cross-cutting concerns from the Context into the carrier. Baggage TraceContext func NewCompositeTextMapPropagator(p ...TextMapPropagator) TextMapPropagator func go.opentelemetry.io/otel.GetTextMapPropagator() TextMapPropagator func go.opentelemetry.io/otel/internal/global.TextMapPropagator() TextMapPropagator func NewCompositeTextMapPropagator(p ...TextMapPropagator) TextMapPropagator func go.opentelemetry.io/otel.SetTextMapPropagator(propagator TextMapPropagator) func go.opentelemetry.io/otel/internal/global.SetTextMapPropagator(p TextMapPropagator)
TraceContext is a propagator that supports the W3C Trace Context format (https://www.w3.org/TR/trace-context/) This propagator will propagate the traceparent and tracestate headers to guarantee traces are not broken. It is up to the users of this propagator to choose if they want to participate in a trace by modifying the traceparent header and relevant parts of the tracestate header containing their proprietary information. Extract reads tracecontext from the carrier into a returned Context. The returned Context will be a copy of ctx and contain the extracted tracecontext as the remote SpanContext. If the extracted tracecontext is invalid, the passed ctx will be returned directly instead. Fields returns the keys who's values are set with Inject. Inject injects the trace context from ctx into carrier. TraceContext : TextMapPropagator
ValuesGetter can return multiple values for a single key, with contrast to TextMapCarrier.Get which returns a single value. Values returns all values associated with the passed key. HeaderCarrier github.com/nats-io/nats.go.Header net/http.Header net/textproto.MIMEHeader
Package-Level Functions (only one)
NewCompositeTextMapPropagator returns a unified TextMapPropagator from the group of passed TextMapPropagator. This allows different cross-cutting concerns to be propagates in a unified manner. The returned TextMapPropagator will inject and extract cross-cutting concerns in the order the TextMapPropagators were provided. Additionally, the Fields method will return a de-duplicated slice of the keys that are set with the Inject method.