remove unnecessary buckets on exponential histograms
Description
Updates the serialization of exponential histogram buckets to remove unnecessary zero buckets. If there are no non-zero buckets, then none are serialized. This matches better the payloads from the JavaScript SDK and avoids ingestion problems with a downstream vendor when an empty negative bucket appears.
Fixes #3767
Type of change
Please delete options that are not relevant.
- [X] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Added unit tests to ensure that the truncation of the zero buckets works as expected. Updated the unit test for metric encoding to exercise this functionality.
Does This PR Require a Contrib Repo Change?
Answer the following question based on these examples of changes that would require a Contrib Repo Change:
-
The OTel specification has changed which prompted this PR to update the method interfaces of
opentelemetry-api/oropentelemetry-sdk/ -
The method interfaces of
test/utilhave changed -
Scripts in
scripts/that were copied over to the Contrib repo have changed -
Configuration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in
pyproject.tomlisort.cfg.flake8
-
When a new
.github/CODEOWNERis added -
Major changes to project information, such as in:
README.mdCONTRIBUTING.md
-
[ ] Yes. - Link to PR:
-
[X] No.
Checklist:
- [x] Followed the style guidelines of this project
- [x] Changelogs have been updated
- [x] Unit tests have been added
- ~[ ] Documentation has been updated~
@euroelessar any chance you can take a look at this please?
unfortunately this PR has to be rebased due to #3798 being merged @loomis-relativity any chance you can take on it? if not, I probably will be able to prepare a new PR somewhere within a week
@loomis-relativity any chance you can rebase your changes please?
@xrmx Merge conflict resolved.
@euroelessar hello, do you have time to take a look at it?
Apologies, the notifications got lost in my inbox. @euroelessar I've refactored the code to remove some duplication. Don't think that it can be moved into the def bucket_counts without changing the code generated from the protobuf definitions.