fix(ops): hide percentiles in Live Ops Console when sample size is too small - #40
Merged
Merged
Conversation
LatencyRow unconditionally stamped p50, p95, and p99, so with n=1 it rendered the same number three times (e.g. "p50 1182 p95 1182 p99 1182") — mathematically correct but visually indistinguishable from a broken measurement. Switch to `n=N last X ms` when n<5, and only show the percentile breakdown once there are enough samples for those numbers to differ meaningfully. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
p50/p95/p99, so withn=1it stamped the same number three times (e.g.p50 1182 ms p95 1182 ms p99 1182 ms). Mathematically correct (one sample → all percentiles equal that sample), but visually indistinguishable from a broken measurement.n=N last X mswhenn < 5, and kept the percentile breakdown once there are enough samples for the numbers to differ meaningfully.Why this looked "broken"
deals.getActivityOfferPlacementsgets a client-side sample only from the page-header Refresh button, arefetchOnWindowFocus, or a staleTime expiry — the SSR prefetch at page.tsx:28 bypasses thelatencyLink.deals.simulatePartnerWebhookmutation, and itsonSuccesswrites events straight into the React Query cache (useApplyServerEvents.ts:32) — it never triggers a refetch ofgetActivityOfferPlacements, so that row stayed atn=1.sorted[0]for every p — so the three percentiles were identical by construction.Test plan
pnpm typecheckpnpm test(327/327 pass; added cases cover both then<5andn≥5branches)n=1 last X msinstead of three identical percentiles, and that rows with ≥5 samples still showp50/p95/p99.Note
Low Risk
Low risk UI-only change in the Live Ops Console latency display; behavior is gated by a simple
n < 5condition and covered by updated tests.Overview
Updates the Live Ops Console Latency tab to avoid misleading percentile output for tiny sample sizes: when
n < 5, rows now rendern=N last X msinstead ofp50/p95/p99, while keeping percentile breakdown forn ≥ 5.Adds/adjusts tests in
LiveOpsConsole.test.tsxto assert the newlastformatting for a single sample and thatp50/p95/p99appear once five samples are recorded.Reviewed by Cursor Bugbot for commit fbf07af. Bugbot is set up for automated code reviews on this repo. Configure here.