rules/online-slo.md
GitHubOnline stats: EWMA, burn rate, coordinated omission, sliding windows
EWMA options on createHistogram
createHistogram({ halfLife, threshold }). The YAML has no changes: entry
for these options. They ship with the EWMA getters (v26.8.0; v24.21.0 for most
getters).
halfLifeis in samples, not time. AfterhalfLiferecordings, a value has 50% influence. The default0disables EWMA.thresholduses the same unit as the recorded values (for example 200 ms as200_000_000ns). It needshalfLife.ewmaMean(YAML: v26.8.0 only),ewmaStddev,ewmaErrorRate(v26.8.0, v24.21.0). They are0when disabled or when no values are recorded.burnRate(sloTarget)(v26.8.0, v24.21.0) isewmaErrorRate / (1 - sloTarget).sloTargetmust be in (0, 1), otherwise it throwsERR_OUT_OF_RANGE. A value above 1 means the error budget burns faster than allowed. Verified: withouthalfLifeandthresholdit returns0and does not throw.
Verified: with halfLife: 10, 100 records of 100 followed by 10 records of 300
give ewmaMean === 200 and ewmaErrorRate ≈ 0.5, with the threshold at 200.
EWMA state survives snapshot() and export()/importHistogram(). diff()
results have no EWMA state.
recordCorrected(val, expectedInterval) (v26.8.0, v24.21.0)
This is HdrHistogram coordinated-omission correction. Verified behavior:
each call records val, then val - i, val - 2i, … while the value is
>= i. It does not depend on earlier records:
recordCorrected(1000, 100)records 10 values (1000, 900, …, 100).recordCorrected(950, 100)thenrecordCorrected(1000, 100)records 19.- A value below
expectedIntervalis recorded once.
Use it when a load generator sends at a fixed rate and a stall delays
measurement. expectedInterval is the intended send interval, in the same unit.
createSlidingWindowHistogram(options) (v26.10.0, v24.22.0)
chunksis 1-1024. Pass exactly one ofchunkDuration(ms) andrecordsPerChunk. Passing both or neither throwsERR_INVALID_ARG_VALUE.lowest,highestandfigureswork as increateHistogram.- Methods:
record(val),snapshot()→Histogram, andreset(). There are no stats on the window itself, so always usesnapshot(). The window cannot be constructed directly (ERR_ILLEGAL_CONSTRUCTOR) or sent over a MessagePort. - Rotation is lazy and uses no timer. A time window keeps a value for between
(N-1)*DandN*Dms. A count window keeps between(N-1)*C+1andN*Cattempts, and attempts abovehighestcount toward rotation (verified: they show up insnapshot().exceeds).
const win = createSlidingWindowHistogram({ chunks: 6, chunkDuration: 10_000 }); // ~last 60 s
win.record(latencyNs);
const s = win.snapshot();
report(s.percentile(99), s.ccdf(slo));