ProbabilitySampler class

A sampler that randomly samples traces based on a probability.

This sampler makes a random decision for each span, with the specified probability of sampling. Unlike the TraceIdRatioSampler, which uses the trace ID to make a consistent decision for all spans in a trace, this sampler uses a fresh random number for each decision.

Note that this means the same trace ID might get different sampling decisions if evaluated multiple times, which could lead to inconsistent sampling within a trace. For consistent sampling across a trace, use TraceIdRatioSampler or ParentBasedSampler.

Implemented types

Constructors

ProbabilitySampler(double probability, {int? seed})
Creates a probability sampler with the given probability.

Properties

description → String
Gets a description of this sampler.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
probability → double
The probability of sampling a span, in the range 0.0, 1.0.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldSample({required Context parentContext, required String traceId, required String name, required SpanKind spanKind, required Attributes? attributes, required List<SpanLink>? links}) → SamplingResult
Makes a sampling decision based on random probability.
override
toString() → String
A string representation of this object.
inherited

Operators

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