Class TraceIdRatioBasedSampler

Inheritance Relationships

Base Type

Class Documentation

class opentelemetry::sdk::trace::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)
Parameters

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.

Throws

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

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

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
Returns

Description MUST be TraceIdRatioBasedSampler{0.000100}