Module otel_propagator_text_map

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

Behaviours: otel_propagator.

This module defines the otel_propagator_text_map behaviour.
Required callback functions: inject/4, extract/5, fields/1.

Description

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(Headers, Key, Value) ->
    hackney_headers:store(Key, Value, Headers).
 
  some_fun_calling_hackney() ->
    Headers = otel_propagator_text_map:inject(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">>}.

Data Types

carrier_get()

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

carrier_keys()

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

carrier_set()

carrier_set() = fun((otel_propagator:carrier(), unicode:latin1_binary(), unicode:latin1_binary()) -> otel_propagator:carrier())

default_text_map_carrier()

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

field_key()

field_key() = unicode:latin1_binary()

field_value()

field_value() = unicode:latin1_binary()

propagator_options()

propagator_options() = term()

t()

t() = module() | {module(), propagator_options()}

Function Index

default_carrier_get/2
default_carrier_keys/1
default_carrier_set/3
extract/1
extract/2
extract/4
extract_to/2
extract_to/3
extract_to/5
fields/1
inject/1
inject/2
inject/3
inject_from/2
inject_from/3
inject_from/4

Function Details

default_carrier_get/2

default_carrier_get(Key::field_key(), List::default_text_map_carrier()) -> field_value() | undefined

default_carrier_keys/1

default_carrier_keys(Rest::default_text_map_carrier()) -> [field_key()]

default_carrier_set/3

default_carrier_set(Key::field_key(), Value::field_value(), Rest::default_text_map_carrier()) -> default_text_map_carrier()

extract/1

extract(Carrier::otel_propagator:carrier()) -> otel_ctx:t()

extract/2

extract(Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier()) -> otel_ctx:t()

extract/4

extract(Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier(), CarrierKeysFun::function(), CarrierGetFun::function()) -> otel_ctx:t()

extract_to/2

extract_to(Context::otel_ctx:t(), Carrier::otel_propagator:carrier()) -> otel_ctx:t()

extract_to/3

extract_to(Context::otel_ctx:t(), Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier()) -> otel_ctx:t()

extract_to/5

extract_to(Context::otel_ctx:t(), Module::otel_propagator:t(), Carrier::otel_propagator:carrier(), CarrierKeysFun::function(), CarrierGetFun::function()) -> otel_ctx:t()

fields/1

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

inject/1

inject(Carrier::otel_propagator:carrier()) -> otel_propagator:carrier()

inject/2

inject(Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier()) -> otel_propagator:carrier()

inject/3

inject(Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier(), CarrierSetFun::function()) -> otel_propagator:carrier()

inject_from/2

inject_from(Context::otel_ctx:t(), Carrier::otel_propagator:carrier()) -> otel_propagator:carrier()

inject_from/3

inject_from(Context::otel_ctx:t(), Propagator::otel_propagator:t(), Carrier::otel_propagator:carrier()) -> otel_propagator:carrier()

inject_from/4

inject_from(Context::otel_ctx:t(), Module::otel_propagator:t(), Carrier::otel_propagator:carrier(), CarrierSetFun::function()) -> otel_propagator:carrier()


Generated by EDoc