Skip to content

Commit a9d0066

Browse files
committed
Add note about pow-of-10 precision issue
Signed-off-by: beorn7 <[email protected]>
1 parent d1f5366 commit a9d0066

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

prometheus/histogram.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ func (h *histogram) observe(v float64, bucket int) {
531531
case v < -h.sparseThreshold:
532532
whichSparse = -1
533533
}
534+
// TODO(beorn7): This sometimes gives inaccurate results for
535+
// floats that are actual powers of 10, e.g. math.Log10(0.1) is
536+
// calculated as -0.9999999999999999 rather than -1 and thus
537+
// yields a key unexpectedly one off. Maybe special-case precise
538+
// powers of 10.
534539
sparseKey = int(math.Ceil(math.Log10(math.Abs(v)) * float64(h.sparseResolution)))
535540
}
536541
// We increment h.countAndHotIdx so that the counter in the lower

0 commit comments

Comments
 (0)