Skip to content

How does one use a custom sampler? #1396

@davidji99

Description

@davidji99

Hi,

I am aware of the built-in samplers:

always_on - Sampler that always samples spans, regardless of the parent span’s sampling decision.

always_off - Sampler that never samples spans, regardless of the parent span’s sampling decision.

traceidratio - Sampler that samples probabalistically based on rate.

parentbased_always_on - (default) Sampler that respects its parent span’s sampling decision, but otherwise always samples.

parentbased_always_off - Sampler that respects its parent span’s sampling decision, but otherwise never samples.

parentbased_traceidratio - Sampler that respects its parent span’s sampling decision, but otherwise samples probabalistically based on rate.

But I'd like to understand how to use a custom sampler?

I currently have the following:

sampler = CustomSampler.new(sampling_probability)
trace_provider = OpenTelemetry::SDK::Trace::TracerProvider.new(sampler: sampler)
OpenTelemetry.tracer_provider = trace_provider

But these lines of code don't seem to be taking effect. Any guidance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions