Behaviour for a single soft-metric probe.
A sampler is the I/O-bearing source of instantaneous readings driven by
Sys.Mon.Server. It may carry private state between samples (e.g. the previous
/proc/stat snapshot needed to turn cumulative counters into a rate).
The sampler module fully describes its monitor: alongside the readings it
declares its own schedule (period/0, tau/0), so
Sys.Mon.Server.start_link(SamplerModule) needs nothing else.
A reading is whatever domain value the sampler chooses - a number or any
Unit.Quantity (a Unit.Information for memory, a Unit.Bandwidth for
throughput, a bare Float fraction for CPU) - so Sys.Mon.Server can
low-pass-filter it and it flows out of the monitor unchanged, with no float-only
bottleneck.
Summary
Callbacks
Initialize sampler-private state.
How often to sample.
Produce the next reading.
The low-pass filter time constant (the smoothing window, independent of period/0).
Types
@type private() :: term()
Sampler-private carry-over state.
@type reading() :: number() | Unit.Quantity.t()
An instantaneous reading: a number or any Unit.Quantity.
Callbacks
Initialize sampler-private state.
@callback period() :: Unit.Time.t()
How often to sample.
Produce the next reading.
:skip means a reading could not yet be formed (e.g. no baseline for a rate),
and the filter is left untouched. :error is a transient failure to be logged.
@callback tau() :: Unit.Time.t()
The low-pass filter time constant (the smoothing window, independent of period/0).