Skip to content

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

chore(worker): consolidate ClickhouseWriter drop logs into single summary (#11636)

Steffen Schmitz02a83085e980
diff --git a/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts b/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
index 86dbad6eef..8e4eab9cb8 100644
--- a/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
+++ b/worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts
@@ -152,32 +152,6 @@ describe("ClickhouseWriter", () => {
expect(writer["queue"][TableName.Traces]).toHaveLength(0);
});
- it("should truncate logged events after dropping", async () => {
- const mockInsert = vi
- .spyOn(clickhouseClientMock, "insert")
- .mockRejectedValue(new Error("DB Error"));
-
- const baseString =
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ";
- const repeatCount = Math.ceil(150000);
- const input = baseString.repeat(repeatCount);
- writer.addToQueue(TableName.Traces, { id: "1", name: "test", input });
-
- for (let i = 0; i < writer.maxAttempts; i++) {
- await vi.advanceTimersByTimeAsync(writer.writeInterval);
- }
-
- await vi.advanceTimersByTimeAsync(writer.writeInterval);
-
- expect(mockInsert).toHaveBeenCalledTimes(writer.maxAttempts);
- expect(
- logger.error.mock.calls.some((call) =>
- call[1]?.item?.input?.includes("TRUNCATED: Field exceeded size limit"),
- ),
- ).toBe(true);
- expect(writer["queue"][TableName.Traces]).toHaveLength(0);
- });
-
it("should shutdown gracefully", async () => {
writer.addToQueue(TableName.Traces, { id: "1", name: "test" });
const mockInsert = vi
diff --git a/worker/src/services/ClickhouseWriter/index.ts b/worker/src/services/ClickhouseWriter/index.ts
index 32153aa7ab..7149e3e4c4 100644
--- a/worker/src/services/ClickhouseWriter/index.ts
+++ b/worker/src/services/ClickhouseWriter/index.ts
@@ -417,6 +417,7 @@ export class ClickhouseWriter {
logger.error(`ClickhouseWriter.flush ${tableName}`, err);
// Re-add the records to the queue with incremented attempts
+ let droppedCount = 0;
queueItems.forEach((item) => {
if (item.attempts < this.maxAttempts) {
entityQueue.push({
@@ -426,12 +427,15 @@ export class ClickhouseWriter {
} else {
// TODO - Add to a dead letter queue in Redis rather than dropping
recordIncrement("langfuse.queue.clickhouse_writer.error");
- logger.error(
- `Max attempts reached for ${tableName} record. Dropping record.`,
- { item: this.truncateOversizedRecord(tableName, item.data) },
- );
+ droppedCount++;
}
});
+
+ if (droppedCount > 0) {
+ logger.error(
+ `ClickhouseWriter: Max attempts reached, dropped ${droppedCount} ${tableName} record(s)`,
+ );
+ }
}
}