-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(preprod): Add TRACE_ITEM_PREPROD support to snuba #106569
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
Add routing logic for TRACE_ITEM_PREPROD event type to use the PreprodSize dataset module in entity_subscription.py. Without this, preprod alerts would incorrectly query the Spans dataset.
…ROD alerts When TRACE_ITEM_PREPROD is selected for alerts, we need to use PreprodSizeSearchResolverConfig instead of the default SearchResolverConfig. This ensures the critical `sub_item_type="size_metric"` filter is applied, so preprod alerts query only size metric data instead of all preprod data.
| extrapolation_mode=proto_extrapolation_mode, | ||
| stable_timestamp_quantization=False, | ||
| ) | ||
| elif is_preprod: | ||
| search_config = PreprodSizeSearchResolverConfig( | ||
| stable_timestamp_quantization=False, | ||
| extrapolation_mode=proto_extrapolation_mode, | ||
| ) | ||
| else: | ||
| search_config = SearchResolverConfig( | ||
| stable_timestamp_quantization=False, |
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 chart generation logic in incidents/charts.py incorrectly sets the dataset to "spans" instead of "preprodSize" for the new TRACE_ITEM_PREPROD event type.
Severity: MEDIUM
Suggested Fix
In incidents/charts.py, add a condition to check for the TRACE_ITEM_PREPROD event type. When this event type is detected, explicitly set query_params["dataset"] to "preprodSize" to ensure the correct dataset is queried for chart data.
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/snuba/entity_subscription.py#L347-L357
Potential issue: The introduction of the `TRACE_ITEM_PREPROD` event type is not fully
handled in the alert chart generation logic. In `incidents/charts.py`, when
`build_metric_alert_chart()` is called for a `TRACE_ITEM_PREPROD` alert, the code
defaults to setting the `dataset` query parameter to `"spans"`. However, this new event
type requires the dataset to be `"preprodSize"`. This mismatch will cause the
`/organizations/{slug}/events-stats/` API endpoint to query the wrong Snuba dataset,
resulting in incorrect or empty charts for preprod size alerts.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| SnubaQueryEventType.EventType.TRACE_ITEM_LOG, | ||
| SnubaQueryEventType.EventType.TRACE_ITEM_SPAN, | ||
| SnubaQueryEventType.EventType.TRACE_ITEM_METRIC, | ||
| SnubaQueryEventType.EventType.TRACE_ITEM_PREPROD, |
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.
Missing aggregate validation for TRACE_ITEM_PREPROD causes runtime failures
Medium Severity
TRACE_ITEM_PREPROD is added as a valid event type, but unlike TRACE_ITEM_METRIC which has validate_trace_metrics_aggregate(), there's no validation ensuring the aggregate is supported by PreprodSize. The PREPROD_SIZE_AGGREGATE_DEFINITIONS only defines max and min functions. Users can create alerts with common aggregates like count() that pass validation but fail at runtime with "Unknown function" errors when SearchResolver.resolve_function() can't find the function in the limited preprod definitions.
No description provided.