fix(metricstransformprocessor): preserve absent histogram sum on merge#49404
Open
CedricConday wants to merge 2 commits into
Open
fix(metricstransformprocessor): preserve absent histogram sum on merge#49404CedricConday wants to merge 2 commits into
CedricConday wants to merge 2 commits into
Conversation
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>
|
|
Contributor
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
|
Member
|
/workflow-approve |
…rocessor/metrics_transform
Member
|
/workflow-approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When merging (exponential) histogram datapoints in
aggregateutil, the sum was set unconditionally (dp.SetSum(dp.Sum() + dps.At(i).Sum())). BecauseSetSumalways marks the value present, merging datapoints that had no sum (HasSum() == false) producedHasSum() == truewithSum() == 0, which is indistinguishable from a genuine zero sum. Min and max in the same loop are already guarded withHasMin()/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,HasSumstays true) and the any-absent case (HasSumbecomes false). ExistingTest_MergeDataPointsexpectations that encoded the old behavior (a fabricatedSum=0on sumless inputs) were corrected. The new and corrected tests fail before the change and pass after;go test,gofmt, andgo vetpass for the package.Documentation
No user-facing documentation changes; a
.chloggenchangelog entry is included.Authorship
Authored with AI assistance (Claude Code) and reviewed before submission.