Skip to content

Fix: avgHistogramPercentile / sumHistogramPercentile meter functions reported the smallest finite bucket boundary#13866

Open
wankai123 wants to merge 3 commits intoapache:masterfrom
wankai123:fix-HistogramPercentile
Open

Fix: avgHistogramPercentile / sumHistogramPercentile meter functions reported the smallest finite bucket boundary#13866
wankai123 wants to merge 3 commits intoapache:masterfrom
wankai123:fix-HistogramPercentile

Conversation

@wankai123
Copy link
Copy Markdown
Member

  • 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 CHANGES log.

…ons reported the smallest finite bucket boundary
@wankai123 wankai123 added this to the 10.5.0 milestone May 9, 2026
@wankai123 wankai123 requested review from Copilot and wu-sheng May 9, 2026 09:05
@wankai123 wankai123 added the bug Something isn't working and you are sure it's a bug! label May 9, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 0 for all ranks when the windowed histogram total is 0 (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working and you are sure it's a bug!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants