feat(tracemetrics): Expose unit type in metrics UI#108036
feat(tracemetrics): Expose unit type in metrics UI#108036narsaynorath merged 15 commits intomasterfrom
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Aci
Admin
Agent
Agents
Ai Conversations
Ai Insights
Autofix
Autopilot
Billing
Cells
Code Review
Conversations
Copilot
Core
Crons Detector Schedule Preview
Dashboards
Dynamic Grouping
Dynamic Sampling
Eco
Explore
Grouping
Infra
Integrations
Issue Details
Issues
Js Loader
Lint
Llm Detection
Notifications
Oauth
Objectstore
Occurrences On Eap
Onboarding
Preprod
Replay
Replays
Search Agent
Seer
Seer Explorer
Sentry Apps
Settings
Spans
Spans Buffer
Toolbar
Trace
Tracemetrics
Ui
Uptime
Uptime Assertion Failure Data
Other
Bug Fixes 🐛Aci
Agent Insights
Agents
Ai Conversations
Ai Insights
Alerts
Auth
Autofix
Autopilot
Billing
Cells
Code Mappings
Code Review
Codeowners
Cursor
Dashboards
Data Forwarding
Eap
Explore
Explorer
Forms
Github Copilot
Grouping
Infra
Insights
Issue Details
Issues
Lint
Notifications
Onboarding
Preprod
Releases
Replay
Seer
Settings
Span Buffer
Spans Migration
Stories
Tests
Top Issues
Trace Waterfall
Tracemetrics
Typing
Ui
Uptime
Users
Other
Documentation 📚
Internal Changes 🔧Aci
Agent
Agents
Alerts
Api
Autofix
Autopilot
Billing
Cells
Code Review
Code Review
Codeowners
Conversations
Cross Event
Dashboards
Deps
Dynamic Sampling
Eslint
Explorer
Forms
Grouping
Infra
Integrations
Issues
Llm Detection
Open Periods
Ownership
Preprod
Promotions
Relay
Replay
Routes
Scraps
Seer
Sentry Apps
Slack
Span Buffer
Spans
Stories
Tests
Theme
Tracemetrics
Ui
Uptime
Workflow Engine
Other
Other
Plus 102 more 🤖 This preview updates automatically when you update the PR. |
static/app/views/explore/metrics/metricToolbar/metricSelector.tsx
Outdated
Show resolved
Hide resolved
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.
| name: metricOptions[0].metricName, | ||
| type: metricOptions[0].metricType, | ||
| unit: hasMetricUnitsUI ? (metricOptions[0].metricUnit ?? NONE_UNIT) : undefined, | ||
| }); | ||
| } | ||
| }, [metricOptions, onChange, traceMetric.name]); | ||
| }, [metricOptions, onChange, traceMetric.name, hasMetricUnitsUI]); | ||
|
|
||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| const debouncedSetSearch = useCallback( |
There was a problem hiding this comment.
Bug: Inconsistent default values for missing metric units ('-' vs. 'none') cause comparison failures in the metric selector, breaking backward compatibility for old widgets.
Severity: HIGH
Suggested Fix
Unify the default value for missing or undefined metric units across the application. Either consistently use '-', 'none', or undefined and ensure that makeMetricSelectValue and the logic in metricSelector.tsx handle the chosen default value correctly for both the current metric and the options from the API.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/views/explore/metrics/metricToolbar/metricSelector.tsx#L74-L81
Potential issue: When the `tracemetrics-units-ui` feature is enabled, there is
inconsistent handling of missing metric units. Metrics from older widgets have their
unit placeholder `'-'` parsed into `undefined`. In the metric selector, this `undefined`
unit is defaulted to `'-'` for the currently selected metric. However, when comparing
against the list of available metrics from the API, a missing unit is defaulted to
`'none'`. This discrepancy causes the string comparison in `makeMetricSelectValue` to
fail (e.g., `'name||type||-'` does not equal `'name||type||none'`), preventing the
currently selected metric from being correctly identified in the dropdown and
potentially causing it to be duplicated.
Exposes the unit type for the metric in the selector for both Explore and Dashboards. Alerts will follow in another PR.
For the selector, we've denoted unit by placing it before the metric type (distribution, gauge, etc) tag. The UI may still change but since this is feature flagged (i.e. we only request the unit data if the user has the flag) it's fine to do this for now.
Open in Explore, Edit Widget, and Add to Dashboard should all work with units optionally (i.e. creating a widget with a unit should carry the unit over when doing these flows). We should still be able to render old widgets and saved queries that were originally saved using the hardcoded
-unit