🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(web): enable error level filtering in custom dashboard widgets (#12481)
Max Deichmann50a0b5400918
diff --git a/packages/shared/src/tableDefinitions/mapDashboards.ts b/packages/shared/src/tableDefinitions/mapDashboards.tsindex d08123d2e1..c929f57abe 100644--- a/packages/shared/src/tableDefinitions/mapDashboards.ts+++ b/packages/shared/src/tableDefinitions/mapDashboards.ts@@ -69,6 +69,12 @@ export const dashboardColumnDefinitions: UiColumnMappings = [uiTableId: "type",uiTableName: "Type",},+ {+ clickhouseTableName: "observations",+ clickhouseSelect: "o.level",+ uiTableId: "level",+ uiTableName: "Level",+ },{clickhouseTableName: "traces",clickhouseSelect: "t.user_id",diff --git a/web/src/__tests__/server/queryBuilderDashboards.servertest.ts b/web/src/__tests__/server/queryBuilderDashboards.servertest.tsindex be19f647a8..4670448e9e 100644--- a/web/src/__tests__/server/queryBuilderDashboards.servertest.ts+++ b/web/src/__tests__/server/queryBuilderDashboards.servertest.ts@@ -7,6 +7,7 @@ import {} from "@langfuse/shared/src/server";import { type QueryType } from "@/src/features/query/types";import { executeQuery } from "@/src/features/query/server/queryExecutor";+import { mapLegacyUiTableFilterToView } from "@/src/features/query";describe("selfServeDashboards", () => {// Single project ID for all tests@@ -31,6 +32,7 @@ describe("selfServeDashboards", () => {recentProductionTraces: 0, // within the last hourtraceCounts: {} as Record<string, number>, // counts by trace nameenvironmentCounts: {} as Record<string, number>, // counts by environment+ observationLevelCounts: {} as Record<string, number>, // counts by level};beforeAll(async () => {@@ -126,6 +128,7 @@ describe("selfServeDashboards", () => {trace_id: traceId,name: "gpt-4-turbo",type: "generation",+ level: i === 0 ? "ERROR" : i === 1 ? "WARNING" : ("DEFAULT" as const),environment: "production",start_time: now.getTime() - i * 10000,completion_start_time: now.getTime() - i * 10000 + 800, // 800ms time to first token@@ -144,6 +147,7 @@ describe("selfServeDashboards", () => {trace_id: traceId,name: "text-embedding-ada-002",type: "generation",+ level: i === 0 ? "ERROR" : ("WARNING" as const),environment: "production",start_time: now.getTime() - i * 15000,completion_start_time: now.getTime() - i * 15000 + 200, // 200ms time to first token@@ -162,6 +166,7 @@ describe("selfServeDashboards", () => {trace_id: traceId,name: "claude-3-opus",type: "generation",+ level: i === 0 ? "DEFAULT" : ("ERROR" as const),environment: "development",start_time: oneHourAgo.getTime() - i * 20000,completion_start_time: oneHourAgo.getTime() - i * 20000 + 1200, // 1200ms time to first token@@ -192,6 +197,13 @@ describe("selfServeDashboards", () => {(stats.traceCounts[trace.name || ""] || 0) + 1;});+ // Count observations by level+ observations.forEach((observation) => {+ const level = observation.level || "DEFAULT";+ stats.observationLevelCounts[level] =+ (stats.observationLevelCounts[level] || 0) + 1;+ });+// Count recent production traces (within the last hour)stats.recentProductionTraces = traces.filter((t) =>@@ -550,6 +562,41 @@ describe("selfServeDashboards", () => {});});+ describe("observations-level filter query", () => {+ it("should support legacy dashboard Level filters after widget remapping", async () => {+ const legacyFilters: Parameters<typeof mapLegacyUiTableFilterToView>[1] =+ [+ {+ column: "Level",+ operator: "any of",+ value: ["ERROR"],+ type: "stringOptions",+ },+ ];++ const queryBuilderQuery: QueryType = {+ view: "observations",+ dimensions: [],+ metrics: [{ measure: "count", aggregation: "count" }],+ filters: mapLegacyUiTableFilterToView("observations", legacyFilters),+ timeDimension: null,+ fromTimestamp: defaultFromTime,+ toTimestamp: defaultToTime,+ orderBy: null,+ };++ const queryBuilderResult = await executeQuery(+ projectId,+ queryBuilderQuery,+ );++ expect(queryBuilderResult).toHaveLength(1);+ expect(Number(queryBuilderResult[0].count_count)).toBe(+ stats.observationLevelCounts["ERROR"],+ );+ });+ });+describe("traces-timeseries query", () => {it("should return traces grouped by time correctly", async () => {// 1. Define the query for the query builderdiff --git a/web/src/features/query/dashboardUiTableToViewMapping.ts b/web/src/features/query/dashboardUiTableToViewMapping.tsindex 9e6c1b1e78..1341bcdb90 100644--- a/web/src/features/query/dashboardUiTableToViewMapping.ts+++ b/web/src/features/query/dashboardUiTableToViewMapping.ts@@ -86,6 +86,10 @@ const viewMappings: Record<z.infer<typeof views>, Record<string, string>[]> = {uiTableName: "Model",viewName: "providedModelName",},+ {+ uiTableName: "Level",+ viewName: "level",+ },{uiTableName: "Tool Names",viewName: "toolNames",diff --git a/web/src/features/widgets/components/WidgetForm.tsx b/web/src/features/widgets/components/WidgetForm.tsxindex eae2f7ddd4..e900be20ee 100644--- a/web/src/features/widgets/components/WidgetForm.tsx+++ b/web/src/features/widgets/components/WidgetForm.tsx@@ -567,6 +567,12 @@ export function WidgetForm({const tagsOptions = traceFilterOptions.data?.tags || [];const modelOptions = generationsFilterOptions.data?.model || [];const toolNamesOptions = generationsFilterOptions.data?.toolNames || [];+ const observationLevelOptions = [+ { value: "DEBUG" },+ { value: "DEFAULT" },+ { value: "WARNING" },+ { value: "ERROR" },+ ];// Filter columns for PopoverFilterBuilderconst filterColumns: ColumnDefinition[] = [@@ -649,6 +655,13 @@ export function WidgetForm({options: modelOptions,internal: "internalValue",});+ filterColumns.push({+ name: "Level",+ id: "level",+ type: "stringOptions",+ options: observationLevelOptions,+ internal: "internalValue",+ });}if (selectedView === "scores-categorical") {filterColumns.push({