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:
Claude
2026-01-22 13:57:34 +00:00
parent 5b8ea3bb2b
commit f9ed1dc16f
3 changed files with 48 additions and 0 deletions
+13
View File
@@ -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
// ============================================