Skip to content

feat(tracemetrics): Add tracemetrics to dashboard global filters#110781

Merged
k-fish merged 6 commits intomasterfrom
feat/metrics/global-filters-on-metric
Mar 17, 2026
Merged

feat(tracemetrics): Add tracemetrics to dashboard global filters#110781
k-fish merged 6 commits intomasterfrom
feat/metrics/global-filters-on-metric

Conversation

@k-fish
Copy link
Member

@k-fish k-fish commented Mar 16, 2026

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

Add trace metrics as a filter dataset for global filters. Getting the
list without a specific metric filter, therefore it shows all keys.
@k-fish k-fish requested a review from a team as a code owner March 16, 2026 18:51
@k-fish k-fish requested review from narsaynorath and removed request for a team March 16, 2026 18:51
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 16, 2026
@linear-code
Copy link

linear-code bot commented Mar 16, 2026

Copy link
Member

@narsaynorath narsaynorath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?? '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop widgetQuery as a prop and here as well, since the context of this hook is at the top level filter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@cursor cursor bot left a comment

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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Unused widgetQuery destructuring is dead code
    • Removed the unused widgetQuery parameter from useGlobalFilterTraceMetricsSearchBarDataProvider and replaced widgetQuery?.conditions ?? '' with '' since it always evaluated to empty string.

Create PR

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.

k-fish and others added 3 commits March 17, 2026 12:40
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
@k-fish k-fish merged commit cbef79a into master Mar 17, 2026
63 checks passed
@k-fish k-fish deleted the feat/metrics/global-filters-on-metric branch March 17, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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