AttributeFilteringSpanProcessor implements SpanProcessor
Filters spans by their attributes.
Wraps another SpanProcessor and forwards only the spans that survive the configured AttributeFilter. The decision is made at self::onEnd() because span attributes are only fully populated once the span has ended; self::onStart() is always delegated unchanged.
Interfaces
- SpanProcessor
- Interface for processing spans when they start and end.
Methods
- __construct() : mixed
- flush() : bool
- Export all pending spans and return success status.
- onEnd() : void
- Called when a span ends.
- onStart() : void
- Called when a span starts.
- shutdown() : void
- Shutdown the processor.
Methods
__construct()
public
__construct(SpanProcessor $processor, AttributeFilter $filter) : mixed
Parameters
- $processor : SpanProcessor
- $filter : AttributeFilter
flush()
Export all pending spans and return success status.
public
flush() : bool
Forces immediate export of any buffered spans. Returns true if all spans were successfully exported.
Return values
boolonEnd()
Called when a span ends.
public
onEnd(Span $span) : void
This is invoked synchronously when the span completes. The span is fully populated at this point (end time, status, all attributes).
Parameters
- $span : Span
onStart()
Called when a span starts.
public
onStart(Span $span) : void
This is invoked synchronously when the span begins. Implementations should avoid blocking operations in this method.
Parameters
- $span : Span
shutdown()
Shutdown the processor.
public
shutdown() : void
Implementations SHOULD flush() pending data before delegating shutdown to the underlying exporter. MUST be idempotent and MUST NOT throw.