PyBreaker exposes a set of properties and methods for runtime monitoring and management. These allow operations teams to observe circuit health at a glance, integrate circuit state into existing dashboards and health endpoints, and intervene manually when circumstances require it — for example, forcing a circuit open during planned maintenance or forcing it closed after confirming a dependency has recovered.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/danielfm/pybreaker/llms.txt
Use this file to discover all available pages before exploring further.
Reading Circuit Breaker State
The most commonly needed runtime attributes are exposed as simple read-only properties.| Property | Type | Description |
|---|---|---|
current_state | str | One of 'closed', 'open', or 'half-open' as reported by the state storage |
fail_counter | int | Number of consecutive failures recorded since the last reset |
success_counter | int | Number of consecutive successes recorded in half-open state |
name | str | None | Optional human-readable name set at construction time |
Reading and Updating Configuration
All three threshold properties are mutable. You can read their current values and update them at runtime without restarting the application — useful for dynamically adjusting sensitivity in response to observed behaviour.success_threshold controls how many consecutive successful trial calls are required while in the half-open state before the circuit closes. Setting it higher than 1 adds a confirmation window before fully restoring traffic.
Manual State Control
In exceptional situations, you may need to override the automatic state machine. PyBreaker provides three methods for direct state manipulation.Naming Circuit Breakers
Setting aname at construction time is strongly recommended for any deployment where you have more than one circuit breaker. Names appear in listener callbacks and make log messages, metrics, and health payloads immediately actionable.
Exposing to Operations
Circuit breaker state is most valuable when surfaced through your existing operational tooling. Consider the following patterns:- Health endpoints — expose
current_state,fail_counter, andreset_timeoutin your service’s/healthor/statusendpoint so load balancers and monitoring systems can observe circuit health. - Metrics pipelines — use a
CircuitBreakerListenerto emit counters and gauges to Prometheus, DataDog, StatsD, or any other metrics backend on everyfailure,success, andstate_changeevent. - Structured logging — log state changes with the circuit breaker’s
nameproperty so log aggregation tools can correlate events across service instances.
