From 5d36f045a469304e099bd53f095e3cdcad48d1bf Mon Sep 17 00:00:00 2001 From: Steven Vroonland Date: Wed, 17 Jul 2024 09:52:10 +0200 Subject: [PATCH] Add CircuitBreaker metrics documentation to docs --- docs/docs/docs/circuitbreaker.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/docs/docs/circuitbreaker.md b/docs/docs/docs/circuitbreaker.md index 210a26cb..7c282fb5 100644 --- a/docs/docs/docs/circuitbreaker.md +++ b/docs/docs/docs/circuitbreaker.md @@ -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._ @@ -107,4 +107,16 @@ CircuitBreaker // Make calls to an external system circuitBreaker(ZIO.unit) // etc } -``` \ No newline at end of file +``` + +## 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. \ No newline at end of file