Skip to content

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

style(observations): correctly display costs as sums (#6725)

marliessophie75b4c6da1e9f
diff --git a/web/src/components/trace/ObservationPreview.tsx b/web/src/components/trace/ObservationPreview.tsx
index 5319acf853..6bb48b9c5e 100644
--- a/web/src/components/trace/ObservationPreview.tsx
+++ b/web/src/components/trace/ObservationPreview.tsx
@@ -244,7 +244,7 @@ export const ObservationPreview = ({
</Badge>
</BreakdownTooltip>
) : undefined}
- {totalCost && totalCost !== thisCost ? (
+ {totalCost && (!thisCost || !totalCost.equals(thisCost)) ? (
<Badge variant="tertiary">
∑ {usdFormatter(totalCost.toNumber())}
</Badge>
diff --git a/web/src/components/trace/ObservationTree.tsx b/web/src/components/trace/ObservationTree.tsx
index e2ca47fd38..bea64aa793 100644
--- a/web/src/components/trace/ObservationTree.tsx
+++ b/web/src/components/trace/ObservationTree.tsx
@@ -190,12 +190,18 @@ const ObservationTreeTraceNode = (props: {
{props.showMetrics && (
<div className="flex gap-2">
{props.trace.latency ? (
- <span className="text-xs text-muted-foreground">
+ <span
+ className="text-xs text-muted-foreground"
+ title="Aggregated duration of all observations"
+ >
{formatIntervalSeconds(props.trace.latency)}
</span>
) : null}
{props.totalCost ? (
- <span className="text-xs text-muted-foreground">
+ <span
+ className="text-xs text-muted-foreground"
+ title="Aggregated cost of all observations"
+ >
{usdFormatter(props.totalCost.toNumber())}
</span>
) : null}
@@ -424,6 +430,11 @@ const ObservationTreeNodeCard = ({
<div className="flex w-full flex-wrap gap-2">
{duration ? (
<span
+ title={
+ observation.children.length > 0
+ ? "Aggregated duration of all child observations"
+ : undefined
+ }
className={cn(
"text-xs text-muted-foreground",
parentTotalDuration &&
@@ -447,6 +458,11 @@ const ObservationTreeNodeCard = ({
) : null}
{totalCost ? (
<span
+ title={
+ observation.children.length > 0
+ ? "Aggregated cost of all child observations"
+ : undefined
+ }
className={cn(
"text-xs text-muted-foreground",
parentTotalCost &&
@@ -457,6 +473,7 @@ const ObservationTreeNodeCard = ({
}),
)}
>
+ {observation.children.length > 0 ? "∑ " : ""}
{usdFormatter(totalCost.toNumber())}
</span>
) : null}