Class W3CBaggagePropagator
java.lang.Object
io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator
- All Implemented Interfaces:
TextMapPropagator
TextMapPropagator that implements the W3C specification for baggage header propagation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final W3CBaggagePropagatorprivate static final PercentEscaper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanbaggageIsInvalid(String key, BaggageEntry baggageEntry) private static StringbaggageToString(Baggage baggage) private static StringencodeValue(String value) <C> Contextextract(Context context, C carrier, TextMapGetter<C> getter) Extracts data from upstream.private static voidextractEntries(String baggageHeader, BaggageBuilder baggageBuilder) fields()The propagation fields defined.static W3CBaggagePropagatorSingleton instance of the W3C Baggage Propagator.<C> voidinject(Context context, C carrier, TextMapSetter<C> setter) Injects data for downstream consumers, for example as HTTP headers.private static booleanisValidBaggageKey(String name) Determines whether the givenStringis a valid entry key.private static booleanisValidBaggageValue(String value) Determines whether the givenStringis a valid entry value.toString()
-
Field Details
-
FIELD
- See Also:
-
FIELDS
-
INSTANCE
-
URL_ESCAPER
-
-
Constructor Details
-
W3CBaggagePropagator
private W3CBaggagePropagator()
-
-
Method Details
-
getInstance
Singleton instance of the W3C Baggage Propagator. -
fields
Description copied from interface:TextMapPropagatorThe propagation fields defined. If your carrier is reused, you should delete the fields here before callingTextMapPropagator.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
- Specified by:
fieldsin interfaceTextMapPropagator- Returns:
- the fields that will be used by this formatter.
-
inject
Description copied from interface:TextMapPropagatorInjects data for downstream consumers, for example as HTTP headers. The carrier may be null to facilitate calling this method with a lambda for theTextMapSetter, in which case that null will be passed to theTextMapSetterimplementation.- Specified by:
injectin interfaceTextMapPropagator- Type Parameters:
C- carrier of propagation fields, such as an http request- Parameters:
context- theContextcontaining the value to be injected.carrier- holds propagation fields. For example, an outgoing message or http request.setter- invoked for each propagation key to add or remove.
-
baggageToString
-
encodeValue
-
extract
Description copied from interface:TextMapPropagatorExtracts 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.
- Specified by:
extractin interfaceTextMapPropagator- Type Parameters:
C- the type of carrier of the propagation fields, such as an http request.- Parameters:
context- theContextused to store the extracted value.carrier- holds propagation fields. For example, an outgoing message or http request.getter- invoked for each propagation key to get data from the carrier.- Returns:
- the
Contextcontaining the extracted data.
-
extractEntries
-
baggageIsInvalid
-
isValidBaggageKey
Determines whether the givenStringis a valid entry key.- Parameters:
name- the entry key name to be validated.- Returns:
- whether the name is valid.
-
isValidBaggageValue
Determines whether the givenStringis a valid entry value.- Parameters:
value- the entry value to be validated.- Returns:
- whether the value is valid.
-
toString
-