Skip to content

[Feature]: Add RecordOnlyOnDrop sampler to contrib tracing utilities #436

@agent-adam

Description

@agent-adam

Related Problems?

Today the Rust SDK exposes the three standard sampling decisions (Drop, RecordOnly, RecordAndSample), but the built-in samplers only ever return Drop or RecordAndSample.

There are valid use cases (e.g. span-to-metrics pipelines, local tail sampling) where you want all spans to be recording, even when they’re not marked Sampled.

Right now users must roll their own wrapper sampler to downgrade Drop → RecordOnly.

What component are you working with?

No response

Describe the solution you'd like:

Add a small utility sampler (e.g. RecordOnlyOnDrop) in opentelemetry-contrib/src/trace/ that wraps an inner sampler and converts any Drop decision into RecordOnly.

use opentelemetry_sdk::trace::{Sampler, SdkTracerProvider};
use opentelemetry_contrib::trace::RecordOnlyOnDrop;

let base = Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(0.05)));
let sampler = RecordOnlyOnDrop::new(base);

let provider = SdkTracerProvider::builder()
    .with_config(opentelemetry_sdk::trace::Config {
        sampler: Box::new(sampler),
        ..Default::default()
    })
    .build();

Considered Alternatives

No response

Additional Context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions