Skip to content
Merged
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/adhoc-filter-click-timechart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

feat: Filter time chart series into adhoc dashboard filters
3 changes: 3 additions & 0 deletions packages/app/src/ChartUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ export interface LineData {
displayName: string;
/** The original result column name this series' values were pulled from. */
valueColumnName: string;
/** The series' raw group-by values, in group column order. */
groupValues: unknown[];
color: string;
isDashed?: boolean;
}
Expand Down Expand Up @@ -814,6 +816,7 @@ function addResponseToFormattedData({
previousPeriodKey: `${currentPeriodKey}${PreviousPeriodSuffix}`,
displayName: keyName,
valueColumnName,
groupValues: groupColumnNames.map(name => row[name]),
color: applyLogLevelColor
? logLevelColor(row[groupColumnNames[0]])
: undefined,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/DBDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ const Tile = ({
});
}
}
onFilter={onFilter}
/>
)}
{effectiveQueriedConfig?.displayType === DisplayType.Table && (
Expand Down
45 changes: 45 additions & 0 deletions packages/app/src/__tests__/ChartUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ describe('ChartUtils', () => {
'AVG(toFloat64OrDefault(toString(Duration))) (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration)))',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: [],
isDashed: false,
},
]);
Expand Down Expand Up @@ -246,6 +247,7 @@ describe('ChartUtils', () => {
'AVG(toFloat64OrDefault(toString(Duration))) · checkout (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration))) · checkout',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: ['checkout'],
isDashed: false,
},
{
Expand All @@ -255,6 +257,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'max · checkout (previous)',
displayName: 'max · checkout',
valueColumnName: 'max',
groupValues: ['checkout'],
isDashed: false,
},
{
Expand All @@ -266,6 +269,7 @@ describe('ChartUtils', () => {
'AVG(toFloat64OrDefault(toString(Duration))) · shipping (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration))) · shipping',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: ['shipping'],
isDashed: false,
},
{
Expand All @@ -275,6 +279,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'max · shipping (previous)',
displayName: 'max · shipping',
valueColumnName: 'max',
groupValues: ['shipping'],
isDashed: false,
},
]);
Expand Down Expand Up @@ -336,6 +341,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'info (previous)',
displayName: 'info',
valueColumnName: 'count()',
groupValues: ['info'],
isDashed: false,
},
{
Expand All @@ -345,6 +351,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'debug (previous)',
displayName: 'debug',
valueColumnName: 'count()',
groupValues: ['debug'],
isDashed: false,
},
{
Expand All @@ -354,6 +361,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'error (previous)',
displayName: 'error',
valueColumnName: 'count()',
groupValues: ['error'],
isDashed: false,
},
]);
Expand Down Expand Up @@ -444,6 +452,7 @@ describe('ChartUtils', () => {
'AVG(toFloat64OrDefault(toString(Duration))) · checkout (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration))) · checkout',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: ['checkout'],
isDashed: false,
},
{
Expand All @@ -453,6 +462,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'max · checkout (previous)',
displayName: 'max · checkout',
valueColumnName: 'max',
groupValues: ['checkout'],
isDashed: false,
},
{
Expand All @@ -464,6 +474,7 @@ describe('ChartUtils', () => {
'AVG(toFloat64OrDefault(toString(Duration))) · shipping (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration))) · shipping',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: ['shipping'],
isDashed: false,
},
{
Expand All @@ -473,6 +484,7 @@ describe('ChartUtils', () => {
previousPeriodKey: 'max · shipping (previous)',
displayName: 'max · shipping',
valueColumnName: 'max',
groupValues: ['shipping'],
isDashed: false,
},
]);
Expand Down Expand Up @@ -672,11 +684,41 @@ describe('ChartUtils', () => {
previousPeriodKey: 'foo · {"key":"val"} · [1,2,3] (previous)',
displayName: 'foo · {"key":"val"} · [1,2,3]',
valueColumnName: 'count()',
groupValues: ['foo', { key: 'val' }, [1, 2, 3]],
isDashed: false,
},
]);
});

it('keeps raw group values, including nulls and values containing the key joiner', () => {
const path = `GET${ChartKeyJoiner}/api`;
const actual = formatResponseForTimeChart({
currentPeriodResponse: {
data: [
{
'count()': 5,
severity: null,
span_name: path,
__hdx_time_bucket: '2025-11-26T11:12:00Z',
},
],
meta: [
{ name: 'count()', type: 'UInt64' },
{ name: 'severity', type: 'Nullable(String)' },
{ name: 'span_name', type: 'String' },
{ name: '__hdx_time_bucket', type: 'DateTime' },
],
},
dateRange: [new Date(), new Date()],
granularity: '1 minute',
generateEmptyBuckets: false,
});

expect(actual.lineData).toHaveLength(1);
expect(actual.lineData[0].dataKey).toBe(`${ChartKeyJoiner}${path}`);
expect(actual.lineData[0].groupValues).toEqual([null, path]);
});

it('should plot previous period data when provided, shifted to align with current period', () => {
const currentPeriodResponse = {
data: [
Expand Down Expand Up @@ -762,6 +804,7 @@ describe('ChartUtils', () => {
dataKey: 'AVG(toFloat64OrDefault(toString(Duration)))',
displayName: 'AVG(toFloat64OrDefault(toString(Duration)))',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: [],
isDashed: false,
},
{
Expand All @@ -772,6 +815,7 @@ describe('ChartUtils', () => {
dataKey: 'AVG(toFloat64OrDefault(toString(Duration))) (previous)',
displayName: 'AVG(toFloat64OrDefault(toString(Duration))) (previous)',
valueColumnName: 'AVG(toFloat64OrDefault(toString(Duration)))',
groupValues: [],
isDashed: true,
},
]);
Expand Down Expand Up @@ -1839,6 +1883,7 @@ describe('getSeriesColorForGroup', () => {
previousPeriodKey: `${currentPeriodKey} (previous)`,
displayName: currentPeriodKey,
valueColumnName: 'count()',
groupValues: [],
color,
isDashed,
});
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/__tests__/DBSearchPageQueryKey.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { DBTimeChart } from '@/components/DBTimeChart';
import SearchTotalCountChart from '@/components/SearchTotalCountChart';

// Mock the API and hooks
jest.mock('@/hooks/useResultColumnFilterKeys', () => ({
useResultColumnFilterKeys: jest.fn(() => new Map()),
}));

jest.mock('@/api', () => ({
__esModule: true,
default: {
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/__tests__/HDXMultiSeriesTimeChart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ describe('scanYAxisValueRange', () => {
previousPeriodKey: `${dataKey}.prev`,
displayName: dataKey,
valueColumnName: dataKey,
groupValues: [],
color: '#a',
});

Expand All @@ -417,6 +418,7 @@ describe('computeYAxisBounds', () => {
previousPeriodKey: `${dataKey}.prev`,
displayName: dataKey,
valueColumnName: dataKey,
groupValues: [],
color: '#a',
});

Expand Down Expand Up @@ -836,6 +838,7 @@ describe('getVisibleLineData', () => {
previousPeriodKey: `${dataKey}.prev`,
displayName: displayName ?? dataKey,
valueColumnName: dataKey,
groupValues: [],
color: '#abcdef',
});

Expand Down Expand Up @@ -903,6 +906,7 @@ describe('getSelectedLineData', () => {
previousPeriodKey: `${dataKey}.prev`,
displayName: displayName ?? dataKey,
valueColumnName: dataKey,
groupValues: [],
color: '#abcdef',
});

Expand Down Expand Up @@ -949,6 +953,7 @@ describe('buildActiveClickSeries', () => {
previousPeriodKey: `${dataKey}.prev`,
displayName: displayName ?? dataKey,
valueColumnName: dataKey,
groupValues: [],
color: `#${dataKey}`,
});

Expand Down Expand Up @@ -1022,6 +1027,7 @@ describe('buildActiveClickSeries', () => {
previousPeriodKey: 'a.prev',
displayName: 'Alpha (previous)',
valueColumnName: 'a',
groupValues: [],
color: '#a',
isDashed: true,
};
Expand Down
Loading
Loading