-
Notifications
You must be signed in to change notification settings - Fork 200
Open
Description
When the circuit breaker transitions into the open state, the count is reset. This reset prevents us from feeding accurate metrics to Prometheus at the exact moment of the state change. As a result, Prometheus cannot capture the metrics correctly during this critical transition phase.
Would it be possible to retain the current count value at the moment of the state change to ensure proper metric logging? This would help us get more accurate insights into the behavior of the circuit breaker.
https://github.com/sony/gobreaker/blob/master/v2/gobreaker.go#L366
func (cb *CircuitBreaker[T]) toNewGeneration(now time.Time) {
cb.generation++
cb.counts.clear()
var zero time.Time
switch cb.state {
case StateClosed:
if cb.interval == 0 {
cb.expiry = zero
} else {
cb.expiry = now.Add(cb.interval)
}
case StateOpen:
cb.expiry = now.Add(cb.timeout)
default: // StateHalfOpen
cb.expiry = zero
}
}
Metadata
Metadata
Assignees
Labels
No labels