feat(dynamic-sampling): add per-project volume query#114286
Conversation
fd999fa to
3ec582f
Compare
0d92603 to
6be8020
Compare
2461de9 to
661c994
Compare
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>
| keep = _get_aggregate_int(row, "count_sample()") | ||
| project_volumes.append( | ||
| ProjectVolume( | ||
| project_id=ProjectId(int(row["sentry.dsc.root_project"])), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.

Closes TET-2276