je_load_density.utils.reliability.failure_budget

Sliding-window failure budget / circuit breaker.

Subscribes to Locust’s events.request and tracks the proportion of failed requests in a rolling window. Once the failure rate exceeds the threshold and the window has enough samples, the next request fires runner.quit() and raises CircuitOpenError on the main greenlet.

Functions

current_budget()

install_failure_budget([threshold, ...])

Subscribe to Locust request events; trip the breaker when the sliding-window failure rate exceeds threshold.

uninstall_failure_budget()

Classes

FailureBudget(threshold, window_seconds, ...)

Exceptions

CircuitOpenError

Raised when the failure budget trips.

exception je_load_density.utils.reliability.failure_budget.CircuitOpenError

Bases: RuntimeError

Raised when the failure budget trips.

class je_load_density.utils.reliability.failure_budget.FailureBudget(threshold: float = 0.05, window_seconds: float = 30.0, min_samples: int = 50, _events: Deque[tuple] = <factory>, _lock: <built-in function allocate_lock> = <factory>, _tripped: bool = False)

Bases: object

failure_rate(now: float | None = None) float
is_breached(now: float | None = None) bool
min_samples: int = 50
record(failed: bool, now: float | None = None) None
sample_count() int
threshold: float = 0.05
trip() None
property tripped: bool
window_seconds: float = 30.0
je_load_density.utils.reliability.failure_budget.current_budget() FailureBudget | None
je_load_density.utils.reliability.failure_budget.install_failure_budget(threshold: float = 0.05, window_seconds: float = 30.0, min_samples: int = 50, runner_quit_callback: Callable[[], None] | None = None) FailureBudget

Subscribe to Locust request events; trip the breaker when the sliding-window failure rate exceeds threshold. The supplied runner_quit_callback is invoked once on breach.

je_load_density.utils.reliability.failure_budget.uninstall_failure_budget() None