diff --git a/.changeset/trace-search-mv-indicator.md b/.changeset/trace-search-mv-indicator.md new file mode 100644 index 000000000..9cc6bb386 --- /dev/null +++ b/.changeset/trace-search-mv-indicator.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': patch +--- + +feat: the trace search Throughput, Errors and Duration charts show the same materialized view indicators as dashboard tiles: whether a view accelerated the chart, and the time range it queried when the view's rollups widened it diff --git a/packages/app/src/components/Search/TraceRedMetricsChart.tsx b/packages/app/src/components/Search/TraceRedMetricsChart.tsx index 457c5f585..d7a035b58 100644 --- a/packages/app/src/components/Search/TraceRedMetricsChart.tsx +++ b/packages/app/src/components/Search/TraceRedMetricsChart.tsx @@ -8,6 +8,7 @@ import { Flex, SegmentedControl } from '@mantine/core'; import { IsolatedChartSyncProvider } from '@/chartSync'; import { ChartCard } from '@/components/charts/ChartCard'; +import { CollapsedToolbarProvider } from '@/components/charts/ChartContainer'; import DBHeatmapChart, { HEATMAP_DURATION_NUMBER_FORMAT, toHeatmapQuery, @@ -144,8 +145,6 @@ export function TraceRedMetricsChart({ sourceId: source.id, enabled: isReady, showDisplaySwitcher: false, - showMVOptimizationIndicator: false, - showDateRangeIndicator: false, queryKeyPrefix, onTimeRangeSelect, enableParallelQueries: true, @@ -174,61 +173,65 @@ export function TraceRedMetricsChart({ return ( - - - {/* Throughput is the status-grouped count histogram this view - replaces, rendered from the same config under the results header's - query-key prefix so react-query runs a single shared scan, and it - keeps the per-status drill-down via onFocusSeries. */} - - - {errors != null && ( + {/* Narrow tiles fold their header controls into a menu, as + dashboard tiles do, so the titles keep their room. */} + + - {/* Remount on mode change: DBTimeChart seeds its display type - from the initial config when uncontrolled, so a key swap - re-seeds bars (volume) vs line (rate). */} + {/* Throughput is the status-grouped count histogram this view + replaces, rendered from the same config under the results header's + query-key prefix so react-query runs a single shared scan, and it + keeps the per-status drill-down via onFocusSeries. */} + + {errors != null && ( + + {/* Remount on mode change: DBTimeChart seeds its display type + from the initial config when uncontrolled, so a key swap + re-seeds bars (volume) vs line (rate). */} + + + )} + + {/* The duration series pin their colors on their select items (set + in durationConfig); applySelectColors opts this chart into them. */} + - )} - - {/* The duration series pin their colors on their select items (set - in durationConfig); applySelectColors opts this chart into them. */} - - - + + ); } diff --git a/packages/app/src/components/Search/__tests__/TraceRedMetricsChart.test.tsx b/packages/app/src/components/Search/__tests__/TraceRedMetricsChart.test.tsx index a2b1a3a83..e56062d8d 100644 --- a/packages/app/src/components/Search/__tests__/TraceRedMetricsChart.test.tsx +++ b/packages/app/src/components/Search/__tests__/TraceRedMetricsChart.test.tsx @@ -142,4 +142,15 @@ describe('TraceRedMetricsChart', () => { ), ).toEqual(new Set(['Duration'])); }); + + it('shows the acceleration and date-range indicators on every RED tile', () => { + renderChart('red'); + + expect(mockTimeChartProps.length).toBeGreaterThan(0); + for (const props of mockTimeChartProps) { + // Left unset, DBTimeChart shows both, as on dashboard tiles. + expect(props.showMVOptimizationIndicator).not.toBe(false); + expect(props.showDateRangeIndicator).not.toBe(false); + } + }); }); diff --git a/packages/app/tests/e2e/features/materialized-views.spec.ts b/packages/app/tests/e2e/features/materialized-views.spec.ts index 4ea83825a..55fc8e158 100644 --- a/packages/app/tests/e2e/features/materialized-views.spec.ts +++ b/packages/app/tests/e2e/features/materialized-views.spec.ts @@ -145,6 +145,33 @@ test.describe( await expect(aggTable).toContainText('count'); }); + test('trace search RED charts show that the view accelerated them', async ({ + page, + }) => { + const searchPage = new SearchPage(page); + const mvComponent = new MaterializedViewComponent(page); + + await searchPage.goto(); + await searchPage.selectSource(DEFAULT_TRACES_MV_SOURCE_NAME); + // One-minute buckets, the view's granularity. + await searchPage.timePicker.selectRelativeTime('Last 1 hour'); + + // Throughput, Errors and Duration each read the view: counts by status, + // the error ratio, and avg/p95/p99 of Duration are all pre-aggregated. + const indicators = mvComponent.getIndicator(); + await expect(indicators).toHaveCount(3, { timeout: 15000 }); + for (const indicator of await indicators.all()) { + await expect(indicator).toHaveAttribute('data-mv-accelerated', 'true', { + timeout: 15000, + }); + } + + // The dialog explains which view served the chart. + await indicators.first().click(); + await expect(mvComponent.getModal()).toBeVisible({ timeout: 10000 }); + await expect(mvComponent.getModalItem(E2E_TRACES_MV_TABLE)).toBeVisible(); + }); + test( 'Configuring an MV with auto-population in the source form', { tag: '@sources' },