fix: add buffer_cache_cleanup_total metric increment

The metric was defined but never incremented when LRU cleanup happened.

Added recordCacheCleanup() function and call it from cleanupHistoryCache()
when cache entries are removed due to exceeding maxHistoryCacheSize.
This commit is contained in:
Claude
2026-01-22 13:31:32 +00:00
parent 68f6a2ae88
commit 6570a1fc6e
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -482,6 +482,10 @@ export const makeEventBuffer = (
removed: removed.length,
remaining: historyCache.size
})
// Record metrics for cache cleanup
if (metricsModule) {
metricsModule.recordCacheCleanup(removed.length)
}
}
}
+12
View File
@@ -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
// ============================================