opentelemetry.propagators.cloud_trace_propagator.CloudTraceOneWayPropagator

class opentelemetry.propagators.cloud_trace_propagator.CloudTraceOneWayPropagator[source]

Bases: CloudTraceFormatPropagator

This class extracts Trace Context in the Google Cloud format, but does not inject this header. It is intended for use in a Composite Propagator to inject context in a different format than was received.

Methods

extract

Create a Context from values in the carrier.

inject

Inject values from a Context into a carrier.

Attributes

fields

Gets the fields set in the carrier by the inject method.

extract(carrier, context=None, getter=<opentelemetry.propagators.textmap.DefaultGetter object>)

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) – 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 (TypeVar(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:

Context

Returns:

A Context with configuration found in the carrier.

property fields: Set[str]

Gets the fields set in the carrier by the inject method.

If the carrier is reused, its fields that correspond with the ones present in this attribute should be deleted before calling inject.

Returns:

A set with the fields set in inject.

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 (TypeVar(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) – An optional Setter object that can set values on the carrier.

Return type:

None