diff --git a/src/Utils/event-buffer.ts b/src/Utils/event-buffer.ts index 5ae8614b..262eb3c0 100644 --- a/src/Utils/event-buffer.ts +++ b/src/Utils/event-buffer.ts @@ -449,6 +449,10 @@ export const makeEventBuffer = ( currentSize: currentEventCount, maxSize: config.maxBufferSize }) + // Record overflow metric + if (metricsModule) { + metricsModule.recordBufferOverflow() + } flush(true) return true } diff --git a/src/Utils/prometheus-metrics.ts b/src/Utils/prometheus-metrics.ts index 3708f456..6bf20816 100644 --- a/src/Utils/prometheus-metrics.ts +++ b/src/Utils/prometheus-metrics.ts @@ -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 // ============================================