Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sampler that passes spans based on name prefix #54

Open
breedx-splk opened this issue Jul 15, 2021 · 6 comments
Open

Sampler that passes spans based on name prefix #54

breedx-splk opened this issue Jul 15, 2021 · 6 comments
Assignees
Labels

Comments

@breedx-splk
Copy link
Contributor

Users have asked for a way to ensure that their manually created spans are never sampled out while still allowing the rest of instrumentation to sample normally. One approach I'm suggesting here is to create a new sampler that can be preconfigured with a set of span name prefixes to always include. That is, if a span name starts with one of the prefixes, it always passes. If it does not, then this sampler will delegate to another sampler.

Might be a little tricky to choose a name for this. Something like NamePrefixedForceInclusionSampler.

@jkwatson
Copy link
Contributor

The opposite of this would also be super useful... To remove spans based on name.

@anuraaga
Copy link
Contributor

If it's about manual sampling instead of relying on name, I think context attribute to force sampling can work and more flexible.

@iNikem
Copy link
Contributor

iNikem commented Jul 15, 2021

One more option to always include manual spans is to use InstrumentationLibrary.Name: if it does not start with io.opentelemetry, then return RECORD

@jkwatson
Copy link
Contributor

One more option to always include manual spans is to use InstrumentationLibrary.Name: if it does not start with io.opentelemetry, then return RECORD

how would you implement that with a Sampler? Samplers don't have access to the Tracer implementation being used to create the span.

@breedx-splk
Copy link
Contributor Author

If it's about manual sampling instead of relying on name, I think context attribute to force sampling can work and more flexible.

The usage then looks something like this?

Context context = Context.current().withValue(MANUALLY_CONTROLLED_SAMPLER, NEVER_DROP);
Span span = tracer.spanBuilder("xxx").setParent(context).startSpan();
[...]

I agree, it's more explicit that way and requires less fiddling with the sampler and specifying some names.

There's probably opportunity to make that even more convenient with helpers on the SpanBuilder too I suppose.

@iNikem
Copy link
Contributor

iNikem commented Jul 16, 2021

One more option to always include manual spans is to use InstrumentationLibrary.Name: if it does not start with io.opentelemetry, then return RECORD

how would you implement that with a Sampler? Samplers don't have access to the Tracer implementation being used to create the span.

They are going to, hopefully: open-telemetry/opentelemetry-specification#1588

@trask trask self-assigned this Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants