@ParametersAreNonnullByDefault
Package io.opentelemetry.sdk.trace.samplers
Sampler
s for selecting traces
that are recorded and exported. Sampling is a mechanism to control the noise and overhead introduced by OpenTelemetry by
reducing the number of samples of traces collected and sent to the backend. See the OpenTelemetry
specification for more details.
The following sampling strategies are provided here:
Sampler.alwaysOff()
: This strategy will ensure
that no Spans are ever sent to the export pipeline.
Sampler.alwaysOn()
: This strategy will ensure
that every Span will be sent to the export pipeline.
Sampler.traceIdRatioBased(double)
: This strategy
will sample the provided fraction of Spans, deterministically based on the TraceId of the Spans.
This means that all spans from the a given trace will have the same sampling result.
Sampler.parentBased(io.opentelemetry.sdk.trace.samplers.Sampler)
: This strategy will always use the sampled state of the parent span when deciding whether to
sample a Span or not. If the the Span has no parent, the provided "root" Sampler will be used for
that decision. The parent-based strategy is highly configurable, using the ParentBasedSamplerBuilder
which can be acquired from the
Sampler.parentBasedBuilder(io.opentelemetry.sdk.trace.samplers.Sampler)
method.
-
Interface Summary Interface Description Sampler A Sampler is used to make decisions onSpan
sampling.SamplingResult Sampling result returned bySampler.shouldSample(Context, String, String, SpanKind, Attributes, List)
. -
Class Summary Class Description AutoValue_ImmutableSamplingResult ImmutableSamplingResult ParentBasedSampler A Sampler that uses the sampled flag of the parent Span, if present.ParentBasedSamplerBuilder A builder for creating ParentBased sampler instances.TraceIdRatioBasedSampler We assume the lower 64 bits of the traceId's are randomly distributed around the whole (long) range. -
Enum Summary Enum Description AlwaysOffSampler AlwaysOnSampler SamplingDecision A decision on whether a span should be recorded, recorded and sampled or dropped.