View Source otel_propagator_text_map behaviour (opentelemetry_api v1.0.3)

A TextMap Propagator is a Propagator that performs injection and extraction with ASCII keys and values.

An example of configuring the TextMap Propagator to inject and extract Baggage and TraceContext:

  {text_map_propagators, [trace_context, baggage]},

The propagators are then used at the points that cross service communication is performed. By default inject and extract work on a generic list of 2-tuple's with binary string keys and values. A user defined function for setting a key/value in the carrier and for getting the value of a key from a carrier can be passed as an argument. For example, injecting and extracting to and from Hackney headers could be done with Hackney specific functions:

  set_header(Key, Value, Headers) ->
    hackney_headers:store(Key, Value, Headers).
 
  some_fun_calling_hackney() ->
    Headers = otel_propagator_text_map:inject(opentelemetry:get_text_map_injector(), hackney_headers:new(), fun set_header/2),
    ...

An example of extraction in an Elli request handler:

  get_header(Req, Key) ->
    elli_request:get_header(Key, Req, Default).
 
  handle(Req, _Args) ->
    otel_propagator_text_map:extract(Req, fun get_header/2),
    ...
    {ok, [], <<"hello world">>}.

Link to this section Summary

Link to this section Types

Specs

carrier_get() ::
    fun((otel_propagator:carrier(), unicode:latin1_binary()) ->
            unicode:latin1_binary() | undefined).

Specs

carrier_keys() :: fun((otel_propagator:carrier()) -> [unicode:latin1_binary()]).

Specs

Link to this type

default_text_map_carrier/0

View Source

Specs

default_text_map_carrier() :: [{unicode:latin1_binary(), unicode:latin1_binary()}].

Specs

field_key() :: unicode:latin1_binary().

Specs

field_value() :: unicode:latin1_binary().

Specs

propagator_options() :: term().

Specs

t() :: module() | {module(), propagator_options()}.

Link to this section Callbacks

Link to this section Functions

Link to this function

default_carrier_get(Key, List)

View Source

Specs

default_carrier_get(field_key(), default_text_map_carrier()) -> field_value() | undefined.
Link to this function

default_carrier_keys(Rest)

View Source

Specs

default_carrier_keys(default_text_map_carrier()) -> [field_key()].
Link to this function

default_carrier_set(Key, Value, Rest)

View Source

Specs

Specs

Link to this function

extract(Propagator, Carrier)

View Source

Specs

Link to this function

extract(Propagator, Carrier, CarrierKeysFun, CarrierGetFun)

View Source

Specs

extract(otel_propagator:t(), otel_propagator:carrier(), fun(), fun()) -> otel_ctx:t().
Link to this function

extract_to(Context, Carrier)

View Source

Specs

Link to this function

extract_to(Context, Propagator, Carrier)

View Source

Specs

Link to this function

extract_to(Context, Module, Carrier, CarrierKeysFun, CarrierGetFun)

View Source

Specs

extract_to(otel_ctx:t(), otel_propagator:t(), otel_propagator:carrier(), fun(), fun()) ->
              otel_ctx:t().

Specs

fields(otel_propagator:t()) -> [field_key()].

Specs

Link to this function

inject(Propagator, Carrier)

View Source

Specs

Link to this function

inject(Propagator, Carrier, CarrierSetFun)

View Source

Specs

Link to this function

inject_from(Context, Carrier)

View Source

Specs

Link to this function

inject_from(Context, Propagator, Carrier)

View Source

Specs

Link to this function

inject_from(Context, Module, Carrier, CarrierSetFun)

View Source

Specs