Skip to content

Commit

Permalink
upstream fix from lightstep/otel-launcher-go#238
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacd committed Aug 4, 2022
1 parent 7f89f95 commit a158af8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/metric/aggregator/exponential/structure/exponential.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (h *Histogram[N]) UpdateByIncr(number N, incr uint64) {
h.count += incr

if value == 0 {
h.zeroCount++
h.zeroCount += incr
return
}

Expand Down
10 changes: 10 additions & 0 deletions sdk/metric/aggregator/exponential/structure/exponential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ func TestAggregatorCopySwap(t *testing.T) {
requireEqual(t, h2, h3)
}

// TestZeroCountByIncr verifies that zero counts are incremented properly.
func TestZeroCountByIncr(t *testing.T) {
// 10 "0" values
h1 := NewFloat64(NewConfig(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
h2 := NewFloat64(NewConfig())
h2.UpdateByIncr(0, 10)

requireEqual(t, h1, h2)
}

// Benchmarks the Update() function for values in the range [1,2)
func BenchmarkLinear(b *testing.B) {
src := rand.NewSource(77777677777)
Expand Down

0 comments on commit a158af8

Please sign in to comment.