Note: This is an experimental package under active development. New releases may include breaking changes.
This package provides implementations of composite samplers that propagate sampling information across a trace. This implements the experimental specification.
Currently ComposableRuleBased
and ComposableAnnotating
are not implemented.
To get started you will need to install a compatible OpenTelemetry SDK.
This module exports samplers that follow the general behavior of the standard SDK samplers, but ensuring it is consistent across a trace by using the tracestate header. Notably, the tracestate can be examined in exported spans to reconstruct population metrics.
import {
createCompositeSampler,
createComposableAlwaysOffSampler,
createComposableAlwaysOnSampler,
createComposableParentThresholdSampler,
createComposableTraceIDRatioBasedSampler,
} from '@opentelemetry/sampler-composite';
// never sample
const sampler = createCompositeSampler(createComposableAlwaysOffSampler());
// always sample
const sampler = createCompositeSampler(createComposableAlwaysOnSampler());
// follow the parent, or otherwise sample with a probability if root
const sampler = createCompositeSampler(
createComposableParentThresholdSampler(createComposableTraceIDRatioBasedSampler(0.3)));
Apache 2.0 - See LICENSE for more information.