Skip to content

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

fix: GET /traces endpoint, typing of params, return empty [] instead of null (#1324)

Marc Klingen4a362ee10fdb
diff --git a/fern/apis/server/definition/trace.yml b/fern/apis/server/definition/trace.yml
index 433d26ddcc..158cbcbd68 100644
--- a/fern/apis/server/definition/trace.yml
+++ b/fern/apis/server/definition/trace.yml
@@ -27,8 +27,8 @@ service:
userId: optional<string>
name: optional<string>
orderBy:
- type: string
- docs: Format of the string sort_by=timestamp.asc (id, timestamp, name, userId, release, version, public, bookmarked, sessionId)
+ type: optional<string>
+ docs: "Format of the string [field].[asc/desc]. Fields: id, timestamp, name, userId, release, version, public, bookmarked, sessionId. Example: timestamp.asc"
tags:
type: optional<string>
allow-multiple: true
diff --git a/generated/postman/collection.json b/generated/postman/collection.json
index 85b56779f7..b55b6e6cae 100644
--- a/generated/postman/collection.json
+++ b/generated/postman/collection.json
@@ -864,7 +864,7 @@
{
"key": "orderBy",
"value": "",
- "description": "Format of the string sort_by=timestamp.asc (id, timestamp, name, userId, release, version, public, bookmarked, sessionId)"
+ "description": "Format of the string [field].[asc/desc]. Fields: id, timestamp, name, userId, release, version, public, bookmarked, sessionId. Example: timestamp.asc"
},
{
"key": "tags",
diff --git a/web/generated/openapi-server/openapi.yml b/web/generated/openapi-server/openapi.yml
index 91a78a315c..a63e442edd 100644
--- a/web/generated/openapi-server/openapi.yml
+++ b/web/generated/openapi-server/openapi.yml
@@ -1050,11 +1050,13 @@ paths:
- name: orderBy
in: query
description: >-
- Format of the string sort_by=timestamp.asc (id, timestamp, name,
- userId, release, version, public, bookmarked, sessionId)
- required: true
+ Format of the string [field].[asc/desc]. Fields: id, timestamp,
+ name, userId, release, version, public, bookmarked, sessionId.
+ Example: timestamp.asc
+ required: false
schema:
type: string
+ nullable: true
- name: tags
in: query
description: Only traces that include all of these tags will be returned.
diff --git a/web/src/pages/api/public/traces.ts b/web/src/pages/api/public/traces.ts
index 5713629b7f..9551dd1071 100644
--- a/web/src/pages/api/public/traces.ts
+++ b/web/src/pages/api/public/traces.ts
@@ -131,8 +131,8 @@ export default async function handler(
t.tags,
COALESCE(SUM(o.calculated_total_cost), 0)::DOUBLE PRECISION AS "totalCost",
COALESCE(EXTRACT(EPOCH FROM COALESCE(MAX(o."end_time"), MAX(o."start_time"))) - EXTRACT(EPOCH FROM MIN(o."start_time")), 0)::double precision AS "latency",
- ARRAY_AGG(DISTINCT o.id) FILTER (WHERE o.id IS NOT NULL) AS "observations",
- ARRAY_AGG(DISTINCT s.id) FILTER (WHERE s.id IS NOT NULL) AS "scores"
+ COALESCE(ARRAY_AGG(DISTINCT o.id) FILTER (WHERE o.id IS NOT NULL), ARRAY[]::text[]) AS "observations",
+ COALESCE(ARRAY_AGG(DISTINCT s.id) FILTER (WHERE s.id IS NOT NULL), ARRAY[]::text[]) AS "scores"
FROM "traces" AS t
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_id