Package io.opentelemetry.sdk.trace.samplers


@ParametersAreNonnullByDefault package io.opentelemetry.sdk.trace.samplers
This package contains Samplers 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.