diff --git a/src/Utils/event-buffer.ts b/src/Utils/event-buffer.ts index b701542f..5ae8614b 100644 --- a/src/Utils/event-buffer.ts +++ b/src/Utils/event-buffer.ts @@ -482,6 +482,10 @@ export const makeEventBuffer = ( removed: removed.length, remaining: historyCache.size }) + // Record metrics for cache cleanup + if (metricsModule) { + metricsModule.recordCacheCleanup(removed.length) + } } } diff --git a/src/Utils/prometheus-metrics.ts b/src/Utils/prometheus-metrics.ts index d5690329..3708f456 100644 --- a/src/Utils/prometheus-metrics.ts +++ b/src/Utils/prometheus-metrics.ts @@ -1898,6 +1898,18 @@ export function updateBufferStatistics(stats: { } } +/** + * Record a cache cleanup operation + * Used by event-buffer.ts when LRU cleanup is performed + */ +export function recordCacheCleanup(removedCount: number): void { + try { + metrics.bufferCacheCleanup?.inc({}) + } catch { + // Metrics not initialized, ignore silently + } +} + // ============================================ // Global Instance // ============================================