Skip to content

feat(dynamic-sampling): Add per-project sample rate override for custom DS#117796

Merged
shellmayr merged 4 commits into
masterfrom
shellmayr/tet-2490-dynamic-sampling-sample-rate-override
Jun 17, 2026
Merged

feat(dynamic-sampling): Add per-project sample rate override for custom DS#117796
shellmayr merged 4 commits into
masterfrom
shellmayr/tet-2490-dynamic-sampling-sample-rate-override

Conversation

@shellmayr

Copy link
Copy Markdown
Member
  • Add dynamic-sampling.sample-rate-override-per-project option — a map of stringified project id → fixed sample rate — to pin specific projects to a known rate out-of-band
  • Closes the gap where the custom (AM3) DS path had no override hook (the existing getsentry override only wraps the blended/automatic rate, which the custom path never calls)
  • Legacy path: apply the override in get_guarded_project_sample_rate, winning over org/project targets and the recently-added/rebalanced rate
  • New per-org path: apply it as an explicit apply_project_sample_rate_overrides step in the scheduler after balancing, so it's surfaced in the pipeline and feeds the cached rates + transaction balancing
  • Out-of-range/invalid values are ignored (hard-replace semantics otherwise)
  • Tests cover both paths, no-op-without-option, and the AM3 organization-mode baseline behavior

Contributes to TET-2490

shellmayr and others added 2 commits June 16, 2026 15:45
…om DS

Allow pinning specific projects to a fixed dynamic sampling rate out-of-band via
the dynamic-sampling.sample-rate-override-per-project option (a map of project id to
rate). Previously the custom (AM3) dynamic sampling path had no override hook -- the
existing getsentry override only wraps the blended/automatic rate, which the custom
path never calls.

The override hard-replaces the resolved rate in both custom-DS paths:
- Legacy path: get_guarded_project_sample_rate, winning over org/project targets and
  the recently-added/rebalanced rate.
- New per-org path: applied as an explicit apply_project_sample_rate_overrides step in
  the scheduler after balancing, so it is surfaced in the pipeline and feeds the cached
  rates and transaction balancing.

Out-of-range or invalid values are ignored. Also adds tests covering both paths and the
AM3 organization-mode sample rate behavior.

Refs TET-2490
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rg mode

Add tests for the per-project override applied in get_guarded_project_sample_rate
(override wins over the recently-added boost; out-of-range values ignored) and for
the AM3 organization-mode sample rate being the configured target regardless of
ingested volume.

Refs TET-2490
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 16, 2026

Copy link
Copy Markdown

TET-2490

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 16, 2026
Remove the AM3 organization-mode high-volume tests that are unrelated to the
per-project sample rate override; keep only the override tests.

Refs TET-2490
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shellmayr shellmayr marked this pull request as ready for review June 16, 2026 13:50
@shellmayr shellmayr requested review from a team as code owners June 16, 2026 13:50

@constantinius constantinius 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.

Looks good.

apply_project_sample_rate_overrides called get_sample_rate_override_for_project
per project, which read the option on every call. Add get_sample_rate_overrides
that reads and validates the option once into a {project_id: rate} map; the batch
path builds it once and intersects against it, and the single-project helper now
delegates to it.

Refs TET-2490
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@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 2 potential issues.

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 7db4245. Configure here.

Comment thread src/sentry/dynamic_sampling/rules/base.py
Comment thread src/sentry/dynamic_sampling/rules/base.py

@vgrozdanic vgrozdanic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

@shellmayr shellmayr merged commit 8371a87 into master Jun 17, 2026
85 checks passed
@shellmayr shellmayr deleted the shellmayr/tet-2490-dynamic-sampling-sample-rate-override branch June 17, 2026 06:57
billyvg pushed a commit that referenced this pull request Jun 17, 2026
…om DS (#117796)

- Add `dynamic-sampling.sample-rate-override-per-project` option — a map
of stringified project id → fixed sample rate — to pin specific projects
to a known rate out-of-band
- Closes the gap where the custom (AM3) DS path had no override hook
(the existing getsentry override only wraps the blended/automatic rate,
which the custom path never calls)
- **Legacy path:** apply the override in
`get_guarded_project_sample_rate`, winning over org/project targets and
the recently-added/rebalanced rate
- **New per-org path:** apply it as an explicit
`apply_project_sample_rate_overrides` step in the scheduler after
balancing, so it's surfaced in the pipeline and feeds the cached rates +
transaction balancing
- Out-of-range/invalid values are ignored (hard-replace semantics
otherwise)
- Tests cover both paths, no-op-without-option, and the AM3
organization-mode baseline behavior

Contributes to TET-2490

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
sehr-m pushed a commit that referenced this pull request Jun 23, 2026
…om DS (#117796)

- Add `dynamic-sampling.sample-rate-override-per-project` option — a map
of stringified project id → fixed sample rate — to pin specific projects
to a known rate out-of-band
- Closes the gap where the custom (AM3) DS path had no override hook
(the existing getsentry override only wraps the blended/automatic rate,
which the custom path never calls)
- **Legacy path:** apply the override in
`get_guarded_project_sample_rate`, winning over org/project targets and
the recently-added/rebalanced rate
- **New per-org path:** apply it as an explicit
`apply_project_sample_rate_overrides` step in the scheduler after
balancing, so it's surfaced in the pipeline and feeds the cached rates +
transaction balancing
- Out-of-range/invalid values are ignored (hard-replace semantics
otherwise)
- Tests cover both paths, no-op-without-option, and the AM3
organization-mode baseline behavior

Contributes to TET-2490

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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