AttributeMatchingSampler implements Sampler
Drops spans whose start-time attributes match an {@see AttributeFilter}, and defers every other span to a delegate sampler.
The decision is made at span start, so a matched span becomes non-recording and is never handed to a processor or exporter (no attributes accumulate, no onEnd).
Only attributes available at span start are visible here - attributes added during the span's lifetime (status codes, durations) are not. End-state filtering remains the job of a span processor or tail sampling.
The matcher tree, its compiled drop closure, the inspected AttributeSources and the exclude polarity are all reused from the shared AttributeFilter: a match drops the span (AttributeFilter::$exclude true, the default) or keeps ONLY matching spans (exclude false).
Interfaces
- Sampler
- Interface for sampling decisions.
Methods
- __construct() : mixed
- __toString() : string
- Get a string representation of this sampler for debugging.
- shouldSample() : SamplingResult
- Determine if a span should be sampled.
Methods
__construct()
public
__construct(AttributeFilter $filter[, Sampler $delegate = new AlwaysOnSampler() ]) : mixed
Parameters
- $filter : AttributeFilter
- $delegate : Sampler = new AlwaysOnSampler()
__toString()
Get a string representation of this sampler for debugging.
public
__toString() : string
Examples:
- "AlwaysOnSampler"
- "TraceIdRatioBasedSampler{0.001}"
- "ParentBased{root=AlwaysOnSampler}"
Return values
stringshouldSample()
Determine if a span should be sampled.
public
shouldSample(Span $span) : SamplingResult
Parameters
- $span : Span
-
The span to evaluate for sampling
Return values
SamplingResult —The sampling decision