in processor/lsmintervalprocessor/internal/data/add.go [70:107]
func (add Adder) Histograms(state, dp pmetric.HistogramDataPoint) error {
// bounds different: no way to merge, so reset observation to new boundaries
if !pslice.Equal(state.ExplicitBounds(), dp.ExplicitBounds()) {
dp.CopyTo(state)
return nil
}
// spec requires len(BucketCounts) == len(ExplicitBounds)+1.
// given we have limited error handling at this stage (and already verified boundaries are correct),
// doing a best-effort add of whatever we have appears reasonable.
n := min(state.BucketCounts().Len(), dp.BucketCounts().Len())
for i := 0; i < n; i++ {
sum := state.BucketCounts().At(i) + dp.BucketCounts().At(i)
state.BucketCounts().SetAt(i, sum)
}
state.SetCount(state.Count() + dp.Count())
if state.HasSum() && dp.HasSum() {
state.SetSum(state.Sum() + dp.Sum())
} else {
state.RemoveSum()
}
if state.HasMin() && dp.HasMin() {
state.SetMin(math.Min(state.Min(), dp.Min()))
} else {
state.RemoveMin()
}
if state.HasMax() && dp.HasMax() {
state.SetMax(math.Max(state.Max(), dp.Max()))
} else {
state.RemoveMax()
}
return nil
}