Class TraceIdRatioBasedSampler

Inheritance Relationships

Base Type

Class Documentation

class TraceIdRatioBasedSampler : public opentelemetry::sdk::trace::Sampler

The TraceIdRatioBased sampler computes and returns a decision based on the provided trace_id and the configured ratio.

Public Functions

explicit TraceIdRatioBasedSampler(double ratio)

ratio – a required value, 1.0 >= ratio >= 0.0. If the given trace_id falls into a given ratio of all possible trace_id values, ShouldSample will return RECORD_AND_SAMPLE.


invalid_argument – if ratio is out of bounds [0.0, 1.0]

virtual SamplingResult ShouldSample(const opentelemetry::trace::SpanContext&, opentelemetry::trace::TraceId trace_id, nostd::string_view, opentelemetry::trace::SpanKind, const opentelemetry::common::KeyValueIterable&, const opentelemetry::trace::SpanContextKeyValueIterable&) noexcept override

Returns either RECORD_AND_SAMPLE or DROP based on current sampler configuration and provided trace_id and ratio. trace_id is used as a pseudorandom value in conjunction with the predefined ratio to determine whether this trace should be sampled

virtual nostd::string_view GetDescription() const noexcept override

Description MUST be TraceIdRatioBasedSampler{0.000100}