Skip to content

fix(tracemetrics): Metric panel title should use equation with label#113143

Merged
narsaynorath merged 2 commits into
masterfrom
nar/fix/tracemetrics-equation-chart-labels
Apr 16, 2026
Merged

fix(tracemetrics): Metric panel title should use equation with label#113143
narsaynorath merged 2 commits into
masterfrom
nar/fix/tracemetrics-equation-chart-labels

Conversation

@narsaynorath

@narsaynorath narsaynorath commented Apr 16, 2026

Copy link
Copy Markdown
Member

Primarily, the equation builder was supposed to avoid leaking the internal representation out of itself, but because we want to display it in another component (i.e. the chart title), we need to expose a way to hook into the internal value when a change is reported.

In this case, call the handleExpressionChange callback with both the resolved version, and the internal version so we can read it and store it in local state for the metric panel to use for the title. This only applies to equations right now but I've made the terminology more general (i.e. title, etc)

Ideally, useMetricLabel would have been able to provide this but I didn't really want to store more metadata higher than the metric panel, where it's relevant

Screenshot 2026-04-15 at 11 35 01 PM

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 16, 2026
Base automatically changed from nar/fix/tracemetrics-resync-all-metric-queries-on-change to master April 16, 2026 13:20
@narsaynorath
narsaynorath marked this pull request as ready for review April 16, 2026 14:07
@narsaynorath
narsaynorath requested a review from a team as a code owner April 16, 2026 14:07
Comment thread static/app/views/explore/metrics/metricPanel/index.tsx

@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.

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 dfdb148. Configure here.

return unresolveExpression(visualize.expression.text, referenceMap);
}
return undefined;
});

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.

Stale chart title in non-refresh UI path

Medium Severity

The title state is initialized once via useState and only updated through onTitleChange (which is setTitle). In the non-refresh UI path, MetricToolbar is rendered in MetricsQueryBuilderSection without passing onTitleChange, while MetricPanel is rendered separately. When a user edits an equation through the external toolbar, title becomes stale but still takes precedence over metricLabel in the chart title via title ?? metricLabel. Before this PR, the chart title correctly showed the updated resolved expression from metricLabel; now it shows the original unresolved expression from initial mount.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dfdb148. Configure here.

@narsaynorath narsaynorath Apr 16, 2026

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.

I suppose this is a concern and should be recalculated, but it works out because even if a reference map item changes, the label shouldn't because the equation itself wasn't affected. Going to accept this for now.

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.

Seems reasonable to accept 👍

return unresolveExpression(visualize.expression.text, referenceMap);
}
return undefined;
});

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.

Seems reasonable to accept 👍

@narsaynorath
narsaynorath merged commit af0eefa into master Apr 16, 2026
64 of 65 checks passed
@narsaynorath
narsaynorath deleted the nar/fix/tracemetrics-equation-chart-labels branch April 16, 2026 14:44
@github-actions github-actions Bot locked and limited conversation to collaborators May 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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