Skip to content

Commit cfcfcd1

Browse files
Merge branch 'main' into brandon/mcp-search-partial-results
2 parents 39ff8e7 + 661a5a1 commit cfcfcd1

24 files changed

Lines changed: 2076 additions & 62 deletions

‎.changeset/json-array-paths.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
fix: address JSON array elements by index in row-panel filters
6+
7+
"Add to Filters" on a value inside an array in a native JSON column now uses
8+
1-based array subscripts, for example `events[1]`, instead of quoted keys such
9+
as `events.0`, so the filter matches rows instead of silently returning none.
10+
11+
The same applies to arrays inside a JSON string (for example a String `Body`
12+
column), which now pass 1-based integer indexes to `JSONExtract*`. JSON strings
13+
stored in a native JSON column are wrapped in `toString()` so `JSONExtract*`
14+
accepts them.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': minor
3+
---
4+
5+
Show RED metrics (Throughput, Errors, Duration) above the trace search results instead of the single count histogram. The three charts share a synced hover cursor, Errors toggles between rate and volume, and clicking a status series on the volume chart filters the results. Logs and other sources keep the existing histogram.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': minor
3+
---
4+
5+
Add a RED/Heatmap switch to the trace search results view. Heatmap shows the duration distribution over time as the same tile the dashboard renders, and the choice is kept in the URL so a reload or a shared link reopens the same view.

‎packages/app/src/ChartUtils.tsx‎

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ import {
3535
BuilderSavedChartConfig,
3636
ChartConfigWithDateRange,
3737
ChartConfigWithOptDateRange,
38+
ChartPaletteToken,
3839
DateRange,
3940
DisplayType,
4041
Filter,
4142
isSearchableSource,
4243
MetricsDataType as MetricsDataTypeV2,
4344
PromqlChartConfig,
45+
resolveChartPaletteToken,
4446
SourceKind,
4547
SQLInterval,
4648
TMetricSource,
@@ -62,7 +64,12 @@ import {
6264
import { getMetricNameSql } from './otelSemanticConventions';
6365
import { AggFn, TableChartSeries, TimeChartSeries } from './types';
6466
import { NumberFormat } from './types';
65-
import { getColorProps, getLogLevelColorOrder, logLevelColor } from './utils';
67+
import {
68+
getColorFromCSSToken,
69+
getColorProps,
70+
getLogLevelColorOrder,
71+
logLevelColor,
72+
} from './utils';
6673

6774
type SortOrder = 'asc' | 'desc';
6875

@@ -634,8 +641,33 @@ interface LineDataWithOptionalColor extends Omit<LineData, 'color'> {
634641
color?: string;
635642
}
636643

644+
/**
645+
* Series colors set on a chart's select items, keyed by result-column name
646+
* (the item's alias), in the shape formatResponseForTimeChart's
647+
* `seriesColors` takes. Tokens go through resolveChartPaletteToken, as on
648+
* table and number tiles, so a legacy token maps to its hue and an
649+
* unrecognized one is skipped: that series falls back to the positional
650+
* palette instead of failing the whole chart.
651+
*/
652+
export function getSelectSeriesColors(
653+
config: ChartConfigWithDateRange,
654+
): Record<string, ChartPaletteToken> | undefined {
655+
if (!isBuilderChartConfig(config) || !Array.isArray(config.select)) {
656+
return undefined;
657+
}
658+
const entries: [string, ChartPaletteToken][] = [];
659+
for (const selectItem of config.select) {
660+
const token = resolveChartPaletteToken(selectItem.color);
661+
if (selectItem.alias && token) {
662+
entries.push([selectItem.alias, token]);
663+
}
664+
}
665+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
666+
}
667+
637668
function setLineColors(
638669
sortedLineData: LineDataWithOptionalColor[],
670+
seriesColors?: Record<string, ChartPaletteToken>,
639671
): LineData[] {
640672
// Ensure that the current and previous period lines are the same color
641673
const lineColorByCurrentPeriodKey = new Map<string, string>();
@@ -646,10 +678,15 @@ function setLineColors(
646678
if (lineColorByCurrentPeriodKey.has(currentPeriodKey)) {
647679
line.color = lineColorByCurrentPeriodKey.get(currentPeriodKey);
648680
} else if (!line.color) {
649-
line.color = getColorProps(
650-
colorIndex++,
651-
line.displayName ?? line.dataKey,
652-
);
681+
const seriesName = line.displayName ?? line.dataKey;
682+
// A color set on the series' select item (keyed by its result-column name)
683+
// wins over the positional palette, so a series keeps the same hue no
684+
// matter how the data sorts it. A pinned series does not consume a
685+
// positional slot, so unpinned series keep their natural palette order.
686+
const pinnedToken = seriesColors?.[line.valueColumnName];
687+
line.color = pinnedToken
688+
? getColorFromCSSToken(pinnedToken)
689+
: getColorProps(colorIndex++, seriesName);
653690
lineColorByCurrentPeriodKey.set(currentPeriodKey, line.color);
654691
} else {
655692
lineColorByCurrentPeriodKey.set(currentPeriodKey, line.color);
@@ -801,6 +838,7 @@ export function formatResponseForTimeChart({
801838
hiddenSeries = [],
802839
previousPeriodOffsetSeconds = 0,
803840
maxSeries = MAX_RENDERED_TIME_CHART_SERIES,
841+
seriesColors,
804842
}: {
805843
dateRange: [Date, Date];
806844
granularity?: SQLInterval;
@@ -816,6 +854,14 @@ export function formatResponseForTimeChart({
816854
* every series (the "load all" escape hatch behind the hidden-series notice).
817855
*/
818856
maxSeries?: number;
857+
/**
858+
* Pin specific series (keyed by result-column name) to a palette token instead
859+
* of the positional palette, so their color is stable across sessions and can
860+
* avoid hues reserved for other meanings (e.g. keeping latency off error red).
861+
* DBTimeChart derives this from each select item's `color`
862+
* (getSelectSeriesColors) when its caller opts in with `applySelectColors`.
863+
*/
864+
seriesColors?: Record<string, ChartPaletteToken>;
819865
}) {
820866
const meta = currentPeriodResponse.meta;
821867

@@ -1058,7 +1104,7 @@ export function formatResponseForTimeChart({
10581104
(a, b) => a[timestampColumn.name] - b[timestampColumn.name],
10591105
);
10601106

1061-
const sortedLineDataWithColors = setLineColors(sortedLineData);
1107+
const sortedLineDataWithColors = setLineColors(sortedLineData, seriesColors);
10621108

10631109
// Count of LOGICAL groups actually rendered, in the same unit as
10641110
// hiddenSeriesCount — so a comparison chart (current + previous entries per

0 commit comments

Comments
 (0)