View Source otel_sampler behaviour (opentelemetry v1.5.0)
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 theopentelemetry
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
Should return the description of the sampler.
Called when a sampler is created to set up the sampler. Should return the sampler configuration that is then passed to other callbacks.
Main callback that determines whether a span should be sampled.\
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()}}.
-type description() :: unicode:unicode_binary().
-type sampler_config() :: term().
-type sampler_opts() :: term().
-type sampler_spec() :: builtin_sampler() | {module(), sampler_opts()}.
-type sampling_decision() :: drop | record_only | record_and_sample.
-type sampling_result() :: {sampling_decision(), opentelemetry:attributes_map(), opentelemetry:tracestate() | otel_tracestate:members()}.
-opaque t()
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().
-spec new(SamplerSpec :: sampler_spec()) -> t().