Top Description Inners Fields Methods
io.micrometer.tracing.propagation

public Interface Propagator

Imports
io.micrometer.common.lang.Nullable, io.micrometer.tracing.Span, .TraceContext, java.util.Collections, .List

Inspired by OpenZipkin Brave and OpenTelemetry. Most of the documentation is taken directly from OpenTelemetry.

Injects and extracts a value as text into carriers that travel in-band across process boundaries. Encoding is expected to conform to the HTTP Header Field semantics. Values are often encoded as RPC/HTTP request headers.

Authors
OpenZipkin Brave Authors, OpenTelemetry Authors, Marcin Grzejszczak
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Propagator.Getter<
carrier of propagation fields, such as an http request.
C
>

Interface that allows a Propagator to read propagated fields from a carrier.

public static interface
Propagator.Setter<
carrier of propagation fields, such as an http request
C
>

Class that allows a Propagator to set propagated fields into a carrier.

Field Summary

Modifier and TypeField and Description
public static final Propagator
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public <
carrier of propagation fields, such as an http request.
C
>
Span.Builder

Returns:

the Context containing the extracted value.
extract
(C
holds propagation fields. For example, an outgoing message or http request.
carrier
,
Propagator.Getter<C>
invoked for each propagation key to get.
getter
)

Extracts the value from upstream.

public List<String>

Returns:

collection of headers that contain tracing information
fields
()

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

Injects the value downstream, for example as HTTP headers.

Field Detail

NOOPback to summary
public static final Propagator NOOP

A noop implementation.

This implementation could be used with sender/receiver that do not need any propagation. e.g. database access

Method Detail

extractback to summary
public <C> Span.Builder extract(C carrier, Propagator.Getter<C> getter)

Extracts the value from upstream. For example, as http headers.

If the value could not be parsed, the underlying implementation will decide to set an object representing either an empty value, an invalid value, or a valid value. Implementation must not set null.

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

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

getter:Propagator.Getter<C>

invoked for each propagation key to get.

Returns:Span.Builder

the Context containing the extracted value.

fieldsback to summary
public List<String> fields()
Returns:List<String>

collection of headers that contain tracing information

injectback to summary
public <C> void inject(TraceContext context, C carrier, Propagator.Setter<C> setter)

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

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

the Context containing the value to be injected.

carrier:C

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

setter:Propagator.Setter<C>

invoked for each propagation key to add or remove.

io.micrometer.tracing.propagation back to summary

public Interface Propagator.Getter<C>

Type Parameters
<C>
carrier of propagation fields, such as an http request.

Interface that allows a Propagator to read propagated fields from a carrier.

Getter is stateless and allows to be saved as a constant to avoid runtime allocations.

Field Summary

Modifier and TypeField and Description
public static final Propagator.Getter<C>
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the first value of the given propagation key or returns null.
get
(C
carrier of propagation fields, such as an http request.
carrier
,
String
the key of the field.
key
)

Returns the first value of the given propagation key or returns null.

Field Detail

NOOPback to summary
public static final Propagator.Getter<C> NOOP

A noop implementation.

Annotations
@SuppressWarnings:rawtypes

Method Detail

getback to summary
public String get(C carrier, String key)

Returns the first value of the given propagation key or returns null.

Parameters
carrier:C

carrier of propagation fields, such as an http request.

key:String

the key of the field.

Returns:String

the first value of the given propagation key or returns null.

Annotations
@Nullable
io.micrometer.tracing.propagation back to summary

public Interface Propagator.Setter<C>

Type Parameters
<C>
carrier of propagation fields, such as an http request

Class that allows a Propagator to set propagated fields into a carrier.

Setter is stateless and allows to be saved as a constant to avoid runtime allocations.

Since
0.1.0

Field Summary

Modifier and TypeField and Description
public static final Propagator.Setter<C>
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public void
set(C
holds propagation fields. For example, an outgoing message or http request. To facilitate implementations as java lambdas, this parameter may be null.
carrier
,
String
the key of the field.
key
,
String
the value of the field.
value
)

Replaces a propagated field with the given value.

Field Detail

NOOPback to summary
public static final Propagator.Setter<C> NOOP

A noop implementation.

Annotations
@SuppressWarnings:rawtypes

Method Detail

setback to summary
public void set(C carrier, String key, String value)

Replaces a propagated field with the given value.

For example, a setter for an java.net.HttpURLConnection would be the method reference java.net.HttpURLConnection#addRequestProperty(String, String)

Parameters
carrier:C

holds propagation fields. For example, an outgoing message or http request. To facilitate implementations as java lambdas, this parameter may be null.

key:String

the key of the field.

value:String

the value of the field.