Skip to content

fix(dynamic-sampling): Skip a per-org recalibration write within one cycle - #122974

Merged
shellmayr merged 5 commits into
masterfrom
fix/ds-per-org-recalibration-write-guard
Aug 28, 2026
Merged

fix(dynamic-sampling): Skip a per-org recalibration write within one cycle#122974
shellmayr merged 5 commits into
masterfrom
fix/ds-per-org-recalibration-write-guard

Conversation

@shellmayr

@shellmayr shellmayr commented Aug 28, 2026

Copy link
Copy Markdown
Member
  • Currently, when the CursoredScheduler runs the task too often, we see a sawtooth-style pattern in the recalibration factor. Therefore, we need to make sure this doesn't run multiple times as long as it's not been applied for long enough. Each application of the recalibration factor needs time to have an effect, only then we can measure its effects and do the next correction.
  • Skip the per-org recalibration factor write when the stored factor is younger than 9 minutes, derived from its remaining TTL, so a duplicate pass within one cycle cannot compound the correction

Contributes to TET-2897

shellmayr and others added 2 commits August 28, 2026 11:02
…cycle

Each pass applies its correction on top of the stored factor, so a pass that
runs again within one scheduler cycle compounds it. Derive the stored factor's
age from its remaining TTL and leave a factor younger than nine minutes alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Orgs in the per-org serving-org-ids option get a log line each time the
recalibration bias runs for one of their projects, with the factor it served.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

TET-2897

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 28, 2026
@shellmayr shellmayr changed the title fix(dynamic-sampling): Guard per-org recalibration writes and log the served factor fix(dynamic-sampling): Skip a per-org recalibration write within one cycle Aug 28, 2026
@shellmayr
shellmayr marked this pull request as ready for review August 28, 2026 09:27
@shellmayr
shellmayr requested a review from a team as a code owner August 28, 2026 09:27
Comment thread src/sentry/dynamic_sampling/per_org/cache.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 761d9b2. Configure here.

Comment thread src/sentry/dynamic_sampling/per_org/cache.py
@shellmayr
shellmayr merged commit 138f818 into master Aug 28, 2026
69 checks passed
@shellmayr
shellmayr deleted the fix/ds-per-org-recalibration-write-guard branch August 28, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants