Documentation
¶
Overview ¶
Package stats provides pure analysis functions used by the aggregator and report generator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillBucketRTTStats ¶
func FillBucketRTTStats(out *BucketSummary, rttsInTimeOrder []float64)
FillBucketRTTStats populates percentile/max/mean/jitter pointer fields from RTTs in time order. No-op when empty.
func JitterMs ¶
JitterMs is RFC 3550-style jitter: the mean absolute delta between consecutive RTTs in time order. This is what voice/video codecs feel; std-dev-of-all misses bursty jitter that matters for call quality. Caller orders by timestamp ascending; mixing targets gives nonsense. Returns (0, false) for fewer than 2 samples.
func Percentile ¶
Percentile returns the value at quantile q (0..1) from a sorted slice using floor(len*q), clamped. Empty input returns (0, false).
Types ¶
type BucketSummary ¶
type BucketSummary struct {
Count int
SuccessCount int
FailCount int
P50Ms *float64
P95Ms *float64
P99Ms *float64
MaxMs *float64
MeanMs *float64
JitterMs *float64
Errors map[string]int
}
BucketSummary is what the aggregator writes to sample_5min/sample_1h.
func Aggregate ¶
func Aggregate(samples []SampleInput) BucketSummary
Aggregate folds a slice of samples (any order) into a BucketSummary. Stats pointer fields stay nil when there are no successful samples — that distinguishes "no signal" from "0ms latency" in the UI.
func AggregateFromBuckets ¶
func AggregateFromBuckets(children []BucketSummary) BucketSummary
AggregateFromBuckets folds child summaries into a coarser one for the 5min→1h rollup. Counts/errors sum exactly. Percentiles and jitter use success-count-weighted means of the child values — a fidelity trade-off once raw RTTs have been pruned.