Add experimental composite sampler#4714
Conversation
xrmx
left a comment
There was a problem hiding this comment.
Added a bunch of comments, I have yet to review the PR after looking at the doc here
https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling/
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/__init__.py
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_always_off.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_fixed_threshold.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_sampler.py
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_parent_based.py
Outdated
Show resolved
Hide resolved
anuraaga
left a comment
There was a problem hiding this comment.
Thanks all. Actually I had realized while I was looking at the tracestate handling section of the spec, I completely missed the SDK portions... So I have compared with that and renamed things to match it. Notably, the word consistent isn't used much and the concept seems to composite sampling.
One note is I made an editorial decision on the public API - one thing I noticed with the sampling.py one is some samplers are constants, others are classes, which seemed inconsistent. Here I hid all the classes and only expose functions to be able to use singleton or not as needed with a consistent surface. Happy to go with anything the maintainers prefer though.
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_composable.py
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_trace_state.py
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_traceid_ratio.py
Show resolved
Hide resolved
|
Thanks @tammy-baylis-swi sorry for missing that - ran formatting |
* Add experimental consistent sampler * Fix import * Fix lint * CHANGELOG * Fix test name * Cleanup and match spec better * Format * Cleanup * Formatting --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Add experimental consistent sampler * Fix import * Fix lint * CHANGELOG * Fix test name * Cleanup and match spec better * Format * Cleanup * Formatting --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
This is a reopening of open-telemetry/opentelemetry-python-contrib#3668 as was recommended to target this repo.
Looking at some other similar
_exports for experimental features, they seem to be complete concepts (i.e. logs), while this is a type of an existing concept, sampler. So I tried the_sampling_experimentalname to clarify that it is an experimental part of sampling. Let me know any thoughts.Description
Adds an implementation of consistent samplers
https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling/
https://opentelemetry.io/docs/specs/otel/trace/sdk/#built-in-composablesamplers
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
TraceState)/cc @xrmx @tammy-baylis-swi
/cc @PeterF778 as original author in Java if interested
Type of change
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.