Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): tree metrics heatmap update (#17619)

Trang Nguyen62dbd58fdc28
diff --git a/web/src/features/traces/components/SpanContent.tsx b/web/src/features/traces/components/SpanContent.tsx
index c6aebcd6c4..6cd4d1abc7 100644
--- a/web/src/features/traces/components/SpanContent.tsx
+++ b/web/src/features/traces/components/SpanContent.tsx
@@ -6,7 +6,7 @@
* Responsibilities:
* - Render span-specific data (name, metrics, badges, scores)
* - Apply view preferences (show/hide features)
- * - Format and display metrics with color coding
+ * - Format metrics; a row that is most of the trace reads in foreground
*
* Does NOT know about:
* - Tree structure (indents, lines, collapse buttons)
@@ -26,16 +26,17 @@ import { CommentCountIcon } from "@/src/features/comments/CommentCountIcon";
import { cn } from "@/src/utils/tailwind";
import { formatIntervalSeconds } from "@/src/utils/dates";
import { usdFormatter, numberFormatter } from "@/src/utils/numbers";
-import { heatMapTextColor } from "@/src/features/traces/fns/heatMapTextColor";
+import {
+ isEmphasizedShare,
+ type MetricEmphasisContext,
+} from "@/src/features/traces/fns/metricEmphasis";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";
import { selectNodeScores } from "@/src/features/traces/fns/nodeScores";
-import type Decimal from "decimal.js";
interface SpanContentProps {
node: TreeNode;
- parentTotalCost?: Decimal;
- parentTotalDuration?: number;
+ emphasis?: MetricEmphasisContext;
commentCount?: number;
onSelect?: () => void;
onHover?: () => void;
@@ -44,21 +45,15 @@ interface SpanContentProps {
export function SpanContent({
node,
- parentTotalCost,
- parentTotalDuration,
+ emphasis,
commentCount,
onSelect,
onHover,
className,
}: SpanContentProps) {
const { mergedScores } = useTraceData();
- const {
- showDuration,
- showCostTokens,
- showScores,
- colorCodeMetrics,
- showComments,
- } = useViewPreferences();
+ const { showDuration, showCostTokens, showScores, showComments } =
+ useViewPreferences();
// Own cost only; sums over children belong to the detail panel, not the row.
const ownCost =
@@ -72,8 +67,14 @@ export function SpanContent({
? node.latency * 1000
: undefined;
- const shouldRenderDuration =
- showDuration && Boolean(duration || node.latency);
+ const durationMs = duration || (node.latency ? node.latency * 1000 : 0);
+
+ const shouldRenderDuration = showDuration && Boolean(durationMs);
+ const emphasizeDuration = isEmphasizedShare(
+ durationMs,
+ emphasis?.traceTotalDurationMs,
+ );
+ const emphasizeCost = isEmphasizedShare(ownCost, emphasis?.traceTotalCost);
// Tokens stand in for cost only when there is no cost to show.
const tokenTotal = ownCost ? 0 : (node.totalUsage ?? 0);
@@ -128,7 +129,7 @@ export function SpanContent({
{shouldRenderAnyMetrics && (
<div className="flex flex-wrap gap-x-2">
{/* Duration (own span) */}
- {shouldRenderDuration && (duration || node.latency) ? (
+ {shouldRenderDuration ? (
<span
title={
node.type === "TRACE"
@@ -136,19 +137,13 @@ export function SpanContent({
: "Own span duration"
}
className={cn(
- "text-foreground-tertiary text-xs",
- parentTotalDuration &&
- colorCodeMetrics &&
- heatMapTextColor({
- max: parentTotalDuration,
- value:
- duration || (node.latency ? node.latency * 1000 : 0),
- }),
+ "text-xs",
+ emphasizeDuration
+ ? "text-foreground"
+ : "text-foreground-tertiary",
)}
>
- {formatIntervalSeconds(
- (duration || (node.latency ? node.latency * 1000 : 0)) / 1000,
- )}
+ {formatIntervalSeconds(durationMs / 1000)}
</span>
) : null}
@@ -166,13 +161,10 @@ export function SpanContent({
{shouldRenderCostTokens && ownCost ? (
<span
className={cn(
- "text-foreground-tertiary text-xs",
- parentTotalCost &&
- colorCodeMetrics &&
- heatMapTextColor({
- max: parentTotalCost,
- value: ownCost,
- }),
+ "text-xs",
+ emphasizeCost
+ ? "text-foreground"
+ : "text-foreground-tertiary",
)}
>
{usdFormatter(ownCost)}
diff --git a/web/src/features/traces/components/TraceSearchListItem.tsx b/web/src/features/traces/components/TraceSearchListItem.tsx
index c4ce9991b7..bcdfca1f02 100644
--- a/web/src/features/traces/components/TraceSearchListItem.tsx
+++ b/web/src/features/traces/components/TraceSearchListItem.tsx
@@ -26,7 +26,7 @@ export function TraceSearchListItem({
onSelect,
onHover,
}: TraceSearchListItemProps) {
- const { node, parentTotalCost, parentTotalDuration } = item;
+ const { node, emphasis } = item;
const { comments } = useTraceData();
// Format relative timestamps
@@ -51,8 +51,7 @@ export function TraceSearchListItem({
<div className="min-w-0 flex-1 space-y-0.5">
<SpanContent
node={node}
- parentTotalCost={parentTotalCost}
- parentTotalDuration={parentTotalDuration}
+ emphasis={emphasis}
commentCount={comments.get(node.id)}
onSelect={onSelect}
/>
diff --git a/web/src/features/traces/components/TraceSettingsDropdown.tsx b/web/src/features/traces/components/TraceSettingsDropdown.tsx
index c30adf4c5e..fb95d4c763 100644
--- a/web/src/features/traces/components/TraceSettingsDropdown.tsx
+++ b/web/src/features/traces/components/TraceSettingsDropdown.tsx
@@ -7,7 +7,6 @@
* - Show Scores
* - Show Duration
* - Show Cost/Tokens
- * - Color Code Metrics (dependent on duration or cost being enabled)
* - Collapse System Prompts
* - Minimum Observation Level filter
*
@@ -28,7 +27,6 @@ import {
DropdownMenuLabel,
} from "@/src/components/ui/dropdown-menu";
import { Switch } from "@/src/components/design-system/Switch/Switch";
-import { cn } from "@/src/utils/tailwind";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";
@@ -75,17 +73,12 @@ export function TraceViewOptionsMenuItems() {
setShowDuration,
showCostTokens,
setShowCostTokens,
- colorCodeMetrics,
- setColorCodeMetrics,
minObservationLevel,
setMinObservationLevel,
collapseSystemPrompt,
setCollapseSystemPrompt,
} = useViewPreferences();
- // Color coding is only available when duration or cost metrics are shown
- const isColorCodeEnabled = showDuration || showCostTokens;
-
return (
<>
<div className="space-y-0 p-0 py-1">
@@ -159,39 +152,6 @@ export function TraceViewOptionsMenuItems() {
</div>
</DropdownMenuItem>
- {/* Color Code Metrics Toggle (disabled when no metrics shown) */}
- <DropdownMenuItem
- asChild
- onSelect={(e) => e.preventDefault()}
- disabled={!isColorCodeEnabled}
- className={cn([
- "px-2 py-1",
- isColorCodeEnabled ? "" : "cursor-not-allowed",
- ])}
- >
- <div
- className={cn(
- "flex w-full items-center justify-between",
- !isColorCodeEnabled && "cursor-not-allowed",
- )}
- >
- <span
- className={cn(
- "mr-2",
- !isColorCodeEnabled && "cursor-not-allowed",
- )}
- >
- Show Color Code Metrics
- </span>
- <Switch
- size="sm"
- checked={colorCodeMetrics}
- onCheckedChange={setColorCodeMetrics}
- disabled={!isColorCodeEnabled}
- />
- </div>
- </DropdownMenuItem>
-
{/* Collapse System Prompts Toggle */}
<DropdownMenuItem
asChild
diff --git a/web/src/features/traces/components/TraceTree.tsx b/web/src/features/traces/components/TraceTree.tsx
index 1d788a039e..6b12839bcc 100644
--- a/web/src/features/traces/components/TraceTree.tsx
+++ b/web/src/features/traces/components/TraceTree.tsx
@@ -23,7 +23,10 @@ import { useHandlePrefetchObservation } from "@/src/features/traces/hooks/useHan
import { useSelectTraceNode } from "@/src/features/traces/hooks/useSelectTraceNode";
import { type TreeNode } from "../types/treeNode";
import { cn } from "@/src/utils/tailwind";
-import type Decimal from "decimal.js";
+import {
+ metricEmphasisFor,
+ type MetricEmphasisContext,
+} from "@/src/features/traces/fns/metricEmphasis";
/**
* Feature-scoped row container: subscribes to the row's OWN playback-active
@@ -39,8 +42,7 @@ const TraceTreeRow = memo(function TraceTreeRow({
isCollapsed,
onToggleCollapse,
onSelect,
- rootTotalCost,
- rootTotalDuration,
+ emphasis,
commentCount,
onHover,
}: {
@@ -50,8 +52,7 @@ const TraceTreeRow = memo(function TraceTreeRow({
isCollapsed: boolean;
onToggleCollapse: () => void;
onSelect: () => void;
- rootTotalCost?: Decimal;
- rootTotalDuration?: number;
+ emphasis?: MetricEmphasisContext;
commentCount?: number;
onHover: (node: TreeNode) => void;
}) {
@@ -75,8 +76,7 @@ const TraceTreeRow = memo(function TraceTreeRow({
>
<SpanContent
node={node}
- parentTotalCost={rootTotalCost}
- parentTotalDuration={rootTotalDuration}
+ emphasis={emphasis}
commentCount={commentCount}
onSelect={onSelect}
onHover={() => onHover(node)}
@@ -87,28 +87,11 @@ const TraceTreeRow = memo(function TraceTreeRow({
});
export function TraceTree() {
- const { roots, comments } = useTraceData();
+ const { roots, comments, metricEmphasis } = useTraceData();
const { selectedNodeId, collapsedNodes, toggleCollapsed } = useSelection();
const { handleHover } = useHandlePrefetchObservation();
const handleSelectNode = useSelectTraceNode("tree");
- // TODO: Extract aggregation logic to shared utility - duplicated in tree-building.ts and TraceTimeline/index.tsx
- // Calculate aggregated totals across all roots for heatmap color scaling
- const rootTotalCost = roots.reduce(
- (acc, r) => {
- if (!r.totalCost) return acc;
- return acc ? acc.plus(r.totalCost) : r.totalCost;
- },
- undefined as (typeof roots)[0]["totalCost"],
- );
-
- const rootTotalDuration =
- roots.length > 0
- ? Math.max(
- ...roots.map((r) => (r.latency != null ? r.latency * 1000 : 0)),
- )
- : undefined;
-
return (
<VirtualizedTree
roots={roots}
@@ -131,8 +114,7 @@ export function TraceTree() {
isCollapsed={isCollapsed}
onToggleCollapse={onToggleCollapse}
onSelect={onSelect}
- rootTotalCost={rootTotalCost}
- rootTotalDuration={rootTotalDuration}
+ emphasis={metricEmphasisFor(node as TreeNode, metricEmphasis)}
commentCount={comments.get(node.id)}
onHover={handleHover}
/>
diff --git a/web/src/features/traces/contexts/TraceDataContext.tsx b/web/src/features/traces/contexts/TraceDataContext.tsx
index f47c392ec9..a92990e6c8 100644
--- a/web/src/features/traces/contexts/TraceDataContext.tsx
+++ b/web/src/features/traces/contexts/TraceDataContext.tsx
@@ -31,6 +31,7 @@ import {
calculateTraceDuration,
findEarliestStartTime,
} from "@/src/features/traces/fns/timelineCalculations";
+import { type TraceMetricEmphasis } from "@/src/features/traces/fns/metricEmphasis";
import { useViewPreferences } from "./ViewPreferencesContext";
import { useMergedScores } from "@/src/features/scores";
import { traceLevelScoreOwnerIds } from "@/src/features/traces/fns/nodeScores";
@@ -57,6 +58,9 @@ interface TraceDataContextValue {
* children into `roots`, and a promoted child is not a stand-in for the trace. */
traceLevelScoreOwnerIds: Set<string>;
nodeMap: Map<string, TreeNode>;
+ /** Trace-wide cost/duration totals for metric emphasis. Derived from the
+ * UNFILTERED tree so level filtering cannot change which rows read bold. */
+ metricEmphasis: TraceMetricEmphasis;
searchItems: TraceSearchListItem[];
hiddenObservationsCount: number;
/**
@@ -212,6 +216,7 @@ export function TraceDataProvider({
roots: filteredRoots,
traceLevelScoreOwnerIds: traceLevelScoreOwnerIdSet,
nodeMap: uiData.nodeMap,
+ metricEmphasis: uiData.metricEmphasis,
searchItems: filteredSearchItems,
hiddenObservationsCount,
detachedObservationId,
@@ -235,6 +240,7 @@ export function TraceDataProvider({
detachedObservationIsMisplaced,
truncatedAtObservations,
uiData.nodeMap,
+ uiData.metricEmphasis,
comments,
traceStartTime,
traceDuration,
diff --git a/web/src/features/traces/contexts/ViewPreferencesContext.tsx b/web/src/features/traces/contexts/ViewPreferencesContext.tsx
index 647bfb61f3..df7c656ed5 100644
--- a/web/src/features/traces/contexts/ViewPreferencesContext.tsx
+++ b/web/src/features/traces/contexts/ViewPreferencesContext.tsx
@@ -42,8 +42,6 @@ interface ViewPreferencesContextValue {
setShowCostTokens: (value: boolean) => void;
showScores: boolean;
setShowScores: (value: boolean) => void;
- colorCodeMetrics: boolean;
- setColorCodeMetrics: (value: boolean) => void;
showComments: boolean;
setShowComments: (value: boolean) => void;
/** Graph panel build mode (aggregated vs expanded "as it ran") */
@@ -111,10 +109,6 @@ export function ViewPreferencesProvider({
"scoresOnObservationTree",
true,
);
- const [colorCodeMetrics, setColorCodeMetrics] = useLocalStorage(
- "colorCodeMetricsOnObservationTree",
- true,
- );
const [showComments, setShowComments] = useLocalStorage("showComments", true);
const [storedGraphViewMode, setGraphViewMode] =
useLocalStorage<GraphViewMode>("graphViewMode", "aggregated");
@@ -162,8 +156,6 @@ export function ViewPreferencesProvider({
setShowCostTokens,
showScores,
setShowScores,
- colorCodeMetrics,
- setColorCodeMetrics,
showComments,
setShowComments,
graphViewMode,
@@ -191,8 +183,6 @@ export function ViewPreferencesProvider({
setShowCostTokens,
showScores,
setShowScores,
- colorCodeMetrics,
- setColorCodeMetrics,
showComments,
setShowComments,
graphViewMode,
diff --git a/web/src/features/traces/fns/heatMapTextColor.ts b/web/src/features/traces/fns/heatMapTextColor.ts
deleted file mode 100644
index 7fae9d188a..0000000000
--- a/web/src/features/traces/fns/heatMapTextColor.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import Decimal from "decimal.js";
-
-export const heatMapTextColor = (p: {
- min?: Decimal | number;
- max: Decimal | number;
- value: Decimal | number;
-}) => {
- const { min, max, value } = p;
- const minDecimal = min ? new Decimal(min) : new Decimal(0);
- const maxDecimal = new Decimal(max);
- const valueDecimal = new Decimal(value);
-
- const cutOffs: [number, string][] = [
- [0.75, "text-dark-red"], // 75%
- [0.5, "text-dark-yellow"], // 50%
- ];
- const standardizedValueOnStartEndScale = valueDecimal
- .sub(minDecimal)
- .div(maxDecimal.sub(minDecimal));
- const ratio = standardizedValueOnStartEndScale.toNumber();
-
- // pick based on ratio if threshold is exceeded
- for (const [threshold, color] of cutOffs) {
- if (ratio >= threshold) {
- return color;
- }
- }
- return "";
-};
diff --git a/web/src/features/traces/fns/metricEmphasis.ts b/web/src/features/traces/fns/metricEmphasis.ts
new file mode 100644
index 0000000000..301d9c01f7
--- /dev/null
+++ b/web/src/features/traces/fns/metricEmphasis.ts
@@ -0,0 +1,79 @@
+import Decimal from "decimal.js";
+import { type TreeNode } from "@/src/features/traces/types/treeNode";
+
+/** A row at or above this share of the trace total is emphasised. */
+const METRIC_EMPHASIS_THRESHOLD = 0.75;
+
+export type MetricEmphasisContext = {
+ traceTotalCost?: Decimal;
+ traceTotalDurationMs?: number;
+};
+
+export type TraceMetricEmphasis = {
+ totals: MetricEmphasisContext;
+ /** Rows that are the whole trace, so their share is always 100%. */
+ wholeTraceNodeIds: Set<string>;
+};
+
+function nodeDurationMs(node: TreeNode): number | undefined {
+ if (node.latency != null) return node.latency * 1000;
+ if (node.endTime) return node.endTime.getTime() - node.startTime.getTime();
+ return undefined;
+}
+
+/**
+ * Trace-wide totals, derived once per trace from the unfiltered roots so every
+ * view emphasises the same rows regardless of level filtering.
+ */
+export function computeTraceMetricEmphasis(
+ roots: TreeNode[],
+): TraceMetricEmphasis {
+ const traceRoot = roots.find((root) => root.type === "TRACE");
+ const topLevel = traceRoot ? traceRoot.children : roots;
+ const base = traceRoot ? [traceRoot] : roots;
+
+ const wholeTraceNodeIds = new Set<string>();
+ if (traceRoot) wholeTraceNodeIds.add(traceRoot.id);
+ if (topLevel.length === 1 && topLevel[0])
+ wholeTraceNodeIds.add(topLevel[0].id);
+
+ let traceTotalCost: Decimal | undefined;
+ let traceTotalDurationMs: number | undefined;
+ for (const root of base) {
+ if (root.totalCost) {
+ traceTotalCost = traceTotalCost
+ ? traceTotalCost.plus(root.totalCost)
+ : root.totalCost;
+ }
+ const duration = nodeDurationMs(root);
+ if (duration != null && (traceTotalDurationMs ?? -Infinity) < duration) {
+ traceTotalDurationMs = duration;
+ }
+ }
+
+ return {
+ totals: { traceTotalCost, traceTotalDurationMs },
+ wholeTraceNodeIds,
+ };
+}
+
+/** Undefined when the row is the whole trace: its share is always 100%. */
+export function metricEmphasisFor(
+ node: TreeNode,
+ trace: TraceMetricEmphasis | undefined,
+): MetricEmphasisContext | undefined {
+ if (!trace) return undefined;
+ if (node.type === "TRACE") return undefined;
+ if (trace.wholeTraceNodeIds.has(node.id)) return undefined;
+ return trace.totals;
+}
+
+export function isEmphasizedShare(
+ value: number | Decimal | undefined,
+ total: number | Decimal | undefined,
+): boolean {
+ if (value == null || total == null) return false;
+ const totalDecimal = new Decimal(total);
+ if (totalDecimal.lte(0)) return false;
+ return new Decimal(value).div(totalDecimal).gte(METRIC_EMPHASIS_THRESHOLD);
+}
diff --git a/web/src/features/traces/fns/treeBuilding.clienttest.ts b/web/src/features/traces/fns/treeBuilding.clienttest.ts
index 00bc479918..3ad02e18df 100644
--- a/web/src/features/traces/fns/treeBuilding.clienttest.ts
+++ b/web/src/features/traces/fns/treeBuilding.clienttest.ts
@@ -204,8 +204,11 @@ describe("buildTraceUiData", () => {
expect(result.searchItems[1].observationId).toBe("obs-1");
expect(result.searchItems[2].observationId).toBe("obs-2");
- // All items should have parent duration for heatmap
- expect(result.searchItems[0].parentTotalDuration).toBe(2000); // 2s * 1000ms
+ // Trace root and its lone top-level span are the whole trace; the
+ // nested observation compares against the trace duration.
+ expect(result.searchItems[0].emphasis).toBeUndefined();
+ expect(result.searchItems[1].emphasis).toBeUndefined();
+ expect(result.searchItems[2].emphasis?.traceTotalDurationMs).toBe(2000); // 2s * 1000ms
});
it("returns empty children for trace with no observations", () => {
@@ -778,7 +781,7 @@ describe("buildTraceUiData", () => {
expect(result.roots[0].totalCost?.equals(new Decimal(0.8))).toBe(true);
});
- it("propagates trace totalCost to all searchItems as parentTotalCost", () => {
+ it("searchItems compare against the trace totalCost, except rows that are the whole trace", () => {
const trace = createMockTrace();
const observations: ObservationReturnType[] = [
createMockObservation({
@@ -795,14 +798,19 @@ describe("buildTraceUiData", () => {
const result = buildTraceUiData(trace, observations);
- // All searchItems should have the trace's total cost as parentTotalCost
const traceTotalCost = result.roots[0].totalCost;
expect(traceTotalCost).toBeDefined();
- result.searchItems.forEach((item) => {
- expect(item.parentTotalCost).toBeDefined();
- expect(item.parentTotalCost?.equals(traceTotalCost!)).toBe(true);
+ const [traceItem, ...observationItems] = result.searchItems;
+ expect(traceItem.emphasis).toBeUndefined();
+ observationItems.forEach((item) => {
+ expect(item.emphasis?.traceTotalCost?.equals(traceTotalCost!)).toBe(
+ true,
+ );
});
+
+ const single = buildTraceUiData(trace, [observations[0]]);
+ expect(single.searchItems[1].emphasis).toBeUndefined();
});
it("handles zero costs correctly in hierarchy (should not propagate)", () => {
diff --git a/web/src/features/traces/fns/treeBuilding.ts b/web/src/features/traces/fns/treeBuilding.ts
index 66b997bdcb..57e7cde725 100644
--- a/web/src/features/traces/fns/treeBuilding.ts
+++ b/web/src/features/traces/fns/treeBuilding.ts
@@ -1,4 +1,3 @@
-/* eslint-disable no-nested-ternary */
/**
* Tree building utilities for trace component.
*
@@ -24,6 +23,11 @@ import type { TraceSearchListItem } from "@/src/features/traces/types/traceSearc
import { type TreeNode } from "../types/treeNode";
import { type ObservationReturnType } from "@/src/server/api/routers/traces";
import Decimal from "decimal.js";
+import {
+ computeTraceMetricEmphasis,
+ metricEmphasisFor,
+ type TraceMetricEmphasis,
+} from "@/src/features/traces/fns/metricEmphasis";
import {
type ObservationLevelType,
ObservationLevel,
@@ -546,34 +550,16 @@ export function buildTraceUiData(
roots: TreeNode[];
searchItems: TraceSearchListItem[];
nodeMap: Map<string, TreeNode>;
+ metricEmphasis: TraceMetricEmphasis;
} {
const { roots, nodeMap } = buildTraceTree(trace, observations);
+ const metricEmphasis = computeTraceMetricEmphasis(roots);
// Handle empty roots case
if (roots.length === 0) {
- return { roots, searchItems: [], nodeMap };
+ return { roots, searchItems: [], nodeMap, metricEmphasis };
}
- // TODO: Extract aggregation logic to shared utility - duplicated in TraceTree.tsx and TraceTimeline/index.tsx
- // Calculate aggregated totals across all roots for heatmap scaling
- const rootTotalCost = roots.reduce<Decimal | undefined>((acc, r) => {
- if (!r.totalCost) return acc;
- return acc ? acc.plus(r.totalCost) : r.totalCost;
- }, undefined);
-
- const rootDuration =
- roots.length > 0
- ? Math.max(
- ...roots.map((r) =>
- r.latency
- ? r.latency * 1000
- : r.endTime
- ? r.endTime.getTime() - r.startTime.getTime()
- : 0,
- ),
- )
- : undefined;
-
// Build flat search items list (iterative to avoid stack overflow on deep trees)
const searchItems: TraceSearchListItem[] = [];
@@ -587,8 +573,7 @@ export function buildTraceUiData(
const node = stack.pop()!;
searchItems.push({
node,
- parentTotalCost: rootTotalCost,
- parentTotalDuration: rootDuration,
+ emphasis: metricEmphasisFor(node, metricEmphasis),
observationId: node.type === "TRACE" ? undefined : node.id,
});
// Push children in reverse order to maintain depth-first left-to-right traversal
@@ -597,7 +582,7 @@ export function buildTraceUiData(
}
}
- return { roots, searchItems, nodeMap };
+ return { roots, searchItems, nodeMap, metricEmphasis };
}
/**
diff --git a/web/src/features/traces/types/traceSearchListItem.ts b/web/src/features/traces/types/traceSearchListItem.ts
index 14c55894dc..fa1531b839 100644
--- a/web/src/features/traces/types/traceSearchListItem.ts
+++ b/web/src/features/traces/types/traceSearchListItem.ts
@@ -1,12 +1,10 @@
-import type Decimal from "decimal.js";
import type { TreeNode } from "@/src/features/traces/types/treeNode";
+import type { MetricEmphasisContext } from "@/src/features/traces/fns/metricEmphasis";
export interface TraceSearchListItem {
node: TreeNode;
- /** Root-level total cost for heatmap scaling */
- parentTotalCost?: Decimal;
- /** Root-level total duration for heatmap scaling */
- parentTotalDuration?: number;
+ /** Trace totals the row's metrics are compared against; undefined for rows that are the whole trace */
+ emphasis?: MetricEmphasisContext;
/** Observation ID for navigation (undefined for TRACE nodes) */
observationId?: string;
}