Skip to content

Commit

Permalink
Fix usage of deprecated func, fix logic in merging exponential histog…
Browse files Browse the repository at this point in the history
…ram (#12865)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Aug 1, 2022
1 parent b150f19 commit 4cfa1d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
24 changes: 15 additions & 9 deletions processor/metricstransformprocessor/operation_aggregate_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ func groupHistogramDataPoints(dps pmetric.HistogramDataPointSlice,
dpsByAttrsAndTs map[string]pmetric.HistogramDataPointSlice) {
for i := 0; i < dps.Len(); i++ {
dp := dps.At(i)
keyHashParts := make([]interface{}, 0, len(dp.MExplicitBounds())+3)
for _, b := range dp.MExplicitBounds() {
keyHashParts = append(keyHashParts, b)
keyHashParts := make([]interface{}, 0, dp.ExplicitBounds().Len()+3)
for b := 0; b < dp.ExplicitBounds().Len(); b++ {
keyHashParts = append(keyHashParts, dp.ExplicitBounds().At(b))
}
keyHashParts = append(keyHashParts, dp.HasMin(), dp.HasMax(), dp.Flags())
key := dataPointHashKey(dps.At(i).Attributes(), dp.StartTimestamp(), dp.Timestamp(), keyHashParts...)
Expand Down Expand Up @@ -275,6 +275,7 @@ func mergeHistogramDataPoints(dpsMap map[string]pmetric.HistogramDataPointSlice,
for _, dps := range dpsMap {
dp := to.AppendEmpty()
dps.At(0).MoveTo(dp)
counts := dp.BucketCounts().AsRaw()
for i := 1; i < dps.Len(); i++ {
if dps.At(i).Count() == 0 {
continue
Expand All @@ -288,11 +289,12 @@ func mergeHistogramDataPoints(dpsMap map[string]pmetric.HistogramDataPointSlice,
dp.SetMax(dps.At(i).Max())
}
dps.At(i).Exemplars().MoveAndAppendTo(dp.Exemplars())
for b, bc := range dps.At(i).MBucketCounts() {
dp.MBucketCounts()[b] = dp.MBucketCounts()[b] + bc
for b := 0; b < dps.At(i).BucketCounts().Len(); b++ {
counts[b] += dps.At(i).BucketCounts().At(b)
}
dps.At(i).Exemplars().MoveAndAppendTo(dp.Exemplars())
}
dp.SetBucketCounts(pcommon.NewImmutableUInt64Slice(counts))
}
}

Expand All @@ -301,6 +303,8 @@ func mergeExponentialHistogramDataPoints(dpsMap map[string]pmetric.ExponentialHi
for _, dps := range dpsMap {
dp := to.AppendEmpty()
dps.At(0).MoveTo(dp)
negatives := dp.Negative().BucketCounts().AsRaw()
positives := dp.Positive().BucketCounts().AsRaw()
for i := 1; i < dps.Len(); i++ {
if dps.At(i).Count() == 0 {
continue
Expand All @@ -313,13 +317,15 @@ func mergeExponentialHistogramDataPoints(dpsMap map[string]pmetric.ExponentialHi
if dp.HasMax() && dp.Max() < dps.At(i).Max() {
dp.SetMax(dps.At(i).Max())
}
for b, bc := range dps.At(i).Negative().MBucketCounts() {
dps.At(i).Negative().MBucketCounts()[b] = dps.At(i).Negative().MBucketCounts()[b] + bc
for b := 0; b < dps.At(i).Negative().BucketCounts().Len(); b++ {
negatives[b] += dps.At(i).Negative().BucketCounts().At(b)
}
for b, bc := range dps.At(i).Positive().MBucketCounts() {
dps.At(i).Positive().MBucketCounts()[b] = dps.At(i).Positive().MBucketCounts()[b] + bc
for b := 0; b < dps.At(i).Positive().BucketCounts().Len(); b++ {
positives[b] += dps.At(i).Positive().BucketCounts().At(b)
}
dps.At(i).Exemplars().MoveAndAppendTo(dp.Exemplars())
}
dp.Negative().SetBucketCounts(pcommon.NewImmutableUInt64Slice(negatives))
dp.Positive().SetBucketCounts(pcommon.NewImmutableUInt64Slice(positives))
}
}
11 changes: 11 additions & 0 deletions unreleased/metricstransform-fix-merge-exponential-histograms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: "metricstransformprocessor"

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix logic in merging exponential histogram.

# One or more tracking issues related to the change
issues: [12865]

0 comments on commit 4cfa1d3

Please sign in to comment.