Cerbero.Snapshot.Bucketing (cerbero v0.1.0)

Copy Markdown View Source

Opt-in precision: :order_of_magnitude export mode: buckets counts and bytes to their power-of-ten floor so a committed snapshot does not reveal exact business metrics (a subscriptions row count is a revenue proxy).

The default severity tiers (100k/1M rows) are powers of ten, so comparing bucket floors against them preserves verdicts; message precision degrades ("~100M rows"). The bytes tier default (1 GiB) is not a power of ten — teams using this mode should prefer a power-of-ten bytes_error.

Non-positive values (0, and the PG >= 14 never-analyzed -1.0 sentinel) and nil pass through untouched.

Summary

Functions

Buckets every count/byte field of a raw (string-keyed) snapshot map.

The exporter's entry point: stamps the raw map's "precision" field and, in :order_of_magnitude mode, buckets every count/byte field.

Functions

apply(raw)

@spec apply(map()) :: map()

Buckets every count/byte field of a raw (string-keyed) snapshot map.

bucket(n)

@spec bucket(number() | nil) :: number() | nil

finalize(raw, atom)

@spec finalize(map(), :exact | :order_of_magnitude) :: map()

The exporter's entry point: stamps the raw map's "precision" field and, in :order_of_magnitude mode, buckets every count/byte field.