Class MetadataSpanAttributesProvider
- All Implemented Interfaces:
SpanAttributesProvider
<prefix><metadataKey>.
By default the prefix is METADATA_PREFIX (axoniq.metadata.) and every metadata entry is added. The
prefix can be overridden through the constructor. An optional allowlist restricts which metadata keys are added; an
empty allowlist means all keys. Entries with a null value are skipped.
Besides the metadata already attached to the message, this provider also includes correlation data staged on the
ProcessingContext under CorrelationDataInterceptor.CORRELATION_DATA. Dispatch-side spans are created
by the outermost tracing decorators before the CorrelationDataInterceptor dispatch interceptor
merges that staged data onto the outgoing message, so reading the staged resource lets the span report the metadata
the message will effectively carry. Staged entries take precedence over message entries with the same key, mirroring
the interceptor's merge. The allowlist applies to staged entries as well, so disabling or restricting this provider
governs all metadata attributes in one place.
- Since:
- 4.6.0
- Author:
- Mateusz Nowak, Mitchell Herrijgers
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault prefix prepended to each metadata key to form the span attribute key. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a provider that adds all metadata entries under the defaultMETADATA_PREFIXprefix.MetadataSpanAttributesProvider(String prefix, Set<String> allowedKeys) Creates a provider that adds the given metadata keys (when present) under the givenprefix.MetadataSpanAttributesProvider(Set<String> allowedKeys) Creates a provider that adds the given metadata keys (when present) under the defaultMETADATA_PREFIXprefix. -
Method Summary
Modifier and TypeMethodDescriptionprovideForMessage(Message message, @Nullable ProcessingContext context) Provides the attributes this provider contributes for the givenmessageand optionalcontext.
-
Field Details
-
METADATA_PREFIX
Default prefix prepended to each metadata key to form the span attribute key.- See Also:
-
-
Constructor Details
-
MetadataSpanAttributesProvider
public MetadataSpanAttributesProvider()Creates a provider that adds all metadata entries under the defaultMETADATA_PREFIXprefix. -
MetadataSpanAttributesProvider
Creates a provider that adds the given metadata keys (when present) under the defaultMETADATA_PREFIXprefix. An empty set means all keys.- Parameters:
allowedKeys- the metadata keys to add, or an empty set for all keys
-
MetadataSpanAttributesProvider
Creates a provider that adds the given metadata keys (when present) under the givenprefix. An empty allowlist means all keys.- Parameters:
prefix- the prefix prepended to each metadata key to form the span attribute keyallowedKeys- the metadata keys to add, or an empty set for all keys
-
-
Method Details
-
provideForMessage
Description copied from interface:SpanAttributesProviderProvides the attributes this provider contributes for the givenmessageand optionalcontext.- Specified by:
provideForMessagein interfaceSpanAttributesProvider- Parameters:
message- the message the span is created forcontext- the active processing context, ornullwhen none is available- Returns:
- the attributes to add to the span; an empty map when this provider contributes nothing
-