microsoft.opentelemetry.a365.core.exporters.span_processor module

Span processor for propagating OpenTelemetry baggage entries onto spans.

Vendored from microsoft-agents-a365-observability-core trace_processor/span_processor.py and trace_processor/util.py.

For every new span:
  • Retrieve the current (or parent) context

  • Obtain all baggage entries

  • For each documented key with a truthy value not already present as a span attribute, add it via span.set_attribute

  • Never overwrites existing attributes

class microsoft.opentelemetry.a365.core.exporters.span_processor.A365SpanProcessor(tenant_id=None, agent_id=None)[source]

Bases: SpanProcessor

Span processor that stamps agent identity and propagates baggage to span attributes.

Static identity (tenant_id, agent_id) is set from configuration on every span. Additional baggage entries are propagated selectively for documented keys. Never overwrites existing attributes.

on_start(span, parent_context=None)[source]

Called when a opentelemetry.trace.Span is started.

This method is called synchronously on the thread that starts the span, therefore it should not block or throw an exception.

Parameters:
  • span – The opentelemetry.trace.Span that just started.

  • parent_context – The parent context of the span that just started.

on_end(span)[source]

Called when a opentelemetry.trace.Span is ended.

This method is called synchronously on the thread that ends the span, therefore it should not block or throw an exception.

Parameters:

span – The opentelemetry.trace.Span that just ended.