Skip to content

Commit 1e9b828

Browse files
authored
fix: trace panel crashes/missing spans due to misconfig/missing data (#847)
HDX-1772 - if `implicitColumnExpression` had a `Map` column type in it, we'd try to render objects that crashed the trace panel, switching logs to always render off of body expression first. Just to be defensive, we also try to stringify the Body before displaying HDX-1769 - If root/parent spans were missing, their children spans did not render properly, we were incorrectly assuming logs with a spanId were a valid parent span which meant we did not properly render orphaned spans. bonus: Fixes NX cache misconfiguration which should stop Vercel deployment errors due to cache
1 parent 7adb3d0 commit 1e9b828

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

packages/app/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,14 @@
150150
"react": "^18.2.0",
151151
"@types/react-dom": "^18.2.18",
152152
"@types/react": "18.2.23"
153+
},
154+
"nx": {
155+
"targets": {
156+
"build": {
157+
"outputs": [
158+
"{projectRoot}/.next"
159+
]
160+
}
161+
}
153162
}
154163
}

packages/app/src/components/DBTraceWaterfallChart.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function getTableBody(tableModel: TSource) {
5656
if (tableModel?.kind === SourceKind.Trace) {
5757
return getSpanEventBody(tableModel) ?? '';
5858
} else if (tableModel?.kind === SourceKind.Log) {
59-
return tableModel.implicitColumnExpression ?? '';
59+
return (
60+
(tableModel.bodyExpression || tableModel.implicitColumnExpression) ?? ''
61+
);
6062
} else {
6163
return '';
6264
}
@@ -223,6 +225,7 @@ export function useEventsAroundFocus({
223225
const { SpanAttributes, ...rowData } = cd;
224226
return {
225227
...cd, // Keep all fields available for display
228+
SpanId: cd?.SpanId, // for typing
226229
id: rowWhere(rowData), // But only use fields except SpanAttributes for identification
227230
type,
228231
};
@@ -321,11 +324,11 @@ export function DBTraceWaterfallChartContainer({
321324
type Node = SpanRow & { id: string; parentId: string; children: SpanRow[] };
322325
const validSpanID = useMemo(() => {
323326
return new Set(
324-
rows
327+
traceRowsData // only spans in traces can define valid span ids
325328
?.filter(row => _.isString(row.SpanId) && row.SpanId.length > 0)
326329
.map(row => row.SpanId) ?? [],
327330
);
328-
}, [rows]);
331+
}, [traceRowsData]);
329332
const rootNodes: Node[] = [];
330333
const nodesMap = new Map();
331334

@@ -429,7 +432,13 @@ export function DBTraceWaterfallChartContainer({
429432
const start = startOffset - minOffset;
430433
const end = start + tookMs;
431434

432-
const { Body: body, ServiceName: serviceName, id, type } = result;
435+
const { Body: _body, ServiceName: serviceName, id, type } = result;
436+
let body = `${_body}`;
437+
try {
438+
body = typeof _body === 'string' ? _body : JSON.stringify(_body);
439+
} catch (e) {
440+
console.warn("DBTraceWaterfallChart: Couldn't JSON stringify Body", e);
441+
}
433442

434443
// Extract HTTP-related logic
435444
const eventAttributes = result.SpanAttributes || {};

0 commit comments

Comments
 (0)