Skip to content

feat(tracemetrics): Add alert via dropdown in explore#112963

Merged
k-fish merged 3 commits intomasterfrom
feat/tracemetrics/allow-adding-alerts-from-explore
Apr 15, 2026
Merged

feat(tracemetrics): Add alert via dropdown in explore#112963
k-fish merged 3 commits intomasterfrom
feat/tracemetrics/allow-adding-alerts-from-explore

Conversation

@k-fish
Copy link
Copy Markdown
Member

@k-fish k-fish commented Apr 14, 2026

Allows alerts to be added from the 'saveas' dropdown in metrics tab. Will show as 'monitors' for the new workflow engine ui.

Equations are not allowed since they aren't supported in alerts yet.

Allows alerts to be added from the 'saveas' dropdown in metrics tab.
Will show as 'monitors' for the new workflow engine ui.
@k-fish k-fish requested a review from a team as a code owner April 14, 2026 19:28
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 14, 2026
const alertsUrls = metricQueries
.filter(mq => isVisualizeFunction(mq.queryParams.visualizes[0]!))
.map((metricQuery, index) => {
const visualize = metricQuery.queryParams.visualizes[0]!;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should prob fix this in another PR to not allow multiple if they are really 1:1

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Apr 14, 2026

Sentry Snapshot Testing

Name Added Removed Modified Renamed Unchanged Status
sentry-frontend
sentry-frontend
0 0 0 0 204 ✅ Unchanged

Comment on lines +52 to +55
const project =
projects.length === 1
? projects[0]
: projects.find(p => p.id === `${pageFilters.selection.projects[0]}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: When "All Projects" is selected, the project variable becomes undefined, causing the alert creation URL to lack a pre-selected project, degrading the user experience.
Severity: LOW

Suggested Fix

Add an explicit check to handle the "All Projects" case. If pageFilters.selection.projects is empty or contains the sentinel value for all projects, do not attempt to find a specific project. Instead, allow the alert creation URL to be generated without a project, or implement logic to handle this case as intended, ensuring the user experience is not degraded.

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: static/app/views/explore/metrics/useSaveAsMetricItems.tsx#L52-L55

Potential issue: When a user has "All Projects" or "My Projects" selected in the metrics
explore view, the logic to determine the current project results in an `undefined`
value. This is because `projects.find(p => p.id ===
`${pageFilters.selection.projects[0]}`)` fails when `pageFilters.selection.projects[0]`
is `undefined` or `-1`. While the downstream `getAlertsUrl()` function handles the
`undefined` project gracefully by generating a URL without a project slug, this leads to
a functional regression. The user is navigated to the alert creation page but must
manually re-select the project, losing the context from the explore view.

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

@k-fish k-fish merged commit c4e6196 into master Apr 15, 2026
73 of 75 checks passed
@k-fish k-fish deleted the feat/tracemetrics/allow-adding-alerts-from-explore branch April 15, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants