Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/trace-search-mv-indicator.md
Original file line number Diff line number Diff line change
@@ -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
105 changes: 54 additions & 51 deletions packages/app/src/components/Search/TraceRedMetricsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -144,8 +145,6 @@ export function TraceRedMetricsChart({
sourceId: source.id,
enabled: isReady,
showDisplaySwitcher: false,
showMVOptimizationIndicator: false,
showDateRangeIndicator: false,
queryKeyPrefix,
onTimeRangeSelect,
enableParallelQueries: true,
Expand Down Expand Up @@ -174,61 +173,65 @@ export function TraceRedMetricsChart({

return (
<IsolatedChartSyncProvider>
<Flex direction="row" h="100%" gap="sm" mih="0" miw="0">
<ChartCard style={RED_TILE_STYLE}>
{/* 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. */}
<DBTimeChart
title="Throughput"
config={histogramTimeChartConfig}
showLegend={throughputGrouped}
onFocusSeries={onFocusSeries}
{...commonProps}
queryKeyPrefix={throughputQueryKeyPrefix}
/>
</ChartCard>
{errors != null && (
{/* Narrow tiles fold their header controls into a menu, as
dashboard tiles do, so the titles keep their room. */}
<CollapsedToolbarProvider menuItems={null} suffixCount={0}>
<Flex direction="row" h="100%" gap="sm" mih="0" miw="0">
<ChartCard style={RED_TILE_STYLE}>
{/* 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. */}
<DBTimeChart
key={errorsMode}
title="Errors"
toolbarSuffix={[errorsModeControl]}
config={errors}
title="Throughput"
config={histogramTimeChartConfig}
showLegend={throughputGrouped}
onFocusSeries={onFocusSeries}
{...commonProps}
queryKeyPrefix={throughputQueryKeyPrefix}
/>
</ChartCard>
{errors != null && (
<ChartCard style={RED_TILE_STYLE}>
{/* 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). */}
<DBTimeChart
key={errorsMode}
title="Errors"
toolbarSuffix={[errorsModeControl]}
config={errors}
showLegend
hiddenSeries={
errorsMode === 'rate' ? ERROR_RATE_HELPER_SERIES : undefined
}
// Rate is 0-100%: cap the axis so a flat/near-zero series
// can't render a nonsense 0-400% scale, while still
// auto-scaling to small values.
yAxisMaxDomain={errorsMode === 'rate' ? 1 : undefined}
// Volume is grouped by status, so clicking the bar filters the
// results to that status (the histogram's drill-down). Rate is
// a single ungrouped line, so it has nothing to drill into.
onFocusSeries={
errorsMode === 'volume' ? onFocusSeries : undefined
}
{...commonProps}
/>
</ChartCard>
)}
<ChartCard style={RED_TILE_STYLE}>
{/* The duration series pin their colors on their select items (set
in durationConfig); applySelectColors opts this chart into them. */}
<DBTimeChart
title="Duration"
config={duration}
showLegend
hiddenSeries={
errorsMode === 'rate' ? ERROR_RATE_HELPER_SERIES : undefined
}
// Rate is 0-100%: cap the axis so a flat/near-zero series
// can't render a nonsense 0-400% scale, while still
// auto-scaling to small values.
yAxisMaxDomain={errorsMode === 'rate' ? 1 : undefined}
// Volume is grouped by status, so clicking the bar filters the
// results to that status (the histogram's drill-down). Rate is
// a single ungrouped line, so it has nothing to drill into.
onFocusSeries={
errorsMode === 'volume' ? onFocusSeries : undefined
}
applySelectColors
{...commonProps}
/>
</ChartCard>
)}
<ChartCard style={RED_TILE_STYLE}>
{/* The duration series pin their colors on their select items (set
in durationConfig); applySelectColors opts this chart into them. */}
<DBTimeChart
title="Duration"
config={duration}
showLegend
applySelectColors
{...commonProps}
/>
</ChartCard>
</Flex>
</Flex>
</CollapsedToolbarProvider>
</IsolatedChartSyncProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
27 changes: 27 additions & 0 deletions packages/app/tests/e2e/features/materialized-views.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
Loading