MCPcopy
hub / github.com/prometheus/client_golang / TestBuckets

Function TestBuckets

prometheus/histogram_test.go:344–366  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

342}
343
344func TestBuckets(t *testing.T) {
345 got := LinearBuckets(-15, 5, 6)
346 want := []float64{-15, -10, -5, 0, 5, 10}
347 if !reflect.DeepEqual(got, want) {
348 t.Errorf("linear buckets: got %v, want %v", got, want)
349 }
350
351 got = ExponentialBuckets(100, 1.2, 3)
352 want = []float64{100, 120, 144}
353 if !reflect.DeepEqual(got, want) {
354 t.Errorf("exponential buckets: got %v, want %v", got, want)
355 }
356
357 got = ExponentialBucketsRange(1, 100, 10)
358 want = []float64{
359 1.0, 1.6681, 2.7825, 4.6415, 7.7426, 12.9154, 21.5443,
360 35.9381, 59.9484, 100.0000,
361 }
362 const epsilon = 0.0001
363 if !internal.AlmostEqualFloat64s(got, want, epsilon) {
364 t.Errorf("exponential buckets range: got %v, want %v (epsilon %f)", got, want, epsilon)
365 }
366}
367
368func TestHistogramAtomicObserve(t *testing.T) {
369 var (

Callers

nothing calls this directly

Calls 4

AlmostEqualFloat64sFunction · 0.92
LinearBucketsFunction · 0.85
ExponentialBucketsFunction · 0.85
ExponentialBucketsRangeFunction · 0.85

Tested by

no test coverage detected