Experimenting with Greedy Sampling #3167
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Playing around with some ideas for how we could use internal Sentry metrics to avoid randomly dropping envelopes:
These are published as Sytem.Diagnostics.Metrics and we don't necessarily need to capture these and send them through to Sentry. I did that here just to provide a visual of the metrics being captured.
However, I figured it might be possible to listen to these metrics in process and use them in a custom TraceSampler that adjusted the sample rate down if envelopes started to get dropped and adjusted back up if there was lots of space in the queue...
This could be thought of as a GreedySampler or a PoliteSampler. It would try to find the maximum sample rate that could be sustained before envelopes start to get dropped. That way the envelopes that are being selected out are those related to traces (not those related to crash reports or metrics).