Skip to content

fix(tracemetrics): Store label format of equation so duplicates aren't clobbered#118367

Open
narsaynorath wants to merge 2 commits into
masterfrom
nar/fix/tracemetrics-detectors-dropping-filters-when-subcomponents-match
Open

fix(tracemetrics): Store label format of equation so duplicates aren't clobbered#118367
narsaynorath wants to merge 2 commits into
masterfrom
nar/fix/tracemetrics-detectors-dropping-filters-when-subcomponents-match

Conversation

@narsaynorath

@narsaynorath narsaynorath commented Jun 24, 2026

Copy link
Copy Markdown
Member

There's a subtle bug that users were seeing when creating metrics equations in alerts. If you first added two metric queries to your equation that were the same, and then changed a filter or aggregate on one of them, the change would not update properly (i.e the equation would have stale references even though the subcomponent queries UI was updated)

To mitigate this, I've opted to add some more metadata to the VisualizeEquation class about the internal state for the VisualizeEquation. By doing this, we have a stronger method of updating the equation. Previously there was a subtle de-dupe happening with references (which is why the trigger was two of the same metric query). With the internal state stored on the class, the utils for synchronizing changes from the metric queries to the equation can change the correct queries.

As an example, set something up vaguely like this on Explore, Alerts, or Dashboards:
query A: count()
query B: count()
equation: A + B (resolves to count() + count())

Since the synchronization calls take the expression count() + count() and unresolve (i.e. change it back to label format so we can operate on the references), it actually loses A + B and thinks it's working with A + A so changes to B were silently dropped and changes to query A duplicate across both references. Storing the internal state is important to keep this context and avoid re-computing it when unnecessary.

@narsaynorath

Copy link
Copy Markdown
Member Author

@cursor review

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 24, 2026
Comment thread static/app/views/explore/metrics/equationBuilder/utils.ts Outdated
@narsaynorath

Copy link
Copy Markdown
Member Author

@cursor review

@cursor cursor Bot left a comment

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 31a0618. Configure here.

@narsaynorath narsaynorath changed the title fix(tracemetrics): Equations dropping filters when queries match fix(tracemetrics): Store label format of equation so duplicates aren't clobbered Jun 24, 2026
@narsaynorath narsaynorath marked this pull request as ready for review June 24, 2026 18:06
@narsaynorath narsaynorath requested review from a team as code owners June 24, 2026 18:06
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.

1 participant