From d3633d4e764a71a0aff925c699ba0f30d40fd60d Mon Sep 17 00:00:00 2001 From: Ziqi Zhao Date: Thu, 24 Aug 2023 07:17:23 +0800 Subject: [PATCH] Update model/histogram/float_histogram.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Björn Rabenstein Signed-off-by: Ziqi Zhao --- model/histogram/float_histogram.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/model/histogram/float_histogram.go b/model/histogram/float_histogram.go index 360fa68234..d7de64abfe 100644 --- a/model/histogram/float_histogram.go +++ b/model/histogram/float_histogram.go @@ -923,9 +923,18 @@ func mergeToSchema(originSpans []Span, originBuckets []float64, originSchema, ta return targetSpans, targetBuckets } -// addBuckets add two groups of Spans by inspecting the -// spans in other and create missing buckets in origin in batches. -func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, bucketsA []float64, spansB []Span, bucketsB []float64) ([]Span, []float64) { +// addBuckets adds the buckets described by spansB/bucketsB to the buckets described by spansA/bucketsA, +// creating missing buckets in spansA/bucketsA as needed. +// It returns the resulting spans/buckets (which must be used instead of the original spansA/bucketsA, +// although spansA/bucketsA might get modified by this function). +// All buckets must use the same provided schema. +// Buckets in spansB/bucketsB with an absolute upper limit ≤ threshold are ignored. +// If negative is true, the buckets in spansB/bucketsB are subtracted rather than added. +func addBuckets( + schema int32, threshold float64, negative bool, + spansA []Span, bucketsA []float64, + spansB []Span, bucketsB []float64, +) ([]Span, []float64) { var ( iSpan int = -1 iBucket int = -1