nat.observability.processor.span_tagging_processor#

Attributes#

Classes#

SpanTaggingProcessor

Processor that tags spans with multiple key-value metadata attributes.

Module Contents#

logger#
class SpanTaggingProcessor(
tags: collections.abc.Mapping[str, enum.Enum | str] | None = None,
span_prefix: str | None = None,
)#

Bases: nat.observability.processor.processor.Processor[nat.data_models.span.Span, nat.data_models.span.Span]

Processor that tags spans with multiple key-value metadata attributes.

This processor adds custom tags to spans by setting attributes with a configurable prefix. Tags are applied for each key-value pair in the tags dictionary. The processor uses a span prefix (configurable via NAT_SPAN_PREFIX environment variable) to namespace the tag attributes.

Args:

tags: Mapping of tag keys to their values. Values can be enums (converted to strings) or strings span_prefix: The prefix to use for tag attributes (default: from NAT_SPAN_PREFIX env var or “nat”)

tags#
_span_prefix = None#
async process(item: nat.data_models.span.Span) nat.data_models.span.Span#

Tag the span with all configured tags.

Args:

item (Span): The span to tag

Returns:

Span: The tagged span with all configured tags applied