2026-04-25 23:27:35 -04:00
|
|
|
import Box from "@mui/material/Box";
|
2026-02-20 18:13:39 +00:00
|
|
|
import { StatBox } from "@/Components/design-elements";
|
2026-02-06 18:20:26 +00:00
|
|
|
|
|
|
|
|
import prettyBytes from "pretty-bytes";
|
|
|
|
|
import prettyMilliseconds from "pretty-ms";
|
|
|
|
|
import { useTheme } from "@mui/material";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import type { Diagnostics } from "@/Types/Diagnostics";
|
|
|
|
|
|
|
|
|
|
interface StatsProps {
|
|
|
|
|
diagnostics: Diagnostics | null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 23:27:35 -04:00
|
|
|
const PLACEHOLDER = "—";
|
|
|
|
|
|
2026-02-06 18:20:26 +00:00
|
|
|
export const Stats = ({ diagnostics }: StatsProps) => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
2026-04-25 23:27:35 -04:00
|
|
|
const eventLoopDelay = diagnostics
|
|
|
|
|
? prettyMilliseconds(diagnostics.eventLoopDelayMs ?? 0, {
|
|
|
|
|
millisecondsDecimalDigits: 2,
|
|
|
|
|
})
|
|
|
|
|
: PLACEHOLDER;
|
|
|
|
|
const uptime = diagnostics
|
|
|
|
|
? prettyMilliseconds(diagnostics.uptimeMs ?? 0, { hideSeconds: true })
|
|
|
|
|
: PLACEHOLDER;
|
|
|
|
|
const usedHeap = diagnostics
|
|
|
|
|
? prettyBytes(diagnostics.v8HeapStats?.usedHeapSizeBytes ?? 0)
|
|
|
|
|
: PLACEHOLDER;
|
|
|
|
|
const totalHeap = diagnostics
|
|
|
|
|
? prettyBytes(diagnostics.v8HeapStats?.totalHeapSizeBytes ?? 0)
|
|
|
|
|
: PLACEHOLDER;
|
|
|
|
|
const osMemory = diagnostics
|
|
|
|
|
? prettyBytes(diagnostics.osStats?.totalMemoryBytes ?? 0)
|
|
|
|
|
: PLACEHOLDER;
|
2026-02-06 18:20:26 +00:00
|
|
|
|
|
|
|
|
return (
|
2026-04-25 23:27:35 -04:00
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "grid",
|
|
|
|
|
gridTemplateColumns: { xs: "1fr", md: "repeat(5, 1fr)" },
|
|
|
|
|
gap: theme.spacing(8),
|
|
|
|
|
"& > *": { width: "100% !important" },
|
|
|
|
|
}}
|
2026-02-06 18:20:26 +00:00
|
|
|
>
|
|
|
|
|
<StatBox
|
|
|
|
|
title={t("pages.logs.diagnostics.stats.eventLoopDelay")}
|
2026-04-25 23:27:35 -04:00
|
|
|
subtitle={eventLoopDelay}
|
2026-02-06 18:20:26 +00:00
|
|
|
/>
|
|
|
|
|
<StatBox
|
|
|
|
|
title={t("pages.logs.diagnostics.stats.uptime")}
|
2026-04-25 23:27:35 -04:00
|
|
|
subtitle={uptime}
|
2026-02-06 18:20:26 +00:00
|
|
|
/>
|
|
|
|
|
<StatBox
|
|
|
|
|
title={t("pages.logs.diagnostics.stats.usedHeapSize")}
|
2026-04-25 23:27:35 -04:00
|
|
|
subtitle={usedHeap}
|
2026-02-06 18:20:26 +00:00
|
|
|
/>
|
|
|
|
|
<StatBox
|
|
|
|
|
title={t("pages.logs.diagnostics.stats.totalHeapSize")}
|
2026-04-25 23:27:35 -04:00
|
|
|
subtitle={totalHeap}
|
2026-02-06 18:20:26 +00:00
|
|
|
/>
|
|
|
|
|
<StatBox
|
|
|
|
|
title={t("pages.logs.diagnostics.stats.osMemoryLimit")}
|
2026-04-25 23:27:35 -04:00
|
|
|
subtitle={osMemory}
|
2026-02-06 18:20:26 +00:00
|
|
|
/>
|
2026-04-25 23:27:35 -04:00
|
|
|
</Box>
|
2026-02-06 18:20:26 +00:00
|
|
|
);
|
|
|
|
|
};
|