Class BucketedOpStats

java.lang.Object
com.hypixel.hytale.metrics.BucketedOpStats
All Implemented Interfaces:
MetricProvider

public class BucketedOpStats extends Object implements MetricProvider
Per-second rolling-bucket metric for operation stats: tracks count, total bytes, and latency (sum/min/max) per second across a fixed-size circular buffer indexed by (nanoTime second) % bucketCount. Stale buckets are naturally overwritten as their slot is reused. The bucket second is derived from System.nanoTime() so it tracks JVM-uptime seconds, not wall-clock epoch seconds.

Designed for high-rate per-operation recording where the per-sample HistoricMetric would overflow its buffer and lose history. Over the configured periods (default 1m / 5m / 15m), summary(long) returns aggregate stats (count, bytes, latency sum/min/max) for any trailing window not larger than bucketCount seconds.

The hot record(long, long) path is contention-free: per-bucket LongAdder accumulators absorb concurrent writes without locking, and bucket recycling is coordinated by a CAS on the bucket-second slot. summary(long) reads accumulators without coordination and may briefly observe transient values during a recycle, which is acceptable for metric output.