BaggageSpanProcessor class

Automatically copies baggage entries to span attributes on span start.

https://opentelemetry.io/docs/specs/otel/baggage/api/#baggage-propagation "Because a common use case for Baggage is to add data to Span Attributes across a whole trace, several languages have Baggage Span Processors that add data from baggage as attributes on span creation."

This BaggageSpanProcessor extracts all baggage entries from the parent or current context and adds them as span attributes when spans are created.

This enables baggage values to be:

  • Visible in tracing backends (HyperDX, Jaeger, etc.)
  • Searchable and filterable for trace queries
  • Automatically propagated to all spans without manual attribute setting

Example usage:

final tracerProvider = OTel.tracerProvider();
tracerProvider.addSpanProcessor(BaggageSpanProcessor());
Implemented types

Constructors

BaggageSpanProcessor()
Creates a BaggageSpanProcessor instance.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

forceFlush() → Future<void>
Forces the span processor to flush any queued spans.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onEnd(Span span) → Future<void>
Called when a span is ended.
override
onNameUpdate(Span span, String newName) → Future<void>
Called when a span's name is updated.
override
onStart(Span span, Context? parentContext) → Future<void>
Called when a span is started.
override
shutdown() → Future<void>
Shuts down the span processor.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited