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:
@@ -482,6 +482,10 @@ export const makeEventBuffer = (
|
||||
removed: removed.length,
|
||||
remaining: historyCache.size
|
||||
})
|
||||
// Record metrics for cache cleanup
|
||||
if (metricsModule) {
|
||||
metricsModule.recordCacheCleanup(removed.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user