feat: add adaptive metrics and circuit breaker trips tracking
Added metrics tracking for: - circuit_breaker_trips_total: Incremented when circuit opens - adaptive_health_status: 1 if healthy (not in aggressive mode), 0 otherwise - adaptive_event_rate: Current events per second Added methods to AdaptiveTimeoutCalculator: - getEventRate(): Returns current event rate in events/second - isHealthy(): Returns true if not in aggressive mode Metrics are updated on each buffer flush when adaptive timeout is enabled.
This commit is contained in:
@@ -1958,6 +1958,19 @@ export function recordBufferFinalFlush(): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update adaptive system metrics
|
||||
* Used by event-buffer.ts to report adaptive timeout health and event rate
|
||||
*/
|
||||
export function updateAdaptiveMetrics(eventRate: number, isHealthy: boolean): void {
|
||||
try {
|
||||
metrics.adaptiveEventRate?.set({}, eventRate)
|
||||
metrics.adaptiveHealthStatus?.set({}, isHealthy ? 1 : 0)
|
||||
} catch {
|
||||
// Metrics not initialized, ignore silently
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Global Instance
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user