otel_propagator behaviour (OpenTelemetry API v1.4.0)

View Source

A Propagator injects or extracts data from a Context so information like baggage and trace context can be transported along with cross service requests, like an HTTP request.

Propagators are defined based on the type of encoding they inject and extract. At this time there is only a TextMapPropagator, otel_propagator_text_map, which works on ASCII keys and values.

This behaviour is only for defining the callbacks used by each propagator per type and is only used by developers adding a new type of propagator (like for binary protocols), not implementations of propagators themselves (like B3 or W3C TraceContext).

Users configure and call propagators based on their type. See the docs for otel_propagator_text_map for more details.

Summary

Types

A built-in propagator.

A carrier, which can be any type.

t/0

A propagator, which can be a built-in propagator, a module, or a module and associated term.

Callbacks

Extracts a value from a carrier.
Extracts a value from a carrier into a context.
Sets a value into a carrier.
Sets a value from a context into a carrier.

Types

builtin/0

-type builtin() :: trace_context | tracecontext | b3 | b3multi | baggage.

A built-in propagator.

carrier/0

-type carrier() :: term().

A carrier, which can be any type.

t/0

-type t() :: builtin() | module() | {module(), term()}.

A propagator, which can be a built-in propagator, a module, or a module and associated term.

Callbacks

extract/2

-callback extract(t(), carrier()) -> otel_ctx:t() | otel_ctx:token().
Extracts a value from a carrier.

extract_to/3

-callback extract_to(otel_ctx:t(), t(), carrier()) -> otel_ctx:t().
Extracts a value from a carrier into a context.

inject/2

-callback inject(t(), carrier()) -> carrier().
Sets a value into a carrier.

inject_from/3

-callback inject_from(otel_ctx:t(), t(), carrier()) -> carrier().
Sets a value from a context into a carrier.