cap values at p95 on client

This commit is contained in:
Alex Holliday committed 2026-07-31 11:36:10 -07:00
1 parent 8a608961e6
commit 08f167c18e
9 files changed
+52 -70

No files matched your search

@@ -29,7 +29,7 @@ import {
import { useStatusPageTheme } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
import { formatPercentage } from "@/Utils/FormatUtils";
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
type StatusPageMonitor = Monitor;
export interface BaseStyles {
page: SxProps<Theme>;
@@ -8,6 +8,7 @@ import type { CheckSnapshot } from "@/Types/Check";
import { formatDateWithTz } from "@/Utils/TimeUtils";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
import { useStatusPageTheme } from "../StatusPageThemeProvider";
import prettyMilliseconds from "pretty-ms";
const CELLS = MAX_RECENT_CHECKS;
@@ -60,7 +61,7 @@ export const ThemedHeatmap = ({ checks, containerSx, cellSx }: Props) => {
fontWeight={600}
>
{check.status
? `${check.responseTime} ms`
? `${prettyMilliseconds(check.responseTime, { compact: true })}`
: t("pages.statusPages.monitorsList.chart.downTooltip")}
</Typography>
<Typography
@@ -9,6 +9,8 @@ import type { CheckSnapshot } from "@/Types/Check";
import { formatDateWithTz } from "@/Utils/TimeUtils";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
import { useStatusPageTheme } from "../StatusPageThemeProvider";
import { computeBarHeights } from "@/Utils/DataUtils";
import prettyMilliseconds from "pretty-ms";
const CELLS = MAX_RECENT_CHECKS;
const MIN_HEIGHT_PCT = 6;
@@ -35,18 +37,19 @@ export const ThemedHistogram = ({
const { t } = useTranslation();
const { timezone } = useStatusPageTheme();
const { padded, max, avg, peak } = useMemo(() => {
const { padded, heights, avg, peak } = useMemo(() => {
const source = checks.slice(-CELLS);
const out: (CheckSnapshot | null)[] = [
...source,
...Array.from({ length: Math.max(0, CELLS - source.length) }, () => null),
];
const heights = computeBarHeights(source);
const valid = out.filter((c): c is CheckSnapshot => c !== null && c.responseTime > 0);
const maxRt = valid.length ? Math.max(...valid.map((c) => c.responseTime)) : 1;
const avgRt = valid.length
? Math.round(valid.reduce((s, c) => s + c.responseTime, 0) / valid.length)
: 0;
return { padded: out, max: maxRt, avg: avgRt, peak: valid.length ? maxRt : 0 };
return { padded: out, heights, avg: avgRt, peak: maxRt };
}, [checks]);
return (
@@ -61,10 +64,7 @@ export const ThemedHistogram = ({
/>
);
}
const height = Math.max(
MIN_HEIGHT_PCT,
Math.round((check.responseTime / max) * 100)
);
const height = heights[i] ?? MIN_HEIGHT_PCT;
const tooltipContent = (
<Stack gap={0.25}>
<Typography
@@ -72,7 +72,7 @@ export const ThemedHistogram = ({
fontWeight={600}
>
{check.status
? `${check.responseTime} ms`
? `${prettyMilliseconds(check.responseTime, { compact: true })}`
: t("pages.statusPages.monitorsList.chart.downTooltip")}
</Typography>
<Typography
@@ -18,7 +18,7 @@ export interface InfraSx {
}
interface Props {
monitor: Monitor & { checks?: Monitor["recentChecks"] };
monitor: Monitor;
sxApi: InfraSx;
}
@@ -36,7 +36,7 @@ const heatLevel = (value: number): GaugeFillLevel =>
export const ThemedInfrastructure = ({ monitor, sxApi }: Props) => {
const { t } = useTranslation();
const latest = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
const latest = monitor.recentChecks?.[0];
const renderEmpty = () => (
<Box sx={sxApi.emptySx}>{t("pages.statusPages.monitorsList.noData")}</Box>