🪢 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): optionally set timestamp when creating a trace (#1181)
Marc Klingen329f83e8449d
diff --git a/fern/apis/server/definition/ingestion.yml b/fern/apis/server/definition/ingestion.ymlindex 462535f7f2..222a15bed0 100644--- a/fern/apis/server/definition/ingestion.yml+++ b/fern/apis/server/definition/ingestion.yml@@ -128,6 +128,7 @@ types:TraceBody:properties:id: optional<string>+ timestamp: optional<datetime>name: optional<string>userId: optional<string>input: optional<unknown>diff --git a/generated/openapi-server/openapi.yml b/generated/openapi-server/openapi.ymlindex 50ee91af7b..5c30910c5f 100644--- a/generated/openapi-server/openapi.yml+++ b/generated/openapi-server/openapi.yml@@ -1724,6 +1724,10 @@ components:id:type: stringnullable: true+ timestamp:+ type: string+ format: date-time+ nullable: truename:type: stringnullable: truediff --git a/generated/postman/collection.json b/generated/postman/collection.jsonindex a34b4a73ad..dd382b5d96 100644--- a/generated/postman/collection.json+++ b/generated/postman/collection.json@@ -320,7 +320,7 @@"auth": null,"body": {"mode": "raw",- "raw": "{\n \"batch\": [\n {\n \"type\": \"trace-create\",\n \"body\": {\n \"id\": \"example\",\n \"name\": \"example\",\n \"userId\": \"example\",\n \"input\": \"UNKNOWN\",\n \"output\": \"UNKNOWN\",\n \"sessionId\": \"example\",\n \"release\": \"example\",\n \"version\": \"example\",\n \"metadata\": \"UNKNOWN\",\n \"tags\": [\n \"example\"\n ],\n \"public\": true\n },\n \"id\": \"example\",\n \"timestamp\": \"example\",\n \"metadata\": \"UNKNOWN\"\n }\n ]\n}",+ "raw": "{\n \"batch\": [\n {\n \"type\": \"trace-create\",\n \"body\": {\n \"id\": \"example\",\n \"timestamp\": \"1994-11-05T13:15:30Z\",\n \"name\": \"example\",\n \"userId\": \"example\",\n \"input\": \"UNKNOWN\",\n \"output\": \"UNKNOWN\",\n \"sessionId\": \"example\",\n \"release\": \"example\",\n \"version\": \"example\",\n \"metadata\": \"UNKNOWN\",\n \"tags\": [\n \"example\"\n ],\n \"public\": true\n },\n \"id\": \"example\",\n \"timestamp\": \"example\",\n \"metadata\": \"UNKNOWN\"\n }\n ]\n}","options": {"raw": {"language": "json"diff --git a/src/__tests__/traces.servertest.ts b/src/__tests__/traces.servertest.tsindex a21b439bac..1ff3ebbb0a 100644--- a/src/__tests__/traces.servertest.ts+++ b/src/__tests__/traces.servertest.ts@@ -65,6 +65,7 @@ describe("/api/public/traces API Endpoint", () => {await makeAPICall("POST", "/api/public/traces", {id: "trace-id",metadata: { key: "value" },+ timestamp: "2021-01-01T00:00:00.000Z",release: "1.0.0",version: "5.0.0",public: false,@@ -84,6 +85,7 @@ describe("/api/public/traces API Endpoint", () => {version: "5.0.0",public: false,userId: "user-1",+ timestamp: new Date("2021-01-01T00:00:00.000Z"),});});diff --git a/src/features/public-api/server/ingestion-api-schema.ts b/src/features/public-api/server/ingestion-api-schema.tsindex ed7dcc7cae..40d18e95ee 100644--- a/src/features/public-api/server/ingestion-api-schema.ts+++ b/src/features/public-api/server/ingestion-api-schema.ts@@ -61,6 +61,7 @@ export const usage = MixedUsage.nullish()export const TraceBody = z.object({id: z.string().nullish(),+ timestamp: stringDate,name: z.string().nullish(),externalId: z.string().nullish(),input: jsonSchema.nullish(),diff --git a/src/server/api/services/EventProcessor.ts b/src/server/api/services/EventProcessor.tsindex 80ca62381a..dcbd0b8cc1 100644--- a/src/server/api/services/EventProcessor.ts+++ b/src/server/api/services/EventProcessor.ts@@ -469,6 +469,9 @@ export class TraceProcessor implements EventProcessor {},create: {id: internalId,+ timestamp: this.event.body.timestamp+ ? new Date(this.event.body.timestamp)+ : undefined,name: body.name ?? undefined,userId: body.userId ?? undefined,input: body.input ?? undefined,@@ -483,6 +486,9 @@ export class TraceProcessor implements EventProcessor {},update: {name: body.name ?? undefined,+ timestamp: this.event.body.timestamp+ ? new Date(this.event.body.timestamp)+ : undefined,userId: body.userId ?? undefined,input: body.input ?? undefined,output: body.output ?? undefined,