Fix: avgHistogramPercentile / sumHistogramPercentile meter functions reported the smallest finite bucket boundary#13866
Open
wankai123 wants to merge 3 commits intoapache:masterfrom
Open
Conversation
…ons reported the smallest finite bucket boundary
There was a problem hiding this comment.
Pull request overview
This PR fixes an edge case in the meter histogram percentile implementations (avgHistogramPercentile and sumHistogramPercentile) where an empty window (all buckets = 0) incorrectly produced the smallest finite bucket boundary for every percentile rank. It does so by short-circuiting calculate() to emit 0 percentile values when the bucket total is 0, and it adds unit tests to prevent regressions.
Changes:
- Short-circuit percentile calculation to return
0for all ranks when the windowed histogram total is0(no observed samples). - Add unit tests covering “no data” scenarios with and without labels for both avg/sum histogram percentile functions.
- Document the bug and fix in the CHANGES log.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/sum/SumHistogramPercentileFunction.java | Short-circuits percentile calculation when total bucket count is 0 to avoid selecting the first bucket boundary. |
| oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/avg/AvgHistogramPercentileFunction.java | Applies the same “total==0 => all ranks report 0” behavior to avg-based histogram percentiles. |
| oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/meter/function/sum/SumHistogramPercentileFunctionTest.java | Adds regression tests for no-data histogram percentile behavior (with/without labels). |
| oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/meter/function/avg/AvgHistogramPercentileFunctionTest.java | Adds regression tests for no-data histogram percentile behavior (with/without labels). |
| docs/en/changes/changes.md | Records the bug and the fix for release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wu-sheng
approved these changes
May 9, 2026
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.
Add a unit test to verify that the fix works.
Explain briefly why the bug exists and how to fix it.
If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
Update the
CHANGESlog.