Skip to content

Commit

Permalink
Update convertBucketsLayout and its unit tests
Browse files Browse the repository at this point in the history
Add a new parameter that will be used to tell the function how many
buckets to merge when converting the bucket layouts.
Not use yet. Add disabled test cases.

Signed-off-by: György Krajcsovits <[email protected]>
  • Loading branch information
krajorama authored and jpkrohling committed Jul 12, 2023
1 parent b8d41b6 commit 7f2d6ae
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 45 deletions.
8 changes: 5 additions & 3 deletions pkg/translator/prometheusremotewrite/histograms.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func exponentialToNativeHistogram(p pmetric.ExponentialHistogramDataPoint) (prom
// TODO: downscale to 8 if scale > 8
}

pSpans, pDeltas := convertBucketsLayout(p.Positive())
nSpans, nDeltas := convertBucketsLayout(p.Negative())
pSpans, pDeltas := convertBucketsLayout(p.Positive(), 1)
nSpans, nDeltas := convertBucketsLayout(p.Negative(), 1)

h := prompb.Histogram{
Schema: scale,
Expand Down Expand Up @@ -104,7 +104,9 @@ func exponentialToNativeHistogram(p pmetric.ExponentialHistogramDataPoint) (prom
// The bucket indexes conversion was adjusted, since OTel exp. histogram bucket
// index 0 corresponds to the range (1, base] while Prometheus bucket index 0
// to the range (base 1].
func convertBucketsLayout(buckets pmetric.ExponentialHistogramDataPointBuckets) ([]prompb.BucketSpan, []int64) {
//
// scaleMerge is the number of buckets to merge into a single bucket - must be power of 2
func convertBucketsLayout(buckets pmetric.ExponentialHistogramDataPointBuckets, _ int32) ([]prompb.BucketSpan, []int64) {
bucketCounts := buckets.BucketCounts()
if bucketCounts.Len() == 0 {
return nil, nil
Expand Down
Loading

0 comments on commit 7f2d6ae

Please sign in to comment.