@rtkelly-labs/design-system 0.16.0-dev.0.37dedac → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/components/AlertList.js +246 -0
- package/dist/components/AlertList.js.map +1 -0
- package/dist/components/FilterBar.js +215 -0
- package/dist/components/FilterBar.js.map +1 -0
- package/dist/components/FreshnessIndicator.js +50 -0
- package/dist/components/FreshnessIndicator.js.map +1 -0
- package/dist/components/IdChip.js +58 -0
- package/dist/components/IdChip.js.map +1 -0
- package/dist/components/IncidentTimeline.js +122 -0
- package/dist/components/IncidentTimeline.js.map +1 -0
- package/dist/components/LatencyHeatmap.js +382 -0
- package/dist/components/LatencyHeatmap.js.map +1 -0
- package/dist/components/LatencyHistogram.js +282 -0
- package/dist/components/LatencyHistogram.js.map +1 -0
- package/dist/components/LogViewer.js +393 -0
- package/dist/components/LogViewer.js.map +1 -0
- package/dist/components/ServiceMap.js +404 -0
- package/dist/components/ServiceMap.js.map +1 -0
- package/dist/components/SeverityBadge.js +15 -0
- package/dist/components/SeverityBadge.js.map +1 -0
- package/dist/components/TimeRange.js +89 -0
- package/dist/components/TimeRange.js.map +1 -0
- package/dist/components/TimeSeriesChart.js +507 -0
- package/dist/components/TimeSeriesChart.js.map +1 -0
- package/dist/components/TraceViewer.js +159 -0
- package/dist/components/TraceViewer.js.map +1 -0
- package/dist/components/TraceWaterfall.js +226 -0
- package/dist/components/TraceWaterfall.js.map +1 -0
- package/dist/components/saas/ObservabilityConsole.js +220 -0
- package/dist/components/saas/ObservabilityConsole.js.map +1 -0
- package/dist/components/saas/observabilityData.js +250 -0
- package/dist/components/saas/observabilityData.js.map +1 -0
- package/dist/hooks/useMeasuredWidth.js +22 -0
- package/dist/hooks/useMeasuredWidth.js.map +1 -0
- package/dist/hooks/useTraceClock.js +17 -0
- package/dist/hooks/useTraceClock.js.map +1 -0
- package/dist/hooks/useTraceReplay.js +75 -0
- package/dist/hooks/useTraceReplay.js.map +1 -0
- package/dist/index.d.ts +1562 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/filters.js +130 -0
- package/dist/lib/filters.js.map +1 -0
- package/dist/lib/ids.js +9 -0
- package/dist/lib/ids.js.map +1 -0
- package/dist/lib/latency.js +228 -0
- package/dist/lib/latency.js.map +1 -0
- package/dist/lib/logs.js +78 -0
- package/dist/lib/logs.js.map +1 -0
- package/dist/lib/serviceGraph.js +243 -0
- package/dist/lib/serviceGraph.js.map +1 -0
- package/dist/lib/severity.js +23 -0
- package/dist/lib/severity.js.map +1 -0
- package/dist/lib/timeRange.js +94 -0
- package/dist/lib/timeRange.js.map +1 -0
- package/dist/lib/timeSeries.js +285 -0
- package/dist/lib/timeSeries.js.map +1 -0
- package/dist/lib/trace.js +251 -0
- package/dist/lib/trace.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/IdChip.tsx
|
|
4
|
+
import { Copy } from "lucide-react";
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import { recipe } from "../lib/recipe.js";
|
|
7
|
+
import { useCopyToClipboard } from "../hooks/useCopyToClipboard.js";
|
|
8
|
+
import { SiteLink } from "./LinkProvider.js";
|
|
9
|
+
import { Tooltip } from "./Tooltip.js";
|
|
10
|
+
import { truncateId } from "../lib/ids.js";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var idChip = recipe({
|
|
13
|
+
slots: {
|
|
14
|
+
root: "inline-flex max-w-full items-stretch border border-edge-default bg-surface-sunken font-mono text-xs leading-tight text-content-primary",
|
|
15
|
+
label: "flex items-center border-r border-edge-default px-1 text-[0.625rem] uppercase tracking-wider text-content-muted",
|
|
16
|
+
value: "flex items-center whitespace-nowrap px-1 py-0.5 tabular-nums",
|
|
17
|
+
link: "text-accent-primary underline decoration-dotted underline-offset-2 hover:decoration-solid",
|
|
18
|
+
copy: "flex cursor-pointer items-center border-l border-edge-default px-1 text-content-secondary hover:bg-surface-raised hover:text-content-primary",
|
|
19
|
+
copied: "text-intent-success",
|
|
20
|
+
failed: "text-intent-danger"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var IdChip = forwardRef(function IdChip2({ value, label, truncate = 8, href, copyable = true, onCopy, className, ...props }, ref) {
|
|
24
|
+
const styles = idChip();
|
|
25
|
+
const { copied, failed, copy } = useCopyToClipboard();
|
|
26
|
+
const shown = truncateId(value, truncate);
|
|
27
|
+
const name = label ? `${label} ${value}` : value;
|
|
28
|
+
const kind = label ? `${label} ID` : "ID";
|
|
29
|
+
const text = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: shown }),
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: name })
|
|
32
|
+
] });
|
|
33
|
+
const id = href ? /* @__PURE__ */ jsx(SiteLink, { href, "data-slot": "id-chip-value", className: styles.value({ class: styles.link() }), children: text }) : /* @__PURE__ */ jsx("span", { "data-slot": "id-chip-value", className: styles.value(), children: text });
|
|
34
|
+
return /* @__PURE__ */ jsxs("span", { ref, "data-slot": "id-chip", ...props, className: styles.root({ className }), children: [
|
|
35
|
+
label ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", "data-slot": "id-chip-label", className: styles.label(), children: label }) : null,
|
|
36
|
+
shown === value ? id : /* @__PURE__ */ jsx(Tooltip, { content: value, children: id }),
|
|
37
|
+
copyable ? /* @__PURE__ */ jsx(
|
|
38
|
+
"button",
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
"data-slot": "id-chip-copy",
|
|
42
|
+
"aria-label": `Copy ${kind} ${value}`,
|
|
43
|
+
onClick: async () => {
|
|
44
|
+
const ok = await copy(value);
|
|
45
|
+
onCopy?.(value, ok);
|
|
46
|
+
},
|
|
47
|
+
className: styles.copy(),
|
|
48
|
+
children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: copied ? styles.copied() : failed ? styles.failed() : void 0, children: copied ? "\u2713 Copied" : failed ? "\u2715 Failed" : /* @__PURE__ */ jsx(Copy, { size: 12, className: "inline-block align-[-0.125em]" }) })
|
|
49
|
+
}
|
|
50
|
+
) : null,
|
|
51
|
+
copyable ? /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: copied ? "Copied" : failed ? "Copy failed" : "" }) : null
|
|
52
|
+
] });
|
|
53
|
+
});
|
|
54
|
+
IdChip.displayName = "IdChip";
|
|
55
|
+
export {
|
|
56
|
+
IdChip
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=IdChip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/IdChip.tsx"],"sourcesContent":["'use client';\n\nimport { Copy } from 'lucide-react';\nimport { forwardRef } from 'react';\nimport type { HTMLAttributes } from 'react';\nimport { recipe } from '../lib/recipe';\nimport { useCopyToClipboard } from '../hooks/useCopyToClipboard';\nimport { SiteLink } from './LinkProvider';\nimport { Tooltip } from './Tooltip';\nimport { truncateId } from '../lib/ids';\n\nexport interface IdChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'onCopy'> {\n /** The identifier — a trace id, span id or request id. Copied, linked and announced in full. */\n value: string;\n /** What kind of id it is, shown before it in small caps: `trace`, `span`, `req`. */\n label?: string;\n /** How many leading characters to show before `…`. Default `8`; `0` shows the whole id. */\n truncate?: number;\n /** Makes the id a link — to the trace page, say. The copy button stays separate. */\n href?: string;\n /** Show the copy button. Default `true`. */\n copyable?: boolean;\n /** Called after a copy attempt, with whether it succeeded. */\n onCopy?: (value: string, ok: boolean) => void;\n}\n\nconst idChip = recipe({\n slots: {\n root: 'inline-flex max-w-full items-stretch border border-edge-default bg-surface-sunken font-mono text-xs leading-tight text-content-primary',\n label: 'flex items-center border-r border-edge-default px-1 text-[0.625rem] uppercase tracking-wider text-content-muted',\n value: 'flex items-center whitespace-nowrap px-1 py-0.5 tabular-nums',\n link: 'text-accent-primary underline decoration-dotted underline-offset-2 hover:decoration-solid',\n copy:\n 'flex cursor-pointer items-center border-l border-edge-default px-1 text-content-secondary hover:bg-surface-raised hover:text-content-primary',\n copied: 'text-intent-success',\n failed: 'text-intent-danger',\n },\n});\n\n\n/**\n * A compact, monospace identifier — trace, span or request id — sized for a\n * table cell or a log row: the first eight characters and `…`, with the full\n * value in the accessible name and a tooltip, and a button that copies it.\n *\n * With `href` the id is a link (through `LinkProvider`, so an app's router\n * handles it); the copy button stays a separate control beside it, so copying\n * never navigates. After a copy the button reads `Copied` for two seconds,\n * announced as a status.\n */\nexport const IdChip = forwardRef<HTMLSpanElement, IdChipProps>(function IdChip(\n { value, label, truncate = 8, href, copyable = true, onCopy, className, ...props },\n ref,\n) {\n const styles = idChip();\n const { copied, failed, copy } = useCopyToClipboard();\n const shown = truncateId(value, truncate);\n const name = label ? `${label} ${value}` : value;\n const kind = label ? `${label} ID` : 'ID';\n\n const text = (\n <>\n <span aria-hidden=\"true\">{shown}</span>\n <span className=\"sr-only\">{name}</span>\n </>\n );\n\n const id = href ? (\n <SiteLink href={href} data-slot=\"id-chip-value\" className={styles.value({ class: styles.link() })}>\n {text}\n </SiteLink>\n ) : (\n <span data-slot=\"id-chip-value\" className={styles.value()}>\n {text}\n </span>\n );\n\n return (\n <span ref={ref} data-slot=\"id-chip\" {...props} className={styles.root({ className })}>\n {label ? (\n <span aria-hidden=\"true\" data-slot=\"id-chip-label\" className={styles.label()}>\n {label}\n </span>\n ) : null}\n {shown === value ? id : <Tooltip content={value}>{id}</Tooltip>}\n {copyable ? (\n <button\n type=\"button\"\n data-slot=\"id-chip-copy\"\n aria-label={`Copy ${kind} ${value}`}\n onClick={async () => {\n const ok = await copy(value);\n onCopy?.(value, ok);\n }}\n className={styles.copy()}\n >\n <span aria-hidden=\"true\" className={copied ? styles.copied() : failed ? styles.failed() : undefined}>\n {copied ? '✓ Copied' : failed ? '✕ Failed' : <Copy size={12} className=\"inline-block align-[-0.125em]\" />}\n </span>\n </button>\n ) : null}\n {copyable ? (\n <span role=\"status\" className=\"sr-only\">\n {copied ? 'Copied' : failed ? 'Copy failed' : ''}\n </span>\n ) : null}\n </span>\n );\n});\n\nIdChip.displayName = 'IdChip';\n"],"mappings":";;;AAEA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAE3B,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAoDvB,mBACE,KADF;AAnCJ,IAAM,SAAS,OAAO;AAAA,EACpB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MACE;AAAA,IACF,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF,CAAC;AAaM,IAAM,SAAS,WAAyC,SAASA,QACtE,EAAE,OAAO,OAAO,WAAW,GAAG,MAAM,WAAW,MAAM,QAAQ,WAAW,GAAG,MAAM,GACjF,KACA;AACA,QAAM,SAAS,OAAO;AACtB,QAAM,EAAE,QAAQ,QAAQ,KAAK,IAAI,mBAAmB;AACpD,QAAM,QAAQ,WAAW,OAAO,QAAQ;AACxC,QAAM,OAAO,QAAQ,GAAG,KAAK,IAAI,KAAK,KAAK;AAC3C,QAAM,OAAO,QAAQ,GAAG,KAAK,QAAQ;AAErC,QAAM,OACJ,iCACE;AAAA,wBAAC,UAAK,eAAY,QAAQ,iBAAM;AAAA,IAChC,oBAAC,UAAK,WAAU,WAAW,gBAAK;AAAA,KAClC;AAGF,QAAM,KAAK,OACT,oBAAC,YAAS,MAAY,aAAU,iBAAgB,WAAW,OAAO,MAAM,EAAE,OAAO,OAAO,KAAK,EAAE,CAAC,GAC7F,gBACH,IAEA,oBAAC,UAAK,aAAU,iBAAgB,WAAW,OAAO,MAAM,GACrD,gBACH;AAGF,SACE,qBAAC,UAAK,KAAU,aAAU,WAAW,GAAG,OAAO,WAAW,OAAO,KAAK,EAAE,UAAU,CAAC,GAChF;AAAA,YACC,oBAAC,UAAK,eAAY,QAAO,aAAU,iBAAgB,WAAW,OAAO,MAAM,GACxE,iBACH,IACE;AAAA,IACH,UAAU,QAAQ,KAAK,oBAAC,WAAQ,SAAS,OAAQ,cAAG;AAAA,IACpD,WACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,aAAU;AAAA,QACV,cAAY,QAAQ,IAAI,IAAI,KAAK;AAAA,QACjC,SAAS,YAAY;AACnB,gBAAM,KAAK,MAAM,KAAK,KAAK;AAC3B,mBAAS,OAAO,EAAE;AAAA,QACpB;AAAA,QACA,WAAW,OAAO,KAAK;AAAA,QAEvB,8BAAC,UAAK,eAAY,QAAO,WAAW,SAAS,OAAO,OAAO,IAAI,SAAS,OAAO,OAAO,IAAI,QACvF,mBAAS,kBAAa,SAAS,kBAAa,oBAAC,QAAK,MAAM,IAAI,WAAU,iCAAgC,GACzG;AAAA;AAAA,IACF,IACE;AAAA,IACH,WACC,oBAAC,UAAK,MAAK,UAAS,WAAU,WAC3B,mBAAS,WAAW,SAAS,gBAAgB,IAChD,IACE;AAAA,KACN;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["IdChip"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/IncidentTimeline.tsx
|
|
4
|
+
import { forwardRef, useMemo } from "react";
|
|
5
|
+
import { cn, recipe } from "../lib/recipe.js";
|
|
6
|
+
import { formatRangeDuration, formatTimestamp } from "../lib/timeRange.js";
|
|
7
|
+
import { SeverityBadge } from "./SeverityBadge.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function summariseIncident(events, now) {
|
|
10
|
+
const sorted = [...events].sort((a, b) => a.time - b.time);
|
|
11
|
+
const first = (kinds) => sorted.find((event) => kinds.includes(event.kind))?.time ?? null;
|
|
12
|
+
const start = first(["detected", "alert"]) ?? sorted[0]?.time ?? null;
|
|
13
|
+
const since = (time) => time === null || start === null ? null : Math.max(0, time - start);
|
|
14
|
+
const resolvedAt = first(["resolved"]);
|
|
15
|
+
const last = sorted[sorted.length - 1]?.time ?? null;
|
|
16
|
+
const end = resolvedAt ?? (now !== void 0 && Number.isFinite(now) ? Math.max(now, last ?? now) : last);
|
|
17
|
+
return {
|
|
18
|
+
status: resolvedAt === null ? "ongoing" : "resolved",
|
|
19
|
+
start,
|
|
20
|
+
timeToAcknowledge: since(first(["acknowledged"])),
|
|
21
|
+
timeToMitigate: since(first(["mitigated"])),
|
|
22
|
+
timeToResolve: since(resolvedAt),
|
|
23
|
+
duration: since(end)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var MARKER = {
|
|
27
|
+
detected: "bg-intent-danger",
|
|
28
|
+
alert: "bg-intent-danger",
|
|
29
|
+
acknowledged: "bg-intent-warning",
|
|
30
|
+
update: "bg-intent-info",
|
|
31
|
+
deploy: "bg-accent-secondary",
|
|
32
|
+
mitigated: "bg-intent-success",
|
|
33
|
+
resolved: "bg-intent-success"
|
|
34
|
+
};
|
|
35
|
+
var incidentTimeline = recipe({
|
|
36
|
+
slots: {
|
|
37
|
+
root: "flex min-w-0 flex-col gap-4 font-mono text-sm text-content-primary",
|
|
38
|
+
header: "flex flex-wrap items-center gap-2",
|
|
39
|
+
title: "mr-auto text-base font-bold",
|
|
40
|
+
summary: "grid grid-cols-2 gap-px border-2 border-edge-strong bg-edge-strong sm:grid-cols-5",
|
|
41
|
+
stat: "flex flex-col gap-0.5 bg-surface-raised px-3 py-2",
|
|
42
|
+
statLabel: "text-xs uppercase tracking-wider text-content-muted",
|
|
43
|
+
statValue: "font-bold tabular-nums",
|
|
44
|
+
list: "flex flex-col",
|
|
45
|
+
item: "grid grid-cols-[minmax(0,9.5rem)_1rem_minmax(0,1fr)] gap-x-3",
|
|
46
|
+
gapRow: "col-span-3 grid grid-cols-subgrid",
|
|
47
|
+
gapLabel: "col-start-3 py-1 text-xs tabular-nums text-content-muted",
|
|
48
|
+
time: "pt-0.5 text-right text-xs tabular-nums text-content-secondary",
|
|
49
|
+
rail: "flex flex-col items-center",
|
|
50
|
+
railLine: "w-0.5 flex-1 bg-edge-subtle",
|
|
51
|
+
marker: "mt-1 size-3 shrink-0 border-2 border-edge-strong",
|
|
52
|
+
body: "flex min-w-0 flex-col gap-0.5 pb-3",
|
|
53
|
+
kind: "text-xs font-bold uppercase text-content-muted",
|
|
54
|
+
eventTitle: "font-bold",
|
|
55
|
+
eventButton: "text-left font-bold underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-primary",
|
|
56
|
+
detail: "text-content-secondary",
|
|
57
|
+
author: "text-xs text-content-muted",
|
|
58
|
+
empty: "text-content-muted"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var dash = (ms) => ms === null ? "\u2014" : formatRangeDuration(ms);
|
|
62
|
+
var IncidentTimeline = forwardRef(function IncidentTimeline2({ events, title, severity, now, order = "oldest-first", onEventSelect, label = "Incident timeline", className, ...props }, ref) {
|
|
63
|
+
const summary = useMemo(() => summariseIncident(events, now), [events, now]);
|
|
64
|
+
const chronological = useMemo(() => [...events].sort((a, b) => a.time - b.time), [events]);
|
|
65
|
+
const shown = order === "newest-first" ? [...chronological].reverse() : chronological;
|
|
66
|
+
const styles = incidentTimeline();
|
|
67
|
+
const status = summary.status === "resolved" ? "RESOLVED" : `ONGOING${summary.duration === null ? "" : ` \xB7 ${formatRangeDuration(summary.duration)}`}`;
|
|
68
|
+
const stats = [
|
|
69
|
+
["Status", summary.status === "ongoing" && summary.duration !== null ? `ongoing \xB7 ${formatRangeDuration(summary.duration)}` : summary.status],
|
|
70
|
+
["To acknowledge", dash(summary.timeToAcknowledge)],
|
|
71
|
+
["To mitigate", dash(summary.timeToMitigate)],
|
|
72
|
+
["To resolve", dash(summary.timeToResolve)],
|
|
73
|
+
["Duration", dash(summary.duration)]
|
|
74
|
+
];
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { ref, "data-slot": "incident-timeline", "data-status": summary.status, ...props, className: styles.root({ className }), children: [
|
|
76
|
+
title || severity ? /* @__PURE__ */ jsxs("div", { "data-slot": "incident-timeline-header", className: styles.header(), children: [
|
|
77
|
+
title ? /* @__PURE__ */ jsx("span", { className: styles.title(), children: title }) : null,
|
|
78
|
+
severity ? /* @__PURE__ */ jsx(SeverityBadge, { severity }) : null,
|
|
79
|
+
/* @__PURE__ */ jsx(SeverityBadge, { severity: summary.status === "resolved" ? "resolved" : "firing", children: status })
|
|
80
|
+
] }) : null,
|
|
81
|
+
/* @__PURE__ */ jsx("dl", { "data-slot": "incident-timeline-summary", className: styles.summary(), children: stats.map(([name, value]) => /* @__PURE__ */ jsxs("div", { className: styles.stat(), children: [
|
|
82
|
+
/* @__PURE__ */ jsx("dt", { className: styles.statLabel(), children: name }),
|
|
83
|
+
/* @__PURE__ */ jsx("dd", { className: cn(styles.statValue(), name === "Status" && (summary.status === "resolved" ? "text-intent-success" : "text-intent-danger")), children: value })
|
|
84
|
+
] }, name)) }),
|
|
85
|
+
shown.length === 0 ? /* @__PURE__ */ jsx("p", { className: styles.empty(), children: "No events yet." }) : /* @__PURE__ */ jsx("ol", { "aria-label": label, className: styles.list(), children: shown.map((event, index) => {
|
|
86
|
+
const previous = shown[index - 1];
|
|
87
|
+
const gap = previous ? Math.abs(event.time - previous.time) : null;
|
|
88
|
+
const isLast = index === shown.length - 1;
|
|
89
|
+
return /* @__PURE__ */ jsxs("li", { "data-slot": "incident-timeline-event", "data-kind": event.kind, className: styles.item(), children: [
|
|
90
|
+
gap === null ? null : /* @__PURE__ */ jsxs("div", { className: styles.gapRow(), children: [
|
|
91
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true" }),
|
|
92
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles.rail(), children: /* @__PURE__ */ jsx("span", { className: styles.railLine() }) }),
|
|
93
|
+
/* @__PURE__ */ jsxs("span", { "data-slot": "incident-timeline-gap", className: styles.gapLabel(), children: [
|
|
94
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Gap " }),
|
|
95
|
+
"+",
|
|
96
|
+
formatRangeDuration(gap)
|
|
97
|
+
] })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsx("time", { dateTime: new Date(event.time).toISOString(), className: styles.time(), children: formatTimestamp(event.time) }),
|
|
100
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: styles.rail(), children: [
|
|
101
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "incident-timeline-marker", className: cn(styles.marker(), MARKER[event.kind]) }),
|
|
102
|
+
isLast ? null : /* @__PURE__ */ jsx("span", { className: styles.railLine() })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsxs("div", { className: styles.body(), children: [
|
|
105
|
+
/* @__PURE__ */ jsx("span", { className: styles.kind(), children: event.kind }),
|
|
106
|
+
onEventSelect ? /* @__PURE__ */ jsx("button", { type: "button", className: styles.eventButton(), onClick: () => onEventSelect(event), children: event.title }) : /* @__PURE__ */ jsx("span", { className: styles.eventTitle(), children: event.title }),
|
|
107
|
+
event.detail ? /* @__PURE__ */ jsx("p", { className: styles.detail(), children: event.detail }) : null,
|
|
108
|
+
event.author ? /* @__PURE__ */ jsxs("span", { className: styles.author(), children: [
|
|
109
|
+
"\u2014 ",
|
|
110
|
+
event.author
|
|
111
|
+
] }) : null
|
|
112
|
+
] })
|
|
113
|
+
] }, event.id);
|
|
114
|
+
}) })
|
|
115
|
+
] });
|
|
116
|
+
});
|
|
117
|
+
IncidentTimeline.displayName = "IncidentTimeline";
|
|
118
|
+
export {
|
|
119
|
+
IncidentTimeline,
|
|
120
|
+
summariseIncident
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=IncidentTimeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/IncidentTimeline.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useMemo, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn, recipe } from '../lib/recipe';\nimport { formatRangeDuration, formatTimestamp } from '../lib/timeRange';\nimport type { AlertSeverity } from '../lib/severity';\nimport { SeverityBadge } from './SeverityBadge';\n\n/** What happened at one point in an incident. */\nexport type IncidentEventKind = 'detected' | 'alert' | 'acknowledged' | 'update' | 'deploy' | 'mitigated' | 'resolved';\n\n/** One entry in an incident's log. */\nexport interface IncidentEvent {\n /** Stable identity, used for React keys and `onEventSelect`. */\n id: string;\n /** When it happened, in epoch milliseconds. */\n time: number;\n /** What kind of event it is; decides the marker's role colour and the summary's milestones. */\n kind: IncidentEventKind;\n /** One line on what happened. */\n title: string;\n /** Longer prose under the title. */\n detail?: string;\n /** Who did it or wrote it. */\n author?: string;\n}\n\n/** The milestones of an incident, measured from its first `detected` or `alert` event. */\nexport interface IncidentSummary {\n /** `resolved` once any `resolved` event exists, `ongoing` otherwise. */\n status: 'ongoing' | 'resolved';\n /**\n * When the incident started: the first `detected` or `alert` event, or the\n * earliest event of any kind when there is neither. `null` with no events.\n */\n start: number | null;\n /** Milliseconds from start to the first `acknowledged` event; `null` when there is none. */\n timeToAcknowledge: number | null;\n /** Milliseconds from start to the first `mitigated` event; `null` when there is none. */\n timeToMitigate: number | null;\n /** Milliseconds from start to the first `resolved` event; `null` when there is none. */\n timeToResolve: number | null;\n /**\n * Total length: to the resolution when resolved; to `now` when ongoing and\n * `now` is given; otherwise to the latest event.\n */\n duration: number | null;\n}\n\n/** Compute an incident's status and milestones from its events. Pure; order of `events` does not matter. */\nexport function summariseIncident(events: readonly IncidentEvent[], now?: number): IncidentSummary {\n const sorted = [...events].sort((a, b) => a.time - b.time);\n const first = (kinds: readonly IncidentEventKind[]) => sorted.find((event) => kinds.includes(event.kind))?.time ?? null;\n const start = first(['detected', 'alert']) ?? sorted[0]?.time ?? null;\n const since = (time: number | null) => (time === null || start === null ? null : Math.max(0, time - start));\n const resolvedAt = first(['resolved']);\n const last = sorted[sorted.length - 1]?.time ?? null;\n const end = resolvedAt ?? (now !== undefined && Number.isFinite(now) ? Math.max(now, last ?? now) : last);\n return {\n status: resolvedAt === null ? 'ongoing' : 'resolved',\n start,\n timeToAcknowledge: since(first(['acknowledged'])),\n timeToMitigate: since(first(['mitigated'])),\n timeToResolve: since(resolvedAt),\n duration: since(end),\n };\n}\n\n/** Marker fill by kind — a role, never a hue. */\nconst MARKER: Record<IncidentEventKind, string> = {\n detected: 'bg-intent-danger',\n alert: 'bg-intent-danger',\n acknowledged: 'bg-intent-warning',\n update: 'bg-intent-info',\n deploy: 'bg-accent-secondary',\n mitigated: 'bg-intent-success',\n resolved: 'bg-intent-success',\n};\n\nconst incidentTimeline = recipe({\n slots: {\n root: 'flex min-w-0 flex-col gap-4 font-mono text-sm text-content-primary',\n header: 'flex flex-wrap items-center gap-2',\n title: 'mr-auto text-base font-bold',\n summary: 'grid grid-cols-2 gap-px border-2 border-edge-strong bg-edge-strong sm:grid-cols-5',\n stat: 'flex flex-col gap-0.5 bg-surface-raised px-3 py-2',\n statLabel: 'text-xs uppercase tracking-wider text-content-muted',\n statValue: 'font-bold tabular-nums',\n list: 'flex flex-col',\n item: 'grid grid-cols-[minmax(0,9.5rem)_1rem_minmax(0,1fr)] gap-x-3',\n gapRow: 'col-span-3 grid grid-cols-subgrid',\n gapLabel: 'col-start-3 py-1 text-xs tabular-nums text-content-muted',\n time: 'pt-0.5 text-right text-xs tabular-nums text-content-secondary',\n rail: 'flex flex-col items-center',\n railLine: 'w-0.5 flex-1 bg-edge-subtle',\n marker: 'mt-1 size-3 shrink-0 border-2 border-edge-strong',\n body: 'flex min-w-0 flex-col gap-0.5 pb-3',\n kind: 'text-xs font-bold uppercase text-content-muted',\n eventTitle: 'font-bold',\n eventButton: 'text-left font-bold underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-primary',\n detail: 'text-content-secondary',\n author: 'text-xs text-content-muted',\n empty: 'text-content-muted',\n },\n});\n\nexport interface IncidentTimelineProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The incident's log, in any order. */\n events: readonly IncidentEvent[];\n /** The incident's name, shown above the summary. */\n title?: ReactNode;\n /** The incident's severity, shown as a badge beside the title. */\n severity?: AlertSeverity;\n /** The time an unresolved incident's duration runs to. Passed in, never read from the clock. */\n now?: number;\n /** `oldest-first` (default) puts the newest event last; `newest-first` reverses it. */\n order?: 'oldest-first' | 'newest-first';\n /** Makes each event's title a button, called with the event when pressed. */\n onEventSelect?: (event: IncidentEvent) => void;\n /** Accessible name for the list of events. Default `Incident timeline`. */\n label?: string;\n}\n\nconst dash = (ms: number | null) => (ms === null ? '—' : formatRangeDuration(ms));\n\n/**\n * An incident's history on a vertical rail: one marker per event, coloured by\n * kind, with its timestamp, title, detail and author, and the time between\n * consecutive events labelled on the rail.\n *\n * A summary strip above it gives the status and the time to acknowledge,\n * mitigate and resolve, measured from the first `detected` or `alert` event —\n * see `summariseIncident`. The events are an `<ol>` with `<time dateTime>`;\n * nothing is interactive unless `onEventSelect` is given.\n */\nexport const IncidentTimeline = forwardRef<HTMLDivElement, IncidentTimelineProps>(function IncidentTimeline(\n { events, title, severity, now, order = 'oldest-first', onEventSelect, label = 'Incident timeline', className, ...props },\n ref,\n) {\n const summary = useMemo(() => summariseIncident(events, now), [events, now]);\n const chronological = useMemo(() => [...events].sort((a, b) => a.time - b.time), [events]);\n const shown = order === 'newest-first' ? [...chronological].reverse() : chronological;\n const styles = incidentTimeline();\n\n const status = summary.status === 'resolved'\n ? 'RESOLVED'\n : `ONGOING${summary.duration === null ? '' : ` · ${formatRangeDuration(summary.duration)}`}`;\n\n const stats: Array<[string, string]> = [\n ['Status', summary.status === 'ongoing' && summary.duration !== null ? `ongoing · ${formatRangeDuration(summary.duration)}` : summary.status],\n ['To acknowledge', dash(summary.timeToAcknowledge)],\n ['To mitigate', dash(summary.timeToMitigate)],\n ['To resolve', dash(summary.timeToResolve)],\n ['Duration', dash(summary.duration)],\n ];\n\n return (\n <div ref={ref} data-slot=\"incident-timeline\" data-status={summary.status} {...props} className={styles.root({ className })}>\n {title || severity ? (\n <div data-slot=\"incident-timeline-header\" className={styles.header()}>\n {title ? <span className={styles.title()}>{title}</span> : null}\n {severity ? <SeverityBadge severity={severity} /> : null}\n <SeverityBadge severity={summary.status === 'resolved' ? 'resolved' : 'firing'}>{status}</SeverityBadge>\n </div>\n ) : null}\n <dl data-slot=\"incident-timeline-summary\" className={styles.summary()}>\n {stats.map(([name, value]) => (\n <div key={name} className={styles.stat()}>\n <dt className={styles.statLabel()}>{name}</dt>\n <dd className={cn(styles.statValue(), name === 'Status' && (summary.status === 'resolved' ? 'text-intent-success' : 'text-intent-danger'))}>\n {value}\n </dd>\n </div>\n ))}\n </dl>\n {shown.length === 0 ? (\n <p className={styles.empty()}>No events yet.</p>\n ) : (\n <ol aria-label={label} className={styles.list()}>\n {shown.map((event, index) => {\n const previous = shown[index - 1];\n const gap = previous ? Math.abs(event.time - previous.time) : null;\n const isLast = index === shown.length - 1;\n return (\n <li key={event.id} data-slot=\"incident-timeline-event\" data-kind={event.kind} className={styles.item()}>\n {gap === null ? null : (\n <div className={styles.gapRow()}>\n <span aria-hidden=\"true\" />\n <span aria-hidden=\"true\" className={styles.rail()}><span className={styles.railLine()} /></span>\n <span data-slot=\"incident-timeline-gap\" className={styles.gapLabel()}><span className=\"sr-only\">Gap </span>+{formatRangeDuration(gap)}</span>\n </div>\n )}\n <time dateTime={new Date(event.time).toISOString()} className={styles.time()}>{formatTimestamp(event.time)}</time>\n <span aria-hidden=\"true\" className={styles.rail()}>\n <span data-slot=\"incident-timeline-marker\" className={cn(styles.marker(), MARKER[event.kind])} />\n {isLast ? null : <span className={styles.railLine()} />}\n </span>\n <div className={styles.body()}>\n <span className={styles.kind()}>{event.kind}</span>\n {onEventSelect ? (\n <button type=\"button\" className={styles.eventButton()} onClick={() => onEventSelect(event)}>{event.title}</button>\n ) : (\n <span className={styles.eventTitle()}>{event.title}</span>\n )}\n {event.detail ? <p className={styles.detail()}>{event.detail}</p> : null}\n {event.author ? <span className={styles.author()}>— {event.author}</span> : null}\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n );\n});\n\nIncidentTimeline.displayName = 'IncidentTimeline';\n"],"mappings":"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","names":["IncidentTimeline"]}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/LatencyHeatmap.tsx
|
|
4
|
+
import { scaleLinear } from "@visx/scale";
|
|
5
|
+
import { forwardRef, useCallback, useEffect, useId, useMemo, useState } from "react";
|
|
6
|
+
import { useMeasuredWidth } from "../hooks/useMeasuredWidth.js";
|
|
7
|
+
import { recipe } from "../lib/recipe.js";
|
|
8
|
+
import {
|
|
9
|
+
formatCount,
|
|
10
|
+
formatLatencyRange,
|
|
11
|
+
formatRequests,
|
|
12
|
+
heatmapCells,
|
|
13
|
+
latencyBuckets,
|
|
14
|
+
intensityLevel,
|
|
15
|
+
intensityThresholds,
|
|
16
|
+
latencyExtent,
|
|
17
|
+
latencyRowPosition,
|
|
18
|
+
percentile,
|
|
19
|
+
percentiles as samplePercentiles
|
|
20
|
+
} from "../lib/latency.js";
|
|
21
|
+
import { bucketTimes, formatClock, formatRange, formatTimeTick, normaliseRange, timeTicks } from "../lib/timeRange.js";
|
|
22
|
+
import { formatTraceDuration } from "../lib/trace.js";
|
|
23
|
+
import { useTimeCursor, useTimeRange } from "./TimeRange.js";
|
|
24
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
var FALLBACK_WIDTH = 640;
|
|
26
|
+
var LAYOUT = {
|
|
27
|
+
regular: { margin: { top: 8, right: 16, bottom: 24, left: 48 }, font: 10, height: 240, tickGap: 16 },
|
|
28
|
+
compact: { margin: { top: 4, right: 8, bottom: 18, left: 38 }, font: 9, height: 160, tickGap: 13 }
|
|
29
|
+
};
|
|
30
|
+
var OVERLAY_STROKES = ["stroke-content-primary", "stroke-accent-secondary", "stroke-accent-tertiary", "stroke-intent-warning"];
|
|
31
|
+
var LATENCY_HEATMAP_VARIANTS = {
|
|
32
|
+
colorScale: ["sqrt", "linear", "log", "quantile"],
|
|
33
|
+
colorSteps: [6, 3, 4, 5, 7, 8, 9],
|
|
34
|
+
density: ["regular", "compact"],
|
|
35
|
+
showLegend: [true, false],
|
|
36
|
+
zoomable: [true, false],
|
|
37
|
+
cellGap: [1, 0, 2, 4],
|
|
38
|
+
percentileOverlay: [[], [50], [50, 99]]
|
|
39
|
+
};
|
|
40
|
+
function stepOpacity(level, steps) {
|
|
41
|
+
if (level <= 0) return 0;
|
|
42
|
+
if (steps <= 1) return 1;
|
|
43
|
+
return Number((0.14 + 0.86 * (level - 1) / (steps - 1)).toFixed(3));
|
|
44
|
+
}
|
|
45
|
+
var latencyHeatmap = recipe({
|
|
46
|
+
slots: {
|
|
47
|
+
root: "flex min-w-0 flex-col gap-1 font-mono text-xs text-content-primary",
|
|
48
|
+
title: "text-xs uppercase tracking-wide text-content-secondary",
|
|
49
|
+
frame: "w-full min-w-0",
|
|
50
|
+
chart: "block max-w-full cursor-crosshair select-none overflow-visible focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-primary",
|
|
51
|
+
footer: "flex flex-wrap items-center justify-between gap-x-4 gap-y-1",
|
|
52
|
+
readout: "min-h-[1.5em] tabular-nums text-content-secondary",
|
|
53
|
+
legend: "flex items-center gap-1.5 text-content-muted",
|
|
54
|
+
empty: "border border-dashed border-edge-default px-3 py-6 text-center text-content-muted"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var LatencyHeatmap = forwardRef(function LatencyHeatmap2({
|
|
58
|
+
points,
|
|
59
|
+
range: rangeProp,
|
|
60
|
+
columns: columnsProp = 60,
|
|
61
|
+
rows: rowsProp = 16,
|
|
62
|
+
min,
|
|
63
|
+
max,
|
|
64
|
+
height: heightProp,
|
|
65
|
+
title,
|
|
66
|
+
onCellSelect,
|
|
67
|
+
onRangeSelect,
|
|
68
|
+
zoomable = true,
|
|
69
|
+
formatValue = formatTraceDuration,
|
|
70
|
+
colorSteps = 6,
|
|
71
|
+
colorScale = "sqrt",
|
|
72
|
+
cellGap = 1,
|
|
73
|
+
showLegend = true,
|
|
74
|
+
density = "regular",
|
|
75
|
+
percentileOverlay,
|
|
76
|
+
className,
|
|
77
|
+
...props
|
|
78
|
+
}, ref) {
|
|
79
|
+
const id = useId();
|
|
80
|
+
const layout = LAYOUT[density] ?? LAYOUT.regular;
|
|
81
|
+
const MARGIN = layout.margin;
|
|
82
|
+
const height = heightProp ?? layout.height;
|
|
83
|
+
const steps = Math.max(3, Math.min(9, Math.round(Number.isFinite(colorSteps) ? colorSteps : 6)));
|
|
84
|
+
const styles = latencyHeatmap();
|
|
85
|
+
const [measureRef, width] = useMeasuredWidth(FALLBACK_WIDTH);
|
|
86
|
+
const shared = useTimeRange();
|
|
87
|
+
const sharedCursor = useTimeCursor();
|
|
88
|
+
const range = useMemo(() => {
|
|
89
|
+
const explicit = normaliseRange(rangeProp) ?? shared?.range ?? null;
|
|
90
|
+
if (explicit) return explicit;
|
|
91
|
+
let from = Number.POSITIVE_INFINITY;
|
|
92
|
+
let to = Number.NEGATIVE_INFINITY;
|
|
93
|
+
for (const point of points) {
|
|
94
|
+
if (!Number.isFinite(point.time)) continue;
|
|
95
|
+
if (point.time < from) from = point.time;
|
|
96
|
+
if (point.time > to) to = point.time;
|
|
97
|
+
}
|
|
98
|
+
if (to < from) return null;
|
|
99
|
+
return to === from ? { from: from - 3e4, to: to + 3e4 } : { from, to };
|
|
100
|
+
}, [rangeProp, shared?.range, points]);
|
|
101
|
+
const columns = Math.max(1, Math.floor(columnsProp));
|
|
102
|
+
const rows = Math.max(1, Math.floor(rowsProp));
|
|
103
|
+
const inRange = useMemo(() => range ? points.filter((point) => point.time >= range.from && point.time <= range.to && Number.isFinite(point.value)) : [], [points, range]);
|
|
104
|
+
const grid = useMemo(() => {
|
|
105
|
+
if (!range) return null;
|
|
106
|
+
const extent = latencyExtent(inRange.map((point) => point.value));
|
|
107
|
+
const edges = latencyBuckets(min ?? extent?.min ?? 1, max ?? extent?.max ?? 1e3, rows);
|
|
108
|
+
return { ...heatmapCells(inRange, bucketTimes(range, columns), edges), edges };
|
|
109
|
+
}, [range, inRange, min, max, rows, columns]);
|
|
110
|
+
const p99 = useMemo(() => percentile(inRange.map((point) => point.value), 99), [inRange]);
|
|
111
|
+
const thresholds = useMemo(() => grid ? intensityThresholds(grid.cells.map((cell) => cell.count), steps, colorScale) : [], [grid, steps, colorScale]);
|
|
112
|
+
const overlayKey = (percentileOverlay ?? []).join(",");
|
|
113
|
+
const overlays = useMemo(() => {
|
|
114
|
+
const ps = overlayKey ? overlayKey.split(",").map(Number).filter((p) => Number.isFinite(p)) : [];
|
|
115
|
+
if (!range || !grid || !ps.length) return [];
|
|
116
|
+
const byColumn = Array.from({ length: columns }, () => []);
|
|
117
|
+
const span = range.to - range.from;
|
|
118
|
+
for (const point of inRange) {
|
|
119
|
+
const column = span > 0 ? Math.min(columns - 1, Math.floor((point.time - range.from) / span * columns)) : 0;
|
|
120
|
+
byColumn[column].push(point.value);
|
|
121
|
+
}
|
|
122
|
+
const perColumn = byColumn.map((values) => samplePercentiles(values, ps));
|
|
123
|
+
return ps.map((p, index) => ({ p, rows: perColumn.map((values) => latencyRowPosition(values[index], grid.edges)) }));
|
|
124
|
+
}, [overlayKey, range, grid, columns, inRange]);
|
|
125
|
+
const busiest = useMemo(() => grid?.cells.reduce((best, cell) => cell.count > (best?.count ?? 0) ? cell : best, null) ?? null, [grid]);
|
|
126
|
+
const innerWidth = Math.max(10, width - MARGIN.left - MARGIN.right - (overlayKey ? 22 : 0));
|
|
127
|
+
const innerHeight = Math.max(10, height - MARGIN.top - MARGIN.bottom);
|
|
128
|
+
const cellWidth = innerWidth / columns;
|
|
129
|
+
const cellHeight = innerHeight / rows;
|
|
130
|
+
const gap = Math.max(0, Number.isFinite(cellGap) ? cellGap : 1);
|
|
131
|
+
const gapX = Math.min(gap, cellWidth / 2, gap === 1 && cellWidth <= 4 ? 0 : Number.POSITIVE_INFINITY);
|
|
132
|
+
const gapY = Math.min(gap, cellHeight / 2, gap === 1 && cellHeight <= 4 ? 0 : Number.POSITIVE_INFINITY);
|
|
133
|
+
const xScale = useMemo(() => scaleLinear({ domain: range ? [range.from, range.to] : [0, 1], range: [0, innerWidth] }), [range, innerWidth]);
|
|
134
|
+
const [hover, setHover] = useState(null);
|
|
135
|
+
const [focusCell, setFocusCell] = useState(null);
|
|
136
|
+
const [focused, setFocused] = useState(false);
|
|
137
|
+
const [selected, setSelected] = useState(null);
|
|
138
|
+
const [drag, setDrag] = useState(null);
|
|
139
|
+
const brushable = zoomable && Boolean(shared || onRangeSelect);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!drag) return void 0;
|
|
142
|
+
const cancel = () => setDrag(null);
|
|
143
|
+
window.addEventListener("mouseup", cancel);
|
|
144
|
+
return () => window.removeEventListener("mouseup", cancel);
|
|
145
|
+
}, [drag]);
|
|
146
|
+
const cellOf = (position) => grid && position ? grid.cells[position.column * grid.rows + position.row] ?? null : null;
|
|
147
|
+
const centre = (column) => grid ? (grid.cells[column * grid.rows].timeRange.from + grid.cells[column * grid.rows].timeRange.to) / 2 : 0;
|
|
148
|
+
const setCursor = sharedCursor?.setCursor;
|
|
149
|
+
const positionAt = useCallback((event) => {
|
|
150
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
151
|
+
const x = (event.clientX - box.left) * (box.width > 0 ? width / box.width : 1) - MARGIN.left;
|
|
152
|
+
const y = (event.clientY - box.top) * (box.height > 0 ? height / box.height : 1) - MARGIN.top;
|
|
153
|
+
const column = Math.max(0, Math.min(columns - 1, Math.floor(x / cellWidth)));
|
|
154
|
+
const row = rows - 1 - Math.floor(y / cellHeight);
|
|
155
|
+
return { column, row, inside: x >= 0 && x <= innerWidth && y >= 0 && y <= innerHeight && row >= 0 && row < rows };
|
|
156
|
+
}, [width, height, columns, rows, cellWidth, cellHeight, innerWidth, innerHeight, MARGIN]);
|
|
157
|
+
const select = (position) => {
|
|
158
|
+
const cell = cellOf(position);
|
|
159
|
+
if (!cell || !onCellSelect) return;
|
|
160
|
+
setSelected(position);
|
|
161
|
+
onCellSelect(cell);
|
|
162
|
+
};
|
|
163
|
+
const onMouseDown = (event) => {
|
|
164
|
+
if (event.button !== 0) return;
|
|
165
|
+
const at = positionAt(event);
|
|
166
|
+
if (!at.inside) return;
|
|
167
|
+
setDrag({ start: at.column, end: at.column });
|
|
168
|
+
};
|
|
169
|
+
const onMouseMove = (event) => {
|
|
170
|
+
const at = positionAt(event);
|
|
171
|
+
if (drag) setDrag({ ...drag, end: at.column });
|
|
172
|
+
if (!at.inside) {
|
|
173
|
+
setHover(null);
|
|
174
|
+
setCursor?.(null);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
setHover({ column: at.column, row: at.row });
|
|
178
|
+
setCursor?.(centre(at.column));
|
|
179
|
+
};
|
|
180
|
+
const onMouseUp = (event) => {
|
|
181
|
+
const at = positionAt(event);
|
|
182
|
+
const current = drag;
|
|
183
|
+
setDrag(null);
|
|
184
|
+
if (current && brushable && grid && Math.abs(at.column - current.start) >= 1) {
|
|
185
|
+
const first = Math.min(at.column, current.start);
|
|
186
|
+
const last = Math.max(at.column, current.start);
|
|
187
|
+
const zoomed = { from: grid.cells[first * grid.rows].timeRange.from, to: grid.cells[last * grid.rows].timeRange.to };
|
|
188
|
+
if (zoomable && shared) shared.setRange(zoomed);
|
|
189
|
+
onRangeSelect?.(zoomed);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (at.inside) {
|
|
193
|
+
setFocusCell({ column: at.column, row: at.row });
|
|
194
|
+
select({ column: at.column, row: at.row });
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const onMouseLeave = () => {
|
|
198
|
+
setHover(null);
|
|
199
|
+
setCursor?.(null);
|
|
200
|
+
};
|
|
201
|
+
const onKeyDown = (event) => {
|
|
202
|
+
const current = focusCell ?? (busiest ? { column: busiest.column, row: busiest.row } : { column: 0, row: 0 });
|
|
203
|
+
let next = current;
|
|
204
|
+
switch (event.key) {
|
|
205
|
+
case "ArrowRight":
|
|
206
|
+
next = { ...current, column: Math.min(columns - 1, current.column + 1) };
|
|
207
|
+
break;
|
|
208
|
+
case "ArrowLeft":
|
|
209
|
+
next = { ...current, column: Math.max(0, current.column - 1) };
|
|
210
|
+
break;
|
|
211
|
+
case "ArrowUp":
|
|
212
|
+
next = { ...current, row: Math.min(rows - 1, current.row + 1) };
|
|
213
|
+
break;
|
|
214
|
+
case "ArrowDown":
|
|
215
|
+
next = { ...current, row: Math.max(0, current.row - 1) };
|
|
216
|
+
break;
|
|
217
|
+
case "Home":
|
|
218
|
+
next = { ...current, column: 0 };
|
|
219
|
+
break;
|
|
220
|
+
case "End":
|
|
221
|
+
next = { ...current, column: columns - 1 };
|
|
222
|
+
break;
|
|
223
|
+
case "PageUp":
|
|
224
|
+
next = { ...current, row: rows - 1 };
|
|
225
|
+
break;
|
|
226
|
+
case "PageDown":
|
|
227
|
+
next = { ...current, row: 0 };
|
|
228
|
+
break;
|
|
229
|
+
case "Enter":
|
|
230
|
+
case " ":
|
|
231
|
+
select(current);
|
|
232
|
+
break;
|
|
233
|
+
default:
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
setHover(null);
|
|
238
|
+
setFocusCell(next);
|
|
239
|
+
setCursor?.(centre(next.column));
|
|
240
|
+
};
|
|
241
|
+
const timeSpan = range ? range.to - range.from : 0;
|
|
242
|
+
const columnSpan = timeSpan / columns;
|
|
243
|
+
const describeCell = useCallback((cell) => {
|
|
244
|
+
const seconds = columnSpan < 6e4 || Math.abs(columnSpan / 6e4 - Math.round(columnSpan / 6e4)) > 1e-6;
|
|
245
|
+
return `${formatClock(cell.timeRange.from, seconds)}\u2013${formatClock(cell.timeRange.to, seconds)} \xB7 ${formatLatencyRange(cell.latencyRange.from, cell.latencyRange.to, formatValue)} \xB7 ${formatRequests(cell.count)}`;
|
|
246
|
+
}, [columnSpan, formatValue]);
|
|
247
|
+
const cellLayer = useMemo(() => {
|
|
248
|
+
if (!grid) return null;
|
|
249
|
+
return Array.from({ length: grid.rows }, (_, offset) => {
|
|
250
|
+
const row = grid.rows - 1 - offset;
|
|
251
|
+
return /* @__PURE__ */ jsx("g", { role: "row", children: Array.from({ length: grid.columns }, (_2, column) => {
|
|
252
|
+
const cell = grid.cells[column * grid.rows + row];
|
|
253
|
+
const level = intensityLevel(cell.count, thresholds);
|
|
254
|
+
return /* @__PURE__ */ jsx(
|
|
255
|
+
"rect",
|
|
256
|
+
{
|
|
257
|
+
id: `${id}-c${column}-${row}`,
|
|
258
|
+
role: "gridcell",
|
|
259
|
+
"aria-label": `${describeCell(cell)} UTC`,
|
|
260
|
+
"data-level": level,
|
|
261
|
+
x: column * cellWidth,
|
|
262
|
+
y: offset * cellHeight,
|
|
263
|
+
width: Math.max(0.5, cellWidth - gapX),
|
|
264
|
+
height: Math.max(0.5, cellHeight - gapY),
|
|
265
|
+
fillOpacity: stepOpacity(level, thresholds.length),
|
|
266
|
+
className: "fill-accent-primary"
|
|
267
|
+
},
|
|
268
|
+
column
|
|
269
|
+
);
|
|
270
|
+
}) }, row);
|
|
271
|
+
});
|
|
272
|
+
}, [grid, id, cellWidth, cellHeight, gapX, gapY, thresholds, describeCell]);
|
|
273
|
+
if (!range || !grid || !grid.total) {
|
|
274
|
+
return /* @__PURE__ */ jsxs("div", { ref, "data-slot": "latency-heatmap", "data-empty": "", ...props, className: styles.root({ className }), children: [
|
|
275
|
+
title ? /* @__PURE__ */ jsx("p", { className: styles.title(), children: title }) : null,
|
|
276
|
+
/* @__PURE__ */ jsx("p", { className: styles.empty(), children: "No samples." })
|
|
277
|
+
] });
|
|
278
|
+
}
|
|
279
|
+
const label = title ?? "Latency heatmap";
|
|
280
|
+
const summary = [
|
|
281
|
+
`${formatRequests(grid.total)} between ${formatRange(range)} UTC.`,
|
|
282
|
+
busiest ? `Busiest cell: ${describeCell(busiest)}.` : "",
|
|
283
|
+
Number.isFinite(p99) ? `Overall p99 ${formatValue(p99)}.` : ""
|
|
284
|
+
].filter(Boolean).join(" ");
|
|
285
|
+
const rectFor = (position) => ({ x: position.column * cellWidth, y: (rows - 1 - position.row) * cellHeight, width: cellWidth, height: cellHeight });
|
|
286
|
+
const activeFocus = focused ? focusCell : null;
|
|
287
|
+
const shown = cellOf(hover ?? activeFocus ?? (onCellSelect ? selected : null));
|
|
288
|
+
const cursorTime = sharedCursor ? sharedCursor.cursor : hover ? centre(hover.column) : null;
|
|
289
|
+
const cursorX = cursorTime !== null && cursorTime >= range.from && cursorTime <= range.to ? xScale(cursorTime) : null;
|
|
290
|
+
const ticks = timeTicks(range, Math.max(2, Math.floor(innerWidth / 90)));
|
|
291
|
+
const labelEvery = Math.max(1, Math.ceil(rows / Math.max(1, Math.floor(innerHeight / 24))));
|
|
292
|
+
const brush = drag && brushable && drag.end !== drag.start ? { from: Math.min(drag.start, drag.end), to: Math.max(drag.start, drag.end) } : null;
|
|
293
|
+
return /* @__PURE__ */ jsxs("div", { ref, "data-slot": "latency-heatmap", ...props, className: styles.root({ className }), children: [
|
|
294
|
+
title ? /* @__PURE__ */ jsx("p", { "aria-hidden": "true", className: styles.title(), children: title }) : null,
|
|
295
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-summary`, className: "sr-only", children: summary }),
|
|
296
|
+
/* @__PURE__ */ jsx("div", { ref: measureRef, className: styles.frame(), children: /* @__PURE__ */ jsxs(
|
|
297
|
+
"svg",
|
|
298
|
+
{
|
|
299
|
+
role: "grid",
|
|
300
|
+
tabIndex: 0,
|
|
301
|
+
"aria-label": label,
|
|
302
|
+
"aria-describedby": `${id}-summary`,
|
|
303
|
+
"aria-activedescendant": activeFocus ? `${id}-c${activeFocus.column}-${activeFocus.row}` : void 0,
|
|
304
|
+
width,
|
|
305
|
+
height,
|
|
306
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
307
|
+
className: styles.chart(),
|
|
308
|
+
onKeyDown,
|
|
309
|
+
onFocus: () => {
|
|
310
|
+
setFocused(true);
|
|
311
|
+
if (!focusCell && busiest) setFocusCell({ column: busiest.column, row: busiest.row });
|
|
312
|
+
},
|
|
313
|
+
onBlur: () => {
|
|
314
|
+
setFocused(false);
|
|
315
|
+
setCursor?.(null);
|
|
316
|
+
},
|
|
317
|
+
onMouseDown,
|
|
318
|
+
onMouseMove,
|
|
319
|
+
onMouseUp,
|
|
320
|
+
onMouseLeave,
|
|
321
|
+
children: [
|
|
322
|
+
/* @__PURE__ */ jsxs("g", { "aria-hidden": "true", transform: `translate(${MARGIN.left},${MARGIN.top})`, children: [
|
|
323
|
+
/* @__PURE__ */ jsx("rect", { x: 0, y: 0, width: innerWidth, height: innerHeight, fill: "none", className: "stroke-edge-subtle" }),
|
|
324
|
+
grid.edges.map((edge, index) => index % labelEvery === 0 || index === rows ? /* @__PURE__ */ jsxs("g", { transform: `translate(0,${innerHeight - index * cellHeight})`, children: [
|
|
325
|
+
/* @__PURE__ */ jsx("line", { x1: -4, x2: 0, className: "stroke-edge-default" }),
|
|
326
|
+
/* @__PURE__ */ jsx("text", { x: -6, textAnchor: "end", dominantBaseline: "central", fontSize: layout.font, className: "fill-content-muted", children: formatValue(edge) })
|
|
327
|
+
] }, index) : null),
|
|
328
|
+
ticks.map((tick) => /* @__PURE__ */ jsxs("g", { transform: `translate(${xScale(tick)},${innerHeight})`, children: [
|
|
329
|
+
/* @__PURE__ */ jsx("line", { y1: 0, y2: 4, className: "stroke-edge-default" }),
|
|
330
|
+
/* @__PURE__ */ jsx("text", { y: layout.tickGap, textAnchor: "middle", fontSize: layout.font, className: "fill-content-muted", children: formatTimeTick(tick, timeSpan) })
|
|
331
|
+
] }, tick))
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ jsx("g", { transform: `translate(${MARGIN.left},${MARGIN.top})`, children: cellLayer }),
|
|
334
|
+
/* @__PURE__ */ jsxs("g", { "aria-hidden": "true", transform: `translate(${MARGIN.left},${MARGIN.top})`, pointerEvents: "none", children: [
|
|
335
|
+
brush ? /* @__PURE__ */ jsx("rect", { "data-part": "brush", x: brush.from * cellWidth, y: 0, width: (brush.to - brush.from + 1) * cellWidth, height: innerHeight, fillOpacity: 0.12, className: "fill-accent-primary stroke-accent-primary" }) : null,
|
|
336
|
+
overlays.map((overlay, index) => {
|
|
337
|
+
let d = "";
|
|
338
|
+
let open = false;
|
|
339
|
+
overlay.rows.forEach((row, column) => {
|
|
340
|
+
if (!Number.isFinite(row)) {
|
|
341
|
+
open = false;
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const x = (column + 0.5) * cellWidth;
|
|
345
|
+
const y = innerHeight - row * cellHeight;
|
|
346
|
+
d += `${open ? "L" : "M"}${x.toFixed(1)},${y.toFixed(1)}`;
|
|
347
|
+
open = true;
|
|
348
|
+
});
|
|
349
|
+
let lastColumn = overlay.rows.length - 1;
|
|
350
|
+
while (lastColumn >= 0 && !Number.isFinite(overlay.rows[lastColumn])) lastColumn -= 1;
|
|
351
|
+
return /* @__PURE__ */ jsxs("g", { "data-part": "percentile-overlay", "data-percentile": overlay.p, children: [
|
|
352
|
+
/* @__PURE__ */ jsx("path", { d, fill: "none", strokeWidth: 1.5, strokeLinejoin: "round", className: OVERLAY_STROKES[index % OVERLAY_STROKES.length] }),
|
|
353
|
+
lastColumn >= 0 ? /* @__PURE__ */ jsx("text", { x: innerWidth + 2, y: innerHeight - overlay.rows[lastColumn] * cellHeight, dominantBaseline: "central", fontSize: layout.font, className: "fill-content-secondary", children: `p${overlay.p}` }) : null
|
|
354
|
+
] }, overlay.p);
|
|
355
|
+
}),
|
|
356
|
+
cursorX !== null ? /* @__PURE__ */ jsx("line", { "data-part": "cursor", x1: cursorX, x2: cursorX, y1: 0, y2: innerHeight, strokeWidth: 1, className: "stroke-content-secondary" }) : null,
|
|
357
|
+
hover ? /* @__PURE__ */ jsx("rect", { "data-part": "hover", ...rectFor(hover), fill: "none", strokeWidth: 1, className: "stroke-content-secondary" }) : null,
|
|
358
|
+
onCellSelect && selected ? /* @__PURE__ */ jsx("rect", { "data-part": "selected", ...rectFor(selected), fill: "none", strokeWidth: 2, className: "stroke-content-primary" }) : null,
|
|
359
|
+
activeFocus ? /* @__PURE__ */ jsx("rect", { "data-part": "focus", ...rectFor(activeFocus), fill: "none", strokeWidth: 1.5, strokeDasharray: "3 2", className: "stroke-content-primary" }) : null
|
|
360
|
+
] })
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
) }),
|
|
364
|
+
/* @__PURE__ */ jsxs("div", { className: styles.footer(), children: [
|
|
365
|
+
/* @__PURE__ */ jsx("p", { "aria-hidden": "true", "data-part": "readout", className: styles.readout(), children: shown ? describeCell(shown) : `${formatRequests(grid.total)}${Number.isFinite(p99) ? ` \xB7 p99 ${formatValue(p99)}` : ""}${brushable ? " \xB7 drag to zoom" : ""}` }),
|
|
366
|
+
showLegend ? /* @__PURE__ */ jsxs("div", { "aria-hidden": "true", "data-part": "legend", className: styles.legend(), children: [
|
|
367
|
+
/* @__PURE__ */ jsx("span", { children: formatCount(thresholds[0] ?? 1) }),
|
|
368
|
+
/* @__PURE__ */ jsx("svg", { width: thresholds.length * 14, height: 10, viewBox: `0 0 ${thresholds.length * 14} 10`, children: thresholds.map((threshold, index) => /* @__PURE__ */ jsx("rect", { "data-threshold": threshold, x: index * 14, y: 0, width: 13, height: 10, fillOpacity: stepOpacity(index + 1, thresholds.length), className: "fill-accent-primary" }, index)) }),
|
|
369
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
370
|
+
formatCount(grid.max),
|
|
371
|
+
" per cell"
|
|
372
|
+
] })
|
|
373
|
+
] }) : null
|
|
374
|
+
] })
|
|
375
|
+
] });
|
|
376
|
+
});
|
|
377
|
+
LatencyHeatmap.displayName = "LatencyHeatmap";
|
|
378
|
+
export {
|
|
379
|
+
LATENCY_HEATMAP_VARIANTS,
|
|
380
|
+
LatencyHeatmap
|
|
381
|
+
};
|
|
382
|
+
//# sourceMappingURL=LatencyHeatmap.js.map
|