feat(tracemetrics): Add tracemetrics to dashboard global filters#110781
feat(tracemetrics): Add tracemetrics to dashboard global filters#110781
Conversation
Add trace metrics as a filter dataset for global filters. Getting the list without a specific metric filter, therefore it shows all keys.
narsaynorath
left a comment
There was a problem hiding this comment.
Just one comment about an unnecessary prop, and there are some tests missing the mock for the new request but lgtm! tested it with one widget and a browser.name filter
| numberSecondaryAliases, | ||
| stringSecondaryAliases, | ||
| searchSource: 'dashboards', | ||
| initialQuery: widgetQuery?.conditions ?? '', |
There was a problem hiding this comment.
We can drop widgetQuery as a prop and here as well, since the context of this hook is at the top level filter
There was a problem hiding this comment.
Was following from https://github.com/getsentry/sentry/blob/master/static/app/views/dashboards/datasetConfig/logs.tsx#L172, is that also not relevant?
There was a problem hiding this comment.
Weird. I looked it up and these useTraceItemSearchQueryBuilderProps hooks are kind of odd. They just bucket together a bunch of props and have pretty minimal logic. initialQuery is just a passthrough here so it's not actually doing anything, nor is it needed in the return of this hook
Co-Authored-By: Claude <noreply@anthropic.com> Made-with: Cursor
| [WidgetType.ERRORS, t('Errors')], | ||
| [WidgetType.SPANS, t('Spans')], | ||
| [WidgetType.LOGS, t('Logs')], | ||
| [WidgetType.TRACEMETRICS, t('Metrics')], |
There was a problem hiding this comment.
Bug: The "Metrics" option in the global filter dropdown is visible to all users because it is not gated by the tracemetrics-enabled feature flag.
Severity: MEDIUM
Suggested Fix
Wrap the logic that adds the TRACEMETRICS option to the DATASET_CHOICES map in addFilter.tsx with a check for the tracemetrics-enabled feature flag, similar to how it is handled in datasetSelector.tsx. This will ensure the option is only available to organizations with the feature enabled.
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/dashboards/globalFilter/addFilter.tsx#L35
Potential issue: The `TRACEMETRICS` dataset option is unconditionally added to the
`DATASET_CHOICES` map in `addFilter.tsx`. This causes the "Metrics" option to appear in
the global filter dropdown for all users, regardless of whether their organization has
the `tracemetrics-enabled` feature flag. This is inconsistent with the widget builder,
which correctly gates the option. This bypasses the feature flag's purpose of
controlling visibility for unreleased functionality. A related consequence is that the
`useGlobalFilterTraceMetricsSearchBarDataProvider` hook is called unconditionally,
leading to unnecessary API calls for organizations without the feature enabled.
Did we get this right? 👍 / 👎 to inform future reviews.
…rd specs Co-Authored-By: Claude <noreply@anthropic.com> Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Unused
widgetQuerydestructuring is dead code- Removed the unused widgetQuery parameter from useGlobalFilterTraceMetricsSearchBarDataProvider and replaced widgetQuery?.conditions ?? '' with '' since it always evaluated to empty string.
Or push these changes by commenting:
@cursor push e132ecb954
Preview (e132ecb954)
diff --git a/static/app/views/dashboards/datasetConfig/traceMetrics.tsx b/static/app/views/dashboards/datasetConfig/traceMetrics.tsx
--- a/static/app/views/dashboards/datasetConfig/traceMetrics.tsx
+++ b/static/app/views/dashboards/datasetConfig/traceMetrics.tsx
@@ -182,7 +182,7 @@
export function useGlobalFilterTraceMetricsSearchBarDataProvider(
props: SearchBarDataProviderProps
): SearchBarData {
- const {pageFilters, widgetQuery} = props;
+ const {pageFilters} = props;
const {attributes: stringAttributes, secondaryAliases: stringSecondaryAliases} =
useTraceMetricItemAttributes({}, 'string', HiddenTraceMetricSearchFields);
@@ -201,7 +201,7 @@
numberSecondaryAliases,
stringSecondaryAliases,
searchSource: 'dashboards',
- initialQuery: widgetQuery?.conditions ?? '',
+ initialQuery: '',
projects: pageFilters.projects,
});This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
…-filters-on-metric
Co-Authored-By: Claude <noreply@anthropic.com> Made-with: Cursor
…vider The only call site never passes widgetQuery so it's always undefined. Narrow the type to Pick<SearchBarDataProviderProps, 'pageFilters'> and hardcode initialQuery to '' to avoid misleading future readers. Co-Authored-By: Claude <noreply@anthropic.com> Made-with: Cursor


Add trace metrics as a filter dataset for global filters. Getting the list without a specific metric filter, therefore it shows all keys.
Closes LOGS-577