View Source otel_sampler behaviour (opentelemetry v1.4.1)
Behaviour for defining samplers.
A sampler should provide a function run on each started span that returns whether to record and propagate, only record, or not record the span.
For more information on the concept of Sampling, see Sampling in the OpenTelemetry documentation or the Sampling spec. For examples of configuring samplers or implementing your own sampler, see the OpenTelemetry Erlang documentation.
Configuration
To configure sampling for the opentelemetry
application, see the documentation.
Summary
Types
A built-in sampler.
The description of the sampler.
Any term used to configured a given sampler.
Any options passed to a sampler.
Specification to create a sampler.
The decision that a sampler can make on a given span.
The result of a sampling decision.
A sampler.
Callbacks
Functions
Returns the description of the given sampler.
Returns a sampler based on the given specification.
Types
-type 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()}}.
A built-in sampler.
-type description() :: unicode:unicode_binary().
The description of the sampler.
-type sampler_config() :: term().
Any term used to configured a given sampler.
-type sampler_opts() :: term().
Any options passed to a sampler.
-type sampler_spec() :: builtin_sampler() | {module(), sampler_opts()}.
Specification to create a sampler.
-type sampling_decision() :: drop | record_only | record_and_sample.
The decision that a sampler can make on a given span.
-type sampling_result() :: {sampling_decision(), opentelemetry:attributes_map(), opentelemetry:tracestate() | otel_tracestate:members()}.
The result of a sampling decision.
-opaque t()
A sampler.
Callbacks
-callback description(sampler_config()) -> description().
-callback setup(sampler_opts()) -> sampler_config().
-callback should_sample(otel_ctx:t(), opentelemetry:trace_id(), otel_links:t(), opentelemetry:span_name(), opentelemetry:span_kind(), opentelemetry:attributes_map(), sampler_config()) -> sampling_result().
Functions
-spec description(t()) -> description().
Returns the description of the given sampler.
-spec new(SamplerSpec :: sampler_spec()) -> t().
Returns a sampler based on the given specification.