Skip to content

Commit 06cf0be

Browse files
authored
Merge branch 'main' into benchmark
2 parents aa01bf2 + 6f4da61 commit 06cf0be

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Tests/PrometheusTests/HistogramTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ import Prometheus
1616
import XCTest
1717

1818
final class HistogramTests: XCTestCase {
19+
20+
func testFactoryDefaultValueHistogramBuckets() {
21+
var factory = PrometheusMetricsFactory()
22+
factory.defaultValueHistogramBuckets = [
23+
1, 10, 25, 50, 75, 100,
24+
]
25+
let recorder = factory.makeRecorder(label: "label", dimensions: [("a", "b")], aggregate: true)
26+
recorder.record(Int64(12))
27+
28+
var buffer = [UInt8]()
29+
factory.registry.emit(into: &buffer)
30+
31+
XCTAssertEqual(
32+
"""
33+
# TYPE label histogram
34+
label_bucket{a="b",le="1.0"} 0
35+
label_bucket{a="b",le="10.0"} 0
36+
label_bucket{a="b",le="25.0"} 1
37+
label_bucket{a="b",le="50.0"} 1
38+
label_bucket{a="b",le="75.0"} 1
39+
label_bucket{a="b",le="100.0"} 1
40+
label_bucket{a="b",le="+Inf"} 1
41+
label_sum{a="b"} 12.0
42+
label_count{a="b"} 1
43+
44+
""",
45+
String(decoding: buffer, as: Unicode.UTF8.self)
46+
)
47+
}
48+
1949
func testHistogramWithoutDimensions() {
2050
let client = PrometheusCollectorRegistry()
2151
let histogram = client.makeDurationHistogram(

0 commit comments

Comments
 (0)