Skip to content

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

feat(dashboard): add 75th percentile to latency graph (#1195)

Marc Klingeneb8ae94a5dcb
diff --git a/src/features/dashboard/components/LatencyChart.tsx b/src/features/dashboard/components/LatencyChart.tsx
index 0a84c7ba89..c44ca05def 100644
--- a/src/features/dashboard/components/LatencyChart.tsx
+++ b/src/features/dashboard/components/LatencyChart.tsx
@@ -33,6 +33,7 @@ export const LatencyChart = ({
from: "observations",
select: [
{ column: "duration", agg: "50thPercentile" },
+ { column: "duration", agg: "75thPercentile" },
{ column: "duration", agg: "90thPercentile" },
{ column: "duration", agg: "95thPercentile" },
{ column: "duration", agg: "99thPercentile" },
@@ -83,6 +84,10 @@ export const LatencyChart = ({
tabTitle: "50th Percentile",
data: getData("percentile50Duration"),
},
+ {
+ tabTitle: "75th Percentile",
+ data: getData("percentile75Duration"),
+ },
{
tabTitle: "90th Percentile",
data: getData("percentile90Duration"),
diff --git a/src/server/api/services/query-builder.ts b/src/server/api/services/query-builder.ts
index e58f1fb0e2..59e5dd3654 100644
--- a/src/server/api/services/query-builder.ts
+++ b/src/server/api/services/query-builder.ts
@@ -143,6 +143,11 @@ const createOutputColumnName = (
capitalizeFirstLetter(columnDefinition.name),
)}`;
}
+ if (safeAgg === "75thPercentile") {
+ return Prisma.sql`percentile75${Prisma.raw(
+ capitalizeFirstLetter(columnDefinition.name),
+ )}`;
+ }
if (safeAgg === "90thPercentile") {
return Prisma.sql`percentile90${Prisma.raw(
capitalizeFirstLetter(columnDefinition.name),
@@ -182,6 +187,10 @@ const createAggregatedColumn = (
return Prisma.sql`percentile_disc(0.5) within group (order by ${getInternalSql(
columnDefinition,
)})`;
+ case "75thPercentile":
+ return Prisma.sql`percentile_disc(0.75) within group (order by ${getInternalSql(
+ columnDefinition,
+ )})`;
case "90thPercentile":
return Prisma.sql`percentile_disc(0.9) within group (order by ${getInternalSql(
columnDefinition,
diff --git a/src/server/api/services/sqlInterface.ts b/src/server/api/services/sqlInterface.ts
index bb29df2815..e3d32ff139 100644
--- a/src/server/api/services/sqlInterface.ts
+++ b/src/server/api/services/sqlInterface.ts
@@ -18,6 +18,7 @@ export const aggregations = z
"MAX",
"MIN",
"50thPercentile",
+ "75thPercentile",
"90thPercentile",
"95thPercentile",
"99thPercentile",