Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle zero bucket counts in ExponentialHistogram merge #4459

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

mwear
Copy link
Member

@mwear mwear commented Feb 5, 2024

Which problem is this PR solving?

This PR fixes a bug in the exponential histogram merge operation where the source histogram has empty bucket counts. The bucket index was not being set properly in this case, and depending on the histogram being merged, it can lead to corrupted counts in the resulting histogram.

Fixes #4450

Short description of the changes

Added special case handling for the zero-length bucket counts case in the _incrementIndexBy method.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added a unit test that replicates a real world failure that exhibits this issue. If you comment out the changes added to _incrementIndexBy you will see the newly added test fail.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@mwear mwear requested a review from a team as a code owner February 5, 2024 03:31
Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Merging #4459 (e4f1c85) into main (588d8ad) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4459      +/-   ##
==========================================
+ Coverage   92.41%   92.42%   +0.01%     
==========================================
  Files         330      330              
  Lines        9514     9516       +2     
  Branches     2028     2029       +1     
==========================================
+ Hits         8792     8795       +3     
+ Misses        722      721       -1     
Files Coverage Δ
...sdk-metrics/src/aggregator/ExponentialHistogram.ts 98.13% <100.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a tricky one! Thanks for doing the investigation and coming up with a fix so quickly @mwear 🙂

@pichlermarc pichlermarc merged commit 6d276f4 into open-telemetry:main Feb 6, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exponential Histogram : observed bucket counts sometimes not matching with overall count
2 participants