Skip to content
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

[Ingest Investigation] Reservoir of samples #54449

Closed
3 tasks done
Tracked by #54094
matejminar opened this issue Aug 9, 2023 · 1 comment
Closed
3 tasks done
Tracked by #54094

[Ingest Investigation] Reservoir of samples #54449

matejminar opened this issue Aug 9, 2023 · 1 comment
Assignees

Comments

@matejminar
Copy link
Member

matejminar commented Aug 9, 2023

We need to communicate to Relay that the user would like to upsample specific transaction with applied query filters.
E.g. upsample transaction X with custom tag value Y and transaction duration more than Z.

Ideally, this would not just multiply the base sample rate for a limited amount of time, but it would set it to 100% until we collect 10 samples. (10 is made up number)

Tasks

Preview Give feedback
@jan-auer jan-auer assigned jan-auer and TBS1996 and unassigned jan-auer Sep 1, 2023
TBS1996 added a commit to getsentry/relay that referenced this issue Sep 29, 2023
Relay implementation of the reservoir project:
getsentry/sentry#54449

Reservoir bias uses a type of `SamplingRule` which will sample all
matches until a certain limit has been reached. This limit is tracked
both locally on each relay, and with a global synchronized one in redis
that procesisng relays can have access to. The redis counter will update
the local counter if it's available.

The counters are saved on the `Project` struct, with a
Mutex<BTreeMap<Ruleid, i64>> .
When we send an envelope for processing we send its corresponding
project counters in the `ProcessEnvelopeState` to the
`EnvelopeProcessorService`.

There, in the `dynamic-sampling` crate, we introduce a
`ReservoirEvaluator`, which will, when a reservoir rule is matching,
check if the rule has been reached or not by using the local counters we
sent or if applicable the redis global count. The `ReservoirEvaluator`
also takes care of updating both redis and the local counter.

After the limit is reached, the rule is no longer valid and will be
ignored, so that the normal `SampleRate` and `Factor` variant of
`SamplingValue` will apply.

Sentry is responsible for removing the reservoir rule from the
`SamplingConfig` when it has reached its limit.

Whenever we receive a new `ProjectConfig`, we remove all the reservoir
counters from its project that are no longer in the
`DynamicSamplingConfig`.

regarding the use of mutex:
We use try_lock to avoid getting blocked in case the mutex is already in
use. There's two reasons it might be blocked.

1. Another thread is handling a reservoir rule from the same project at
the same time.
2. We are in the process of removing counters from that same project.
@TBS1996
Copy link
Contributor

TBS1996 commented Oct 4, 2023

Ingest-side is finished 🤞

Next phase will be implementation of sentry-side and a test to see if it works, waiting for @RaduW for status here.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants