🪢 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
fix(tools): offer array names on widget x-axis (#11496)
Nimar94ed3a4b0228
diff --git a/web/src/features/filters/config/observations-config.ts b/web/src/features/filters/config/observations-config.tsindex 331cf964f5..6ef36616c1 100644--- a/web/src/features/filters/config/observations-config.ts+++ b/web/src/features/filters/config/observations-config.ts@@ -137,12 +137,12 @@ export const observationFilterConfig: FilterConfig = {{type: "categorical" as const,column: "toolNames",- label: "Available Tool Names",+ label: "Tool Names (Available)",},{type: "categorical" as const,column: "calledToolNames",- label: "Called Tool Names",+ label: "Tool Names (Called)",},{type: "numeric" as const,diff --git a/web/src/features/query/dataModel.ts b/web/src/features/query/dataModel.tsindex adc7b93684..0494a0ff2e 100644--- a/web/src/features/query/dataModel.ts+++ b/web/src/features/query/dataModel.ts@@ -434,12 +434,14 @@ export const observationsView: ViewDeclarationType = {alias: "toolNames",type: "arrayString",description: "Names of available tools defined for the observation.",+ explodeArray: true,},calledToolNames: {sql: "observations.tool_call_names",alias: "calledToolNames",type: "arrayString",description: "Names of tools that were called by the observation.",+ explodeArray: true,},},measures: {@@ -1089,12 +1091,14 @@ export const eventsObservationsView: ViewDeclarationType = {alias: "toolNames",type: "arrayString",description: "Names of available tools defined for the observation.",+ explodeArray: true,},calledToolNames: {sql: "events_observations.tool_call_names",alias: "calledToolNames",type: "arrayString",description: "Names of tools that were called by the observation.",+ explodeArray: true,},},measures: {diff --git a/web/src/features/query/server/queryBuilder.ts b/web/src/features/query/server/queryBuilder.tsindex 9d02bcee3a..2110893ea7 100644--- a/web/src/features/query/server/queryBuilder.ts+++ b/web/src/features/query/server/queryBuilder.ts@@ -25,6 +25,7 @@ type AppliedDimensionType = {alias?: string;relationTable?: string;aggregationFunction?: string;+ explodeArray?: boolean;};type AppliedMetricType = {@@ -100,7 +101,11 @@ export class QueryBuilder {);}const dim = view.dimensions[dimension.field];- return { ...dim, table: dim.relationTable || view.name };+ return {+ ...dim,+ table: dim.relationTable || view.name,+ explodeArray: dim.explodeArray,+ };});}@@ -588,6 +593,10 @@ export class QueryBuilder {if (dimension.aggregationFunction) {return `${dimension.aggregationFunction} as ${dimension.alias ?? dimension.sql}`;}+ // Explode array dimensions using arrayJoin+ if (dimension.explodeArray) {+ return `arrayJoin(${dimension.sql}) as ${dimension.alias ?? dimension.sql}`;+ }// Default: wrap in any()return `any(${dimension.sql}) as ${dimension.alias ?? dimension.sql}`;})@@ -627,12 +636,21 @@ export class QueryBuilder {innerDimensionsPart: string,innerMetricsPart: string,fromClause: string,+ appliedDimensions: AppliedDimensionType[],) {const actualTableName = this.actualTableName(view);// Use actual SQL from view definition for id column (handles events.span_id -> id mapping)const idSql = view.dimensions.id?.sql || `${actualTableName}.id`;const projectIdSql = `${actualTableName}.project_id`;+ // Build inner GROUP BY - include exploded array dimensions (they must be in GROUP BY after arrayJoin)+ const groupByParts = [projectIdSql, idSql];+ for (const dim of appliedDimensions) {+ if (dim.explodeArray) {+ groupByParts.push(dim.alias ?? dim.sql);+ }+ }+return `SELECT${projectIdSql},@@ -640,7 +658,7 @@ export class QueryBuilder {${innerDimensionsPart}${innerMetricsPart}${fromClause}- GROUP BY ${projectIdSql}, ${idSql}`;+ GROUP BY ${groupByParts.join(", ")}`;}private buildOuterDimensionsPart(@@ -823,7 +841,12 @@ export class QueryBuilder {if (appliedDimensions.length > 0) {dimensionsPart =appliedDimensions- .map((d) => `${d.sql} as ${d.alias ?? d.sql}`)+ .map((d) => {+ if (d.explodeArray) {+ return `arrayJoin(${d.sql}) as ${d.alias ?? d.sql}`;+ }+ return `${d.sql} as ${d.alias ?? d.sql}`;+ }).join(",\n") + ",\n";}@@ -1137,6 +1160,7 @@ export class QueryBuilder {innerDimensionsPart,innerMetricsPart,fromClause,+ appliedDimensions,);// Build outer SELECT partsdiff --git a/web/src/features/query/types.ts b/web/src/features/query/types.tsindex 0c289716ea..bc338d6469 100644--- a/web/src/features/query/types.ts+++ b/web/src/features/query/types.ts@@ -22,6 +22,7 @@ export const viewDeclaration = z.object({unit: z.string().optional(),aggregationFunction: z.string().optional(),highCardinality: z.boolean().optional(),+ explodeArray: z.boolean().optional(),}),),measures: z.record(