swift-server / swift-prometheus

Prometheus client library for Swift
https://swiftpackageindex.com/swift-server/swift-prometheus
Apache License 2.0
142 stars 30 forks source link

Use of dimensions produces empty metric #80

Open freef4ll opened 1 year ago

freef4ll commented 1 year ago

If one creates a Gauge or a Counter with dimensions, an exported value actually contains 2 metrics, this when visualized in Grafana will also result in 2 graphs, one which displays the initial 0 value and one with the actual metric:

let g = Gauge(label: "test_gauge", dimensions: [("abc", "123")])
g.record(10)

This will produce the output of:

# TYPE test counter
test_gauge 0
test_gauge{abc="123"} 10

The issue is slightly touched on in https://github.com/swift-server-community/SwiftPrometheus/issues/77

Potential fix/workaround might be https://github.com/swift-server-community/SwiftPrometheus/compare/master...ordo-one:SwiftPrometheus:gauge_label