stable
meter
Pass-through metrics wrapper for any to-* store — records per-method latency, error rate, and CAS conflicts on real traffic without changing behaviour.
@noy-db/to-meter·pnpm add @noy-db/to-meterWraps any store and records what your app is actually doing.
| Shape | n/a — pass-through wrapper |
| Wraps | any NoydbStore |
What it does
toMeter(inner) wraps any NoydbStore and returns the same six-method surface
plus a meter handle, so app code doesn't change. It records real per-method
(get/put/delete/list/loadAll/saveAll) latency percentiles, error
rates, byte counts, and CAS conflicts. An optional synthetic liveness probe emits
degraded/restored events. Unlike the probe — whose
runStoreProbe() / probeTopology() this same package ships — it measures live
traffic rather than synthetic benchmarks.
Notes
meter.snapshot()returns per-method stats plusstatus(ok/degraded/unreachable),casConflicts,totalCalls, andwindowMs(time since start or lastreset()).meteralso offersreset(),subscribe(listener)for degraded/restored transitions, andclose()to stop the optional liveness timer.- Pass-through wrapper — the wrapped store's behaviour is unchanged.