@@ -31,9 +31,12 @@ func newBuckets[N int64 | float64](attrs attribute.Set, n int) *buckets[N] {
3131
3232func (b * buckets [N ]) sum (value N ) { b .total += value }
3333
34- func (b * buckets [N ]) bin (idx int , value N ) {
34+ func (b * buckets [N ]) bin (idx int ) {
3535 b .counts [idx ]++
3636 b .count ++
37+ }
38+
39+ func (b * buckets [N ]) minMax (value N ) {
3740 if value < b .min {
3841 b .min = value
3942 } else if value > b .max {
@@ -44,8 +47,9 @@ func (b *buckets[N]) bin(idx int, value N) {
4447// histValues summarizes a set of measurements as an histValues with
4548// explicitly defined buckets.
4649type histValues [N int64 | float64 ] struct {
47- noSum bool
48- bounds []float64
50+ noMinMax bool
51+ noSum bool
52+ bounds []float64
4953
5054 newRes func (attribute.Set ) FilteredExemplarReservoir [N ]
5155 limit limiter [* buckets [N ]]
@@ -55,7 +59,7 @@ type histValues[N int64 | float64] struct {
5559
5660func newHistValues [N int64 | float64 ](
5761 bounds []float64 ,
58- noSum bool ,
62+ noMinMax , noSum bool ,
5963 limit int ,
6064 r func (attribute.Set ) FilteredExemplarReservoir [N ],
6165) * histValues [N ] {
@@ -66,11 +70,12 @@ func newHistValues[N int64 | float64](
6670 b := slices .Clone (bounds )
6771 slices .Sort (b )
6872 return & histValues [N ]{
69- noSum : noSum ,
70- bounds : b ,
71- newRes : r ,
72- limit : newLimiter [* buckets [N ]](limit ),
73- values : make (map [attribute.Distinct ]* buckets [N ]),
73+ noMinMax : noMinMax ,
74+ noSum : noSum ,
75+ bounds : b ,
76+ newRes : r ,
77+ limit : newLimiter [* buckets [N ]](limit ),
78+ values : make (map [attribute.Distinct ]* buckets [N ]),
7479 }
7580}
7681
@@ -109,7 +114,10 @@ func (s *histValues[N]) measure(
109114 b .min , b .max = value , value
110115 s .values [attr .Equivalent ()] = b
111116 }
112- b .bin (idx , value )
117+ b .bin (idx )
118+ if ! s .noMinMax {
119+ b .minMax (value )
120+ }
113121 if ! s .noSum {
114122 b .sum (value )
115123 }
@@ -125,8 +133,7 @@ func newHistogram[N int64 | float64](
125133 r func (attribute.Set ) FilteredExemplarReservoir [N ],
126134) * histogram [N ] {
127135 return & histogram [N ]{
128- histValues : newHistValues [N ](boundaries , noSum , limit , r ),
129- noMinMax : noMinMax ,
136+ histValues : newHistValues [N ](boundaries , noMinMax , noSum , limit , r ),
130137 start : now (),
131138 }
132139}
@@ -136,8 +143,7 @@ func newHistogram[N int64 | float64](
136143type histogram [N int64 | float64 ] struct {
137144 * histValues [N ]
138145
139- noMinMax bool
140- start time.Time
146+ start time.Time
141147}
142148
143149func (s * histogram [N ]) delta (
0 commit comments