feat(tracemetrics): Implement read-only view for equations in alerts#113446
Conversation
This adds a skeleton that I'll be adding interactivity to. An existing equation (created through the API) can be viewed using this to show what an equation would look like
…for-selecting-metrics-in-alerts
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 ed71620. Configure here.
|
|
||
| const setTraceMetric = () => {}; | ||
| const handleExpressionChange = () => {}; | ||
| const handleReferenceLabelsChange = () => {}; |
There was a problem hiding this comment.
Unstable no-op handlers cause repeated effect re-runs
Medium Severity
The inline () => {} no-op functions for handleExpressionChange and handleReferenceLabelsChange create new references on every render. EquationBuilder has a useEffect with onReferenceLabelsChange in its dependency array, so this effect (which does non-trivial work including new Expression(...) construction and extractReferenceLabels() computation) fires on every single render along with its cleanup. Similarly, handleExpressionChange being unstable causes EquationBuilder's internal useCallback to recreate each render. Since noop from lodash is already imported and provides a stable reference, these inline functions can be replaced with noop to avoid this unnecessary work.
Reviewed by Cursor Bugbot for commit ed71620. Configure here.


This adds a skeleton that I'll be adding interactivity to. An existing equation (created through the API) can be viewed using this to show what an equation would look like
It closely mimics what we have for the Explore equation builder flow. Queries can't be deleted if they're referenced in equations. Everything gets a label. I'm only going to allow one equation at the moment (can open it up later). There is currently no way to transition from the regular single metric view to equations, but I'll make a PR to change that soon.
The following screenshot is of this equation (adjust URL to your viewing env): https://sentry.dev.getsentry.net:7999/monitors/7037172/edit/?project=1&statsPeriod=1h