@@ -158,63 +158,6 @@ func (s *cumulativeSum[N]) Aggregation() metricdata.Aggregation {
158158 return out
159159}
160160
161- // precomputedValue is the recorded measurement value for a set of attributes.
162- type precomputedValue [N int64 | float64 ] struct {
163- // measured is the last value measured for a set of attributes that were
164- // not filtered.
165- measured N
166- // filtered is the sum of values from measurements that had their
167- // attributes filtered.
168- filtered N
169- }
170-
171- // precomputedMap is the storage for precomputed sums.
172- type precomputedMap [N int64 | float64 ] struct {
173- sync.Mutex
174- values map [attribute.Set ]precomputedValue [N ]
175- }
176-
177- func newPrecomputedMap [N int64 | float64 ]() * precomputedMap [N ] {
178- return & precomputedMap [N ]{
179- values : make (map [attribute.Set ]precomputedValue [N ]),
180- }
181- }
182-
183- // Aggregate records value with the unfiltered attributes attr.
184- //
185- // If a previous measurement was made for the same attribute set:
186- //
187- // - If that measurement's attributes were not filtered, this value overwrite
188- // that value.
189- // - If that measurement's attributes were filtered, this value will be
190- // recorded along side that value.
191- func (s * precomputedMap [N ]) Aggregate (value N , attr attribute.Set ) {
192- s .Lock ()
193- v := s .values [attr ]
194- v .measured = value
195- s .values [attr ] = v
196- s .Unlock ()
197- }
198-
199- // aggregateFiltered records value with the filtered attributes attr.
200- //
201- // If a previous measurement was made for the same attribute set:
202- //
203- // - If that measurement's attributes were not filtered, this value will be
204- // recorded along side that value.
205- // - If that measurement's attributes were filtered, this value will be
206- // added to it.
207- //
208- // This method should not be used if attr have not been reduced by an attribute
209- // filter.
210- func (s * precomputedMap [N ]) aggregateFiltered (value N , attr attribute.Set ) { // nolint: unused // Used to agg filtered.
211- s .Lock ()
212- v := s .values [attr ]
213- v .filtered += value
214- s .values [attr ] = v
215- s .Unlock ()
216- }
217-
218161// NewPrecomputedDeltaSum returns an Aggregator that summarizes a set of
219162// pre-computed sums. Each sum is scoped by attributes and the aggregation
220163// cycle the measurements were made in.
@@ -226,17 +169,17 @@ func (s *precomputedMap[N]) aggregateFiltered(value N, attr attribute.Set) { //
226169// The output Aggregation will report recorded values as delta temporality.
227170func NewPrecomputedDeltaSum [N int64 | float64 ](monotonic bool ) Aggregator [N ] {
228171 return & precomputedDeltaSum [N ]{
229- precomputedMap : newPrecomputedMap [N ](),
230- reported : make (map [attribute.Set ]N ),
231- monotonic : monotonic ,
232- start : now (),
172+ valueMap : newValueMap [N ](),
173+ reported : make (map [attribute.Set ]N ),
174+ monotonic : monotonic ,
175+ start : now (),
233176 }
234177}
235178
236179// precomputedDeltaSum summarizes a set of pre-computed sums recorded over all
237180// aggregation cycles as the delta of these sums.
238181type precomputedDeltaSum [N int64 | float64 ] struct {
239- * precomputedMap [N ]
182+ * valueMap [N ]
240183
241184 reported map [attribute.Set ]N
242185
@@ -271,15 +214,14 @@ func (s *precomputedDeltaSum[N]) Aggregation() metricdata.Aggregation {
271214 DataPoints : make ([]metricdata.DataPoint [N ], 0 , len (s .values )),
272215 }
273216 for attr , value := range s .values {
274- v := value .measured + value .filtered
275- delta := v - s .reported [attr ]
217+ delta := value - s .reported [attr ]
276218 out .DataPoints = append (out .DataPoints , metricdata.DataPoint [N ]{
277219 Attributes : attr ,
278220 StartTime : s .start ,
279221 Time : t ,
280222 Value : delta ,
281223 })
282- newReported [attr ] = v
224+ newReported [attr ] = value
283225 // Unused attribute sets do not report.
284226 delete (s .values , attr )
285227 }
@@ -302,15 +244,15 @@ func (s *precomputedDeltaSum[N]) Aggregation() metricdata.Aggregation {
302244// temporality.
303245func NewPrecomputedCumulativeSum [N int64 | float64 ](monotonic bool ) Aggregator [N ] {
304246 return & precomputedCumulativeSum [N ]{
305- precomputedMap : newPrecomputedMap [N ](),
306- monotonic : monotonic ,
307- start : now (),
247+ valueMap : newValueMap [N ](),
248+ monotonic : monotonic ,
249+ start : now (),
308250 }
309251}
310252
311253// precomputedCumulativeSum directly records and reports a set of pre-computed sums.
312254type precomputedCumulativeSum [N int64 | float64 ] struct {
313- * precomputedMap [N ]
255+ * valueMap [N ]
314256
315257 monotonic bool
316258 start time.Time
@@ -345,7 +287,7 @@ func (s *precomputedCumulativeSum[N]) Aggregation() metricdata.Aggregation {
345287 Attributes : attr ,
346288 StartTime : s .start ,
347289 Time : t ,
348- Value : value . measured + value . filtered ,
290+ Value : value ,
349291 })
350292 // Unused attribute sets do not report.
351293 delete (s .values , attr )
0 commit comments