Skip to content

Commit

Permalink
Ingester circuit breakers: remove unnecessary configuration (#8306)
Browse files Browse the repository at this point in the history
* Ingester circuit breakers: remove unnecessary configuration

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>

* Fixing a failing test

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>

---------

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
  • Loading branch information
duricanikolic authored Jun 7, 2024
1 parent f856d70 commit da24777
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pkg/ingester/circuitbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func newCircuitBreaker(cfg CircuitBreakerConfig, logger log.Logger, registerer p
}

cbBuilder := circuitbreaker.Builder[any]().
WithFailureThreshold(cfg.FailureThresholdPercentage).
WithDelay(cfg.CooldownPeriod).
OnClose(func(event circuitbreaker.StateChangedEvent) {
circuitBreakerTransitionsCounterFn(cb.metrics, circuitbreaker.ClosedState).Inc()
Expand Down Expand Up @@ -250,7 +249,7 @@ func (cb *circuitBreaker) recordResult(errs ...error) error {
return err
}
}
cb.metrics.circuitBreakerResults.WithLabelValues(circuitBreakerResultSuccess).Inc()
cb.cb.RecordSuccess()
cb.metrics.circuitBreakerResults.WithLabelValues(circuitBreakerResultSuccess).Inc()
return nil
}
6 changes: 5 additions & 1 deletion pkg/ingester/circuitbreaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ func TestCircuitBreaker_TryAcquirePermit(t *testing.T) {
for testName, testCase := range testCases {
t.Run(testName, func(t *testing.T) {
registry := prometheus.NewRegistry()
cfg := CircuitBreakerConfig{Enabled: true, CooldownPeriod: 10 * time.Second}
cfg := CircuitBreakerConfig{
Enabled: true,
CooldownPeriod: 10 * time.Second,
testModeEnabled: true,
}
cb := newCircuitBreaker(cfg, log.NewNopLogger(), registry)
testCase.circuitBreakerSetup(cb)
status, err := cb.tryAcquirePermit()
Expand Down

0 comments on commit da24777

Please sign in to comment.