@peers-app/peers-ui 0.34.9 → 0.34.11
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/dist/apps-home/apps-home.js +6 -4
- package/dist/components/router.d.ts +1 -1
- package/dist/components/router.js +1 -1
- package/dist/screens/identity/identity-routes.d.ts +2 -1
- package/dist/screens/identity/identity-routes.js +6 -1
- package/dist/screens/monitoring/alerts-tab.d.ts +13 -0
- package/dist/screens/monitoring/alerts-tab.js +68 -0
- package/dist/screens/monitoring/badges.d.ts +25 -0
- package/dist/screens/monitoring/badges.js +68 -0
- package/dist/screens/monitoring/calls-tab.d.ts +30 -0
- package/dist/screens/monitoring/calls-tab.js +104 -0
- package/dist/screens/monitoring/charts/chart-math.d.ts +103 -0
- package/dist/screens/monitoring/charts/chart-math.js +200 -0
- package/dist/screens/monitoring/charts/histogram-chart.d.ts +25 -0
- package/dist/screens/monitoring/charts/histogram-chart.js +74 -0
- package/dist/screens/monitoring/charts/line-chart.d.ts +33 -0
- package/dist/screens/monitoring/charts/line-chart.js +103 -0
- package/dist/screens/monitoring/charts/sparkline.d.ts +30 -0
- package/dist/screens/monitoring/charts/sparkline.js +61 -0
- package/dist/screens/monitoring/charts/use-width.d.ts +9 -0
- package/dist/screens/monitoring/charts/use-width.js +31 -0
- package/dist/screens/monitoring/definition-forms.d.ts +113 -0
- package/dist/screens/monitoring/definition-forms.js +341 -0
- package/dist/screens/monitoring/definitions-tab.d.ts +20 -0
- package/dist/screens/monitoring/definitions-tab.js +110 -0
- package/dist/screens/monitoring/device-picker.d.ts +23 -0
- package/dist/screens/monitoring/device-picker.js +30 -0
- package/dist/screens/monitoring/devices-tab.d.ts +6 -0
- package/dist/screens/monitoring/devices-tab.js +74 -0
- package/dist/screens/monitoring/form-fields.d.ts +76 -0
- package/dist/screens/monitoring/form-fields.js +65 -0
- package/dist/screens/monitoring/format.d.ts +51 -0
- package/dist/screens/monitoring/format.js +150 -0
- package/dist/screens/monitoring/log-lines.d.ts +74 -0
- package/dist/screens/monitoring/log-lines.js +138 -0
- package/dist/screens/monitoring/log-row.d.ts +12 -0
- package/dist/screens/monitoring/log-row.js +23 -0
- package/dist/screens/monitoring/logs-tab.d.ts +15 -0
- package/dist/screens/monitoring/logs-tab.js +256 -0
- package/dist/screens/monitoring/metric-definition-form.d.ts +15 -0
- package/dist/screens/monitoring/metric-definition-form.js +50 -0
- package/dist/screens/monitoring/metrics-tab.d.ts +37 -0
- package/dist/screens/monitoring/metrics-tab.js +149 -0
- package/dist/screens/monitoring/monitored-devices.d.ts +84 -0
- package/dist/screens/monitoring/monitored-devices.js +193 -0
- package/dist/screens/monitoring/monitoring-routes.d.ts +40 -0
- package/dist/screens/monitoring/monitoring-routes.js +82 -0
- package/dist/screens/monitoring/monitoring-screen.d.ts +18 -0
- package/dist/screens/monitoring/monitoring-screen.js +71 -0
- package/dist/screens/monitoring/overview-tab.d.ts +51 -0
- package/dist/screens/monitoring/overview-tab.js +136 -0
- package/dist/screens/monitoring/telemetry-client.d.ts +48 -0
- package/dist/screens/monitoring/telemetry-client.js +92 -0
- package/dist/screens/monitoring/trigger-form.d.ts +18 -0
- package/dist/screens/monitoring/trigger-form.js +71 -0
- package/dist/screens/monitoring/use-telemetry.d.ts +37 -0
- package/dist/screens/monitoring/use-telemetry.js +119 -0
- package/dist/screens/network-viewer/remote-logs-panel.d.ts +1 -1
- package/dist/screens/network-viewer/remote-logs-panel.js +5 -3
- package/dist/system-apps/index.d.ts +1 -1
- package/dist/system-apps/index.js +5 -5
- package/dist/system-apps/monitoring.app.d.ts +6 -0
- package/dist/system-apps/monitoring.app.js +13 -0
- package/dist/tabs-layout/tabs-state.d.ts +4 -2
- package/dist/tabs-layout/tabs-state.js +23 -11
- package/dist/theme.css +32 -0
- package/package.json +3 -3
- package/dist/screens/console-logs/console-logs-list.d.ts +0 -2
- package/dist/screens/console-logs/console-logs-list.js +0 -284
- package/dist/screens/console-logs/follow-newest.d.ts +0 -11
- package/dist/screens/console-logs/follow-newest.js +0 -17
- package/dist/screens/console-logs/log-display.d.ts +0 -12
- package/dist/screens/console-logs/log-display.js +0 -69
- package/dist/screens/console-logs/log-filters.d.ts +0 -10
- package/dist/screens/console-logs/log-filters.js +0 -8
- package/dist/screens/console-logs/mobile-log-card.d.ts +0 -8
- package/dist/screens/console-logs/mobile-log-card.js +0 -94
- package/dist/screens/console-logs/resizable-table-header.d.ts +0 -14
- package/dist/screens/console-logs/resizable-table-header.js +0 -62
- package/dist/system-apps/console-logs.app.d.ts +0 -2
- package/dist/system-apps/console-logs.app.js +0 -8
|
@@ -13,6 +13,7 @@ const delegates_ipc_1 = require("../delegates/delegates-ipc");
|
|
|
13
13
|
const use_observable_1 = require("../hooks/use-observable");
|
|
14
14
|
const use_promise_1 = require("../hooks/use-promise");
|
|
15
15
|
const local_network_offer_1 = require("../local-network/local-network-offer");
|
|
16
|
+
const monitoring_routes_1 = require("../screens/monitoring/monitoring-routes");
|
|
16
17
|
const package_helpers_1 = require("../screens/packages/package-helpers");
|
|
17
18
|
const packages_ipc_1 = require("../screens/packages/packages-ipc");
|
|
18
19
|
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
@@ -227,12 +228,13 @@ function homeSections(catalog, pins, query) {
|
|
|
227
228
|
const pinnedPaths = new Set();
|
|
228
229
|
const pinned = [];
|
|
229
230
|
for (const path of pins) {
|
|
230
|
-
const entry = byPath.get(path);
|
|
231
|
-
if (!entry || pinnedPaths.has(path))
|
|
231
|
+
const entry = byPath.get(path === monitoring_routes_1.LEGACY_CONSOLE_LOGS_PATH ? monitoring_routes_1.MONITORING_APP_PATH : path);
|
|
232
|
+
if (!entry || pinnedPaths.has(entry.path))
|
|
232
233
|
continue;
|
|
233
|
-
pinnedPaths.add(path);
|
|
234
|
+
pinnedPaths.add(entry.path);
|
|
235
|
+
// The stored path also opens the pin and identifies it for reorder and removal.
|
|
234
236
|
if ((0, app_catalog_1.appMatchesQuery)(entry, query))
|
|
235
|
-
pinned.push(entry);
|
|
237
|
+
pinned.push(path === entry.path ? entry : { ...entry, path });
|
|
236
238
|
}
|
|
237
239
|
const rest = catalog.filter((entry) => !pinnedPaths.has(entry.path) && (0, app_catalog_1.appMatchesQuery)(entry, query));
|
|
238
240
|
return {
|
|
@@ -53,7 +53,7 @@ const variable_details_1 = require("../screens/variables/variable-details");
|
|
|
53
53
|
const variable_list_1 = require("../screens/variables/variable-list");
|
|
54
54
|
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
55
55
|
require("../operator-console/console-screen");
|
|
56
|
-
require("../screens/
|
|
56
|
+
require("../screens/monitoring/monitoring-screen");
|
|
57
57
|
require("../screens/identity");
|
|
58
58
|
require("../screens/network-viewer");
|
|
59
59
|
require("../screens/data-explorer");
|
|
@@ -68,7 +68,8 @@ interface ParsedRoute {
|
|
|
68
68
|
*/
|
|
69
69
|
export declare function parseRoute(raw: string | null | undefined): ParsedRoute;
|
|
70
70
|
/**
|
|
71
|
-
* Rewrite legacy identity aliases to their canonical `identity/*` path
|
|
71
|
+
* Rewrite legacy identity aliases to their canonical `identity/*` path, and Console Logs' old
|
|
72
|
+
* `console-logs` path to Monitoring's Logs section.
|
|
72
73
|
*
|
|
73
74
|
* Unrelated routes are returned with only slash cleanup, so other apps keep
|
|
74
75
|
* their existing path casing. `devices?action=pair` becomes the pair route.
|
|
@@ -14,6 +14,7 @@ exports.isIdentityPath = isIdentityPath;
|
|
|
14
14
|
exports.identitySectionFromPath = identitySectionFromPath;
|
|
15
15
|
exports.parseIdentityLocation = parseIdentityLocation;
|
|
16
16
|
exports.identityActivityFilterPath = identityActivityFilterPath;
|
|
17
|
+
const monitoring_routes_1 = require("../monitoring/monitoring-routes");
|
|
17
18
|
/** Top-level Identity app path. Opening this lands on Activity. */
|
|
18
19
|
exports.IDENTITY_APP_PATH = "identity";
|
|
19
20
|
/** Unified invite inbox. */
|
|
@@ -65,7 +66,8 @@ function parseRoute(raw) {
|
|
|
65
66
|
return { pathname, query: new URLSearchParams(queryString) };
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
|
-
* Rewrite legacy identity aliases to their canonical `identity/*` path
|
|
69
|
+
* Rewrite legacy identity aliases to their canonical `identity/*` path, and Console Logs' old
|
|
70
|
+
* `console-logs` path to Monitoring's Logs section.
|
|
69
71
|
*
|
|
70
72
|
* Unrelated routes are returned with only slash cleanup, so other apps keep
|
|
71
73
|
* their existing path casing. `devices?action=pair` becomes the pair route.
|
|
@@ -187,6 +189,9 @@ function rewritePathname(pathname, query) {
|
|
|
187
189
|
else if (root === "account") {
|
|
188
190
|
rewritten = ["identity", "account"];
|
|
189
191
|
}
|
|
192
|
+
else if (root === monitoring_routes_1.LEGACY_CONSOLE_LOGS_PATH) {
|
|
193
|
+
rewritten = monitoring_routes_1.MONITORING_LOGS_PATH.split("/");
|
|
194
|
+
}
|
|
190
195
|
if (!rewritten) {
|
|
191
196
|
return pathname;
|
|
192
197
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ITriggerDefinition } from "@peers-app/peers-sdk";
|
|
2
|
+
import type { MonitoringSectionProps } from "./monitoring-screen";
|
|
3
|
+
/**
|
|
4
|
+
* A trigger's condition in words: "p95 over 5 min > 2000", "ratio over 10 min ≥ 0.2 for 3 min".
|
|
5
|
+
*
|
|
6
|
+
* @param trigger - The trigger.
|
|
7
|
+
*/
|
|
8
|
+
export declare function describeCondition(trigger: ITriggerDefinition): string;
|
|
9
|
+
/**
|
|
10
|
+
* Alerts: each trigger's state on the device and its latest firings, and the user's own triggers
|
|
11
|
+
* to create, edit and delete.
|
|
12
|
+
*/
|
|
13
|
+
export declare function AlertsTab(props: MonitoringSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeCondition = describeCondition;
|
|
4
|
+
exports.AlertsTab = AlertsTab;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const badges_1 = require("./badges");
|
|
8
|
+
const form_fields_1 = require("./form-fields");
|
|
9
|
+
const format_1 = require("./format");
|
|
10
|
+
const telemetry_client_1 = require("./telemetry-client");
|
|
11
|
+
const trigger_form_1 = require("./trigger-form");
|
|
12
|
+
const use_telemetry_1 = require("./use-telemetry");
|
|
13
|
+
/**
|
|
14
|
+
* A trigger's condition in words: "p95 over 5 min > 2000", "ratio over 10 min ≥ 0.2 for 3 min".
|
|
15
|
+
*
|
|
16
|
+
* @param trigger - The trigger.
|
|
17
|
+
*/
|
|
18
|
+
function describeCondition(trigger) {
|
|
19
|
+
const op = { ">": ">", ">=": "≥", "<": "<", "<=": "≤" }[trigger.op];
|
|
20
|
+
const held = trigger.forMinutes && trigger.forMinutes > 1 ? ` for ${trigger.forMinutes} min` : "";
|
|
21
|
+
return `${trigger.stat} over ${trigger.windowMinutes} min ${op} ${(0, format_1.formatNumber)(trigger.threshold)}${held}`;
|
|
22
|
+
}
|
|
23
|
+
/** A trigger's identity: its id, where it came from, and the package that declared it. */
|
|
24
|
+
function triggerKey(trigger) {
|
|
25
|
+
return `${trigger.origin}:${trigger.originPackageId ?? ""}:${trigger.triggerId}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Alerts: each trigger's state on the device and its latest firings, and the user's own triggers
|
|
29
|
+
* to create, edit and delete.
|
|
30
|
+
*/
|
|
31
|
+
function AlertsTab(props) {
|
|
32
|
+
const deviceId = props.location.deviceId;
|
|
33
|
+
const alerts = (0, use_telemetry_1.useTelemetryRead)(deviceId, (t) => t.tools.alerts({ limit: 50 }), []);
|
|
34
|
+
const definitions = (0, use_telemetry_1.useTelemetryRead)(deviceId, (t) => t.tools.listDefinitions({}), []);
|
|
35
|
+
const metrics = (0, use_telemetry_1.useTelemetryRead)(deviceId, async (t) => (await t.tools.listMetrics({})).metrics, []);
|
|
36
|
+
const [editing, setEditing] = (0, react_1.useState)({ kind: "none" });
|
|
37
|
+
const [deleteError, setDeleteError] = (0, react_1.useState)();
|
|
38
|
+
const refresh = () => {
|
|
39
|
+
alerts.refresh();
|
|
40
|
+
definitions.refresh();
|
|
41
|
+
};
|
|
42
|
+
// Two triggers can share an id (a package's, refused, beside another's), so match on origin too.
|
|
43
|
+
const byKey = new Map((definitions.data?.triggers ?? []).map((d) => [triggerKey(d), d]));
|
|
44
|
+
const remove = async (triggerId) => {
|
|
45
|
+
if (!confirm(`Delete the trigger ${triggerId}? It's deleted on all your devices.`))
|
|
46
|
+
return;
|
|
47
|
+
setDeleteError(undefined);
|
|
48
|
+
try {
|
|
49
|
+
await (await (0, telemetry_client_1.getTelemetry)()).tools.deleteTriggerDefinition({ triggerId });
|
|
50
|
+
refresh();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
setDeleteError((0, telemetry_client_1.errorText)(error));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (!alerts.data && alerts.error) {
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-end mb-2", children: (0, jsx_runtime_1.jsx)(form_fields_1.RefreshButton, { onClick: refresh, loading: alerts.loading }) }), (0, jsx_runtime_1.jsx)("div", { className: "alert alert-warning", children: (0, telemetry_client_1.describeTelemetryError)(alerts.error) })] }));
|
|
58
|
+
}
|
|
59
|
+
if (!alerts.data)
|
|
60
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "text-body-secondary", children: "Loading\u2026" });
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { opacity: alerts.loading ? 0.7 : 1, transition: "opacity 150ms" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-center gap-2 mb-2", children: [(0, jsx_runtime_1.jsx)("h2", { className: "h6 mb-0", children: "Triggers" }), (0, jsx_runtime_1.jsx)(form_fields_1.RefreshButton, { className: "ms-auto", onClick: refresh, loading: alerts.loading, readAt: alerts.readAt }), editing.kind === "none" ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-primary btn-sm", onClick: () => setEditing({ kind: "new" }), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-plus-lg me-1", "aria-hidden": "true" }), "New trigger"] })) : null] }), !(0, telemetry_client_1.isThisDevice)(deviceId) && editing.kind !== "none" ? ((0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary", children: "Saved on this device; it reaches the device you're looking at when they sync." })) : null, editing.kind !== "none" ? ((0, jsx_runtime_1.jsx)(trigger_form_1.TriggerForm, { definition: editing.kind === "edit" ? editing.definition : undefined, metrics: metrics.data ?? [], onSaved: () => {
|
|
62
|
+
setEditing((current) => (current === editing ? { kind: "none" } : current));
|
|
63
|
+
refresh();
|
|
64
|
+
}, onCancel: () => setEditing({ kind: "none" }) }, editing.kind === "edit" ? editing.definition.triggerId : undefined)) : null, deleteError ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger small", children: deleteError }) : null, alerts.data.triggers.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-body-secondary small", children: "No triggers on this device yet." })) : ((0, jsx_runtime_1.jsx)("div", { className: "table-responsive mb-4", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-sm table-hover small align-middle", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "State" }), (0, jsx_runtime_1.jsx)("th", { children: "Trigger" }), (0, jsx_runtime_1.jsx)("th", { children: "Condition" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Latest value" }), (0, jsx_runtime_1.jsx)("th", { children: "Since" }), (0, jsx_runtime_1.jsx)("th", { children: "From" }), (0, jsx_runtime_1.jsx)("th", {})] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: alerts.data.triggers.map((trigger) => {
|
|
65
|
+
const definition = byKey.get(triggerKey(trigger));
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)(badges_1.AlertStateBadge, { state: trigger.state, disabled: trigger.disabled }) }), (0, jsx_runtime_1.jsxs)("td", { children: [(0, jsx_runtime_1.jsx)("div", { children: trigger.description || trigger.triggerId }), (0, jsx_runtime_1.jsx)("code", { className: "small text-body-secondary", children: trigger.triggerId })] }), (0, jsx_runtime_1.jsx)("td", { className: "text-nowrap", children: definition ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("code", { children: definition.metricId }), " ", describeCondition(definition)] })) : ("–") }), (0, jsx_runtime_1.jsx)("td", { className: "text-end", style: { fontVariantNumeric: "tabular-nums" }, children: (0, format_1.formatNumber)(trigger.value) }), (0, jsx_runtime_1.jsx)("td", { className: "text-nowrap", children: (0, format_1.formatAgo)(trigger.since) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)(badges_1.OriginBadge, { origin: trigger.origin, packageId: trigger.originPackageId }) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end text-nowrap", children: trigger.origin === "user" && definition ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 me-2", onClick: () => setEditing({ kind: "edit", definition }), children: "Edit" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 text-danger", onClick: () => void remove(trigger.triggerId), children: "Delete" })] })) : null })] }, triggerKey(trigger)));
|
|
67
|
+
}) })] }) })), (0, jsx_runtime_1.jsx)("h2", { className: "h6", children: "Firings" }), alerts.data.events.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-body-secondary small", children: "Nothing has fired on this device." })) : ((0, jsx_runtime_1.jsx)("ul", { className: "list-group small", children: alerts.data.events.map((event) => ((0, jsx_runtime_1.jsxs)("li", { className: "list-group-item", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)(badges_1.AlertStateBadge, { state: event.state }), (0, jsx_runtime_1.jsx)("code", { children: event.triggerId }), (0, jsx_runtime_1.jsx)("span", { className: "ms-auto text-body-secondary text-nowrap", title: new Date(event.at).toLocaleString(), children: (0, format_1.formatAgo)(event.at) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-1", children: [event.detail, " ", (0, jsx_runtime_1.jsxs)("span", { className: "text-body-secondary", children: ["(value ", (0, format_1.formatNumber)(event.value), ")"] })] }), event.actionResult ? ((0, jsx_runtime_1.jsxs)("div", { className: "text-body-secondary mt-1", children: ["Action: ", event.actionResult] })) : null] }, `${event.triggerId}:${event.at}:${event.state}`))) }))] }));
|
|
68
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DefinitionOrigin, IAlertState, ICallSpan, LogLevel } from "@peers-app/peers-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* A package's name, from the packages this device has loaded; its id when it isn't one of them.
|
|
4
|
+
*
|
|
5
|
+
* @param packageId - The package.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePackageName(packageId: string | undefined): string | undefined;
|
|
8
|
+
/** A log line's level, as an icon and its name. */
|
|
9
|
+
export declare function LevelBadge(props: {
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/** A trigger's state, or an alert event's, as an icon and a word. */
|
|
13
|
+
export declare function AlertStateBadge(props: {
|
|
14
|
+
state: IAlertState["state"] | "resolved";
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/** A call's outcome, as an icon and its name. */
|
|
18
|
+
export declare function OutcomeBadge(props: {
|
|
19
|
+
outcome: ICallSpan["outcome"];
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
/** Where a definition came from: Peers, a package (named), or the user. */
|
|
22
|
+
export declare function OriginBadge(props: {
|
|
23
|
+
origin: DefinitionOrigin;
|
|
24
|
+
packageId?: string;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePackageName = usePackageName;
|
|
4
|
+
exports.LevelBadge = LevelBadge;
|
|
5
|
+
exports.AlertStateBadge = AlertStateBadge;
|
|
6
|
+
exports.OutcomeBadge = OutcomeBadge;
|
|
7
|
+
exports.OriginBadge = OriginBadge;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
|
+
const routes_loader_1 = require("../../ui-router/routes-loader");
|
|
11
|
+
/**
|
|
12
|
+
* A package's name, from the packages this device has loaded; its id when it isn't one of them.
|
|
13
|
+
*
|
|
14
|
+
* @param packageId - The package.
|
|
15
|
+
*/
|
|
16
|
+
function usePackageName(packageId) {
|
|
17
|
+
const [packages] = (0, hooks_1.useObservable)(routes_loader_1.allPackages);
|
|
18
|
+
if (!packageId)
|
|
19
|
+
return undefined;
|
|
20
|
+
return packages.find((pkg) => pkg.packageId === packageId)?.name || packageId;
|
|
21
|
+
}
|
|
22
|
+
const LEVELS = {
|
|
23
|
+
error: { icon: "bi-x-circle-fill", className: "text-bg-danger" },
|
|
24
|
+
warn: { icon: "bi-exclamation-triangle-fill", className: "text-bg-warning" },
|
|
25
|
+
info: { icon: "bi-info-circle-fill", className: "text-bg-info" },
|
|
26
|
+
log: { icon: "bi-chat-square-text", className: "text-bg-secondary" },
|
|
27
|
+
debug: { icon: "bi-bug", className: "text-bg-light border" },
|
|
28
|
+
};
|
|
29
|
+
/** A log line's level, as an icon and its name. */
|
|
30
|
+
function LevelBadge(props) {
|
|
31
|
+
const level = LEVELS[props.level] ?? LEVELS.log;
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: `badge ${level.className}`, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${level.icon} me-1`, "aria-hidden": "true" }), props.level] }));
|
|
33
|
+
}
|
|
34
|
+
const STATES = {
|
|
35
|
+
firing: { icon: "bi-exclamation-octagon-fill", className: "text-bg-danger", label: "Firing" },
|
|
36
|
+
pending: { icon: "bi-hourglass-split", className: "text-bg-warning", label: "Pending" },
|
|
37
|
+
ok: { icon: "bi-check-circle", className: "text-bg-success", label: "OK" },
|
|
38
|
+
resolved: { icon: "bi-check-circle", className: "text-bg-success", label: "Resolved" },
|
|
39
|
+
};
|
|
40
|
+
/** A trigger's state, or an alert event's, as an icon and a word. */
|
|
41
|
+
function AlertStateBadge(props) {
|
|
42
|
+
if (props.disabled) {
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: "badge text-bg-light border", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-pause-circle me-1", "aria-hidden": "true" }), "Off"] }));
|
|
44
|
+
}
|
|
45
|
+
const state = STATES[props.state];
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: `badge ${state.className}`, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${state.icon} me-1`, "aria-hidden": "true" }), state.label] }));
|
|
47
|
+
}
|
|
48
|
+
const OUTCOMES = {
|
|
49
|
+
ok: { icon: "bi-check", className: "text-bg-light border" },
|
|
50
|
+
error: { icon: "bi-x-circle-fill", className: "text-bg-danger" },
|
|
51
|
+
denied: { icon: "bi-slash-circle", className: "text-bg-warning" },
|
|
52
|
+
timeout: { icon: "bi-clock-history", className: "text-bg-warning" },
|
|
53
|
+
};
|
|
54
|
+
/** A call's outcome, as an icon and its name. */
|
|
55
|
+
function OutcomeBadge(props) {
|
|
56
|
+
const outcome = OUTCOMES[props.outcome] ?? OUTCOMES.error;
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: `badge ${outcome.className}`, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${outcome.icon} me-1`, "aria-hidden": "true" }), props.outcome] }));
|
|
58
|
+
}
|
|
59
|
+
/** Where a definition came from: Peers, a package (named), or the user. */
|
|
60
|
+
function OriginBadge(props) {
|
|
61
|
+
const packageName = usePackageName(props.packageId);
|
|
62
|
+
const label = props.origin === "peers"
|
|
63
|
+
? "Peers"
|
|
64
|
+
: props.origin === "user"
|
|
65
|
+
? "Yours"
|
|
66
|
+
: packageName || "Package";
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-light border text-truncate", style: { maxWidth: 200 }, title: props.packageId, children: label }));
|
|
68
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ICallSpan } from "@peers-app/peers-sdk";
|
|
2
|
+
import type { MonitoringSectionProps } from "./monitoring-screen";
|
|
3
|
+
/**
|
|
4
|
+
* Order a trace's spans as a tree: each call under the call it was made from, in start order, with
|
|
5
|
+
* its depth. A span whose parent isn't among them starts a branch of its own.
|
|
6
|
+
*
|
|
7
|
+
* @param spans - Calls in one trace.
|
|
8
|
+
*/
|
|
9
|
+
export declare function traceTree(spans: ICallSpan[]): Array<{
|
|
10
|
+
span: ICallSpan;
|
|
11
|
+
depth: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Leave out Monitoring's own reads: calls to System Telemetry, which this screen makes as it
|
|
15
|
+
* refreshes. They're still recorded, like every call.
|
|
16
|
+
*
|
|
17
|
+
* @param spans - Calls, newest first.
|
|
18
|
+
* @returns The rest, and how many were left out.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withoutOwnReads(spans: ICallSpan[]): {
|
|
21
|
+
spans: ICallSpan[];
|
|
22
|
+
hidden: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Calls: the device's recent contract calls, or only the slow and failed ones (kept a day), by
|
|
26
|
+
* contract, provider and caller. Monitoring's own reads are left out unless asked for (or a trace
|
|
27
|
+
* or contract is), so the screen's refreshing doesn't fill the list. A trace narrows the list to
|
|
28
|
+
* its calls, drawn as a tree, and links to its log lines.
|
|
29
|
+
*/
|
|
30
|
+
export declare function CallsTab(props: MonitoringSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceTree = traceTree;
|
|
4
|
+
exports.withoutOwnReads = withoutOwnReads;
|
|
5
|
+
exports.CallsTab = CallsTab;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const badges_1 = require("./badges");
|
|
10
|
+
const form_fields_1 = require("./form-fields");
|
|
11
|
+
const format_1 = require("./format");
|
|
12
|
+
const telemetry_client_1 = require("./telemetry-client");
|
|
13
|
+
const use_telemetry_1 = require("./use-telemetry");
|
|
14
|
+
/**
|
|
15
|
+
* Order a trace's spans as a tree: each call under the call it was made from, in start order, with
|
|
16
|
+
* its depth. A span whose parent isn't among them starts a branch of its own.
|
|
17
|
+
*
|
|
18
|
+
* @param spans - Calls in one trace.
|
|
19
|
+
*/
|
|
20
|
+
function traceTree(spans) {
|
|
21
|
+
const byParent = new Map();
|
|
22
|
+
const ids = new Set(spans.map((span) => span.spanId));
|
|
23
|
+
const roots = [];
|
|
24
|
+
for (const span of [...spans].sort((a, b) => a.start - b.start)) {
|
|
25
|
+
if (span.parentSpanId && ids.has(span.parentSpanId) && span.parentSpanId !== span.spanId) {
|
|
26
|
+
const children = byParent.get(span.parentSpanId) ?? [];
|
|
27
|
+
children.push(span);
|
|
28
|
+
byParent.set(span.parentSpanId, children);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
roots.push(span);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const out = [];
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const visit = (span, depth) => {
|
|
37
|
+
if (seen.has(span.spanId))
|
|
38
|
+
return;
|
|
39
|
+
seen.add(span.spanId);
|
|
40
|
+
out.push({ span, depth });
|
|
41
|
+
for (const child of byParent.get(span.spanId) ?? [])
|
|
42
|
+
visit(child, depth + 1);
|
|
43
|
+
};
|
|
44
|
+
for (const root of roots)
|
|
45
|
+
visit(root, 0);
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Calls the list shows. */
|
|
49
|
+
const SHOWN_CALLS = 200;
|
|
50
|
+
/**
|
|
51
|
+
* Leave out Monitoring's own reads: calls to System Telemetry, which this screen makes as it
|
|
52
|
+
* refreshes. They're still recorded, like every call.
|
|
53
|
+
*
|
|
54
|
+
* @param spans - Calls, newest first.
|
|
55
|
+
* @returns The rest, and how many were left out.
|
|
56
|
+
*/
|
|
57
|
+
function withoutOwnReads(spans) {
|
|
58
|
+
const rest = spans.filter((span) => span.contractId !== peers_sdk_1.telemetryContractId);
|
|
59
|
+
return { spans: rest, hidden: spans.length - rest.length };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Calls: the device's recent contract calls, or only the slow and failed ones (kept a day), by
|
|
63
|
+
* contract, provider and caller. Monitoring's own reads are left out unless asked for (or a trace
|
|
64
|
+
* or contract is), so the screen's refreshing doesn't fill the list. A trace narrows the list to
|
|
65
|
+
* its calls, drawn as a tree, and links to its log lines.
|
|
66
|
+
*/
|
|
67
|
+
function CallsTab(props) {
|
|
68
|
+
const { deviceId, traceId } = props.location;
|
|
69
|
+
const [notableOnly, setNotableOnly] = (0, react_1.useState)(false);
|
|
70
|
+
const [contract, setContract] = (0, react_1.useState)("");
|
|
71
|
+
const [provider, setProvider] = (0, react_1.useState)("");
|
|
72
|
+
const [caller, setCaller] = (0, react_1.useState)("");
|
|
73
|
+
const [includeOwnReads, setIncludeOwnReads] = (0, react_1.useState)(false);
|
|
74
|
+
// A trace or a contract asked for is shown whole.
|
|
75
|
+
const hideOwnReads = !includeOwnReads && !traceId && !contract.trim();
|
|
76
|
+
const spans = (0, use_telemetry_1.useTelemetryRead)(deviceId, async (telemetry) => (await telemetry.tools.readSpans({
|
|
77
|
+
notableOnly: notableOnly || undefined,
|
|
78
|
+
contract: contract.trim() || undefined,
|
|
79
|
+
provider: provider.trim() || undefined,
|
|
80
|
+
caller: caller.trim() || undefined,
|
|
81
|
+
traceId,
|
|
82
|
+
// Ask for more while hiding Monitoring's reads, so the list isn't left short.
|
|
83
|
+
limit: hideOwnReads ? 500 : SHOWN_CALLS,
|
|
84
|
+
})).spans, [notableOnly, contract, provider, caller, traceId, hideOwnReads], traceId ? undefined : 15_000);
|
|
85
|
+
const setTrace = (id) => props.navigate({ section: "calls", traceId: id });
|
|
86
|
+
const shown = spans.data
|
|
87
|
+
? hideOwnReads
|
|
88
|
+
? withoutOwnReads(spans.data)
|
|
89
|
+
: { spans: spans.data, hidden: 0 }
|
|
90
|
+
: undefined;
|
|
91
|
+
const rows = shown
|
|
92
|
+
? traceId
|
|
93
|
+
? traceTree(shown.spans)
|
|
94
|
+
: shown.spans.slice(0, SHOWN_CALLS).map((span) => ({ span, depth: 0 }))
|
|
95
|
+
: [];
|
|
96
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-end gap-2 mb-2", children: [(0, jsx_runtime_1.jsxs)("fieldset", { className: "btn-group btn-group-sm", "aria-label": "Which calls", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${!notableOnly ? "btn-secondary" : "btn-outline-secondary"}`, "aria-pressed": !notableOnly, onClick: () => setNotableOnly(false), children: "Recent" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${notableOnly ? "btn-secondary" : "btn-outline-secondary"}`, "aria-pressed": notableOnly, onClick: () => setNotableOnly(true), children: "Slow and failed" })] }), (0, jsx_runtime_1.jsx)(form_fields_1.OwnReadsSwitch, { id: "calls-own-reads", checked: includeOwnReads, onChange: setIncludeOwnReads }), (0, jsx_runtime_1.jsx)(form_fields_1.RefreshButton, { className: "ms-auto", onClick: spans.refresh, loading: spans.loading })] }), (0, jsx_runtime_1.jsxs)("div", { className: "row g-2 mb-2", children: [(0, jsx_runtime_1.jsx)(form_fields_1.FilterInput, { id: "calls-contract", label: "Contract", value: contract, onChange: setContract, placeholder: "Tasks" }), (0, jsx_runtime_1.jsx)(form_fields_1.FilterInput, { id: "calls-provider", label: "Provider", value: provider, onChange: setProvider, placeholder: "peers, or a package id" }), (0, jsx_runtime_1.jsx)(form_fields_1.FilterInput, { id: "calls-caller", label: "Caller", value: caller, onChange: setCaller, placeholder: "user, device, a package id" }), (0, jsx_runtime_1.jsx)(form_fields_1.FilterInput, { id: "calls-trace", label: "Trace", value: traceId ?? "", onChange: (value) => setTrace(value.trim() || undefined) })] }), traceId ? ((0, jsx_runtime_1.jsxs)("div", { className: "small mb-2 d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-body-secondary", children: "Calls in trace" }), (0, jsx_runtime_1.jsx)("code", { children: traceId }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0", onClick: () => props.navigate({ section: "logs", traceId }), children: "Its log lines" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0", onClick: () => setTrace(undefined), children: "Clear" })] })) : null, spans.error && !spans.data ? ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-warning", children: (0, telemetry_client_1.describeTelemetryError)(spans.error) })) : null, !spans.data && !spans.error ? (0, jsx_runtime_1.jsx)("div", { className: "text-body-secondary", children: "Loading\u2026" }) : null, spans.data && rows.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-body-secondary small", children: "No calls match." })) : null, shown?.hidden ? ((0, jsx_runtime_1.jsxs)("p", { className: "small text-body-secondary mb-2", children: [shown.hidden, " of Monitoring's own reads left out."] })) : null, rows.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "table-responsive", style: { opacity: spans.loading ? 0.7 : 1, transition: "opacity 150ms" }, children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-sm table-hover small align-middle", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "Started" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Took" }), (0, jsx_runtime_1.jsx)("th", { children: "Call" }), (0, jsx_runtime_1.jsx)("th", { children: "Provider" }), (0, jsx_runtime_1.jsx)("th", { children: "Caller" }), (0, jsx_runtime_1.jsx)("th", { children: "Where" }), (0, jsx_runtime_1.jsx)("th", { children: "Outcome" }), (0, jsx_runtime_1.jsx)("th", { children: "Trace" })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: rows.map(({ span, depth }) => ((0, jsx_runtime_1.jsx)(SpanRow, { span: span, depth: depth, onTrace: setTrace }, span.spanId))) })] }) })) : null] }));
|
|
97
|
+
}
|
|
98
|
+
function SpanRow(props) {
|
|
99
|
+
const { span } = props;
|
|
100
|
+
const provider = (0, badges_1.usePackageName)(span.provider === "peers" ? undefined : span.provider) ?? "Peers";
|
|
101
|
+
const caller = (0, badges_1.usePackageName)(span.caller === "user" || span.caller === "device" ? undefined : span.caller) ??
|
|
102
|
+
span.caller;
|
|
103
|
+
return ((0, jsx_runtime_1.jsxs)("tr", { className: span.outcome === "ok" ? undefined : "table-danger", children: [(0, jsx_runtime_1.jsx)("td", { className: "text-nowrap font-monospace", style: { fontSize: "0.75rem" }, children: (0, format_1.formatTime)(span.start) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end text-nowrap", style: { fontVariantNumeric: "tabular-nums" }, children: (0, format_1.formatDuration)(span.durationMs) }), (0, jsx_runtime_1.jsxs)("td", { style: { paddingLeft: `${0.25 + props.depth * 1.25}rem` }, children: [props.depth > 0 ? ((0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-return-right me-1 text-body-secondary", "aria-hidden": "true" })) : null, (0, jsx_runtime_1.jsx)("span", { children: span.contract || span.contractId }), " ", (0, jsx_runtime_1.jsx)("code", { className: "small", children: span.op }), span.error ? ((0, jsx_runtime_1.jsx)("div", { className: "text-danger-emphasis text-truncate", style: { maxWidth: 420 }, title: span.error, children: span.error })) : null] }), (0, jsx_runtime_1.jsx)("td", { className: "text-truncate", style: { maxWidth: 160 }, title: span.provider, children: provider }), (0, jsx_runtime_1.jsx)("td", { className: "text-truncate", style: { maxWidth: 160 }, title: span.caller, children: caller }), (0, jsx_runtime_1.jsx)("td", { className: "text-nowrap", title: span.deviceId, children: span.where }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)(badges_1.OutcomeBadge, { outcome: span.outcome }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 font-monospace", onClick: () => props.onTrace(span.traceId), title: span.traceId, children: span.traceId.slice(0, 8) }) })] }));
|
|
104
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type IHistogramBin, type IMetricPoint, type IMetricQueryResult, type MetricStat } from "@peers-app/peers-sdk";
|
|
2
|
+
/** At most this many series are drawn, the largest first. */
|
|
3
|
+
export declare const MAX_CHART_SERIES = 8;
|
|
4
|
+
/** One line of a time chart: a value per bucket, `undefined` where there's no data. */
|
|
5
|
+
export interface IChartSeries {
|
|
6
|
+
/** Stable key: the group's labels, so a series keeps its color while others come and go. */
|
|
7
|
+
key: string;
|
|
8
|
+
/** What the legend and tooltip call it. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** One value per {@link ITimeSeriesData.times} entry. */
|
|
11
|
+
values: Array<number | undefined>;
|
|
12
|
+
/** Observations over the range, which ranks the series. */
|
|
13
|
+
total: number;
|
|
14
|
+
}
|
|
15
|
+
/** A queried metric laid out for a time chart. */
|
|
16
|
+
export interface ITimeSeriesData {
|
|
17
|
+
/** Bucket starts, epoch ms, oldest first. */
|
|
18
|
+
times: number[];
|
|
19
|
+
/** Every series, largest first. */
|
|
20
|
+
series: IChartSeries[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A group's key and label: `(all)` with no group-by, otherwise `name=value` pairs.
|
|
24
|
+
*
|
|
25
|
+
* @param group - The point's `groupBy` labels.
|
|
26
|
+
*/
|
|
27
|
+
export declare function groupLabel(group: Record<string, string>): string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a missing bucket means zero (counts and sums) or no data (averages, percentiles, gauges).
|
|
30
|
+
*
|
|
31
|
+
* @param stat - The statistic drawn.
|
|
32
|
+
*/
|
|
33
|
+
export declare function missingIsZero(stat: MetricStat): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Lay a query result out for a time chart: every bucket from `from` to `to`, a series per group,
|
|
36
|
+
* largest first. Like `queryMetric`, it stops at {@link MAX_QUERY_BUCKETS} buckets.
|
|
37
|
+
*
|
|
38
|
+
* @param result - What `queryMetric` returned.
|
|
39
|
+
* @param stat - The statistic to draw.
|
|
40
|
+
*/
|
|
41
|
+
export declare function toTimeSeries(result: IMetricQueryResult, stat: MetricStat): ITimeSeriesData;
|
|
42
|
+
/**
|
|
43
|
+
* One statistic of a point.
|
|
44
|
+
*
|
|
45
|
+
* @param point - A queried bucket.
|
|
46
|
+
* @param stat - The statistic.
|
|
47
|
+
*/
|
|
48
|
+
export declare function statOf(point: IMetricPoint, stat: MetricStat): number | undefined;
|
|
49
|
+
/** Rounded ticks for a value axis, and the domain they cover. */
|
|
50
|
+
export interface IAxisTicks {
|
|
51
|
+
min: number;
|
|
52
|
+
max: number;
|
|
53
|
+
ticks: number[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Rounded value-axis ticks from zero (or the lowest value, when it's negative) to at least the
|
|
57
|
+
* highest value: 1, 2 or 5 times a power of ten apart.
|
|
58
|
+
*
|
|
59
|
+
* @param values - Every value drawn.
|
|
60
|
+
* @param count - About how many ticks.
|
|
61
|
+
*/
|
|
62
|
+
export declare function niceTicks(values: Array<number | undefined>, count?: number): IAxisTicks;
|
|
63
|
+
/**
|
|
64
|
+
* Time-axis ticks: about `count` bucket starts, evenly spaced, and how to label them.
|
|
65
|
+
*
|
|
66
|
+
* @param times - The chart's bucket starts.
|
|
67
|
+
* @param count - About how many ticks.
|
|
68
|
+
*/
|
|
69
|
+
export declare function timeTicks(times: number[], count?: number): {
|
|
70
|
+
ticks: number[];
|
|
71
|
+
label: (t: number) => string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A percentile read from histogram bins: the bin the rank falls in, interpolated on a log scale
|
|
75
|
+
* (bins are log-spaced).
|
|
76
|
+
*
|
|
77
|
+
* @param bins - A histogram.
|
|
78
|
+
* @param q - The quantile, 0 to 1 (0.95 for p95).
|
|
79
|
+
* @returns The estimate, or `undefined` for an empty histogram.
|
|
80
|
+
*/
|
|
81
|
+
export declare function percentileFromBins(bins: IHistogramBin[], q: number): number | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* The sum of a series' values, skipping missing buckets.
|
|
84
|
+
*
|
|
85
|
+
* @param values - A series' values.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sumOf(values: Array<number | undefined>): number;
|
|
88
|
+
/**
|
|
89
|
+
* Give each drawn series a color slot (0–7) that it keeps while it stays drawn, so colors follow
|
|
90
|
+
* the series, not their rank: a series keeps its slot from `previous`, and a new one takes the
|
|
91
|
+
* lowest slot no other drawn series holds.
|
|
92
|
+
*
|
|
93
|
+
* @param previous - Slots from the last render (keys to slots).
|
|
94
|
+
* @param keys - The series drawn now, at most {@link MAX_CHART_SERIES}.
|
|
95
|
+
* @returns The slots for `keys`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function assignColorSlots(previous: ReadonlyMap<string, number>, keys: string[]): Map<string, number>;
|
|
98
|
+
/**
|
|
99
|
+
* The CSS color of a series slot, from the theme's `--peers-viz-1` to `--peers-viz-8`.
|
|
100
|
+
*
|
|
101
|
+
* @param slot - 0 to 7.
|
|
102
|
+
*/
|
|
103
|
+
export declare function seriesColor(slot: number): string;
|