Skip to content

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

chore(dashboard): use more granular time buckets on home dashboard (#6795)

Steffen Schmitz2dac75d203eb
diff --git a/fern/apis/server/definition/metrics.yml b/fern/apis/server/definition/metrics.yml
index ca1e8282fc..0ce627b233 100644
--- a/fern/apis/server/definition/metrics.yml
+++ b/fern/apis/server/definition/metrics.yml
@@ -41,7 +41,7 @@ service:
}
],
"timeDimension": { // Optional. Default: null. If provided, results will be grouped by time
- "granularity": string // One of "minute", "hour", "day", "week", "month", "year", "auto"
+ "granularity": string // One of "minute", "hour", "day", "week", "month", "auto"
},
"fromTimestamp": string, // Required. ISO datetime string for start of time range
"toTimestamp": string, // Required. ISO datetime string for end of time range
diff --git a/packages/shared/src/server/repositories/dashboards.ts b/packages/shared/src/server/repositories/dashboards.ts
index 8b680afab8..7dbd361c01 100644
--- a/packages/shared/src/server/repositories/dashboards.ts
+++ b/packages/shared/src/server/repositories/dashboards.ts
@@ -12,7 +12,7 @@ import {
SCORE_TO_TRACE_OBSERVATIONS_INTERVAL,
} from "./constants";
-export type DateTrunc = "year" | "month" | "week" | "day" | "hour" | "minute";
+export type DateTrunc = "month" | "week" | "day" | "hour" | "minute";
const extractEnvironmentFilterFromFilters = (
filter: FilterState,
diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.yml
index ae586013f5..89f8ebe213 100644
--- a/web/public/generated/api/openapi.yml
+++ b/web/public/generated/api/openapi.yml
@@ -1795,7 +1795,7 @@ paths:
}
],
"timeDimension": { // Optional. Default: null. If provided, results will be grouped by time
- "granularity": string // One of "minute", "hour", "day", "week", "month", "year", "auto"
+ "granularity": string // One of "minute", "hour", "day", "week", "month", "auto"
},
"fromTimestamp": string, // Required. ISO datetime string for start of time range
"toTimestamp": string, // Required. ISO datetime string for end of time range
diff --git a/web/public/generated/postman/collection.json b/web/public/generated/postman/collection.json
index f1c9ea9bcf..d145c876dc 100644
--- a/web/public/generated/postman/collection.json
+++ b/web/public/generated/postman/collection.json
@@ -1411,7 +1411,7 @@
{
"key": "query",
"value": "",
- "description": "JSON string containing the query parameters with the following structure:\n```json\n{\n \"view\": string, // Required. One of \"traces\", \"observations\", \"scores-numeric\", \"scores-categorical\"\n \"dimensions\": [ // Optional. Default: []\n {\n \"field\": string // Field to group by, e.g. \"name\", \"userId\", \"sessionId\"\n }\n ],\n \"metrics\": [ // Required. At least one metric must be provided\n {\n \"measure\": string, // What to measure, e.g. \"count\", \"latency\", \"value\"\n \"aggregation\": string // How to aggregate, e.g. \"count\", \"sum\", \"avg\", \"p95\"\n }\n ],\n \"filters\": [ // Optional. Default: []\n {\n \"column\": string, // Column to filter on\n \"operator\": string, // Operator, e.g. \"=\", \">\", \"<\", \"contains\"\n \"value\": any, // Value to compare against\n \"type\": string, // Data type, e.g. \"string\", \"number\", \"stringObject\"\n \"key\": string // Required only when filtering on metadata\n }\n ],\n \"timeDimension\": { // Optional. Default: null. If provided, results will be grouped by time\n \"granularity\": string // One of \"minute\", \"hour\", \"day\", \"week\", \"month\", \"year\", \"auto\"\n },\n \"fromTimestamp\": string, // Required. ISO datetime string for start of time range\n \"toTimestamp\": string, // Required. ISO datetime string for end of time range\n \"orderBy\": [ // Optional. Default: null\n {\n \"field\": string, // Field to order by\n \"direction\": string // \"asc\" or \"desc\"\n }\n ]\n}\n```"
+ "description": "JSON string containing the query parameters with the following structure:\n```json\n{\n \"view\": string, // Required. One of \"traces\", \"observations\", \"scores-numeric\", \"scores-categorical\"\n \"dimensions\": [ // Optional. Default: []\n {\n \"field\": string // Field to group by, e.g. \"name\", \"userId\", \"sessionId\"\n }\n ],\n \"metrics\": [ // Required. At least one metric must be provided\n {\n \"measure\": string, // What to measure, e.g. \"count\", \"latency\", \"value\"\n \"aggregation\": string // How to aggregate, e.g. \"count\", \"sum\", \"avg\", \"p95\"\n }\n ],\n \"filters\": [ // Optional. Default: []\n {\n \"column\": string, // Column to filter on\n \"operator\": string, // Operator, e.g. \"=\", \">\", \"<\", \"contains\"\n \"value\": any, // Value to compare against\n \"type\": string, // Data type, e.g. \"string\", \"number\", \"stringObject\"\n \"key\": string // Required only when filtering on metadata\n }\n ],\n \"timeDimension\": { // Optional. Default: null. If provided, results will be grouped by time\n \"granularity\": string // One of \"minute\", \"hour\", \"day\", \"week\", \"month\", \"auto\"\n },\n \"fromTimestamp\": string, // Required. ISO datetime string for start of time range\n \"toTimestamp\": string, // Required. ISO datetime string for end of time range\n \"orderBy\": [ // Optional. Default: null\n {\n \"field\": string, // Field to order by\n \"direction\": string // \"asc\" or \"desc\"\n }\n ]\n}\n```"
}
],
"variable": []
diff --git a/web/src/features/dashboard/components/ChartScores.tsx b/web/src/features/dashboard/components/ChartScores.tsx
index 5788bb5c34..113786efb6 100644
--- a/web/src/features/dashboard/components/ChartScores.tsx
+++ b/web/src/features/dashboard/components/ChartScores.tsx
@@ -8,7 +8,10 @@ import {
fillMissingValuesAndTransform,
isEmptyTimeSeries,
} from "@/src/features/dashboard/components/hooks";
-import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";
+import {
+ type DashboardDateRangeAggregationOption,
+ dashboardDateRangeAggregationSettings,
+} from "@/src/utils/date-range-utils";
import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";
import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";
import {
@@ -35,7 +38,7 @@ export function ChartScores(props: {
props.globalFilterState,
),
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[props.agg].date_trunc,
},
fromTimestamp: props.fromTimestamp.toISOString(),
toTimestamp: props.toTimestamp.toISOString(),
diff --git a/web/src/features/dashboard/components/LatencyChart.tsx b/web/src/features/dashboard/components/LatencyChart.tsx
index b2a5ff97bf..e79d4d6e7b 100644
--- a/web/src/features/dashboard/components/LatencyChart.tsx
+++ b/web/src/features/dashboard/components/LatencyChart.tsx
@@ -9,7 +9,10 @@ import { DashboardCard } from "@/src/features/dashboard/components/cards/Dashboa
import { BaseTimeSeriesChart } from "@/src/features/dashboard/components/BaseTimeSeriesChart";
import { TabComponent } from "@/src/features/dashboard/components/TabsComponent";
import { latencyFormatter } from "@/src/utils/numbers";
-import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";
+import {
+ type DashboardDateRangeAggregationOption,
+ dashboardDateRangeAggregationSettings,
+} from "@/src/utils/date-range-utils";
import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";
import {
ModelSelectorPopover,
@@ -78,7 +81,7 @@ export const GenerationLatencyChart = ({
},
],
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[agg].date_trunc,
},
fromTimestamp: fromTimestamp.toISOString(),
toTimestamp: toTimestamp.toISOString(),
diff --git a/web/src/features/dashboard/components/ModelUsageChart.tsx b/web/src/features/dashboard/components/ModelUsageChart.tsx
index ee07056687..66ae062cd9 100644
--- a/web/src/features/dashboard/components/ModelUsageChart.tsx
+++ b/web/src/features/dashboard/components/ModelUsageChart.tsx
@@ -82,7 +82,7 @@ export const ModelUsageChart = ({
},
],
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[agg].date_trunc,
},
fromTimestamp: fromTimestamp.toISOString(),
toTimestamp: toTimestamp.toISOString(),
diff --git a/web/src/features/dashboard/components/TracesTimeSeriesChart.tsx b/web/src/features/dashboard/components/TracesTimeSeriesChart.tsx
index 8578ef014b..fc4cbb8563 100644
--- a/web/src/features/dashboard/components/TracesTimeSeriesChart.tsx
+++ b/web/src/features/dashboard/components/TracesTimeSeriesChart.tsx
@@ -5,7 +5,10 @@ import { BaseTimeSeriesChart } from "@/src/features/dashboard/components/BaseTim
import { TotalMetric } from "@/src/features/dashboard/components/TotalMetric";
import { compactNumberFormatter } from "@/src/utils/numbers";
import { isEmptyTimeSeries } from "@/src/features/dashboard/components/hooks";
-import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";
+import {
+ type DashboardDateRangeAggregationOption,
+ dashboardDateRangeAggregationSettings,
+} from "@/src/utils/date-range-utils";
import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";
import { TabComponent } from "@/src/features/dashboard/components/TabsComponent";
import {
@@ -36,7 +39,7 @@ export const TracesAndObservationsTimeSeriesChart = ({
metrics: [{ measure: "count", aggregation: "count" }],
filters: mapLegacyUiTableFilterToView("traces", globalFilterState),
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[agg].date_trunc,
},
fromTimestamp: fromTimestamp.toISOString(),
toTimestamp: toTimestamp.toISOString(),
@@ -82,7 +85,7 @@ export const TracesAndObservationsTimeSeriesChart = ({
metrics: [{ measure: "count", aggregation: "count" }],
filters: mapLegacyUiTableFilterToView("observations", globalFilterState),
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[agg].date_trunc,
},
fromTimestamp: fromTimestamp.toISOString(),
toTimestamp: toTimestamp.toISOString(),
diff --git a/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx b/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx
index 3518dd700d..6742943476 100644
--- a/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx
+++ b/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx
@@ -1,7 +1,10 @@
import { api } from "@/src/utils/api";
import { type FilterState } from "@langfuse/shared";
import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";
-import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";
+import {
+ type DashboardDateRangeAggregationOption,
+ dashboardDateRangeAggregationSettings,
+} from "@/src/utils/date-range-utils";
import React, { useMemo } from "react";
import { DashboardCategoricalScoreAdapter } from "@/src/features/scores/adapters";
import { type ScoreData } from "@/src/features/scores/types";
@@ -50,7 +53,8 @@ export function CategoricalScoreChart(props: {
],
timeDimension: props.agg
? {
- granularity: "day",
+ granularity:
+ dashboardDateRangeAggregationSettings[props.agg].date_trunc,
}
: null,
fromTimestamp: props.fromTimestamp.toISOString(),
diff --git a/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx b/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx
index e76b3647d3..e5bc2c0b4f 100644
--- a/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx
+++ b/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx
@@ -13,7 +13,10 @@ import {
isEmptyTimeSeries,
} from "@/src/features/dashboard/components/hooks";
import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";
-import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";
+import {
+ type DashboardDateRangeAggregationOption,
+ dashboardDateRangeAggregationSettings,
+} from "@/src/utils/date-range-utils";
import React, { useMemo } from "react";
import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";
import {
@@ -61,7 +64,7 @@ export function NumericScoreTimeSeriesChart(props: {
},
],
timeDimension: {
- granularity: "auto",
+ granularity: dashboardDateRangeAggregationSettings[props.agg].date_trunc,
},
fromTimestamp: props.fromTimestamp.toISOString(),
toTimestamp: props.toTimestamp.toISOString(),
diff --git a/web/src/server/api/services/sqlInterface.ts b/web/src/server/api/services/sqlInterface.ts
index 0db222d95f..813be1f686 100644
--- a/web/src/server/api/services/sqlInterface.ts
+++ b/web/src/server/api/services/sqlInterface.ts
@@ -5,14 +5,7 @@ export type DatabaseRow = {
[key: string]: string | number | Date | Record<string, unknown> | null;
};
-export const temporalUnit = z.enum([
- "year",
- "month",
- "week",
- "day",
- "hour",
- "minute",
-]);
+export const temporalUnit = z.enum(["month", "week", "day", "hour", "minute"]);
export const aggregations = z
.enum([
diff --git a/web/src/utils/date-range-utils.ts b/web/src/utils/date-range-utils.ts
index 16a37a8c1c..b5696c5616 100644
--- a/web/src/utils/date-range-utils.ts
+++ b/web/src/utils/date-range-utils.ts
@@ -83,7 +83,7 @@ export const dashboardDateRangeAggregationSettings: DashboardDateRangeAggregatio
minutes: 30 * 24 * 60,
},
"7 days": {
- date_trunc: "day",
+ date_trunc: "hour",
minutes: 7 * 24 * 60,
},
"24 hours": {
@@ -91,7 +91,7 @@ export const dashboardDateRangeAggregationSettings: DashboardDateRangeAggregatio
minutes: 24 * 60,
},
"3 hours": {
- date_trunc: "hour",
+ date_trunc: "minute",
minutes: 3 * 60,
},
"1 hour": {