-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(explorer): update issue tags and timeseries by time range #106316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| if "count()" not in timeseries_response: | ||
| return 0 | ||
| data = timeseries_response["count()"]["data"] | ||
| return sum(item[1][0]["count"] for item in data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The function get_timeseries_count_total may raise an IndexError because it accesses item[1][0] without checking if item[1] is empty for time buckets with no data.
Severity: CRITICAL
Suggested Fix
Add a condition to the generator expression to filter out items where item[1] is empty. The sum should be calculated as sum(item[1][0]["count"] for item in data if item[1]). This matches the defensive pattern used elsewhere in the codebase for processing the same data structure.
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/utils.py#L496
Potential issue: The function `get_timeseries_count_total` calculates a total by summing
counts from a timeseries response. It iterates through data items and accesses
`item[1][0]["count"]`. However, for time buckets that contain no events, the `item[1]`
list will be empty. The code does not check for this case, leading to an `IndexError`
when it attempts to access the 0th element of the empty list. This will cause the
`get_issue_and_event_response` function to fail, breaking the issue details view in
Explorer. Other parts of the codebase defensively check for this condition using `if
item[1]`.
Did we get this right? 👍 / 👎 to inform future reviews.
| interval = interval or "3d" | ||
|
|
||
| # Adjust range to equal period | ||
| end_dt = start_dt + selected_delta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: A time range mismatch between the total event count and tag data queries in get_issue_and_event_response leads to incorrect percentage calculations for tag distribution.
Severity: HIGH
Suggested Fix
Ensure the get_group_tags_overview function is called with the same adjusted time range that was used to generate the event_count. The adjusted end_dt from _get_issue_event_timeseries should be passed down and used for both the timeseries and the facets queries to maintain consistency.
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/tools.py#L768
Potential issue: In `get_issue_and_event_response`, the total event count is calculated
from a timeseries query whose time range is automatically extended (e.g., from 5 minutes
to 6 hours) for resolution alignment. However, this total count is then used as the
denominator for percentage calculations in `get_group_tags_overview`, which queries for
tag data using the original, narrower time range. This mismatch between the time range
used for the total count and the time range for individual tag counts results in
incorrect tag distribution percentages being displayed to the user.
Did we get this right? 👍 / 👎 to inform future reviews.
| interval = interval or "3d" | ||
|
|
||
| # Adjust range to equal period | ||
| end_dt = start_dt + selected_delta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timeseries and tag query time ranges are mismatched
High Severity
The _get_issue_event_timeseries function extends end_dt to match a selected period (e.g., extending a 2-day request to 3 days), but get_group_tags_overview queries tags using the original time range parameters. The event_count from the extended timeseries is then used as the denominator for tag percentage calculations in get_all_tags_overview. This causes incorrect percentages—for example, a tag appearing 50 times in a 2-day period might show 33% instead of 50% because the denominator includes events from an extended 3-day range.
No description provided.