Skip to content

fix(metricstransformprocessor): preserve absent histogram sum on merge#49404

Open
CedricConday wants to merge 2 commits into
open-telemetry:mainfrom
CedricConday:fix/metricstransform-absent-sum-49379
Open

fix(metricstransformprocessor): preserve absent histogram sum on merge#49404
CedricConday wants to merge 2 commits into
open-telemetry:mainfrom
CedricConday:fix/metricstransform-absent-sum-49379

Conversation

@CedricConday

Copy link
Copy Markdown

Description

When merging (exponential) histogram datapoints in aggregateutil, the sum was set unconditionally (dp.SetSum(dp.Sum() + dps.At(i).Sum())). Because SetSum always marks the value present, merging datapoints that had no sum (HasSum() == false) produced HasSum() == true with Sum() == 0, which is indistinguishable from a genuine zero sum. Min and max in the same loop are already guarded with HasMin()/HasMax(); the sum is now handled the same way: it is only accumulated while every merged datapoint carries one, and is otherwise removed.

Link to tracking issue

Fixes #49379

Testing

Added a regression test (Test_MergeDataPoints_SumPresence) covering histogram and exponential-histogram merges for both the all-present case (sums add, HasSum stays true) and the any-absent case (HasSum becomes false). Existing Test_MergeDataPoints expectations that encoded the old behavior (a fabricated Sum=0 on sumless inputs) were corrected. The new and corrected tests fail before the change and pass after; go test, gofmt, and go vet pass for the package.

Documentation

No user-facing documentation changes; a .chloggen changelog entry is included.

Authorship

  • I, a human, wrote this pull request description myself.

Authored with AI assistance (Claude Code) and reviewed before submission.

When merging (exponential) histogram datapoints, only accumulate the sum
while every merged datapoint carries one, mirroring the existing min/max
handling. Previously the sum was set unconditionally, so a merge that
involved a datapoint without a sum produced HasSum=true with Sum=0,
which is indistinguishable from a genuine zero sum.

Fixes open-telemetry#49379

Assisted-by: Claude Opus 4.8
Signed-off-by: Cedric Conday <neumann.alpha@gmail.com>
@CedricConday CedricConday requested a review from a team as a code owner June 30, 2026 18:15
@CedricConday CedricConday requested a review from ArthurSens June 30, 2026 18:15
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 30, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: CedricConday / name: Cedric Conday (b4695a8)

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help or struggle to move your PR forward:

@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor PRs made by new contributors internal/core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[processor/metricstransform] aggregateLabels/aggregateLabelValues corrupts HasSum flag on histograms with no sum

3 participants