🪢 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(api): add htmlPath, latency, totalCost to `GET /traces` (#1201)
Marc Klingen43c325813597
diff --git a/fern/apis/server/definition/commons.yml b/fern/apis/server/definition/commons.ymlindex 31837faf82..fdce8598e6 100644--- a/fern/apis/server/definition/commons.yml+++ b/fern/apis/server/definition/commons.yml@@ -18,16 +18,25 @@ types:public:type: optional<boolean>docs: Public traces are accessible via url without login- TraceWithDetails:+ TraceWithDetails: # GET /tracesextends: Traceproperties:+ htmlPath:+ type: string+ docs: Path of trace in Langfuse UI+ latency:+ type: double+ docs: Latency of trace in seconds+ totalCost:+ type: double+ docs: Cost of trace in USD.observations:type: list<string>docs: List of observation idsscores:type: list<string>docs: List of score ids- TraceWithFullDetails:+ TraceWithFullDetails: # GET traces/[traceID]extends: Traceproperties:observations: list<ObservationsView>diff --git a/generated/openapi-server/openapi.yml b/generated/openapi-server/openapi.ymlindex 326c29286d..36550c5fe3 100644--- a/generated/openapi-server/openapi.yml+++ b/generated/openapi-server/openapi.yml@@ -1025,6 +1025,17 @@ components:title: TraceWithDetailstype: objectproperties:+ htmlPath:+ type: string+ description: Path of trace in Langfuse UI+ latency:+ type: number+ format: double+ description: Latency of trace in seconds+ totalCost:+ type: number+ format: double+ description: Cost of trace in USD.observations:type: arrayitems:@@ -1036,6 +1047,9 @@ components:type: stringdescription: List of score idsrequired:+ - htmlPath+ - latency+ - totalCost- observations- scoresallOf:diff --git a/src/pages/api/public/traces.ts b/src/pages/api/public/traces.tsindex 9675fa6289..f2b42b3e9d 100644--- a/src/pages/api/public/traces.ts+++ b/src/pages/api/public/traces.ts@@ -114,6 +114,7 @@ export default async function handler(>(Prisma.sql`SELECTt.id,+ CONCAT('/project/', t.project_id,'/traces/',t.id) as "htmlPath",t.timestamp,t.name,t.project_id as "projectId",@@ -123,10 +124,12 @@ export default async function handler(t.release,t.version,t.tags,+ SUM(o.calculated_total_cost) AS "totalCost",+ EXTRACT(EPOCH FROM COALESCE(MAX(o."end_time"), MAX(o."start_time"))) - EXTRACT(EPOCH FROM MIN(o."start_time"))::double precision AS "latency",array_remove(array_agg(o.id), NULL) AS "observations",array_remove(array_agg(s.id), NULL) AS "scores"FROM "traces" AS t- LEFT JOIN "observations" AS o ON t.id = o.trace_id AND o.project_id = ${authCheck.scope.projectId}+ LEFT JOIN "observations_view" AS o ON t.id = o.trace_id AND o.project_id = ${authCheck.scope.projectId}LEFT JOIN "scores" AS s ON t.id = s.trace_idWHERE t.project_id = ${authCheck.scope.projectId}${userCondition}