@@ -32,10 +32,9 @@ type expoHistogramDataPoint[N int64 | float64] struct {
3232 attrs attribute.Set
3333 res FilteredExemplarReservoir [N ]
3434
35- count uint64
36- min N
37- max N
38- sum N
35+ min N
36+ max N
37+ sum N
3938
4039 maxSize int
4140 noMinMax bool
@@ -74,8 +73,6 @@ func newExpoHistogramDataPoint[N int64 | float64](
7473
7574// record adds a new measurement to the histogram. It will rescale the buckets if needed.
7675func (p * expoHistogramDataPoint [N ]) record (v N ) {
77- p .count ++
78-
7976 if ! p .noMinMax {
8077 if v < p .min {
8178 p .min = v
@@ -193,6 +190,10 @@ func (p *expoHistogramDataPoint[N]) scaleChange(bin, startBin int32, length int)
193190 return count
194191}
195192
193+ func (p * expoHistogramDataPoint [N ]) count () uint64 {
194+ return p .posBuckets .count () + p .negBuckets .count () + p .zeroCount
195+ }
196+
196197// expoBuckets is a set of buckets in an exponential histogram.
197198type expoBuckets struct {
198199 startBin int32
@@ -285,6 +286,14 @@ func (b *expoBuckets) downscale(delta int32) {
285286 b .startBin >>= delta
286287}
287288
289+ func (b * expoBuckets ) count () uint64 {
290+ var total uint64
291+ for _ , count := range b .counts {
292+ total += count
293+ }
294+ return total
295+ }
296+
288297// newExponentialHistogram returns an Aggregator that summarizes a set of
289298// measurements as an exponential histogram. Each histogram is scoped by attributes
290299// and the aggregation cycle the measurements were made in.
@@ -376,7 +385,7 @@ func (e *expoHistogram[N]) delta(
376385 hDPts [i ].Attributes = val .attrs
377386 hDPts [i ].StartTime = e .start
378387 hDPts [i ].Time = t
379- hDPts [i ].Count = val .count
388+ hDPts [i ].Count = val .count ()
380389 hDPts [i ].Scale = val .scale
381390 hDPts [i ].ZeroCount = val .zeroCount
382391 hDPts [i ].ZeroThreshold = 0.0
@@ -439,7 +448,7 @@ func (e *expoHistogram[N]) cumulative(
439448 hDPts [i ].Attributes = val .attrs
440449 hDPts [i ].StartTime = e .start
441450 hDPts [i ].Time = t
442- hDPts [i ].Count = val .count
451+ hDPts [i ].Count = val .count ()
443452 hDPts [i ].Scale = val .scale
444453 hDPts [i ].ZeroCount = val .zeroCount
445454 hDPts [i ].ZeroThreshold = 0.0
0 commit comments