Skip to content

Commit e7cf58d

Browse files
fix(worker): add rows_dropped metric for ClickhouseWriter exhaust (#13488)
Emit langfuse.queue.clickhouse_writer.rows_dropped with entity_type tag when rows are discarded after max flush attempts, alongside existing error increments and logs. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5a0e189 commit e7cf58d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

worker/src/services/ClickhouseWriter/ClickhouseWriter.unit.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ describe("ClickhouseWriter", () => {
155155
),
156156
).toBe(true);
157157
expect(writer["queue"][TableName.Traces]).toHaveLength(0);
158+
expect(serverExports.recordIncrement).toHaveBeenCalledWith(
159+
"langfuse.queue.clickhouse_writer.rows_dropped",
160+
1,
161+
{ entity_type: TableName.Traces },
162+
);
158163
});
159164

160165
it("should shutdown gracefully", async () => {

worker/src/services/ClickhouseWriter/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ export class ClickhouseWriter {
520520
});
521521

522522
if (droppedCount > 0) {
523+
recordIncrement(
524+
"langfuse.queue.clickhouse_writer.rows_dropped",
525+
droppedCount,
526+
{ entity_type: tableName },
527+
);
528+
523529
const droppedIds = queueItems
524530
.filter((item) => item.attempts >= this.maxAttempts)
525531
.map((item) => {

0 commit comments

Comments
 (0)