opentelemetry.propagators.textmap¶
Module contents¶
-
class
opentelemetry.propagators.textmap.
Getter
(*args, **kwds)[source]¶ Bases:
abc.ABC
,Generic
[opentelemetry.propagators.textmap.CarrierT
]This class implements a Getter that enables extracting propagated fields from a carrier.
-
abstract
get
(carrier, key)[source]¶ Function that can retrieve zero or more values from the carrier. In the case that the value does not exist, returns None.
- Parameters
carrier (~CarrierT) – An object which contains values that are used to construct a Context.
key (
str
) – key of a field in carrier.
- Returns: first value of the propagation key or None if the key doesn’t
exist.
-
abstract
-
class
opentelemetry.propagators.textmap.
Setter
(*args, **kwds)[source]¶ Bases:
abc.ABC
,Generic
[opentelemetry.propagators.textmap.CarrierT
]This class implements a Setter that enables injecting propagated fields into a carrier.
-
class
opentelemetry.propagators.textmap.
DefaultGetter
(*args, **kwds)[source]¶ Bases:
opentelemetry.propagators.textmap.Getter
[Mapping
[str
,Union
[List
[str
],str
]]]
-
class
opentelemetry.propagators.textmap.
DefaultSetter
(*args, **kwds)[source]¶ Bases:
opentelemetry.propagators.textmap.Setter
[MutableMapping
[str
,Union
[List
[str
],str
]]]
-
class
opentelemetry.propagators.textmap.
TextMapPropagator
[source]¶ Bases:
abc.ABC
This class provides an interface that enables extracting and injecting context into headers of HTTP requests. HTTP frameworks and clients can integrate with TextMapPropagator by providing the object containing the headers, and a getter and setter function for the extraction and injection of values, respectively.
-
abstract
extract
(carrier, context=None, getter=<opentelemetry.propagators.textmap.DefaultGetter object>)[source]¶ Create a Context from values in the carrier.
The extract function should retrieve values from the carrier object using getter, and use values to populate a Context value and return it.
- Parameters
getter (
Getter
[~CarrierT]) – a function that can retrieve zero or more values from the carrier. In the case that the value does not exist, return an empty list.carrier (~CarrierT) – and object which contains values that are used to construct a Context. This object must be paired with an appropriate getter which understands how to extract a value from it.
context (
Optional
[Context
]) – an optional Context to use. Defaults to root context if not set.
- Return type
- Returns
A Context with configuration found in the carrier.
-
abstract
inject
(carrier, context=None, setter=<opentelemetry.propagators.textmap.DefaultSetter object>)[source]¶ Inject values from a Context into a carrier.
inject enables the propagation of values into HTTP clients or other objects which perform an HTTP request. Implementations should use the
Setter
‘s set method to set values on the carrier.- Parameters
carrier (~CarrierT) – An object that a place to define HTTP headers. Should be paired with setter, which should know how to set header values on the carrier.
context (
Optional
[Context
]) – an optional Context to use. Defaults to current context if not set.setter (
Setter
[~CarrierT]) – An optionalSetter
object that can set values on the carrier.
- Return type
-
abstract