-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore(tracemetrics): Remove unneeded trace metric from queries #103391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tracemetrics): Remove unneeded trace metric from queries #103391
Conversation
This isn't needed anymore because we parse the condition from the aggregation.
| enabled, | ||
| limit, | ||
| traceMetric, | ||
| queryExtras: { | ||
| ...queryExtras, | ||
| traceMetric, | ||
| }, | ||
| queryExtras, | ||
| }, | ||
| queryOptions: { | ||
| canTriggerHighAccuracy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: useMetricAggregatesTable.tsx fails to add traceMetric filters (metric.name, metric.type) to the search query, leading to unfiltered aggregate results.
Severity: CRITICAL | Confidence: 0.95
🔍 Detailed Analysis
In useMetricAggregatesTable.tsx, the traceMetric parameters were removed from queryExtras, but the corresponding metric filters (TraceMetricKnownFieldKey.METRIC_NAME, TraceMetricKnownFieldKey.METRIC_TYPE) were not added to the search query. The backend expects explicit query parameters for metric filtering, not just parsing from aggregation expressions. Consequently, the aggregates table will return data for all metrics instead of filtering to the selected traceMetric, leading to incorrect and misleading results.
💡 Suggested Fix
Update useMetricAggregatesTable.tsx to add traceMetric.name and traceMetric.type as filters to the MutableSearch object when traceMetric is present, mirroring the implementation in useMetricSamplesTable.tsx.
🤖 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/hooks/useMetricAggregatesTable.tsx#L66-L72
Potential issue: In `useMetricAggregatesTable.tsx`, the `traceMetric` parameters were
removed from `queryExtras`, but the corresponding metric filters
(`TraceMetricKnownFieldKey.METRIC_NAME`, `TraceMetricKnownFieldKey.METRIC_TYPE`) were
not added to the search query. The backend expects explicit query parameters for metric
filtering, not just parsing from aggregation expressions. Consequently, the aggregates
table will return data for all metrics instead of filtering to the selected
`traceMetric`, leading to incorrect and misleading results.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference_id: 2694881
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Metric Filters Compromise Data Integrity
The metric filters are no longer being sent to the backend. The old code explicitly passed metricName and metricType as query parameters in useSortedTimeSeries, but the diff removes these without adding the metric filters to the search query. Unlike useMetricSamplesTableImpl, which adds metric filters using addFilterValue(), this change leaves metric filtering information missing. This will cause timeseries queries to return incorrect data without the intended metric name and type filtering.
static/app/views/explore/metrics/hooks/useMetricTimeseries.tsx#L42-L78
sentry/static/app/views/explore/metrics/hooks/useMetricTimeseries.tsx
Lines 42 to 78 in 85ccbe0
| } | |
| interface UseMetricTimeseriesImplOptions extends UseMetricTimeseriesOptions { | |
| queryExtras?: RPCQueryExtras; | |
| } | |
| function useMetricTimeseriesImpl({ | |
| traceMetric, | |
| queryExtras, | |
| enabled, | |
| }: UseMetricTimeseriesImplOptions) { | |
| const visualize = useMetricVisualize(); | |
| const groupBys = useQueryParamsGroupBys(); | |
| const [interval] = useChartInterval(); | |
| const topEvents = useTopEvents(); | |
| const search = useQueryParamsSearch(); | |
| const sortBys = useQueryParamsAggregateSortBys(); | |
| const timeseriesResult = useSortedTimeSeries( | |
| { | |
| search, | |
| yAxis: [visualize.yAxis], | |
| interval, | |
| fields: [...groupBys, visualize.yAxis], | |
| enabled: enabled && Boolean(traceMetric.name), | |
| topEvents, | |
| orderby: sortBys.map(formatSort), | |
| ...queryExtras, | |
| }, | |
| 'api.explore.metrics-stats', | |
| DiscoverDatasets.TRACEMETRICS | |
| ); | |
| return { | |
| result: timeseriesResult, | |
| }; | |
| } |
This isn't needed anymore because we parse the condition from the aggregation.