fix(tracemetrics): Store label format of equation so duplicates aren't clobbered#118367
Open
narsaynorath wants to merge 2 commits into
Open
Conversation
Member
Author
|
@cursor review |
Member
Author
|
@cursor review |
Contributor
There was a problem hiding this comment.
✅ 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.
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.
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
VisualizeEquationclass about the internal state for theVisualizeEquation. 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 tocount() + 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 losesA + Band thinks it's working withA + Aso changes toBwere 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.