fix: add buffer_overflows_total metric increment

The metric was defined but never incremented when buffer overflow occurred.

Added recordBufferOverflow() function and call it from checkBufferOverflow()
when buffer exceeds maxBufferSize (default 5000 events).
This commit is contained in:
Claude
2026-01-22 13:40:31 +00:00
parent 6570a1fc6e
commit 6412286c73
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -449,6 +449,10 @@ export const makeEventBuffer = (
currentSize: currentEventCount,
maxSize: config.maxBufferSize
})
// Record overflow metric
if (metricsModule) {
metricsModule.recordBufferOverflow()
}
flush(true)
return true
}
+12
View File
@@ -1910,6 +1910,18 @@ export function recordCacheCleanup(removedCount: number): void {
}
}
/**
* Record a buffer overflow event
* Used by event-buffer.ts when buffer exceeds max size
*/
export function recordBufferOverflow(): void {
try {
metrics.bufferOverflows?.inc({ type: 'event' })
} catch {
// Metrics not initialized, ignore silently
}
}
// ============================================
// Global Instance
// ============================================