Skip to content

feat(dynamic-sampling): add per-project volume query#114286

Merged
shellmayr merged 27 commits into
masterfrom
simon-hellmayr/feat/ds-per-org-eap-project-volumes
May 27, 2026
Merged

feat(dynamic-sampling): add per-project volume query#114286
shellmayr merged 27 commits into
masterfrom
simon-hellmayr/feat/ds-per-org-eap-project-volumes

Conversation

@shellmayr
Copy link
Copy Markdown
Member

  • Add Query to EAP for per-project span volumes that will serve as the basis for the low-volume project calculations

Closes TET-2276

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 29, 2026

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 29, 2026
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch from fd999fa to 3ec582f Compare April 29, 2026 13:00
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch 3 times, most recently from 0d92603 to 6be8020 Compare May 6, 2026 12:18
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch from 2461de9 to 661c994 Compare May 7, 2026 13:52
shellmayr and others added 8 commits May 7, 2026 15:54
Keep the per-org project volume work on transaction segments so measure-specific EAP query changes can live on a dependent branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@shellmayr shellmayr marked this pull request as ready for review May 8, 2026 11:51
@shellmayr shellmayr requested review from a team as code owners May 8, 2026 11:51
@shellmayr shellmayr requested a review from constantinius May 8, 2026 11:51
keep = _get_aggregate_int(row, "count_sample()")
project_volumes.append(
ProjectVolume(
project_id=ProjectId(int(row["sentry.dsc.root_project"])),
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.

Bug: Calling int() on row["sentry.dsc.root_project"] will raise a TypeError when the value is None, which occurs for spans lacking a DSC header.
Severity: HIGH

Suggested Fix

Add a null check before casting the sentry.dsc.root_project value to an integer. Handle the None case gracefully, for example by assigning a default value or skipping the row, similar to how _get_aggregate_int handles nulls.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/dynamic_sampling/per_org/tasks/queries.py#L146

Potential issue: The code directly accesses `row["sentry.dsc.root_project"]` and
attempts to cast it to an integer using `int()`. However, when processing spans that
lack a Dynamic Sampling Context (DSC) header, which is a realistic scenario with older
SDKs or incomplete trace propagation, the value for `sentry.dsc.root_project` can be
`None`. Attempting to execute `int(None)` will raise a `TypeError`, causing the task to
crash. While other parts of the code handle null values correctly, this specific access
point lacks the necessary null check.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py
@shellmayr shellmayr marked this pull request as ready for review May 26, 2026 14:08
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 4d371b8. Configure here.

Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py
@shellmayr shellmayr merged commit b767245 into master May 27, 2026
83 checks passed
@shellmayr shellmayr deleted the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch May 27, 2026 09:32
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.

2 participants