Skip to content

Conversation

@roaga
Copy link
Member

@roaga roaga commented Nov 7, 2025

Instead of picking the top transactions for a project by volume, pick them by total time spent. This mirrors what's done on the Insights page and seems to select the more meaningful parts of the app (rather than stuff like health checks and middleware for example).

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 7, 2025
@roaga roaga marked this pull request as ready for review November 7, 2025 17:11
@roaga roaga requested a review from a team as a code owner November 7, 2025 17:11
@roaga roaga requested a review from aliu39 November 7, 2025 17:11
Comment on lines 79 to 88
result = Spans.run_table_query(
params=snuba_params,
query_string=f"is_transaction:true project.id:{project_id}",
query_string="is_transaction:true",
selected_columns=[
"transaction",
"count()",
"sum(span.duration)",
],
orderby=["-count()"], # Sort by count descending (highest volume first)
orderby=["-sum(span.duration)"],
offset=0,
limit=limit,
Copy link

Choose a reason for hiding this comment

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

Bug: get_transactions_for_project() lacks an explicit project.id filter in its query_string, potentially returning data from all projects.
Severity: CRITICAL | Confidence: 0.95

🔍 Detailed Analysis

The get_transactions_for_project() function constructs a query_string="is_transaction:true" without explicitly including project.id:{project_id}. Despite snuba_params containing projects=[project], this metadata is not automatically applied as a server-side filter in the RPC layer, as indicated by similar filtering requirements in SearchResolver.resolve_query(). This results in the function returning transactions from all projects in the organization, rather than being scoped to the specified project_id.

💡 Suggested Fix

Modify the query_string in get_transactions_for_project() to explicitly include project.id:{project_id} to ensure results are correctly scoped.

🤖 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/seer/explorer/index_data.py#L79-L88

Potential issue: The `get_transactions_for_project()` function constructs a
`query_string="is_transaction:true"` without explicitly including
`project.id:{project_id}`. Despite `snuba_params` containing `projects=[project]`, this
metadata is not automatically applied as a server-side filter in the RPC layer, as
indicated by similar filtering requirements in `SearchResolver.resolve_query()`. This
results in the function returning transactions from all projects in the organization,
rather than being scoped to the specified `project_id`.

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

Copy link
Member Author

Choose a reason for hiding this comment

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

i believe this is wrong because the snuba params has the project filter

@roaga roaga merged commit 2575556 into master Nov 7, 2025
66 checks passed
@roaga roaga deleted the explorer/time-spent-transactions branch November 7, 2025 17:28
Jesse-Box pushed a commit that referenced this pull request Nov 12, 2025
Instead of picking the top transactions for a project by volume, pick
them by total time spent. This mirrors what's done on the Insights page
and seems to select the more meaningful parts of the app (rather than
stuff like health checks and middleware for example).
andrewshie-sentry pushed a commit that referenced this pull request Nov 13, 2025
Instead of picking the top transactions for a project by volume, pick
them by total time spent. This mirrors what's done on the Insights page
and seems to select the more meaningful parts of the app (rather than
stuff like health checks and middleware for example).
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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