View Source otel_sampler behaviour (opentelemetry v1.0.5)

A sampler is a function run on each started span that returns whether to record and propagate, only record or not record the span.

Link to this section Summary

Link to this section Types

Specs

builtin_sampler() ::
    always_on | always_off |
    {trace_id_ratio_based, float()} |
    {parent_based,
     #{remote_parent_sampled => sampler_spec(),
       remote_parent_not_sampled => sampler_spec(),
       local_parent_sampled => sampler_spec(),
       local_parent_not_sampled => sampler_spec(),
       root => sampler_spec()}}.

Specs

description() :: unicode:unicode_binary().

Specs

sampler_config() :: term().

Specs

sampler_opts() :: term().

Specs

sampler_spec() :: builtin_sampler() | {module(), sampler_opts()}.

Specs

sampling_decision() :: drop | record_only | record_and_sample.

Specs

sampling_result() ::
    {sampling_decision(), opentelemetry:attributes_map(), opentelemetry:tracestate()}.

Specs

t()

Link to this section Callbacks

Specs

description(sampler_config()) -> description().

Specs

setup(sampler_opts()) -> sampler_config().

Specs

should_sample(otel_ctx:t(),
              opentelemetry:trace_id(),
              otel_links:t(),
              opentelemetry:span_name(),
              opentelemetry:span_kind(),
              opentelemetry:attributes_map(),
              sampler_config()) ->
                 sampling_result().

Link to this section Functions

Specs

description(t()) -> description().

Specs

new(sampler_spec()) -> t().
Link to this function

should_sample(_, Ctx, TraceId, Links, SpanName, Kind, Attributes)

View Source

Specs

should_sample(t(),
              otel_ctx:t(),
              opentelemetry:trace_id(),
              otel_links:t(),
              opentelemetry:span_name(),
              opentelemetry:span_kind(),
              opentelemetry:attributes_map()) ->
                 sampling_result().