Repository navigation
fix(formatting): read camelCase metric alert evidence and link to breach data - #1715
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
…ach data Metric issue output only showed the evaluated value and threshold. The event API camelCases the whole occurrence payload, but the formatter read snake_case keys (`data_sources`, `query_obj`, `snuba_query`, `alert_id`), so dataset, aggregate, query, interval and environment never rendered. Only single-word keys like `value` and `conditions` matched. - Read `dataSources[].queryObj.snubaQuery`, `detectorId` and `alertId`. - Show the Metric Monitor ID, a readable dataset label and the evaluated window. - Replace the stacktrace and trace hints in Response Notes with `get_metric_monitor_details` and a pre-filled `search_errors`, `search_logs`, `search_traces` or `search_metrics` call for the monitor's query, environment and a period covering the breach. - Rebuild the metric tests from the real camelCased event shape. Fixes #1087 Co-Authored-By: Dhrumil Parekh <dhrumil.parekh@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit a819d48. Configure here.
Sentry search binds implicit AND tighter than OR, so appending `environment:` to an OR query only constrained its last term.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #1087.
Metric issue output only showed the evaluated value and threshold. The event API camelCases the whole occurrence payload (
convert_dict_key_case(occurrence.to_dict(), snake_to_camel_case)in sentry'sapi/serializers/models/event.py). The formatter from #1129 read snake_case keys (data_sources,query_obj,snuba_query,alert_id), so the dataset, aggregate, query, interval and environment never rendered. Only single-word keys likevalueandconditionsmatched. The #1129 tests used hand-written snake_case fixtures, so they passed anyway.Agents also had no next step. The Response Notes suggested stacktrace and trace lookups, which don't apply to metric issues: the event's trace context comes from the monitor evaluation, not from the data that crossed the threshold.
Changes
dataSources[].queryObj.snubaQuery,detectorIdand the legacyalertId.getDetectorDatasetmapping) and the evaluated window (timeWindowbefore the occurrence).get_metric_monitor_details(organizationSlug, monitorId)for the monitor configuration and connected Alerts.search_errors,search_logs,search_tracesorsearch_metricscall, chosen by dataset. It is pre-filled with the monitor's query plus anenvironment:filter, the project, and a relativeperiodthat reaches back to the evaluated window. The window's start and end are shown next to it.showArgumentstoformatToolCallInstructionso these notes print the full call. Previously it ignoredarguments.Example (logs monitor)
Notes
transactions,generic_metricsand crash-free (metrics/sessions) monitors. Their query syntax doesn't map cleanly onto the current search tools. The monitor ID and details note still render.period, so the call can return data after the breach too. That's why the note gives the exact window to focus on.EvidenceDatainworkflow_engine/handlers/detector/base.py,DataSourceSerializerandSnubaQuerySerializer). It has not been checked against a captured production payload.Tests
pnpm exec vitest runinpackages/mcp-core: 1886 passed, 6 skippedtsc --noEmit(mcp-core),oxlint,oxfmt --check,ast-grepon changed files: cleanvia Dhrumil.
--
View Junior Session [Sentry]