File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1129,11 +1129,10 @@ export function useClusterFreshness({
11291129} : ClusterFreshnessParams ) {
11301130 const objectIds = objects . map ( ( object ) => object . objectId ) ;
11311131
1132- // The binned series and the latest readings go in separate requests because
1133- // they go stale at different rates. A bin cannot change faster than its own
1134- // width, which at a 24 hour range is 24 minutes, so refetching the series on
1135- // the one minute clock would re-read the whole window to change at most one
1136- // point.
1132+ // The series refetches once per bin, which at a 24 hour range is 24 minutes,
1133+ // so it re-reads the whole window at most once per new point.
1134+ // NOTE: the trailing bin is partial, so between fetches it can miss a lag
1135+ // that started since. See `computeStats`.
11371136 const binSizeMs = calculateBucketSizeFromLookback ( lookbackMs ) ;
11381137
11391138 // NOTE: `useQuery`, not `useSuspenseQuery`. A suspending query stops the
Original file line number Diff line number Diff line change @@ -444,7 +444,8 @@ const FreshnessPage = () => {
444444 percentile of those maxima. The “Now” column is the most
445445 recent single reading rather than a binned point, so at wider ranges a
446446 point on the graph can sit above the “Now” value in its
447- row.
447+ row. The graph refreshes once per point, so pMAX can include a newer
448+ “Now” value that the graph has not drawn yet.
448449 </ Text >
449450 </ VStack >
450451 </ MainContentContainer >
Original file line number Diff line number Diff line change @@ -173,6 +173,12 @@ describe("computeStats", () => {
173173 expect ( stats . peak ) . toBe ( 9_000 ) ;
174174 } ) ;
175175
176+ it ( "counts a lag that started after the series was fetched in pMAX" , ( ) => {
177+ const stats = computeStats ( "spiky" , data , 600_000 ) ;
178+ expect ( stats . peak ) . toBe ( 600_000 ) ;
179+ expect ( stats . p90 ) . toBe ( 9_000 ) ;
180+ } ) ;
181+
176182 it ( "lets one unreadable reading in sixty pass p90" , ( ) => {
177183 // Unreadable once about twenty hours ago, healthy since. It has to still
178184 // breach "at any moment", because that reading was
Original file line number Diff line number Diff line change @@ -117,12 +117,16 @@ export function computeStats(
117117 const sorted = [ ...values ] . sort ( ( a , b ) => a - b ) ;
118118 const rank = Math . max ( 0 , Math . ceil ( 0.9 * sorted . length ) - 1 ) ;
119119
120+ const current = currentFrom ( latest ) ;
121+
120122 return {
121123 // The newest reading, not the newest bin. A bin reports the worst reading
122124 // in its span, so at a 24 hour range the last one answers "the worst of
123125 // the last 24 minutes" when the question asked was "right now".
124- current : currentFrom ( latest ) ,
125- peak : sorted [ sorted . length - 1 ] ,
126+ current,
127+ // The series refetches once per bin and the latest reading once a minute,
128+ // so a lag that starts between series fetches is only in `current`.
129+ peak : Math . max ( sorted [ sorted . length - 1 ] , current ?? - Infinity ) ,
126130 p90 : sorted [ rank ] ,
127131 } ;
128132}
You can’t perform that action at this time.
0 commit comments