fix(sdk-metrics): repair ExponentialHistogram tests#6565
Merged
pichlermarc merged 4 commits intoopen-telemetry:mainfrom Apr 8, 2026
Merged
fix(sdk-metrics): repair ExponentialHistogram tests#6565pichlermarc merged 4 commits intoopen-telemetry:mainfrom
pichlermarc merged 4 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6565 +/- ##
=======================================
Coverage 95.75% 95.75%
=======================================
Files 371 371
Lines 12514 12514
Branches 2962 2962
=======================================
Hits 11983 11983
Misses 531 531 🚀 New features to boost your workflow:
|
overbalance
added a commit
to embrace-io/opentelemetry-js
that referenced
this pull request
Apr 7, 2026
75db0ae to
354ca5d
Compare
dyladan
approved these changes
Apr 8, 2026
Member
dyladan
left a comment
There was a problem hiding this comment.
Wow great catch. What were you working on where you noticed that?
Contributor
Author
|
@dyladan On my monster mocha -> vitest PR |
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.
Summary
Fixes several bugs in the
ExponentialHistogramAccumulationtest suite. Two test cases were defined inside the body of anotherit()block, which Mocha silently ignores, making them dead code:handles permutations of [1, 1/2, 1/4] with maxSize: 2handles ascending sequencesThese tests have been moved to the correct
describe('record', ...)scope so they actually run. Once exposed, four bugs surfaced:maxFillwas reset instead of tracked. Every non-zero bucket resetmaxFillto0instead of recording the index:maxFill >= maxSize / 2fails for some parameter combos. After downscaling,positive.lengthcan be less thanmaxSize(e.g., 2 buckets when maxSize=3). The midpoint check should compare against the actual bucket array length, not the max capacity:Count assertions only check an upper bound. We record exactly
maxSize + 1values (all positive, no NaN), so bothtotalCountandaccumulation.countmust be exactly that:Sum assertion only checks one direction. The manual sum and
accumulation.sumadd the same values in the same order, so they are bit-identical:Test plan
handles ascending sequencespasses across all parameter combinations (maxSize in [3,4,6,9], offset in [-5..5], initScale in [0,4], step in [maxSize..4*maxSize))handles permutations of [1, 1/2, 1/4] with maxSize: 2passes