opentelemetry.io icon indicating copy to clipboard operation
opentelemetry.io copied to clipboard

[Page feedback]: Flesh out usage of combining sampling strategies

Open sinback opened this issue 2 months ago β€’ 6 comments

URL

https://opentelemetry.io/docs/languages/go/sampling/

Description

As-written, this page currently explains that TracerProviders can be set up with Samplers and some useful Sampler primitives are already supplied (AlwaysSample, NeverSample, TraceIDRatioBased and ParentBased β€”Β these cover most sampling policies, so it's great to have them available out-of-the-box!)

Pedagogically, I think the page would be helped by a reference to the concepts of head-based and tail-based sampling.

More concretely, I find this phrasing unhelpful:

By default, the tracer provider uses a ParentBased sampler with the AlwaysSample sampler.

When in a production environment, consider using the ParentBased sampler with the TraceIDRatioBased sampler.

It's good to know samplers can be combined, but it doesn't explain how they should be combined, and I don't personally find it self-explanatory from the example which sets up a TracerProvider that uses a withSampler that only uses one of the four basic samplers. If you can use two samplers together, what's the way to do that?

While we're at it it would be nice if a corresponding page with examples for the Python SDK existed (that's what I'm really using, but I didn't see a Sampling page in the Python section sidebar)

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.

sinback avatar Oct 28 '25 20:10 sinback

While we're at it it would be nice if a corresponding page with examples for the Python SDK existed (that's what I'm really using, but I didn't see a Sampling page in the Python section sidebar)

Oh, regarding this point, I found what I wanted here, pretty easily too.

I just got a bit confused since the two information sources are hosted in separate places...

sinback avatar Oct 28 '25 20:10 sinback

Hi @sinback, thanks a lot for the detailed feedback! πŸ™ŒπŸΌ

You've raised some really good points here β€” I see we have a few opportunities for improvement, so let me break them down.

Concepts reference: Under the Sampling section in the Concepts page, we already describe head- and tail-based sampling. We could link to that page directly from the Go docs, or even bring a short summary and examples showing how those concepts could be applied in Go.

Combining samplers: I agree that the current explanation doesn't cover how multiple samplers can be combined or what the expected outcome is. Adding a few short, practical examples would definitely make this section more complete.

Mentioning @open-telemetry/go-approvers for an opinion here.


You also mentioned the separate information sources for the Python docs. This is something we've seen across multiple technologies in the project, and we've been tracking those cases in the meta issue #833. We might want to revisit this as part of the ongoing effort to consolidate non-API docs under opentelemetry.io, so we can ensure the consistency and improve discoverability across all SDKs.

@open-telemetry/docs-triagers WDYT?

vitorvasc avatar Oct 30 '25 11:10 vitorvasc

Rather than have one sampling doc in each SDK (that'll be the same everywhere), should there be a global one that SDK docs can link to?

dmathieu avatar Oct 30 '25 11:10 dmathieu

+1 to dmathieu's suggestion :)

Yeah, regarding the awkwardness of switching between centralized/spec- or concept-oriented docs and specific language docs, it would be really great if the sdk docs focused on in-code-level documentation (so for Python, the docstrings and stuff, which the readthedocs docs already do πŸ‘πŸ»), but they had links at the top of sections to centralized/spec-oriented stuff. It can be really helpful to refer to both but it adds a little cognitive overload for me to go hunting and flipping in between the two, especially because some of the centralized docs are tailored towards different languages (not always directly in line with the generated and generally "more official" docs for each language), and some are tailored towards the overarching architectural concepts. So yeah organizationally it's a bit haphazard for new learners like me.

sinback avatar Nov 04 '25 19:11 sinback

I think having a central document is the way to go, I suspect that the declarative configuration is going to help a lot with that, so maybe we need to revisit that in general with the "configuration" section and have some more parts here and there. It's still not stable, in the mean time I am open to update the concept page around sampling with some language-agnostic best practices and notes and pointers to the languages

svrnm avatar Dec 10 '25 07:12 svrnm

So what I think I'd personally like to see is:

  1. Adjust each of the pages to emphasize that this is to configure head sampling at the SDK level, and link to the general sampling page that defines this term
  2. Use environment variables for configuration and code-based config as an alternative
  3. Explain that head samplers can be combined

cartermp avatar Dec 12 '25 15:12 cartermp