You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bb43abb
Browse filesBrowse the repository at this point in the historyBrowse files
Outcomes now carry an epoch ticket from admission, so a request that finishes
after its circuit changed state no longer reopens, closes or frees the probe
slot. A RetryBudgetExhaustedError is classified by its last_exception.
circuit.rejected is emitted outside the sync lock, at most once per second per
circuit, with a suppressed count.
Each log record has an `event` field holding the event name, such as `event="circuit.opened"`, which you can filter on in your log aggregator. Events from `AsyncKeyedCircuitBreaker` and `KeyedCircuitBreaker` also carry `circuit_key`, the circuit they belong to. [Resilience](resilience.md) describes when each event fires.
14
+
Each log record has an `event` field holding the event name, such as `event="circuit.opened"`, which you can filter on in your log aggregator. `circuit.rejected` is emitted at most once per second per circuit, so an open circuit under heavy traffic does not flood your logs; its `suppressed` attribute counts the rejections that were left out since the previous one. Events from `AsyncKeyedCircuitBreaker` and `KeyedCircuitBreaker` also carry `circuit_key`, the circuit they belong to. [Resilience](resilience.md) describes when each event fires.
Copy file name to clipboardExpand all lines: docs/resilience.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,8 @@ A circuit breaker counts consecutive failures and, past a threshold, stops sendi
160
160
- OPEN: until `reset_timeout` has passed, every request fails at once with `CircuitOpenError`, whose `retry_after` says how many seconds remain. The first request after that moves the circuit to HALF_OPEN and becomes the probe.
161
161
- HALF_OPEN: one probe at a time is let through. After `success_threshold` successful probes in a row the circuit closes; one failed probe opens it again.
162
162
163
+
An outcome only counts against the state its request was admitted under. A request that is still in flight when the circuit changes state, such as a slow call sent before the circuit opened, finishes without touching the circuit. It cannot reopen a HALF_OPEN circuit, count toward `success_threshold`, or free the probe slot.
164
+
163
165
### Constructor
164
166
165
167
| Parameter | Default | Effect |
@@ -176,6 +178,8 @@ A circuit breaker counts consecutive failures and, past a threshold, stops sendi
176
178
177
179
A counted failure is a `NetworkError`, an httpware `TimeoutError`, or a `StatusError` whose status is in `failure_status_codes`. Other exceptions pass through without changing the circuit.
178
180
181
+
A `RetryBudgetExhaustedError` from a retry placed after the breaker is classified by its `last_exception`. If the last attempt failed with a counted failure, the breaker counts one; if it failed with a 4xx, that is a success.
182
+
179
183
4xx responses, 429 included, count as successes. A 429 means the service is up and throttling you; opening the circuit on it would add circuit-open rejections on top of the throttling.
180
184
181
185
### `CircuitOpenError`
@@ -189,7 +193,7 @@ Emitted on logger `httpware.circuit_breaker`:
189
193
| Event | When |
190
194
|---|---|
191
195
|`circuit.opened`| The failure threshold was reached and the circuit went from CLOSED to OPEN. |
192
-
|`circuit.rejected`| A request failed fast because the circuit was OPEN or a HALF_OPEN probe was already running. |
196
+
|`circuit.rejected`| A request failed fast because the circuit was OPEN or a HALF_OPEN probe was already running. Emitted at most once per second per circuit; its `suppressed` attribute counts the rejections since the previous `circuit.rejected` that were not emitted. |
193
197
|`circuit.half_open`| The reset timeout passed and the circuit went from OPEN to HALF_OPEN. |
194
198
|`circuit.closed`| The success threshold was reached and the circuit went from HALF_OPEN to CLOSED. |
0 commit comments