Repository navigation
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Dumbris
approved these changes
Oct 26, 2026
Dumbris
left a comment
Member
There was a problem hiding this comment.
Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.
Member
|
Merged. Thank you, @rudycelekli! P95/p99 in the Usage view use nearest-rank, so a lone slow call is no longer hidden. |
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.
Bug
ToolUsage.Percentilecomputes the target rank asint64(float64(total) * p), which truncates. The nearest-rank method needsceil. For small call counts the p95/p99 lands one rank too low, so the slowest call never shows up in the tail percentile. The Usage view (GET /api/v1/activity/usage,httpapi/activity.go) reports exactly these values as the tool's p95.Trigger
One tool receives 9 calls at ~30 ms and 1 call at 3000 ms.
ceil(9.5) = 10, which is the 3000 ms call, so the bucket bound is ≤ 5000 ms.int(9.5) = 9, so p95 is ≤ 50 ms. The slow call is invisible.Fix
Use
math.Ceilfor the target rank. The existingtarget < 1clamp is kept, and large totals are unaffected, because the existing 100-call tests still pass.Test
TestToolUsagePercentile_SmallTotalsUseNearestRankcovers the 9-fast + 1-slow case above. It asserts p95 = 5000 (the bucket that holds 3000 ms) and p50 = 50.Commands run
CGO_ENABLED=0 go test -count=1 ./internal/runtime: okCGO_ENABLED=0 go test -count=1 -run 'Usage|Percentile' ./internal/httpapi: okgit stashofusage_aggregate.go), the new test fails withp95 = 50 ms, want 5000.gofmt -lon the edited files: no output