From abdad09b793f0ad1bab320656bbe6bd950f34b8f Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Wed, 23 Oct 2024 13:45:59 +0200 Subject: [PATCH] collector: Fix histogram Signed-off-by: Ondra Machacek --- internal/agent/collector.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/agent/collector.go b/internal/agent/collector.go index a73dcb7..a0fdbee 100644 --- a/internal/agent/collector.go +++ b/internal/agent/collector.go @@ -276,6 +276,8 @@ func histogram(d []int) struct { binIndex := int(float64(data-minVal) / binSize) if binIndex == numberOfBins { binIndex-- + } else if binIndex < 0 { + binIndex = 0 } bins[binIndex]++ }