Skip to content

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

feat(ui): add toggle for color coding of metrics on trace tree (#3722)

Marc Klingen1c8b81843c7f
diff --git a/web/src/components/trace/ObservationTree.tsx b/web/src/components/trace/ObservationTree.tsx
index 193a7f46d8..5095fb96dc 100644
--- a/web/src/components/trace/ObservationTree.tsx
+++ b/web/src/components/trace/ObservationTree.tsx
@@ -31,6 +31,7 @@ export const ObservationTree = (props: {
setCurrentObservationId: (id: string | undefined) => void;
showMetrics: boolean;
showScores: boolean;
+ colorCodeMetrics: boolean;
observationCommentCounts?: Map<string, number>;
traceCommentCounts?: Map<string, number>;
className?: string;
@@ -70,7 +71,7 @@ export const ObservationTree = (props: {
setCurrentObservationId={props.setCurrentObservationId}
showMetrics={props.showMetrics}
showScores={props.showScores}
- colorCodeMetrics={props.observations.length >= 3}
+ colorCodeMetrics={props.colorCodeMetrics}
parentTotalCost={totalCost}
parentTotalDuration={
props.trace.latency ? props.trace.latency * 1000 : undefined
diff --git a/web/src/components/trace/index.tsx b/web/src/components/trace/index.tsx
index 63708d7d89..936930d384 100644
--- a/web/src/components/trace/index.tsx
+++ b/web/src/components/trace/index.tsx
@@ -24,6 +24,7 @@ import {
ChevronsUpDown,
ListTree,
Network,
+ Percent,
} from "lucide-react";
import { usdFormatter } from "@/src/utils/numbers";
import { useCallback, useState } from "react";
@@ -57,6 +58,10 @@ export function Trace(props: {
"scoresOnObservationTree",
true,
);
+ const [
+ colorCodeMetricsOnObservationTree,
+ setColorCodeMetricsOnObservationTree,
+ ] = useLocalStorage("colorCodeMetricsOnObservationTree", true);
const [collapsedObservations, setCollapsedObservations] = useState<string[]>(
[],
@@ -201,6 +206,14 @@ export function Trace(props: {
<ChevronsUpDown className="h-4 w-4" />
)}
</Toggle>
+ <Toggle
+ pressed={colorCodeMetricsOnObservationTree}
+ onPressedChange={(e) => setColorCodeMetricsOnObservationTree(e)}
+ size="xs"
+ title="Color code metrics (>50% yellow, >75% red)"
+ >
+ <Percent className="h-4 w-4" />
+ </Toggle>
</div>
<ObservationTree
@@ -215,6 +228,7 @@ export function Trace(props: {
setCurrentObservationId={setCurrentObservationId}
showMetrics={metricsOnObservationTree}
showScores={scoresOnObservationTree}
+ colorCodeMetrics={colorCodeMetricsOnObservationTree}
observationCommentCounts={observationCommentCounts.data}
traceCommentCounts={traceCommentCounts.data}
className="flex w-full flex-col overflow-y-auto"