Flow PHP

SamplingResult

Read onlyYes
FinalYes

Result of a sampling decision.

Contains the sampling decision along with additional attributes that should be added to the span and an optional updated trace state.

Example usage:

$result = new SamplingResult(
    SamplingDecision::RECORD_AND_SAMPLE,
    ['sampling.reason' => 'head-based'],
);

if ($result->decision->isSampled()) {
    // Create and export the span
}

Properties

$attributes  : array<string|int, mixed>
$decision  : SamplingDecision
$traceState  : TraceState|null

Methods

__construct()  : mixed
drop()  : self
Create a result indicating the span should be dropped.
recordAndSample()  : self
Create a result indicating the span should be recorded and exported.
recordOnly()  : self
Create a result indicating the span should be recorded but not exported.

Properties

Methods

__construct()

public __construct(SamplingDecision $decision[, array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ][, null|TraceState $traceState = null ]) : mixed
Parameters
$decision : SamplingDecision

The sampling decision

$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []

Additional span attributes from the sampler

$traceState : null|TraceState = null

Updated trace state, or null to keep existing

drop()

Create a result indicating the span should be dropped.

public static drop() : self
Return values
self

recordAndSample()

Create a result indicating the span should be recorded and exported.

public static recordAndSample([array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ][, TraceState|null $traceState = null ]) : self
Parameters
$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
$traceState : TraceState|null = null
Return values
self

recordOnly()

Create a result indicating the span should be recorded but not exported.

public static recordOnly([array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ][, TraceState|null $traceState = null ]) : self
Parameters
$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
$traceState : TraceState|null = null
Return values
self

        
On this page

Search results