@Immutable public final class Samplers extends Object
Samplers
.Modifier and Type | Method and Description |
---|---|
static Sampler |
alwaysOff()
|
static Sampler |
alwaysOn()
|
static Sampler.SamplingResult |
emptySamplingResult(Sampler.Decision decision)
Returns a
Sampler.SamplingResult with empty attributes and Sampler.SamplingResult.getDecision()
returning decision . |
static Sampler |
parentOrElse(Sampler delegateSampler)
Returns a
Sampler that always makes the same decision as the parent Span to
whether or not to sample. |
static Sampler |
probability(double probability)
Returns a new Probability
Sampler . |
static Sampler.SamplingResult |
samplingResult(Sampler.Decision decision,
io.opentelemetry.common.Attributes attributes)
Returns a
Sampler.SamplingResult with the given attributes and Sampler.SamplingResult.getDecision() returning decision . |
public static Sampler.SamplingResult samplingResult(Sampler.Decision decision, io.opentelemetry.common.Attributes attributes)
Sampler.SamplingResult
with the given attributes
and Sampler.SamplingResult.getDecision()
returning decision
.
This is meant for use by custom Sampler
implementations.
Using #emptySamplingResult(Decision)
instead of this method is slightly faster and
shorter if you don't need attributes.
decision
- The decision made on the span.attributes
- The attributes to return from Sampler.SamplingResult.getAttributes()
. A
different object instance with the same elements may be returned.Sampler.SamplingResult
with the attributes equivalent to attributes
and the
provided decision
.public static Sampler.SamplingResult emptySamplingResult(Sampler.Decision decision)
Sampler.SamplingResult
with empty attributes and Sampler.SamplingResult.getDecision()
returning decision
.
This is meant for use by custom Sampler
implementations.
Use #samplingResult(Decision, Attributes)
if you need attributes.
decision
- The decision made on the span.Sampler.SamplingResult
with empty attributes and the provided decision
.public static Sampler alwaysOn()
Sampler
that always makes a "yes" Sampler.SamplingResult
for Span
sampling.public static Sampler alwaysOff()
Sampler
that always makes a "no" Sampler.SamplingResult
for Span
sampling.public static Sampler parentOrElse(Sampler delegateSampler)
Sampler
that always makes the same decision as the parent Span
to
whether or not to sample. If there is no parent, the Sampler uses the provided Sampler delegate
to determine the sampling decision.delegateSampler
- the Sampler
which is used to make the sampling decisions if the
parent does not exist.Sampler
that follows the parent's sampling decision if one exists, otherwise
following the delegate sampler's decision.public static Sampler probability(double probability)
Sampler
. The probability of sampling a trace is equal to that
of the specified probability.probability
- The desired probability of sampling. Must be within [0.0, 1.0].Sampler
.IllegalArgumentException
- if probability
is out of range