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

Function TestHistogramNonMonotonicBuckets

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

Source from the content-addressed store, hash-verified

127}
128
129func TestHistogramNonMonotonicBuckets(t *testing.T) {
130 testCases := map[string][]float64{
131 "not strictly monotonic": {1, 2, 2, 3},
132 "not monotonic at all": {1, 2, 4, 3, 5},
133 "have +Inf in the middle": {1, 2, math.Inf(+1), 3},
134 }
135 for name, buckets := range testCases {
136 func() {
137 defer func() {
138 if r := recover(); r == nil {
139 t.Errorf("Buckets %v are %s but NewHistogram did not panic.", buckets, name)
140 }
141 }()
142 _ = NewHistogram(HistogramOpts{
143 Name: "test_histogram",
144 Help: "helpless",
145 Buckets: buckets,
146 })
147 }()
148 }
149}
150
151// Intentionally adding +Inf here to test if that case is handled correctly.
152// Also, getCumulativeCounts depends on it.

Callers

nothing calls this directly

Calls 1

NewHistogramFunction · 0.70

Tested by

no test coverage detected