hashicorp / go-metrics

A Golang library for exporting performance and runtime metrics to external metrics systems (i.e. statsite, statsd)
MIT License
1.46k stars 177 forks source link

Why not use float64? #164

Open woodliu opened 4 months ago

woodliu commented 4 months ago

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"}})