otel: go.opentelemetry.io/otel/propagators Index | Examples | Files

package propagators

import "go.opentelemetry.io/otel/propagators"

Package propagators 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://w3c.github.io/baggage/).

Index

Examples

Package Files

baggage.go doc.go trace_context.go

type Baggage Uses

type Baggage struct{}

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://w3c.github.io/baggage/.

func (Baggage) Extract Uses

func (b Baggage) Extract(parent context.Context, carrier otel.TextMapCarrier) context.Context

Extract returns a copy of parent with the baggage from the carrier added.

func (Baggage) Fields Uses

func (b Baggage) Fields() []string

Fields returns the keys who's values are set with Inject.

func (Baggage) Inject Uses

func (b Baggage) Inject(ctx context.Context, carrier otel.TextMapCarrier)

Inject sets baggage key-values from ctx into the carrier.

type TraceContext Uses

type TraceContext struct{}

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.

Code:

tc := propagators.TraceContext{}
// Register the TraceContext propagator globally.
global.SetTextMapPropagator(tc)

func (TraceContext) Extract Uses

func (tc TraceContext) Extract(ctx context.Context, carrier otel.TextMapCarrier) context.Context

Extract reads tracecontext from the carrier into a returned Context.

func (TraceContext) Fields Uses

func (tc TraceContext) Fields() []string

Fields returns the keys who's values are set with Inject.

func (TraceContext) Inject Uses

func (tc TraceContext) Inject(ctx context.Context, carrier otel.TextMapCarrier)

Inject set tracecontext from the Context into the carrier.

Package propagators imports 9 packages (graph) and is imported by 3 packages. Updated 2020-10-19. Refresh now. Tools for package owners.