Skip to content

Commit d1f5366

Browse files
committed
Fix span offset
Signed-off-by: beorn7 <[email protected]>
1 parent abe540f commit d1f5366

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

prometheus/histogram.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,20 +473,20 @@ func makeSparseBuckets(buckets *sync.Map) *dto.SparseBuckets {
473473

474474
sbs := dto.SparseBuckets{}
475475
var prevCount uint64
476-
var prevI int
476+
var nextI int
477477
for n, i := range ii {
478478
v, _ := buckets.Load(i)
479479
count := atomic.LoadUint64(v.(*uint64))
480-
if n == 0 || i-prevI != 1 {
480+
if n == 0 || i-nextI != 0 {
481481
sbs.Span = append(sbs.Span, &dto.SparseBuckets_Span{
482-
Offset: proto.Int(i - prevI),
482+
Offset: proto.Int(i - nextI),
483483
Length: proto.Uint32(1),
484484
})
485485
} else {
486486
*sbs.Span[len(sbs.Span)-1].Length++
487487
}
488488
sbs.Delta = append(sbs.Delta, int64(count)-int64(prevCount)) // TODO(beorn7): Do proper overflow handling.
489-
prevI, prevCount = i, count
489+
nextI, prevCount = i+1, count
490490
}
491491
return &sbs
492492
}

0 commit comments

Comments
 (0)