PhiAccrual.PauseMonitor (phi_accrual v1.0.0)

View Source

Owns the node-local :erlang.system_monitor/2 subscription and tracks whether a local-pause event is currently suppressing φ-computation confidence.

Subscribes to three conditions:

  • {:long_schedule, N} — a process held a scheduler for > N ms
  • {:long_gc, N} — GC took > N ms
  • :busy_dist_port — the distribution TCP send buffer filled; heartbeats are queued behind user traffic. This is the head-of-line blocking signal and is the primary reason v1 is observability-grade rather than decision-grade.

When any of these fire, pause state flips to true for a lockout window (default 500 ms). Each new event extends the window. State is published via :persistent_term so estimators can read it without synchronising on this GenServer.

Telemetry:

  • [:phi_accrual, :local_pause, :start] on rising edge
  • [:phi_accrual, :local_pause, :stop] on falling edge

Caveat: Only one system_monitor can be installed per node. If your application already uses :erlang.system_monitor/2, disable this module via config :phi_accrual, pause_monitor: false and feed pause state in yourself by calling put_state/1.

Summary

Functions

Returns a specification to start this module under a supervisor.

True if a local pause was detected within the lockout window.

Force pause state — for users who have disabled the built-in system_monitor subscription and want to feed pause state from their own instrumentation.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

paused?()

@spec paused?() :: boolean()

True if a local pause was detected within the lockout window.

Cheap lock-free read (:persistent_term); safe to call from any process. Returns false if the monitor has not been started.

put_state(active?)

@spec put_state(boolean()) :: :ok

Force pause state — for users who have disabled the built-in system_monitor subscription and want to feed pause state from their own instrumentation.