Skip to content

Commit

Permalink
Fix bucket count in FakeGen Histogram
Browse files Browse the repository at this point in the history
See #261
  • Loading branch information
lquerel authored Oct 15, 2024
1 parent 971440e commit 9fd3276
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/datagen/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,12 @@ func (dg *DataGenerator) FakeHistogram(metric pmetric.Metric) {
dp.SetSum(dg.GenF64Range(0, 100))
}

// The number of elements in bucket_counts array must be by one greater than
// the number of elements in explicit_bounds array.
// See https://github.com/open-telemetry/opentelemetry-proto/blob/a76fe9dea26871e8a6c494024bc9927fe73b8142/opentelemetry/proto/metrics/v1/metrics.proto#L461
bcs := dp.BucketCounts()
bcs.EnsureCapacity(10)
for j := 0; j < 10; j++ {
bcs.EnsureCapacity(10+1)
for j := 0; j < 10+1; j++ {
bcs.Append(uint64(dg.GenI64Range(0, 100)))
}

Expand Down

0 comments on commit 9fd3276

Please sign in to comment.