🪢 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 `from_timestamp` param to get /traces (#1544)
Marc Klingen4c4ab027d992
diff --git a/fern/apis/server/definition/trace.yml b/fern/apis/server/definition/trace.ymlindex 158cbcbd68..16c29cf041 100644--- a/fern/apis/server/definition/trace.yml+++ b/fern/apis/server/definition/trace.yml@@ -26,6 +26,9 @@ service:limit: optional<integer>userId: optional<string>name: optional<string>+ from_timestamp:+ type: optional<datetime>+ docs: Retrieve only traces newer than this timestamp.orderBy:type: optional<string>docs: "Format of the string [field].[asc/desc]. Fields: id, timestamp, name, userId, release, version, public, bookmarked, sessionId. Example: timestamp.asc"diff --git a/generated/postman/collection.json b/generated/postman/collection.jsonindex f6c6c6524f..027785c5ef 100644--- a/generated/postman/collection.json+++ b/generated/postman/collection.json@@ -831,7 +831,7 @@"request": {"description": "Get list of traces","url": {- "raw": "{{baseUrl}}/api/public/traces?page=&limit=&userId=&name=&orderBy=&tags=",+ "raw": "{{baseUrl}}/api/public/traces?page=&limit=&userId=&name=&from_timestamp=&orderBy=&tags=","host": ["{{baseUrl}}"],@@ -861,6 +861,11 @@"value": "","description": null},+ {+ "key": "from_timestamp",+ "value": "",+ "description": "Retrieve only traces newer than this timestamp."+ },{"key": "orderBy","value": "",diff --git a/web/generated/openapi-server/openapi.yml b/web/generated/openapi-server/openapi.ymlindex a54a830f16..07e620a47b 100644--- a/web/generated/openapi-server/openapi.yml+++ b/web/generated/openapi-server/openapi.yml@@ -1047,6 +1047,14 @@ paths:schema:type: stringnullable: true+ - name: from_timestamp+ in: query+ description: Retrieve only traces newer than this timestamp.+ required: false+ schema:+ type: string+ format: date-time+ nullable: true- name: orderByin: querydescription: >-diff --git a/web/src/pages/api/public/traces.ts b/web/src/pages/api/public/traces.tsindex 7e14f7530b..2617c794ef 100644--- a/web/src/pages/api/public/traces.ts+++ b/web/src/pages/api/public/traces.ts@@ -12,6 +12,7 @@ import {import {TraceBody,eventTypes,+ stringDate,} from "@/src/features/public-api/server/ingestion-api-schema";import { v4 } from "uuid";import { telemetry } from "@/src/features/telemetry";@@ -25,6 +26,7 @@ const GetTracesSchema = z.object({userId: z.string().nullish(),name: z.string().nullish(),tags: z.union([z.array(z.string()), z.string()]).nullish(),+ from_timestamp: stringDate,orderBy: z.string() // orderBy=timestamp.asc.nullish()@@ -104,6 +106,9 @@ export default async function handler(", ",)}] <@ t."tags"`: Prisma.empty;+ const fromTimestampCondition = obj.from_timestamp+ ? Prisma.sql`AND t."timestamp" >= ${obj.from_timestamp}::timestamp with time zone at time zone 'UTC'`+ : Prisma.empty;const orderByCondition = orderByToPrismaSql(obj.orderBy ?? null,@@ -140,6 +145,7 @@ export default async function handler(${userCondition}${nameCondition}${tagsCondition}+ ${fromTimestampCondition}GROUP BY t.id${orderByCondition}LIMIT ${obj.limit} OFFSET ${skipValue}@@ -149,6 +155,14 @@ export default async function handler(projectId: authCheck.scope.projectId,name: obj.name ? obj.name : undefined,userId: obj.userId ? obj.userId : undefined,+ timestamp: obj.from_timestamp+ ? { gte: new Date(obj.from_timestamp) }+ : undefined,+ tags: obj.tags+ ? {+ hasEvery: Array.isArray(obj.tags) ? obj.tags : [obj.tags],+ }+ : undefined,},});