Skip to content

Commit fe8ed22

Browse files
authored
fix: colors display for traces (#860)
Adds a groupby for traces based on statusCodeExpression akin to severityTextExpression for logs. Colors based on message
1 parent becf06c commit fe8ed22

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.changeset/empty-balloons-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: color display on search page for traces

packages/app/src/ChartUtils.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
DisplayType,
1515
MetricsDataType as MetricsDataTypeV2,
1616
SavedChartConfig,
17+
SourceKind,
1718
SQLInterval,
1819
TSource,
1920
} from '@hyperdx/common-utils/dist/types';
@@ -507,8 +508,12 @@ export function formatResponseForTimeChart({
507508

508509
let color: string | undefined = undefined;
509510
if (
511+
source &&
510512
groupColumns.length === 1 &&
511-
groupColumns[0].name === source?.severityTextExpression
513+
groupColumns[0].name ===
514+
(source.kind === SourceKind.Log
515+
? source.severityTextExpression
516+
: source.statusCodeExpression)
512517
) {
513518
color = logLevelColor(row[groupColumns[0].name]);
514519
}

packages/app/src/DBSearchPage.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
ChartConfigWithDateRange,
2626
DisplayType,
2727
Filter,
28+
SourceKind,
2829
} from '@hyperdx/common-utils/dist/types';
2930
import { splitAndTrimWithBracket } from '@hyperdx/common-utils/dist/utils';
3031
import {
@@ -955,6 +956,16 @@ function DBSearchPage() {
955956
return undefined;
956957
}
957958

959+
const variableConfig: any = {};
960+
switch (searchedSource?.kind) {
961+
case SourceKind.Log:
962+
variableConfig.groupBy = searchedSource?.severityTextExpression;
963+
break;
964+
case SourceKind.Trace:
965+
variableConfig.groupBy = searchedSource?.statusCodeExpression;
966+
break;
967+
}
968+
958969
return {
959970
...chartConfig,
960971
select: [
@@ -968,8 +979,8 @@ function DBSearchPage() {
968979
granularity: 'auto',
969980
dateRange: searchedTimeRange,
970981
displayType: DisplayType.StackedBar,
971-
groupBy: searchedSource?.severityTextExpression,
972982
with: aliasWith,
983+
...variableConfig,
973984
};
974985
}, [chartConfig, searchedSource, aliasWith, searchedTimeRange]);
975986

0 commit comments

Comments
 (0)