Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: György Krajcsovits <[email protected]>
  • Loading branch information
krajorama committed Jul 14, 2023
1 parent bafdf7b commit a685502
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions pkg/translator/prometheusremotewrite/histograms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,24 +583,16 @@ func validateNativeHistogramCount(t *testing.T, h prompb.Histogram) {
want := h.Count.(*prompb.Histogram_CountInt).CountInt
var (
actualCount uint64
prevCount int64
prevBucket int64
)
for i, delta := range h.PositiveDeltas {
if i == 0 {
actualCount += uint64(delta)
} else {
actualCount += uint64(prevCount + delta)
}
prevCount += delta
for _, delta := range h.PositiveDeltas {
prevBucket += delta
actualCount += uint64(prevBucket)
}
prevCount = 0
for i, delta := range h.NegativeDeltas {
if i == 0 {
actualCount += uint64(delta)
} else {
actualCount += uint64(prevCount + delta)
}
prevCount += delta
prevBucket = 0
for _, delta := range h.NegativeDeltas {
prevBucket += delta
actualCount += uint64(prevBucket)
}
assert.Equal(t, want, actualCount, "native histogram count mismatch")
}
Expand Down

0 comments on commit a685502

Please sign in to comment.