fix: add buffer_destroyed_total and buffer_final_flush_total metrics
Added recordBufferDestroyed() and recordBufferFinalFlush() functions and integrated into destroy() function in event-buffer.ts. Tracks: - Buffer destruction with reason and whether there was pending flush - Final flushes that occur during buffer destruction
This commit is contained in:
@@ -607,11 +607,16 @@ export const makeEventBuffer = (
|
||||
}
|
||||
|
||||
logger.debug('Destroying event buffer')
|
||||
const hadPendingFlush = isBuffering
|
||||
destroyed = true
|
||||
|
||||
// Flush any remaining events
|
||||
if (isBuffering) {
|
||||
if (hadPendingFlush) {
|
||||
flush(true)
|
||||
// Record final flush metric
|
||||
if (metricsModule) {
|
||||
metricsModule.recordBufferFinalFlush()
|
||||
}
|
||||
}
|
||||
|
||||
// Clear all timers
|
||||
@@ -624,6 +629,11 @@ export const makeEventBuffer = (
|
||||
// Remove all event listeners
|
||||
ev.removeAllListeners()
|
||||
|
||||
// Record buffer destroyed metric
|
||||
if (metricsModule) {
|
||||
metricsModule.recordBufferDestroyed('normal', hadPendingFlush)
|
||||
}
|
||||
|
||||
logger.debug('Event buffer destroyed successfully')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user