swift-metrics doesn't currently provide a Gauge.record api for Counters and this probably makes as Counters are supposed to be strictly incrementing. However this behavior doesn't compose if the metric source already accumulates the value.
let total = GetTotalNetworkPackets()
Counter(label: "network_packets_total")
.increment(total) // <-- increment is wrong here (double counting)
Instead you have to use a Gauge to directly set this value. However consumers now see the value as a gauge and not a counter which is the real behavior.
I'm not sure if this is actually something we want to support, but it probably warrants some thought.
Prometheus in go provides an escape hatch for this using NewConstMetric
swift-metrics doesn't currently provide a
Gauge.recordapi forCounters and this probably makes as Counters are supposed to be strictly incrementing. However this behavior doesn't compose if the metric source already accumulates the value.Instead you have to use a Gauge to directly set this value. However consumers now see the value as a gauge and not a counter which is the real behavior.
I'm not sure if this is actually something we want to support, but it probably warrants some thought.
Prometheus in go provides an escape hatch for this using
NewConstMetric