-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add sampling capabilities to the tracing module #2886
Conversation
de9c14f
to
12f68d0
Compare
Codecov Report
@@ Coverage Diff @@
## master #2886 +/- ##
==========================================
+ Coverage 76.83% 76.94% +0.11%
==========================================
Files 229 230 +1
Lines 16923 16978 +55
==========================================
+ Hits 13002 13063 +61
+ Misses 3078 3076 -2
+ Partials 843 839 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
It could be good to address #2889 here |
@codebien I'll give it shot, if it takes more than an hour or two, I would address it during cooldown in a separate PR 👍🏻 |
12f68d0
to
24a3d13
Compare
4cd3f1c
to
c691b5c
Compare
f1a8666
to
4caeffe
Compare
This commit adds a Sampler interface defining a contract for implementing support for sampling. This means that any client of a sampler could go through the interface to decide whether or not to perform an action or keep some piece of data. This commit adds a ProbabilisticSampler implementation of Sampler, meant to be implemented by propagators to decide whether they should set their sampling flag to true or false. This commit also adds a chance function which returns true with a `percentage` of chance, to support the ProbabilisticSampler implem.
This commit defines a SamplerPropagator interface, which established the contract for a propagator which bases its sampling flag on a Sampler implementation. It also makes the concrete implementations of Propagators implement the Sampler interface, and ensure the flags field of the generated trace context headers is set based on the Sampler's result.
4caeffe
to
1545df1
Compare
1545df1
to
e6080c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
A nitpick was that it seems to be we can just inline the chance
function, but I am okay either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, has some minor comments. Really well done, I'm out from tracing domain but it has been easy to understand 👏
Addressed all comments, looking forward to your 👍🏻 👏🏻 🙇🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I restarted the failed checks
About
This Pull Request adds probabilistic sampling support to the tracing module. Using it, users can specify the percentage of their instrumented requests which should have their trace context header's sampled field set to true.
From a user-interface perspective, this feature is introduced as an option meant to be set during either the instantiation of a
tracing.Client
, or during a call toinstrumentHTTP
. It consists of a single integer field of the tracing options, whose value, within the0 <= n <= 100
bounds, is meant to represent a percentage.This feature is implemented using probabilistic sampling. Meaning that over an extensive series of iterations, the number of requests with their sampled flag set to true will tend to converge to the selected
sampling
rate value. It was a design choice without explicit constraints, preferring randomness over accuracy: each trace context generation evaluates its chance of being sampled independently. If you find an implementation emphasizing accuracy more suitable, I'm open to exploring that route; just let me know.Note that regardless of the sampled header flag's value, the
trace_id
metadata will be attached to each output sample.