View Source otel_propagator_text_map behaviour (opentelemetry_api v1.3.0)

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

-type carrier_get() ::
    fun((unicode:latin1_binary(), otel_propagator:carrier()) ->
            unicode:latin1_binary() | undefined).
-type carrier_keys() :: fun((otel_propagator:carrier()) -> [unicode:latin1_binary()]).
Link to this type

default_text_map_carrier/0

View Source
-type default_text_map_carrier() :: [{unicode:latin1_binary(), unicode:latin1_binary()}].
-type field_key() :: unicode:latin1_binary().
-type field_value() :: unicode:latin1_binary().
-type propagator_options() :: term().
-type 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
-spec default_carrier_get(field_key(), default_text_map_carrier()) -> field_value() | undefined.
Link to this function

default_carrier_keys(Rest)

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

default_carrier_set(Key, Value, Rest)

View Source
-spec default_carrier_set(field_key(), field_value(), default_text_map_carrier()) ->
                       default_text_map_carrier().
-spec extract(otel_propagator:carrier()) -> otel_ctx:token().
Link to this function

extract(Propagator, Carrier)

View Source
Link to this function

extract(Propagator, Carrier, CarrierKeysFun, CarrierGetFun)

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

extract_to(Context, Carrier)

View Source
-spec extract_to(otel_ctx:t(), otel_propagator:carrier()) -> otel_ctx:t().
Link to this function

extract_to(Context, Propagator, Carrier)

View Source
Link to this function

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

View Source
-spec extract_to(otel_ctx:t(), otel_propagator:t(), otel_propagator:carrier(), fun(), fun()) ->
              otel_ctx:t().
-spec fields(otel_propagator:t()) -> [field_key()].
Link to this function

inject(Propagator, Carrier)

View Source
Link to this function

inject(Propagator, Carrier, CarrierSetFun)

View Source
Link to this function

inject_from(Context, Carrier)

View Source
Link to this function

inject_from(Context, Propagator, Carrier)

View Source
Link to this function

inject_from(Context, Module, Carrier, CarrierSetFun)

View Source