@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 |
parentBased(Sampler root)
Returns a
Sampler that always makes the same decision as the parent Span to
whether or not to sample. |
static io.opentelemetry.sdk.trace.Samplers.ParentBased.Builder |
parentBasedBuilder(Sampler root)
Returns a
ParentBased.Builder that follows the parent's sampling decision if one
exists, otherwise following the root sampler and other optional sampler's decision. |
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. |
static Sampler |
traceIdRatioBased(double ratio)
Returns a new TraceIdRatioBased
Sampler. |
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 parentBased(Sampler root)
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.root - 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 root sampler's decision.public static io.opentelemetry.sdk.trace.Samplers.ParentBased.Builder parentBasedBuilder(Sampler root)
ParentBased.Builder that follows the parent's sampling decision if one
exists, otherwise following the root sampler and other optional sampler's decision.root - the required Sampler which is used to make the sampling decisions if the
parent does not exist.ParentBased.Builderpublic static Sampler traceIdRatioBased(double ratio)
Sampler. The ratio of sampling a trace is equal to that
of the specified ratio.ratio - The desired ratio of sampling. Must be within [0.0, 1.0].Sampler.IllegalArgumentException - if ratio is out of range