Skip to content

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

fix: add latencies to trace exports (#4804)

Max Deichmann9917aff8cfc3
diff --git a/web/src/__tests__/async/dataset-service.servertest.ts b/web/src/__tests__/async/dataset-service.servertest.ts
index ca05ab0301..d06ab8d17e 100644
--- a/web/src/__tests__/async/dataset-service.servertest.ts
+++ b/web/src/__tests__/async/dataset-service.servertest.ts
@@ -244,7 +244,7 @@ describe("Fetch datasets for UI presentation", () => {
expect(JSON.stringify(secondRun.scores)).toEqual(JSON.stringify({}));
});
- it.only("should test that dataset runs can link to the same traces", async () => {
+ it("should test that dataset runs can link to the same traces", async () => {
const datasetId = v4();
await prisma.dataset.create({
diff --git a/worker/src/__tests__/batch-export.test.ts b/worker/src/__tests__/batch-export.test.ts
index d5d8776ece..c34c49feea 100644
--- a/worker/src/__tests__/batch-export.test.ts
+++ b/worker/src/__tests__/batch-export.test.ts
@@ -353,16 +353,22 @@ describe("batch export test suite", () => {
project_id: projectId,
trace_id: traces[0].id,
type: "GENERATION",
+ start_time: new Date().getTime() - 1000,
+ end_time: new Date().getTime(),
}),
createObservation({
project_id: projectId,
trace_id: traces[1].id,
type: "GENERATION",
+ start_time: new Date().getTime() - 2000,
+ end_time: new Date().getTime(),
}),
createObservation({
project_id: projectId,
trace_id: traces[1].id,
type: "GENERATION",
+ start_time: new Date().getTime() - 2123,
+ end_time: new Date().getTime(),
}),
];
@@ -397,10 +403,12 @@ describe("batch export test suite", () => {
expect.arrayContaining([
expect.objectContaining({
id: traces[0].id,
+ latency: 1,
test: [score.value],
}),
expect.objectContaining({
id: traces[1].id,
+ latency: 2.123,
}),
]),
);
diff --git a/worker/src/features/batchExport/handleBatchExportJob.ts b/worker/src/features/batchExport/handleBatchExportJob.ts
index 27eb1ac967..d6d2810c09 100644
--- a/worker/src/features/batchExport/handleBatchExportJob.ts
+++ b/worker/src/features/batchExport/handleBatchExportJob.ts
@@ -401,6 +401,7 @@ export const getDatabaseReadStream = async ({
input: fullTrace?.input,
output: fullTrace?.output,
metadata: fullTrace?.metadata,
+ latency: metric?.latency,
name: t.name ?? "",
usage: {
promptTokens: metric?.promptTokens,