Skip to content

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

Revert "perf: stream new records to clickhouse in writer (#8421)" (#8459)

Steffen Schmitz21b3ce3c829f
diff --git a/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts b/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
index 689eaabb21..e00f9e869d 100644
--- a/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
+++ b/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
@@ -344,12 +344,12 @@ describe("ClickhouseWriter", () => {
await vi.advanceTimersByTimeAsync(writer.writeInterval);
expect(mockInsert).toHaveBeenCalledTimes(1);
- const streamValues = await mockInsert.mock.calls[0][0].values.toArray();
- expect(streamValues).toHaveLength(partialQueueSize);
- expect(streamValues).toEqual(
- expect.arrayContaining(
- new Array(partialQueueSize).fill(expect.any(Object)),
- ),
+ expect(mockInsert).toHaveBeenCalledWith(
+ expect.objectContaining({
+ values: expect.arrayContaining(
+ new Array(partialQueueSize).fill(expect.any(Object)),
+ ),
+ }),
);
expect(writer["queue"][TableName.Traces]).toHaveLength(0);
});
@@ -518,8 +518,8 @@ describe("ClickhouseWriter", () => {
expect(writer["queue"][TableName.Traces]).toHaveLength(0);
// Verify that the second call used truncated data
- const secondCallArgs = await mockInsert.mock.calls[1][0].values.toArray();
- expect(secondCallArgs[0].input).toContain(
+ const secondCallArgs = mockInsert.mock.calls[1][0];
+ expect(secondCallArgs.values[0].input).toContain(
"[TRUNCATED: Field exceeded size limit]",
);
});
diff --git a/worker/src/services/ClickhouseWriter/index.ts b/worker/src/services/ClickhouseWriter/index.ts
index 4a5df66663..238ca52cc5 100644
--- a/worker/src/services/ClickhouseWriter/index.ts
+++ b/worker/src/services/ClickhouseWriter/index.ts
@@ -12,7 +12,6 @@ import {
TraceNullRecordInsertType,
DatasetRunItemRecordInsertType,
} from "@langfuse/shared/src/server";
-import { Readable } from "stream";
import { env } from "../../env";
import { logger } from "@langfuse/shared/src/server";
@@ -380,7 +379,7 @@ export class ClickhouseWriter {
.insert({
table: params.table,
format: "JSONEachRow",
- values: Readable.from(params.records),
+ values: params.records,
clickhouse_settings: {
log_comment: JSON.stringify({ feature: "ingestion" }),
},