Skip to content

Commit

Permalink
Add CircuitBreaker metrics documentation to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
svroonland committed Jul 17, 2024
1 parent 7db2812 commit 5d36f04
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docs/docs/docs/circuitbreaker.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ZIO.scoped {
```

## Monitoring
You may want to monitor circuit breaker failures and trigger alerts when the circuit breaker trips. For this purpose, CircuitBreaker publishes state changes via a callback provided to `make`. Usage:
You may want to monitor circuit breaker failures and trigger alerts when the circuit breaker trips. For this purpose, CircuitBreaker publishes state changes via the `stateChanges` property. Usage:

```scala mdoc:silent
import zio.stream._
Expand All @@ -107,4 +107,16 @@ CircuitBreaker
// Make calls to an external system
circuitBreaker(ZIO.unit) // etc
}
```
```

## Metrics

When `CircuitBreaker.make` is called with the `metricLabels` parameter, the following metrics will be recorded, tagged with the given labels:

* rezilience_circuit_breaker_state: current state (0 = closed, 1 = half-open, 2 = open)
* rezilience_circuit_breaker_state_changes: number of state changes
* rezilience_circuit_breaker_calls_success: number of successful calls
* rezilience_circuit_breaker_calls_failure: number of failed calls
* rezilience_circuit_breaker_calls_rejected: number of calls rejected in the open state

See [ZIO metrics documentation](https://zio.dev/reference/observability/metrics/) for more information on how to integrate this with your observability tooling.

0 comments on commit 5d36f04

Please sign in to comment.