go-metrics icon indicating copy to clipboard operation
go-metrics copied to clipboard

Why not use float64?

Open woodliu opened this issue 1 year ago • 0 comments

https://github.com/hashicorp/go-metrics/blob/0ec744010d013e2ce8d0d71c69a9c43bfe523efc/prometheus/prometheus.go#L329 I check the second parameter of AddSampleWithLabels, it all convert from float32 to float64, why not use float64 directly? As the example below, the result of time.Since(s).Milliseconds() is float64, i have to convert to float32, and in AddSampleWithLabels it will convert to float64 again...

s := time.Now()
err := srv.r.SetValue(c.Body())
utils.PromSink.AddSampleWithLabels(raft_set_latency, float32(time.Since(s).Milliseconds()), []metrics.Label{{Name: "version", Value: "v1.0"}})

woodliu avatar Jun 12 '24 03:06 woodliu