Top Description Fields Constructors Methods
io.opentelemetry.api.trace.propagation

public final Class W3CTraceContextPropagator

extends Object
implements TextMapPropagator
Class Inheritance
All Implemented Interfaces
io.opentelemetry.context.propagation.TextMapPropagator
Annotations
@Immutable
Static Imports
io.opentelemetry.api.trace.propagation.internal.W3CTraceContextEncoding.decodeTraceState, .W3CTraceContextEncoding.encodeTraceState

Implementation of the W3C TraceContext propagation protocol. See W3C Trace Context.

This is the default propagator for SpanContexts. The SpanContext type is designed to support all the data propagated via W3C propagation natively.

Field Summary

Modifier and TypeField and Description
private static final List<String>
private static final W3CTraceContextPropagator
private static final Logger
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
pack-priv static final String
pack-priv static final String
private static final char
private static final int
private static final int
private static final Set<String>
private static final String
private static final String
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public <C> Context
extract(Context
the Context used to store the extracted value.
context
,
C
holds propagation fields. For example, an outgoing message or http request.
carrier
,
TextMapGetter<C>
invoked for each propagation key to get data from the carrier.
getter
)

Implements io.opentelemetry.context.propagation.TextMapPropagator.extract.

Extracts data from upstream.

private static SpanContext
private static <C> SpanContext
extractImpl(C carrier, TextMapGetter<C> getter)

public Collection<String>
fields()

Implements io.opentelemetry.context.propagation.TextMapPropagator.fields.

The propagation fields defined.

public static W3CTraceContextPropagator
getInstance()

Returns a singleton instance of a TextMapPropagator implementing the W3C TraceContext propagation.

public <C> void
inject(Context
the Context containing the value to be injected.
context
,
C
holds propagation fields. For example, an outgoing message or http request.
carrier
,
TextMapSetter<C>
invoked for each propagation key to add or remove.
setter
)

Implements io.opentelemetry.context.propagation.TextMapPropagator.inject.

Injects data for downstream consumers, for example as HTTP headers.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

FIELDSback to summary
private static final List<String> FIELDS
INSTANCEback to summary
private static final W3CTraceContextPropagator INSTANCE
loggerback to summary
private static final Logger logger
SPAN_ID_HEX_SIZEback to summary
private static final int SPAN_ID_HEX_SIZE
SPAN_ID_OFFSETback to summary
private static final int SPAN_ID_OFFSET
TRACE_ID_HEX_SIZEback to summary
private static final int TRACE_ID_HEX_SIZE
TRACE_ID_OFFSETback to summary
private static final int TRACE_ID_OFFSET
TRACE_OPTION_HEX_SIZEback to summary
private static final int TRACE_OPTION_HEX_SIZE
TRACE_OPTION_OFFSETback to summary
private static final int TRACE_OPTION_OFFSET
TRACE_PARENTback to summary
pack-priv static final String TRACE_PARENT
TRACE_STATEback to summary
pack-priv static final String TRACE_STATE
TRACEPARENT_DELIMITERback to summary
private static final char TRACEPARENT_DELIMITER
TRACEPARENT_DELIMITER_SIZEback to summary
private static final int TRACEPARENT_DELIMITER_SIZE
TRACEPARENT_HEADER_SIZEback to summary
private static final int TRACEPARENT_HEADER_SIZE
VALID_VERSIONSback to summary
private static final Set<String> VALID_VERSIONS
VERSIONback to summary
private static final String VERSION
VERSION_00back to summary
private static final String VERSION_00
VERSION_SIZEback to summary
private static final int VERSION_SIZE

Constructor Detail

W3CTraceContextPropagatorback to summary
private W3CTraceContextPropagator()

Method Detail

extractback to summary
public <C> Context extract(Context context, C carrier, TextMapGetter<C> getter)

Implements io.opentelemetry.context.propagation.TextMapPropagator.extract.

Doc from io.opentelemetry.context.propagation.TextMapPropagator.extract.

Extracts data from upstream. For example, from incoming http headers. The returned Context should contain the extracted data, if any, merged with the data from the passed-in Context.

If the incoming information could not be parsed, implementations MUST return the original Context, unaltered.

Parameters
<C>
the type of carrier of the propagation fields, such as an http request.
context:Context

the Context used to store the extracted value.

carrier:C

holds propagation fields. For example, an outgoing message or http request.

getter:TextMapGetter<C>

invoked for each propagation key to get data from the carrier.

Returns:Context

the Context containing the extracted data.

Annotations
@Override
extractContextFromTraceParentback to summary
private static SpanContext extractContextFromTraceParent(String traceparent)
extractImplback to summary
private static <C> SpanContext extractImpl(C carrier, TextMapGetter<C> getter)
fieldsback to summary
public Collection<String> fields()

Implements io.opentelemetry.context.propagation.TextMapPropagator.fields.

Doc from io.opentelemetry.context.propagation.TextMapPropagator.fields.

The propagation fields defined. If your carrier is reused, you should delete the fields here before calling inject(Context, Object, TextMapSetter) )}.

For example, if the carrier is a single-use or immutable request object, you don't need to clear fields as they couldn't have been set before. If it is a mutable, retryable object, successive calls should clear these fields first.

Some use cases for this are:

  • Allow pre-allocation of fields, especially in systems like gRPC Metadata
  • Allow a single-pass over an iterator
Returns:Collection<String>

the fields that will be used by this formatter.

Annotations
@Override
getInstanceback to summary
public static W3CTraceContextPropagator getInstance()

Returns a singleton instance of a TextMapPropagator implementing the W3C TraceContext propagation.

injectback to summary
public <C> void inject(Context context, C carrier, TextMapSetter<C> setter)

Implements io.opentelemetry.context.propagation.TextMapPropagator.inject.

Doc from io.opentelemetry.context.propagation.TextMapPropagator.inject.

Injects data for downstream consumers, for example as HTTP headers. The carrier may be null to facilitate calling this method with a lambda for the TextMapSetter, in which case that null will be passed to the TextMapSetter implementation.

Parameters
<C>
carrier of propagation fields, such as an http request
context:Context

the Context containing the value to be injected.

carrier:C

holds propagation fields. For example, an outgoing message or http request.

setter:TextMapSetter<C>

invoked for each propagation key to add or remove.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override