Open fabianfett opened 12 months ago
@ktoso I should have stressed in my pr description more that I don't love this either and mainly want to drive a discussion here.
@ktoso @FranzBusch @tomerd
What pain did it cause that we want to drop the generic?
Mostly requiring adopters to write generic code.
This feels like a step backwards as well tbh
I agree here as well. However, if we decide that Histogram should be generic, we should probably make Counter
and Gauge
generic as well. wdyt?
I agree here as well. However, if we decide that Histogram should be generic, we should probably make
Counter
andGauge
generic as well. wdyt?
Not sure. When would we use a Duration
based Counter
or Gauge
? Maybe that's useful. From my understanding on this PR I thought we only had the generic abstractions to make the interop with Prometheus easier but not because of swift-metrics
.
Not sure. When would we use a
Duration
basedCounter
orGauge
? Maybe that's useful. From my understanding on this PR I thought we only had the generic abstractions to make the interop with Prometheus easier but not because ofswift-metrics
.
@FranzBusch For Counter
and Gauge
generics would be more about Int64 vs UInt64 vs Double.
@ktoso
Metric values in OpenMetrics MUST be either floating points or integers. Note that ingestors of the format MAY only support float64. The non-real values NaN, +Inf and -Inf MUST be supported. NaN MUST NOT be considered a missing value, but it MAY be used to signal a division by zero.
https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#values
Yeah though that's about storage / emitting isn't it? so, maybe meet in the happy middle and keep the Duration histogram API but store in terms of Doubles if that's what you're after to simplify the implementation @fabianfett ?
Duration effectively "is" an integer.
I'm confused why the pushback to the language's default way of expressing duration. It'll be a pain to accept measurements from things which WILL express them as Duration.
What's the gain we're seeking by dropping support for Duration?
In #92, we added a
Histogram
that is generic over the observed type. This means that eachHistogram
was also carrying a generic argument. To make it easier to deal with differentHistogram
types, we added two typealiasesDurationHistogram
andValueHistogram
.The motivation behind using a generic argument was to preserve as much detailed information as possible.
Duration
can be more precise thanDouble
. However in the grand scheme of things we now believe that this is overkill for aHistogram
and a simpler to useHistogram
type is more valuable than the lost precision. Thus this patch removes the generic argument fromHistogram
.