PhiAccrual.Threshold
(phi_accrual v1.0.0)
View Source
Optional threshold layer.
The core detector emits φ values; this module turns them into
:suspected / :recovered events with hysteresis. Thresholding is
policy, not detection — the library keeps it out of the core so that
consumers can:
- run multiple thresholds concurrently (e.g. φ=4 for dashboards, φ=8 for automated routing), each a separate instance,
- skip this module entirely and roll their own hysteresis,
- filter on confidence,
:recoveringstate, etc. without touching the detector.
Events
Subscribes to [:phi_accrual, :phi, :computed]. Emits:
[:phi_accrual, :threshold, :suspected]when φ crossessuspect_atfrom below,[:phi_accrual, :threshold, :recovered]when φ crossesrecover_atfrom above.
Both events include %{node: node(), instance: name, threshold: ...}
in metadata. The instance tag lets you disambiguate multiple
threshold modules sharing the same event namespace.
Hysteresis
recover_at must be strictly less than suspect_at. Default band:
suspect at 8.0, recover at 7.0. Widen the band if you see flapping
around the boundary.
φ events for nodes in :insufficient_data state are ignored — φ is
not meaningful there. :steady, :recovering, and :stale states
all feed the threshold logic.
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type opts() :: [name: GenServer.name(), suspect_at: float(), recover_at: float()]
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(opts()) :: GenServer.on_start()