Skip to content

Add consistent sampler #3668

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

Closed
wants to merge 3 commits into from

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Aug 1, 2025

Description

Adds an implementation of consistent samplers

https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling/

Based on the Java implementation

https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56

Some differences from Java

  • Does not add non-standard samplers for now, e.g. ratelimited, rule based
  • Some trace state validation is assumed to be done by the SDK and invalid cases aren't tested (the API doesn't accept string but SDK TraceState)

/cc @xrmx for maintainer review
/cc @PeterF778 as original author in Java if interested

Type of change

  • [C] New feature (non-breaking change which adds functionality)- [ ] This change requires a documentation update

How Has This Been Tested?

  • Unit tests

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anuraaga anuraaga requested a review from a team as a code owner August 1, 2025 08:49
@tammy-baylis-swi
Copy link
Contributor

Thanks for working on this and providing those links!

The Python repos are purposed a bit differently than Java. I think this new sampler might be better in opentelemetry-python SDK trace instead, with all other existing samplers.

@anuraaga
Copy link
Contributor Author

anuraaga commented Aug 7, 2025

Thanks @tammy-baylis-swi - currently the sampler is a draft in the OTel spec so the idea is to be able to have a way to get something to try to verify and stabilize the spec. Would it still be appropriate in the main repo as a draft spec?

@tammy-baylis-swi
Copy link
Contributor

Thanks @tammy-baylis-swi - currently the sampler is a draft in the OTel spec so the idea is to be able to have a way to get something to try to verify and stabilize the spec. Would it still be appropriate in the main repo as a draft spec?

I think so, though maybe the @open-telemetry/python-maintainers should chime in on this.

We do use _ prefixing to indicate new features are not yet stable. For example, the Python Logging API is still experimental so we've put it in _logs. Maybe it could go in an SDK subdir for now like _sampler.

@anuraaga
Copy link
Contributor Author

anuraaga commented Aug 8, 2025

Thanks - I've opened a PR in the SDK repo so will close this one

open-telemetry/opentelemetry-python#4714

@anuraaga anuraaga closed this Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants