CompositeSampler
in package
implements
SamplerInterface
Makes the final sampling decision for a {@see ComposableSamplerInterface} and maintains the `ot` entry of the TraceState.
The decision compares the threshold of the intent with the randomness: rv or the last 56 bits of the trace ID
when the adjusted count is reliable, a fresh random value otherwise. The th sub-key is written only for sampled
spans with a reliable adjusted count and is erased otherwise; rv is never modified.
Tags
Table of Contents
Interfaces
- SamplerInterface
- This interface is used to organize sampling logic.
Properties
Methods
- __construct() : mixed
- getDescription() : string
- Returns the sampler name or short description with the configuration.
- shouldSample() : SamplingResult
- Returns SamplingResult.
- withOtEntry() : TraceStateInterface
- Sets the `ot` entry. When the TraceState is full the rightmost member is evicted first, as W3C Trace Context requires when adding an entry; otherwise {@see TraceState::with()} would refuse the entry and lose the threshold.
Properties
$delegate read-only
private
ComposableSamplerInterface
$delegate
Methods
__construct()
public
__construct(ComposableSamplerInterface $delegate) : mixed
Parameters
- $delegate : ComposableSamplerInterface
getDescription()
Returns the sampler name or short description with the configuration.
public
getDescription() : string
This may be displayed on debug pages or in the logs. Example: "TraceIdRatioBased{0.000100}"
Attributes
- #[Override]
Return values
stringshouldSample()
Returns SamplingResult.
public
shouldSample(ContextInterface $parentContext, string $traceId, string $spanName, int $spanKind, AttributesInterface $attributes, array<string|int, mixed> $links) : SamplingResult
Parameters
- $parentContext : ContextInterface
-
Context with parent Span. The Span's SpanContext may be invalid to indicate a root span.
- $traceId : string
-
TraceId of the Span to be created. It can be different from the TraceId in the SpanContext. Typically in situations when the Span to be created starts a new Trace.
- $spanName : string
-
Name of the Span to be created.
- $spanKind : int
-
Span kind.
- $attributes : AttributesInterface
-
Initial set of Attributes for the Span being constructed.
- $links : array<string|int, mixed>
-
Collection of links that will be associated with the Span to be created. Typically, useful for batch operations. @see https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#links-between-spans
Attributes
- #[Override]
Return values
SamplingResultwithOtEntry()
Sets the `ot` entry. When the TraceState is full the rightmost member is evicted first, as W3C Trace Context requires when adding an entry; otherwise {@see TraceState::with()} would refuse the entry and lose the threshold.
private
static withOtEntry(TraceStateInterface $traceState, string $serializedOt) : TraceStateInterface
Parameters
- $traceState : TraceStateInterface
- $serializedOt : string