instrument_sampler_probability (instrument v1.0.0)

View Source

Probability-based sampler (TraceIdRatioBased).

Samples a configurable percentage of traces based on their trace ID. The sampling decision is deterministic: the same trace ID will always produce the same sampling decision.

Configuration

- ratio: A float between 0.0 and 1.0 (default: 1.0) - 0.0 means never sample - 1.0 means always sample - 0.5 means sample approximately 50% of traces

Example

  instrument_sampler:set_sampler(instrument_sampler_probability, #{ratio => 0.1}).

Summary

Functions

Returns the sampler description.

Functions

get_description(Config)

-spec get_description(Config :: map()) -> binary().

Returns the sampler description.

should_sample(Config, TraceId, SpanName, SpanKind, Attributes, Links, ParentCtx)

-spec should_sample(Config :: map(),
                    TraceId :: binary(),
                    SpanName :: binary(),
                    SpanKind :: atom(),
                    Attributes :: map(),
                    Links :: list(),
                    ParentCtx ::
                        #span_ctx{trace_id :: <<_:128>> | undefined,
                                  span_id :: <<_:64>> | undefined,
                                  trace_flags :: 0 | 1,
                                  trace_state :: [{binary(), binary()}],
                                  is_remote :: boolean()} |
                        undefined) ->
                       #sampling_result{decision :: drop | record_only | record_and_sample,
                                        attributes :: map(),
                                        trace_state :: [{binary(), binary()}]}.

Samples based on trace ID probability.