豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

feat(tracemetrics): Implement read-only view for equations in alerts#113446

Merged
narsaynorath merged 5 commits intomasterfrom
nar/feat/tracemetrics-implement-new-field-for-selecting-metrics-in-alerts
Apr 20, 2026
Merged

feat(tracemetrics): Implement read-only view for equations in alerts#113446
narsaynorath merged 5 commits intomasterfrom
nar/feat/tracemetrics-implement-new-field-for-selecting-metrics-in-alerts

Conversation

@narsaynorath
Copy link
Copy Markdown
Member

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

Screenshot 2026-04-20 at 12 12 39 PM

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
@narsaynorath narsaynorath requested review from a team as code owners April 20, 2026 16:16
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 20, 2026
Comment thread static/app/views/detectors/datasetConfig/components/metricsSearchBar.tsx Outdated
Comment thread static/app/views/detectors/components/forms/metric/metricsEquationVisualize.tsx Outdated
Comment thread static/app/views/detectors/components/forms/metric/metric.tsx
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a 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.

Fix All in Cursor

❌ 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 = () => {};
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.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ed71620. Configure here.

@narsaynorath narsaynorath merged commit 5aa0724 into master Apr 20, 2026
64 of 65 checks passed
@narsaynorath narsaynorath deleted the nar/feat/tracemetrics-implement-new-field-for-selecting-metrics-in-alerts branch April 20, 2026 18:34
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