Skip to content

Commit 55438e1

Browse files
jdonelsonclaude
andcommitted
console: Fold the latest reading into freshness pMAX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ef42dfb commit 55438e1

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎console/src/platform/clusters/queries.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff 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

‎console/src/platform/freshness/FreshnessPage.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ const FreshnessPage = () => {
444444
percentile of those maxima. The &ldquo;Now&rdquo; 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 &ldquo;Now&rdquo; value in its
447-
row.
447+
row. The graph refreshes once per point, so pMAX can include a newer
448+
&ldquo;Now&rdquo; value that the graph has not drawn yet.
448449
</Text>
449450
</VStack>
450451
</MainContentContainer>

‎console/src/platform/freshness/freshnessRows.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

‎console/src/platform/freshness/freshnessRows.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)