@localstack/appinspector-ui 1.0.220 → 1.0.222
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/index.cjs +1044 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1040 -243
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2421,8 +2421,8 @@ var init_event_streams = __esm({
|
|
|
2421
2421
|
});
|
|
2422
2422
|
|
|
2423
2423
|
// src/pages/spans-list-page.tsx
|
|
2424
|
-
import { Box as
|
|
2425
|
-
import { useCallback as
|
|
2424
|
+
import { Box as Box25, Paper as Paper3 } from "@mui/material";
|
|
2425
|
+
import { useCallback as useCallback14, useEffect as useEffect29, useMemo as useMemo14, useRef as useRef25, useState as useState26 } from "react";
|
|
2426
2426
|
|
|
2427
2427
|
// src/api/errors.ts
|
|
2428
2428
|
var AppInspectorDisabledError = class extends Error {
|
|
@@ -2548,6 +2548,21 @@ var WATERFALL_AXIS_LABEL_TEST_ID = "waterfall-axis-label";
|
|
|
2548
2548
|
var WATERFALL_TREE_VIEW_BUTTON_TEST_ID = "waterfall-tree-view-button";
|
|
2549
2549
|
var WATERFALL_LIST_VIEW_BUTTON_TEST_ID = "waterfall-list-view-button";
|
|
2550
2550
|
var WATERFALL_ROW_OFFSET_TEST_ID = "waterfall-row-offset";
|
|
2551
|
+
var TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID = "trace-sidebar-sequence-button";
|
|
2552
|
+
var SEQUENCE_DIAGRAM_TEST_ID = "sequence-diagram";
|
|
2553
|
+
var SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID = "sequence-diagram-participant";
|
|
2554
|
+
var SEQUENCE_DIAGRAM_MESSAGE_TEST_ID = "sequence-diagram-message";
|
|
2555
|
+
var SEQUENCE_DIAGRAM_RETURN_TEST_ID = "sequence-diagram-return";
|
|
2556
|
+
var SEQUENCE_DIAGRAM_ARROW_TEST_ID = "sequence-diagram-arrow";
|
|
2557
|
+
var SEQUENCE_DIAGRAM_SEGMENT_TEST_ID = "sequence-diagram-segment";
|
|
2558
|
+
var SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID = "sequence-diagram-hover-card";
|
|
2559
|
+
var SEQUENCE_DIAGRAM_TOGGLE_TEST_ID = "sequence-diagram-toggle";
|
|
2560
|
+
var SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID = "sequence-diagram-zoom-in-button";
|
|
2561
|
+
var SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID = "sequence-diagram-zoom-out-button";
|
|
2562
|
+
var SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID = "sequence-diagram-zoom-reset-button";
|
|
2563
|
+
var SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID = "sequence-diagram-zoom-fit-button";
|
|
2564
|
+
var SEQUENCE_DIAGRAM_MINIMAP_TEST_ID = "sequence-diagram-minimap";
|
|
2565
|
+
var SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID = "sequence-diagram-minimap-toggle";
|
|
2551
2566
|
|
|
2552
2567
|
// src/utils/emulator-version.ts
|
|
2553
2568
|
var import_semver = __toESM(require_semver2(), 1);
|
|
@@ -7170,12 +7185,12 @@ var isColorString = (type, testProp) => (v) => {
|
|
|
7170
7185
|
var splitColor = (aName, bName, cName) => (v) => {
|
|
7171
7186
|
if (!isString(v))
|
|
7172
7187
|
return v;
|
|
7173
|
-
const [a3, b3, c3,
|
|
7188
|
+
const [a3, b3, c3, alpha9] = v.match(floatRegex);
|
|
7174
7189
|
return {
|
|
7175
7190
|
[aName]: parseFloat(a3),
|
|
7176
7191
|
[bName]: parseFloat(b3),
|
|
7177
7192
|
[cName]: parseFloat(c3),
|
|
7178
|
-
alpha:
|
|
7193
|
+
alpha: alpha9 !== void 0 ? parseFloat(alpha9) : 1
|
|
7179
7194
|
};
|
|
7180
7195
|
};
|
|
7181
7196
|
|
|
@@ -8289,7 +8304,7 @@ function hueToRgb(p, q, t) {
|
|
|
8289
8304
|
return p + (q - p) * (2 / 3 - t) * 6;
|
|
8290
8305
|
return p;
|
|
8291
8306
|
}
|
|
8292
|
-
function hslaToRgba({ hue, saturation, lightness, alpha:
|
|
8307
|
+
function hslaToRgba({ hue, saturation, lightness, alpha: alpha9 }) {
|
|
8293
8308
|
hue /= 360;
|
|
8294
8309
|
saturation /= 100;
|
|
8295
8310
|
lightness /= 100;
|
|
@@ -8309,7 +8324,7 @@ function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
|
|
|
8309
8324
|
red: Math.round(red * 255),
|
|
8310
8325
|
green: Math.round(green * 255),
|
|
8311
8326
|
blue: Math.round(blue * 255),
|
|
8312
|
-
alpha:
|
|
8327
|
+
alpha: alpha9
|
|
8313
8328
|
};
|
|
8314
8329
|
}
|
|
8315
8330
|
|
|
@@ -13160,10 +13175,10 @@ var getOperationLabel = (span) => {
|
|
|
13160
13175
|
|
|
13161
13176
|
// src/components/operation-name.tsx
|
|
13162
13177
|
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
13163
|
-
var OperationName = ({ span }) => {
|
|
13178
|
+
var OperationName = ({ span, tooltip = true }) => {
|
|
13164
13179
|
const label = getOperationLabel(span);
|
|
13165
|
-
if (label === span.operation_name) {
|
|
13166
|
-
return /* @__PURE__ */ jsx4("span", { title: label, children: label });
|
|
13180
|
+
if (label === span.operation_name || !tooltip) {
|
|
13181
|
+
return /* @__PURE__ */ jsx4("span", { title: tooltip ? label : void 0, children: label });
|
|
13167
13182
|
}
|
|
13168
13183
|
return /* @__PURE__ */ jsx4(
|
|
13169
13184
|
Tooltip,
|
|
@@ -16989,9 +17004,9 @@ var getTraceBounds = (spans) => {
|
|
|
16989
17004
|
|
|
16990
17005
|
// src/components/trace-panel/trace-sidebar.tsx
|
|
16991
17006
|
import { Close as Close4, CloseFullscreen, OpenInFull } from "@mui/icons-material";
|
|
16992
|
-
import { Box as
|
|
17007
|
+
import { Box as Box23, IconButton as IconButton9, ToggleButton as ToggleButton3, ToggleButtonGroup as ToggleButtonGroup3, Typography as Typography16 } from "@mui/material";
|
|
16993
17008
|
import { ReactFlowProvider } from "@xyflow/react";
|
|
16994
|
-
import * as
|
|
17009
|
+
import * as React127 from "react";
|
|
16995
17010
|
|
|
16996
17011
|
// src/components/event-details/event-details.tsx
|
|
16997
17012
|
import { Cancel as Cancel5, Close as Close3, GppBad as GppBad2, GppMaybe as GppMaybe6 } from "@mui/icons-material";
|
|
@@ -17000,7 +17015,7 @@ import { useEffect as useEffect17, useMemo as useMemo10, useRef as useRef13, use
|
|
|
17000
17015
|
|
|
17001
17016
|
// src/dev-settings.tsx
|
|
17002
17017
|
import * as React122 from "react";
|
|
17003
|
-
var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", succeededIconColor: "green", waterfallLayout: "tree" };
|
|
17018
|
+
var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", sequenceBlocks: "detached", sequenceClickTargets: "arrows-and-segments", sequenceHoverCard: "on", succeededIconColor: "green", waterfallLayout: "tree" };
|
|
17004
17019
|
var DevSettingsContext = React122.createContext(DEFAULT_DEV_SETTINGS);
|
|
17005
17020
|
var useDevSettings = () => React122.useContext(DevSettingsContext);
|
|
17006
17021
|
|
|
@@ -31786,8 +31801,8 @@ var OPTIONAL_TABS = ["logs", "permissions", "response"];
|
|
|
31786
31801
|
var getOptionalTabs = (span, eventGroups) => ({
|
|
31787
31802
|
logs: checkIsLambdaInvoke(span) && typeof span.attributes?.["localstack.request_id"] === "string",
|
|
31788
31803
|
permissions: span.iam_errors_suppressed === true || eventGroups.permissions !== void 0,
|
|
31789
|
-
// A failed call
|
|
31790
|
-
response: span.attributes?.["localstack.aws.service.response_suppressed"] === true || tryParseJson(span.attributes?.["localstack.aws.service.response"]) !== void 0
|
|
31804
|
+
// A failed call shows its error here, even with no response payload.
|
|
31805
|
+
response: getSpanIssues(span).error || span.attributes?.["localstack.aws.service.response_suppressed"] === true || tryParseJson(span.attributes?.["localstack.aws.service.response"]) !== void 0
|
|
31791
31806
|
});
|
|
31792
31807
|
var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
31793
31808
|
/* @__PURE__ */ jsx145(Typography13, { sx: { fontWeight: 600 }, variant: "caption", children: label }),
|
|
@@ -31797,14 +31812,19 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
|
|
|
31797
31812
|
] })
|
|
31798
31813
|
] });
|
|
31799
31814
|
var EmptyTab = ({ children }) => /* @__PURE__ */ jsx145(Typography13, { color: "text.secondary", variant: "body2", children });
|
|
31800
|
-
var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
31815
|
+
var EventDetails = ({ onClose, onOperationShown, requestedTab, selectedEvent }) => {
|
|
31801
31816
|
const eventGroups = useMemo10(
|
|
31802
31817
|
() => getEventGroupsByType(selectedEvent?.events ?? []),
|
|
31803
31818
|
[selectedEvent?.events]
|
|
31804
31819
|
);
|
|
31805
31820
|
const { headingPills } = useDevSettings();
|
|
31806
31821
|
const [parseNestedJson, setParseNestedJson] = useState14(true);
|
|
31807
|
-
const [tab, setTab] = useState14("details");
|
|
31822
|
+
const [tab, setTab] = useState14(requestedTab?.view ?? "details");
|
|
31823
|
+
const [appliedRequest, setAppliedRequest] = useState14(requestedTab);
|
|
31824
|
+
if (requestedTab !== appliedRequest) {
|
|
31825
|
+
setAppliedRequest(requestedTab);
|
|
31826
|
+
if (requestedTab) setTab(requestedTab.view);
|
|
31827
|
+
}
|
|
31808
31828
|
const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
|
|
31809
31829
|
const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
|
|
31810
31830
|
const onOperationShownRef = useRef13(onOperationShown);
|
|
@@ -31921,9 +31941,9 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
|
31921
31941
|
value: activeTab,
|
|
31922
31942
|
variant: "scrollable",
|
|
31923
31943
|
children: [
|
|
31924
|
-
/* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID,
|
|
31944
|
+
/* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, label: "Details", value: "details" }),
|
|
31925
31945
|
/* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "payload" }),
|
|
31926
|
-
showResponse && /* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, label: "Response", value: "response" }),
|
|
31946
|
+
showResponse && /* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, icon: showError ? /* @__PURE__ */ jsx145(Cancel5, { color: "error", sx: { fontSize: 16 } }) : void 0, iconPosition: "end", label: "Response", value: "response" }),
|
|
31927
31947
|
showPermissions && /* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_PERMISSIONS_TEST_ID, icon: permissionsIcon, iconPosition: "end", label: "Permissions", value: "permissions" }),
|
|
31928
31948
|
showLogs && /* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_LOGS_TEST_ID, label: "Logs", value: "logs" }),
|
|
31929
31949
|
/* @__PURE__ */ jsx145(Tab, { "data-testid": DETAIL_TAB_ADVANCED_TEST_ID, label: "Advanced", value: "advanced" })
|
|
@@ -31932,35 +31952,6 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
|
31932
31952
|
),
|
|
31933
31953
|
/* @__PURE__ */ jsxs132(Box18, { sx: { p: 2 }, children: [
|
|
31934
31954
|
activeTab === "details" && /* @__PURE__ */ jsxs132(Stack4, { spacing: 2, children: [
|
|
31935
|
-
showError && /* @__PURE__ */ jsxs132(Stack4, { spacing: 2, sx: ERROR_BOX_SX, children: [
|
|
31936
|
-
/* @__PURE__ */ jsxs132(Stack4, { spacing: 1, children: [
|
|
31937
|
-
/* @__PURE__ */ jsx145(Field, { label: "Type", children: errorType }),
|
|
31938
|
-
errorMessages.length > 0 && /* @__PURE__ */ jsx145(Field, { label: "Message", children: errorMessages.join(" \xB7 ") }),
|
|
31939
|
-
functionError && /* @__PURE__ */ jsxs132(Box18, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
|
|
31940
|
-
functionError.requestId !== void 0 && /* @__PURE__ */ jsx145(Field, { label: "Request ID", children: functionError.requestId }),
|
|
31941
|
-
/* @__PURE__ */ jsx145(Field, { label: "Function Error", testId: EVENT_DETAILS_FUNCTION_ERROR_TEST_ID, children: functionError.functionError })
|
|
31942
|
-
] })
|
|
31943
|
-
] }),
|
|
31944
|
-
functionError?.stackTrace !== void 0 && /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
31945
|
-
/* @__PURE__ */ jsxs132(Stack4, { alignItems: "center", direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
|
|
31946
|
-
/* @__PURE__ */ jsx145(Typography13, { sx: { fontWeight: 600 }, variant: "caption", children: "Stack Trace" }),
|
|
31947
|
-
/* @__PURE__ */ jsx145(CopyButton, { value: functionError.stackTrace })
|
|
31948
|
-
] }),
|
|
31949
|
-
/* @__PURE__ */ jsx145(
|
|
31950
|
-
Box18,
|
|
31951
|
-
{
|
|
31952
|
-
component: "pre",
|
|
31953
|
-
"data-testid": EVENT_DETAILS_STACK_TRACE_TEST_ID,
|
|
31954
|
-
sx: { backgroundColor: "background.default", borderRadius: 1, fontFamily: "monospace", fontSize: 12, m: 0, overflow: "auto", p: 1 },
|
|
31955
|
-
children: functionError.stackTrace
|
|
31956
|
-
}
|
|
31957
|
-
)
|
|
31958
|
-
] }),
|
|
31959
|
-
exceptionPayload !== void 0 && /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
31960
|
-
/* @__PURE__ */ jsx145(Typography13, { sx: { fontWeight: 600, mb: 0.5 }, variant: "caption", children: "Exception" }),
|
|
31961
|
-
/* @__PURE__ */ jsx145(PayloadViewer, { testId: EVENT_DETAILS_EXCEPTION_PAYLOAD_TEST_ID, value: exceptionPayload })
|
|
31962
|
-
] })
|
|
31963
|
-
] }),
|
|
31964
31955
|
/* @__PURE__ */ jsxs132(Stack4, { "data-testid": EVENT_DETAILS_SECTION_BASIC_INFORMATION_TEST_ID, spacing: 1, children: [
|
|
31965
31956
|
/* @__PURE__ */ jsxs132(Box18, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
|
|
31966
31957
|
/* @__PURE__ */ jsx145(Field, { copy: getServiceDisplayName(selectedEvent.service_name), label: "Service", testId: EVENT_DETAILS_SERVICE_NAME_TEST_ID, children: getServiceDisplayName(selectedEvent.service_name) }),
|
|
@@ -32000,9 +31991,40 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
|
32000
31991
|
rawDataSwitch,
|
|
32001
31992
|
/* @__PURE__ */ jsx145(PayloadViewer, { testId: EVENT_DETAILS_REQUEST_PAYLOAD, value: requestPayload })
|
|
32002
31993
|
] })),
|
|
32003
|
-
activeTab === "response" && /* @__PURE__ */ jsxs132(
|
|
32004
|
-
|
|
32005
|
-
|
|
31994
|
+
activeTab === "response" && /* @__PURE__ */ jsxs132(Stack4, { spacing: 2, children: [
|
|
31995
|
+
showError && /* @__PURE__ */ jsxs132(Stack4, { spacing: 2, sx: ERROR_BOX_SX, children: [
|
|
31996
|
+
/* @__PURE__ */ jsxs132(Stack4, { spacing: 1, children: [
|
|
31997
|
+
/* @__PURE__ */ jsx145(Field, { label: "Type", children: errorType }),
|
|
31998
|
+
errorMessages.length > 0 && /* @__PURE__ */ jsx145(Field, { label: "Message", children: errorMessages.join(" \xB7 ") }),
|
|
31999
|
+
functionError && /* @__PURE__ */ jsxs132(Box18, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
|
|
32000
|
+
functionError.requestId !== void 0 && /* @__PURE__ */ jsx145(Field, { label: "Request ID", children: functionError.requestId }),
|
|
32001
|
+
/* @__PURE__ */ jsx145(Field, { label: "Function Error", testId: EVENT_DETAILS_FUNCTION_ERROR_TEST_ID, children: functionError.functionError })
|
|
32002
|
+
] })
|
|
32003
|
+
] }),
|
|
32004
|
+
functionError?.stackTrace !== void 0 && /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
32005
|
+
/* @__PURE__ */ jsxs132(Stack4, { alignItems: "center", direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
|
|
32006
|
+
/* @__PURE__ */ jsx145(Typography13, { sx: { fontWeight: 600 }, variant: "caption", children: "Stack Trace" }),
|
|
32007
|
+
/* @__PURE__ */ jsx145(CopyButton, { value: functionError.stackTrace })
|
|
32008
|
+
] }),
|
|
32009
|
+
/* @__PURE__ */ jsx145(
|
|
32010
|
+
Box18,
|
|
32011
|
+
{
|
|
32012
|
+
component: "pre",
|
|
32013
|
+
"data-testid": EVENT_DETAILS_STACK_TRACE_TEST_ID,
|
|
32014
|
+
sx: { backgroundColor: "background.default", borderRadius: 1, fontFamily: "monospace", fontSize: 12, m: 0, overflow: "auto", p: 1 },
|
|
32015
|
+
children: functionError.stackTrace
|
|
32016
|
+
}
|
|
32017
|
+
)
|
|
32018
|
+
] }),
|
|
32019
|
+
exceptionPayload !== void 0 && /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
32020
|
+
/* @__PURE__ */ jsx145(Typography13, { sx: { fontWeight: 600, mb: 0.5 }, variant: "caption", children: "Exception" }),
|
|
32021
|
+
/* @__PURE__ */ jsx145(PayloadViewer, { testId: EVENT_DETAILS_EXCEPTION_PAYLOAD_TEST_ID, value: exceptionPayload })
|
|
32022
|
+
] })
|
|
32023
|
+
] }),
|
|
32024
|
+
(isResponseSuppressed || responsePayload !== void 0) && /* @__PURE__ */ jsxs132(Box18, { children: [
|
|
32025
|
+
rawDataSwitch,
|
|
32026
|
+
isResponseSuppressed ? /* @__PURE__ */ jsx145(Alert4, { severity: "warning", children: "Response payload is available \u2014 upgrade your license to view" }) : /* @__PURE__ */ jsx145(PayloadViewer, { testId: EVENT_DETAILS_RESPONSE_PAYLOAD_TEST_ID, value: responsePayload })
|
|
32027
|
+
] })
|
|
32006
32028
|
] }),
|
|
32007
32029
|
activeTab === "permissions" && /* @__PURE__ */ jsxs132(Fragment11, { children: [
|
|
32008
32030
|
selectedEvent.iam_errors_suppressed && /* @__PURE__ */ jsx145(Alert4, { "data-testid": EVENT_DETAILS_IAM_ERRORS_SUPPRESSED_TEST_ID, severity: "warning", sx: { mb: 1 }, children: "IAM errors are suppressed \u2014 upgrade your license to view" }),
|
|
@@ -32551,10 +32573,40 @@ var TraceGraph = ({
|
|
|
32551
32573
|
] });
|
|
32552
32574
|
};
|
|
32553
32575
|
|
|
32576
|
+
// src/hooks/use-content-width.ts
|
|
32577
|
+
import * as React124 from "react";
|
|
32578
|
+
var contentWidth = (element) => {
|
|
32579
|
+
const style = getComputedStyle(element);
|
|
32580
|
+
const edges = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"];
|
|
32581
|
+
return edges.reduce((width, edge) => width - (Number.parseFloat(style[edge]) || 0), element.getBoundingClientRect().width);
|
|
32582
|
+
};
|
|
32583
|
+
var useContentWidth = (elementRef, parent = false) => {
|
|
32584
|
+
const [width, setWidth] = React124.useState(0);
|
|
32585
|
+
React124.useLayoutEffect(() => {
|
|
32586
|
+
const element = parent ? elementRef.current?.parentElement : elementRef.current;
|
|
32587
|
+
if (!element) return;
|
|
32588
|
+
setWidth(contentWidth(element));
|
|
32589
|
+
let frame2 = 0;
|
|
32590
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
32591
|
+
if (!entry) return;
|
|
32592
|
+
cancelAnimationFrame(frame2);
|
|
32593
|
+
frame2 = requestAnimationFrame(() => {
|
|
32594
|
+
setWidth(entry.contentRect.width);
|
|
32595
|
+
});
|
|
32596
|
+
});
|
|
32597
|
+
observer.observe(element);
|
|
32598
|
+
return () => {
|
|
32599
|
+
cancelAnimationFrame(frame2);
|
|
32600
|
+
observer.disconnect();
|
|
32601
|
+
};
|
|
32602
|
+
}, [elementRef, parent]);
|
|
32603
|
+
return width;
|
|
32604
|
+
};
|
|
32605
|
+
|
|
32554
32606
|
// src/hooks/use-local-storage.tsx
|
|
32555
|
-
import { useCallback as useCallback8, useEffect as useEffect19, useState as
|
|
32607
|
+
import { useCallback as useCallback8, useEffect as useEffect19, useState as useState18 } from "react";
|
|
32556
32608
|
function useLocalStorage(key, initialValue) {
|
|
32557
|
-
const [storedValue, setStoredValue] =
|
|
32609
|
+
const [storedValue, setStoredValue] = useState18(() => {
|
|
32558
32610
|
try {
|
|
32559
32611
|
const item = globalThis.localStorage.getItem(key);
|
|
32560
32612
|
return item ? JSON.parse(item) : initialValue;
|
|
@@ -32596,11 +32648,118 @@ function useLocalStorage(key, initialValue) {
|
|
|
32596
32648
|
return [storedValue, setValue];
|
|
32597
32649
|
}
|
|
32598
32650
|
|
|
32651
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
32652
|
+
import { keyframes as keyframes3 } from "@emotion/react";
|
|
32653
|
+
import { Cancel as Cancel8, FitScreen as FitScreen2, GppMaybe as GppMaybe9, KeyboardArrowDown as KeyboardArrowDown3, KeyboardArrowRight as KeyboardArrowRight3, KeyboardArrowUp, ZoomIn, ZoomOut } from "@mui/icons-material";
|
|
32654
|
+
import { Box as Box22, ButtonBase as ButtonBase2, Collapse, IconButton as IconButton8, Paper as Paper2, Popper, Tooltip as Tooltip7, Typography as Typography15 } from "@mui/material";
|
|
32655
|
+
import { alpha as alpha8, useTheme as useTheme7 } from "@mui/material/styles";
|
|
32656
|
+
import * as React126 from "react";
|
|
32657
|
+
|
|
32658
|
+
// src/components/trace-panel/sequence-layout.ts
|
|
32659
|
+
var CALLER_KEY = "";
|
|
32660
|
+
var resourceOf = (span) => {
|
|
32661
|
+
const resource = shortResourceName(span.resource_name, span.arn);
|
|
32662
|
+
return resource === "*" ? "" : resource;
|
|
32663
|
+
};
|
|
32664
|
+
var participantOf = (span, mode, callers) => {
|
|
32665
|
+
const resource = mode === "resource" || mode === "caller" && callers.has(`${span.service_name}/${resourceOf(span)}`) ? resourceOf(span) : "";
|
|
32666
|
+
return { key: `${span.service_name}/${resource}`, label: resource, resource, service: span.service_name };
|
|
32667
|
+
};
|
|
32668
|
+
var countDescendants = (node) => node.children.reduce((sum2, child) => sum2 + 1 + countDescendants(child), 0);
|
|
32669
|
+
var layoutSequence = (spans, mode, folded) => {
|
|
32670
|
+
const tree = buildTraceTree(spans);
|
|
32671
|
+
const visible = [];
|
|
32672
|
+
const visit = (nodes2, parent) => {
|
|
32673
|
+
for (const node of nodes2) {
|
|
32674
|
+
visible.push({ node, parent });
|
|
32675
|
+
if (!folded.has(node.span.span_id)) visit(node.children, node.span);
|
|
32676
|
+
}
|
|
32677
|
+
};
|
|
32678
|
+
visit(tree.roots);
|
|
32679
|
+
visible.sort((left, right) => compareNano(left.node.span.start_time_unix_nano, right.node.span.start_time_unix_nano));
|
|
32680
|
+
const callers = new Set(spans.filter((span) => tree.parentOf.has(span.span_id)).flatMap((span) => {
|
|
32681
|
+
const parent = spans.find((candidate) => candidate.span_id === tree.parentOf.get(span.span_id));
|
|
32682
|
+
return parent ? [`${parent.service_name}/${resourceOf(parent)}`] : [];
|
|
32683
|
+
}));
|
|
32684
|
+
const participants = [{ key: CALLER_KEY, label: "", resource: "", service: "" }];
|
|
32685
|
+
const indexOf = /* @__PURE__ */ new Map([[CALLER_KEY, 0]]);
|
|
32686
|
+
const place = (participant) => {
|
|
32687
|
+
const known = indexOf.get(participant.key);
|
|
32688
|
+
if (known !== void 0) return known;
|
|
32689
|
+
participants.push(participant);
|
|
32690
|
+
indexOf.set(participant.key, participants.length - 1);
|
|
32691
|
+
return participants.length - 1;
|
|
32692
|
+
};
|
|
32693
|
+
const rowOf = /* @__PURE__ */ new Map();
|
|
32694
|
+
const parentRows = [];
|
|
32695
|
+
const messages = [];
|
|
32696
|
+
for (const [row, { node, parent }] of visible.entries()) {
|
|
32697
|
+
const { span } = node;
|
|
32698
|
+
const issues = getSpanIssues(span);
|
|
32699
|
+
const from = parent ? place(participantOf(parent, mode, callers)) : 0;
|
|
32700
|
+
const hasChildren = node.children.length > 0;
|
|
32701
|
+
parentRows.push(parent ? rowOf.get(parent.span_id) : void 0);
|
|
32702
|
+
messages.push({
|
|
32703
|
+
async: parent !== void 0 && span.parent_span_id !== parent.span_id,
|
|
32704
|
+
depth: 0,
|
|
32705
|
+
descendantCount: countDescendants(node),
|
|
32706
|
+
endRow: row,
|
|
32707
|
+
error: issues.error,
|
|
32708
|
+
folded: hasChildren && folded.has(span.span_id),
|
|
32709
|
+
from,
|
|
32710
|
+
fromDepth: 0,
|
|
32711
|
+
resource: resourceOf(span),
|
|
32712
|
+
returnLevel: 0,
|
|
32713
|
+
span,
|
|
32714
|
+
to: place(participantOf(span, mode, callers)),
|
|
32715
|
+
warning: issues.warning
|
|
32716
|
+
});
|
|
32717
|
+
rowOf.set(span.span_id, row);
|
|
32718
|
+
}
|
|
32719
|
+
for (let row = messages.length - 1; row >= 0; row--) {
|
|
32720
|
+
const message = messages[row];
|
|
32721
|
+
const parent = messages[parentRows[row] ?? -1];
|
|
32722
|
+
if (message && parent && !message.async) parent.endRow = Math.max(parent.endRow, message.endRow);
|
|
32723
|
+
}
|
|
32724
|
+
const endings = messages.map(() => 0);
|
|
32725
|
+
for (const message of messages.toReversed()) {
|
|
32726
|
+
message.returnLevel = endings[message.endRow] ?? 0;
|
|
32727
|
+
endings[message.endRow] = message.returnLevel + 1;
|
|
32728
|
+
}
|
|
32729
|
+
for (const [row, message] of messages.entries()) {
|
|
32730
|
+
message.depth = messages.slice(0, row).filter((earlier) => earlier.to === message.to && earlier.endRow >= row).length;
|
|
32731
|
+
message.fromDepth = messages[parentRows[row] ?? -1]?.depth ?? 0;
|
|
32732
|
+
}
|
|
32733
|
+
const prefix = sharedPrefix(participants.map((participant) => participant.resource));
|
|
32734
|
+
const strip2 = (name) => name.startsWith(prefix) ? name.slice(prefix.length) : name;
|
|
32735
|
+
return {
|
|
32736
|
+
endings,
|
|
32737
|
+
messages: messages.map((message) => ({ ...message, resource: strip2(message.resource) })),
|
|
32738
|
+
participants: participants.map((participant) => ({ ...participant, label: strip2(participant.resource) }))
|
|
32739
|
+
};
|
|
32740
|
+
};
|
|
32741
|
+
var sharedPrefix = (names2) => {
|
|
32742
|
+
const counts = /* @__PURE__ */ new Map();
|
|
32743
|
+
for (const name of new Set(names2)) {
|
|
32744
|
+
for (let index = 0; index < name.length - 1; index++) {
|
|
32745
|
+
if ("-_/.".includes(name.charAt(index))) {
|
|
32746
|
+
const prefix = name.slice(0, index + 1);
|
|
32747
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
32748
|
+
}
|
|
32749
|
+
}
|
|
32750
|
+
}
|
|
32751
|
+
let best = "";
|
|
32752
|
+
for (const [prefix, count2] of counts) {
|
|
32753
|
+
if (count2 >= 2 && count2 * prefix.length > (counts.get(best) ?? 0) * best.length) best = prefix;
|
|
32754
|
+
}
|
|
32755
|
+
return best;
|
|
32756
|
+
};
|
|
32757
|
+
|
|
32599
32758
|
// src/components/trace-panel/waterfall.tsx
|
|
32600
32759
|
import { AccountTreeOutlined, Cancel as Cancel7, FormatListBulleted, GppMaybe as GppMaybe8, KeyboardArrowDown as KeyboardArrowDown2, KeyboardArrowRight as KeyboardArrowRight2 } from "@mui/icons-material";
|
|
32601
32760
|
import { Box as Box21, ButtonBase, ToggleButton as ToggleButton2, ToggleButtonGroup as ToggleButtonGroup2, Typography as Typography14 } from "@mui/material";
|
|
32602
32761
|
import { alpha as alpha7 } from "@mui/material/styles";
|
|
32603
|
-
import * as
|
|
32762
|
+
import * as React125 from "react";
|
|
32604
32763
|
|
|
32605
32764
|
// src/components/trace-panel/axis-ticks.ts
|
|
32606
32765
|
var getAxisTicks = (durationMs, maxIntervals) => {
|
|
@@ -32692,25 +32851,10 @@ var Line = ({ height, left, top = 0, width = 1 }) => /* @__PURE__ */ jsx150(
|
|
|
32692
32851
|
);
|
|
32693
32852
|
var AXIS_HEIGHT = 22;
|
|
32694
32853
|
var TRACK_INSET = 1.5;
|
|
32695
|
-
var useWidth = (elementRef) => {
|
|
32696
|
-
const [width, setWidth] = React124.useState(0);
|
|
32697
|
-
React124.useLayoutEffect(() => {
|
|
32698
|
-
const element = elementRef.current;
|
|
32699
|
-
if (!element) return;
|
|
32700
|
-
const observer = new ResizeObserver(([entry]) => {
|
|
32701
|
-
if (entry) setWidth(entry.contentRect.width);
|
|
32702
|
-
});
|
|
32703
|
-
observer.observe(element);
|
|
32704
|
-
return () => {
|
|
32705
|
-
observer.disconnect();
|
|
32706
|
-
};
|
|
32707
|
-
}, [elementRef]);
|
|
32708
|
-
return width;
|
|
32709
|
-
};
|
|
32710
32854
|
var LABEL_TRANSFORMS = { center: "translateX(-50%)", end: "translateX(-100%)", start: void 0 };
|
|
32711
32855
|
var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
32712
|
-
const trackRef =
|
|
32713
|
-
const width =
|
|
32856
|
+
const trackRef = React125.useRef(null);
|
|
32857
|
+
const width = useContentWidth(trackRef);
|
|
32714
32858
|
const { labels: labels2, marks } = layoutAxis(durationMs, width);
|
|
32715
32859
|
return /* @__PURE__ */ jsxs137(
|
|
32716
32860
|
Box21,
|
|
@@ -32778,15 +32922,15 @@ var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
|
32778
32922
|
);
|
|
32779
32923
|
};
|
|
32780
32924
|
var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
32781
|
-
const [collapsed, setCollapsed] =
|
|
32782
|
-
const containerRef =
|
|
32783
|
-
const tree =
|
|
32784
|
-
const bounds =
|
|
32925
|
+
const [collapsed, setCollapsed] = React125.useState(() => /* @__PURE__ */ new Set());
|
|
32926
|
+
const containerRef = React125.useRef(null);
|
|
32927
|
+
const tree = React125.useMemo(() => buildTraceTree(spans), [spans]);
|
|
32928
|
+
const bounds = React125.useMemo(() => getTraceBounds(spans), [spans]);
|
|
32785
32929
|
const { waterfallLayout } = useDevSettings();
|
|
32786
|
-
const [toggledFlat, setToggledFlat] =
|
|
32930
|
+
const [toggledFlat, setToggledFlat] = React125.useState(false);
|
|
32787
32931
|
const flat = waterfallLayout === "list" || waterfallLayout === "toggle" && toggledFlat;
|
|
32788
|
-
const rows =
|
|
32789
|
-
const [revealed, setRevealed] =
|
|
32932
|
+
const rows = React125.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
|
|
32933
|
+
const [revealed, setRevealed] = React125.useState();
|
|
32790
32934
|
if (selectedSpanId !== revealed) {
|
|
32791
32935
|
setRevealed(selectedSpanId);
|
|
32792
32936
|
const ancestors = /* @__PURE__ */ new Set();
|
|
@@ -32795,7 +32939,7 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32795
32939
|
setCollapsed((current) => new Set([...current].filter((id2) => !ancestors.has(id2))));
|
|
32796
32940
|
}
|
|
32797
32941
|
}
|
|
32798
|
-
|
|
32942
|
+
React125.useEffect(() => {
|
|
32799
32943
|
if (selectedSpanId === void 0) return;
|
|
32800
32944
|
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest" });
|
|
32801
32945
|
}, [selectedSpanId]);
|
|
@@ -32970,8 +33114,661 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32970
33114
|
] });
|
|
32971
33115
|
};
|
|
32972
33116
|
|
|
33117
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
33118
|
+
import { Fragment as Fragment15, jsx as jsx151, jsxs as jsxs138 } from "react/jsx-runtime";
|
|
33119
|
+
var COLUMN_WIDTH = 136;
|
|
33120
|
+
var HEADER_HEIGHT = 52;
|
|
33121
|
+
var LABEL_TOP = 1;
|
|
33122
|
+
var LABEL_HEIGHT = 18;
|
|
33123
|
+
var ARROW_Y = 24;
|
|
33124
|
+
var ARROW_HEAD = 5;
|
|
33125
|
+
var SELF_LOOP = 22;
|
|
33126
|
+
var BLOCK_WIDTH = 8;
|
|
33127
|
+
var BLOCK_OFFSET = BLOCK_WIDTH + 6;
|
|
33128
|
+
var BLOCK_OVERLAP_OFFSET = BLOCK_WIDTH * 3 / 4;
|
|
33129
|
+
var HATCH_MARGIN = 4;
|
|
33130
|
+
var BLOCK_OVERHANG = 4;
|
|
33131
|
+
var BLOCK_MIN_HEIGHT = 24;
|
|
33132
|
+
var BLOCK_TAIL = BLOCK_MIN_HEIGHT - BLOCK_OVERHANG;
|
|
33133
|
+
var BLOCK_RADIUS = 2;
|
|
33134
|
+
var RETURN_GAP = 10;
|
|
33135
|
+
var ROW_GAP = 8;
|
|
33136
|
+
var rowHeight = (endings) => ARROW_Y + (endings === 0 ? 0 : BLOCK_TAIL + (endings - 1) * RETURN_GAP) + ROW_GAP;
|
|
33137
|
+
var SLIDE_MS = 200;
|
|
33138
|
+
var SLIDE = `${String(SLIDE_MS)}ms cubic-bezier(0.4, 0, 0.2, 1)`;
|
|
33139
|
+
var SLIDE_TRANSITION = `transform ${SLIDE}, height ${SLIDE}`;
|
|
33140
|
+
var RETURN_HIT_HEIGHT = 9;
|
|
33141
|
+
var ARROW_HIT_HEIGHT = 15;
|
|
33142
|
+
var BLOCK_HIT_MARGIN = 3;
|
|
33143
|
+
var enter = keyframes3`from { opacity: 0 }`;
|
|
33144
|
+
var ENTER_ANIMATION = `${enter} ${SLIDE}`;
|
|
33145
|
+
var slideTo = (y, entering = false) => ({
|
|
33146
|
+
animation: entering ? ENTER_ANIMATION : void 0,
|
|
33147
|
+
transform: `translateY(${String(y)}px)`,
|
|
33148
|
+
transition: SLIDE_TRANSITION
|
|
33149
|
+
});
|
|
33150
|
+
var blockRect = (height) => ({ height, style: { height, transition: SLIDE_TRANSITION }, y: 0 });
|
|
33151
|
+
var hatchId = (color2) => `sequence-hatch-${color2.replace("#", "")}`;
|
|
33152
|
+
var lifelineX = (index) => index * COLUMN_WIDTH + COLUMN_WIDTH / 2;
|
|
33153
|
+
var blockX = (index, depth, offset) => lifelineX(index) + depth * offset;
|
|
33154
|
+
var Arrow = ({ blockOffset, blockWidth, color: color2, entering, message, top }) => {
|
|
33155
|
+
const y = ARROW_Y;
|
|
33156
|
+
const dash = message.async ? "4 3" : void 0;
|
|
33157
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33158
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33159
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33160
|
+
if (message.from === message.to) {
|
|
33161
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33162
|
+
const endX2 = toX + blockWidth / 2;
|
|
33163
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33164
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(fromX + fromHalf)} ${String(y - 6)}H${String(loopX)}v8H${String(endX2 + ARROW_HEAD)}`, fill: "none", strokeDasharray: dash }),
|
|
33165
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(endX2)} ${String(y + 2)}l${String(ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33166
|
+
] });
|
|
33167
|
+
}
|
|
33168
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33169
|
+
const startX = fromX + direction * fromHalf;
|
|
33170
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33171
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33172
|
+
/* @__PURE__ */ jsx151("line", { strokeDasharray: dash, x1: startX, x2: endX - direction * ARROW_HEAD, y1: y, y2: y }),
|
|
33173
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(endX)} ${String(y)}l${String(-direction * ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33174
|
+
] });
|
|
33175
|
+
};
|
|
33176
|
+
var arrowHitBox = (message, blockWidth, blockOffset, height) => {
|
|
33177
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33178
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33179
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33180
|
+
if (message.from === message.to) {
|
|
33181
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33182
|
+
const left = Math.min(fromX + fromHalf, toX + blockWidth / 2);
|
|
33183
|
+
return { height, left, top: ARROW_Y - 2 - height / 2, width: loopX - left };
|
|
33184
|
+
}
|
|
33185
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33186
|
+
const startX = fromX + direction * fromHalf;
|
|
33187
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33188
|
+
return { height, left: Math.min(startX, endX), top: ARROW_Y - height / 2, width: Math.abs(endX - startX) };
|
|
33189
|
+
};
|
|
33190
|
+
var hasReturn = (message) => !message.async && message.from !== message.to;
|
|
33191
|
+
var ReturnArrow = ({ blockOffset, blockWidth, color: color2, entering, message, y: lineY }) => {
|
|
33192
|
+
const y = 0;
|
|
33193
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33194
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33195
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33196
|
+
const startX = fromX + direction * blockWidth / 2;
|
|
33197
|
+
const endX = toX - direction * (message.from === 0 ? 0 : blockWidth / 2);
|
|
33198
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(lineY, entering), children: [
|
|
33199
|
+
/* @__PURE__ */ jsx151("line", { strokeDasharray: "3 3", x1: startX, x2: endX, y1: y, y2: y }),
|
|
33200
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(endX - direction * ARROW_HEAD)} ${String(y - 3)}L${String(endX)} ${String(y)}L${String(endX - direction * ARROW_HEAD)} ${String(y + 3)}`, fill: "none" })
|
|
33201
|
+
] });
|
|
33202
|
+
};
|
|
33203
|
+
var MIN_ZOOM = 0.25;
|
|
33204
|
+
var MAX_ZOOM = 1;
|
|
33205
|
+
var ZOOM_STEP = 1.25;
|
|
33206
|
+
var WHEEL_ZOOM_SPEED = 0.01;
|
|
33207
|
+
var MINIMAP_WIDTH = 168;
|
|
33208
|
+
var MINIMAP_MAX_HEIGHT = 160;
|
|
33209
|
+
var MINIMAP_MAX_VIEW_SHARE = 1 / 3;
|
|
33210
|
+
var WIDGET_MARGIN = 16;
|
|
33211
|
+
var BOTTOM_ROOM = 44 + WIDGET_MARGIN + 16;
|
|
33212
|
+
var MINIMAP_OPEN_STORAGE_KEY = "appinspector-sequence-minimap-open";
|
|
33213
|
+
var bodyIds = 0;
|
|
33214
|
+
var useBodyId = () => {
|
|
33215
|
+
const [id2] = React126.useState(() => `sequence-body-${String(++bodyIds)}`);
|
|
33216
|
+
return id2;
|
|
33217
|
+
};
|
|
33218
|
+
var clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
|
|
33219
|
+
var useZoom = (scrollRef, areaRef, widgetRef, enabled) => {
|
|
33220
|
+
const [zoom, setZoom] = React126.useState(1);
|
|
33221
|
+
const zoomRef = React126.useRef(zoom);
|
|
33222
|
+
const anchorRef = React126.useRef();
|
|
33223
|
+
const zoomTo = React126.useCallback((next, x, y) => {
|
|
33224
|
+
const element = scrollRef.current;
|
|
33225
|
+
const clamped = clampZoom(next);
|
|
33226
|
+
if (!element || clamped === zoomRef.current) return;
|
|
33227
|
+
anchorRef.current = { ratio: clamped / zoomRef.current, x: x ?? element.clientWidth / 2, y: y ?? element.clientHeight / 2 };
|
|
33228
|
+
zoomRef.current = clamped;
|
|
33229
|
+
setZoom(clamped);
|
|
33230
|
+
}, [scrollRef]);
|
|
33231
|
+
React126.useLayoutEffect(() => {
|
|
33232
|
+
const element = scrollRef.current;
|
|
33233
|
+
const anchor = anchorRef.current;
|
|
33234
|
+
if (!element || !anchor) return;
|
|
33235
|
+
element.scrollLeft = (element.scrollLeft + anchor.x) * anchor.ratio - anchor.x;
|
|
33236
|
+
element.scrollTop = (element.scrollTop + anchor.y) * anchor.ratio - anchor.y;
|
|
33237
|
+
anchorRef.current = void 0;
|
|
33238
|
+
}, [scrollRef, zoom]);
|
|
33239
|
+
React126.useEffect(() => {
|
|
33240
|
+
const element = scrollRef.current;
|
|
33241
|
+
const area = areaRef.current;
|
|
33242
|
+
if (!element || !area || !enabled) return;
|
|
33243
|
+
const pointer = (event) => {
|
|
33244
|
+
if (event.target instanceof Node && widgetRef.current?.contains(event.target)) return [];
|
|
33245
|
+
const bounds = element.getBoundingClientRect();
|
|
33246
|
+
return [event.clientX - bounds.left, event.clientY - bounds.top];
|
|
33247
|
+
};
|
|
33248
|
+
const handleWheel = (event) => {
|
|
33249
|
+
if (!event.ctrlKey && !event.metaKey) return;
|
|
33250
|
+
event.preventDefault();
|
|
33251
|
+
zoomTo(zoomRef.current * Math.exp(-event.deltaY * WHEEL_ZOOM_SPEED), ...pointer(event));
|
|
33252
|
+
};
|
|
33253
|
+
let gestureStart = 1;
|
|
33254
|
+
const handleGestureStart = (event) => {
|
|
33255
|
+
event.preventDefault();
|
|
33256
|
+
gestureStart = zoomRef.current;
|
|
33257
|
+
};
|
|
33258
|
+
const handleGestureChange = (event) => {
|
|
33259
|
+
event.preventDefault();
|
|
33260
|
+
const { scale: scale2 } = event;
|
|
33261
|
+
zoomTo(gestureStart * scale2, ...pointer(event));
|
|
33262
|
+
};
|
|
33263
|
+
area.addEventListener("wheel", handleWheel, { passive: false });
|
|
33264
|
+
area.addEventListener("gesturestart", handleGestureStart);
|
|
33265
|
+
area.addEventListener("gesturechange", handleGestureChange);
|
|
33266
|
+
return () => {
|
|
33267
|
+
area.removeEventListener("wheel", handleWheel);
|
|
33268
|
+
area.removeEventListener("gesturestart", handleGestureStart);
|
|
33269
|
+
area.removeEventListener("gesturechange", handleGestureChange);
|
|
33270
|
+
};
|
|
33271
|
+
}, [scrollRef, areaRef, widgetRef, enabled, zoomTo]);
|
|
33272
|
+
return { zoom, zoomTo };
|
|
33273
|
+
};
|
|
33274
|
+
var lifelineName = (participant) => participant.service === "" ? "Caller" : [getServiceDisplayName(participant.service), participant.label].filter(Boolean).join(" ");
|
|
33275
|
+
var hoverDirection = (hover) => {
|
|
33276
|
+
if (hover.kind === "segment") return `Active on ${hover.to}`;
|
|
33277
|
+
const kind = hover.kind === "response" ? "Response" : hover.message.async ? "Async request" : "Request";
|
|
33278
|
+
return `${kind} \xB7 ${hover.from} \u2192 ${hover.to}`;
|
|
33279
|
+
};
|
|
33280
|
+
var ArrowHoverCard = ({ hover }) => {
|
|
33281
|
+
const { span } = hover.message;
|
|
33282
|
+
const duration = span.end_time_unix_nano === null ? void 0 : formatDuration(Number(BigInt(span.end_time_unix_nano) - BigInt(span.start_time_unix_nano)) / 1e6);
|
|
33283
|
+
const issue = span.errors?.find((item) => item.level === "error")?.message ?? (hover.message.error ? span.status_message ?? void 0 : void 0) ?? span.errors?.find((item) => item.level === "warning")?.message;
|
|
33284
|
+
const anchor = { getBoundingClientRect: () => new DOMRect(hover.x, hover.y, 0, 0) };
|
|
33285
|
+
return /* @__PURE__ */ jsx151(Popper, { anchorEl: anchor, "data-testid": SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID, modifiers: [{ name: "offset", options: { offset: [12, 16] } }], open: true, placement: "bottom-start", sx: { pointerEvents: "none", zIndex: "tooltip" }, children: /* @__PURE__ */ jsxs138(Paper2, { elevation: 6, sx: { display: "flex", flexDirection: "column", gap: 0.75, maxWidth: 360, px: 1.5, py: 1 }, children: [
|
|
33286
|
+
/* @__PURE__ */ jsx151(OperationIdentity, { arn: span.arn, density: "stacked", iconSize: 24, operation: /* @__PURE__ */ jsx151(OperationName, { span, tooltip: false }), resourceName: span.resource_name, service: span.service_name }),
|
|
33287
|
+
getOperationLabel(span) !== span.operation_name && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: `Action: ${span.operation_name}` }),
|
|
33288
|
+
/* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: [hoverDirection(hover), duration].filter(Boolean).join(" \xB7 ") }),
|
|
33289
|
+
issue !== void 0 && issue !== "" && /* @__PURE__ */ jsx151(Typography15, { color: hover.message.error ? "error" : "warning.main", sx: { fontSize: 12 }, children: issue })
|
|
33290
|
+
] }) });
|
|
33291
|
+
};
|
|
33292
|
+
var SequenceDiagram = ({ onSelectSpan, participantMode = "caller", selectedSpanId, spans }) => {
|
|
33293
|
+
const theme = useTheme7();
|
|
33294
|
+
const [folded, setFolded] = React126.useState(() => /* @__PURE__ */ new Set());
|
|
33295
|
+
const containerRef = React126.useRef(null);
|
|
33296
|
+
const scrollRef = React126.useRef(null);
|
|
33297
|
+
const areaRef = React126.useRef(null);
|
|
33298
|
+
const widgetRef = React126.useRef(null);
|
|
33299
|
+
const { zoom, zoomTo } = useZoom(scrollRef, areaRef, widgetRef, spans.length > 0);
|
|
33300
|
+
const bodyId = useBodyId();
|
|
33301
|
+
const [minimapOpen, setMinimapOpen] = useLocalStorage(MINIMAP_OPEN_STORAGE_KEY, true);
|
|
33302
|
+
const [scrollView, setScrollView] = React126.useState({ height: 0, left: 0, scrollbarHeight: 0, scrollbarWidth: 0, top: 0, width: 0 });
|
|
33303
|
+
const measureView = React126.useCallback(() => {
|
|
33304
|
+
const element = scrollRef.current;
|
|
33305
|
+
if (element) setScrollView({
|
|
33306
|
+
height: element.clientHeight,
|
|
33307
|
+
left: element.scrollLeft,
|
|
33308
|
+
// Classic scrollbars take room; overlay ones (macOS by default) measure 0.
|
|
33309
|
+
scrollbarHeight: element.offsetHeight - element.clientHeight,
|
|
33310
|
+
scrollbarWidth: element.offsetWidth - element.clientWidth,
|
|
33311
|
+
top: element.scrollTop,
|
|
33312
|
+
width: element.clientWidth
|
|
33313
|
+
});
|
|
33314
|
+
}, []);
|
|
33315
|
+
React126.useLayoutEffect(() => {
|
|
33316
|
+
const element = scrollRef.current;
|
|
33317
|
+
if (!element) return;
|
|
33318
|
+
measureView();
|
|
33319
|
+
let frame2 = 0;
|
|
33320
|
+
const observer = new ResizeObserver(() => {
|
|
33321
|
+
cancelAnimationFrame(frame2);
|
|
33322
|
+
frame2 = requestAnimationFrame(measureView);
|
|
33323
|
+
});
|
|
33324
|
+
observer.observe(element);
|
|
33325
|
+
return () => {
|
|
33326
|
+
cancelAnimationFrame(frame2);
|
|
33327
|
+
observer.disconnect();
|
|
33328
|
+
};
|
|
33329
|
+
}, [measureView, zoom, spans.length]);
|
|
33330
|
+
const { sequenceBlocks, sequenceClickTargets, sequenceHoverCard } = useDevSettings();
|
|
33331
|
+
const arrowTargets = sequenceClickTargets === "arrows-and-segments";
|
|
33332
|
+
const returnHitHeight = arrowTargets ? ARROW_HIT_HEIGHT : RETURN_HIT_HEIGHT;
|
|
33333
|
+
const hoverCard = sequenceHoverCard === "on";
|
|
33334
|
+
const [hover, setHover] = React126.useState();
|
|
33335
|
+
const blocks = sequenceBlocks === "detached" || sequenceBlocks === "overlapped";
|
|
33336
|
+
const hatched = sequenceBlocks === "detached";
|
|
33337
|
+
const blockOffset = sequenceBlocks === "overlapped" ? BLOCK_OVERLAP_OFFSET : BLOCK_OFFSET;
|
|
33338
|
+
const merged = sequenceBlocks === "merged";
|
|
33339
|
+
const blockWidth = sequenceBlocks === "off" ? 0 : BLOCK_WIDTH;
|
|
33340
|
+
const segmentTargets = (arrowTargets || hoverCard) && blockWidth > 0;
|
|
33341
|
+
const { endings, messages, participants } = React126.useMemo(() => {
|
|
33342
|
+
const layout = layoutSequence(spans, participantMode, folded);
|
|
33343
|
+
return blocks ? layout : { ...layout, messages: layout.messages.map((message) => ({ ...message, depth: 0, fromDepth: 0 })) };
|
|
33344
|
+
}, [spans, participantMode, folded, blocks]);
|
|
33345
|
+
const pickedHereRef = React126.useRef();
|
|
33346
|
+
const select = React126.useCallback((spanId, view2) => {
|
|
33347
|
+
pickedHereRef.current = spanId;
|
|
33348
|
+
onSelectSpan(spanId, view2);
|
|
33349
|
+
}, [onSelectSpan]);
|
|
33350
|
+
React126.useEffect(() => {
|
|
33351
|
+
if (selectedSpanId === void 0 || selectedSpanId === pickedHereRef.current) return;
|
|
33352
|
+
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
33353
|
+
}, [selectedSpanId]);
|
|
33354
|
+
const [folding, setFolding] = React126.useState(false);
|
|
33355
|
+
const foldingTimerRef = React126.useRef();
|
|
33356
|
+
React126.useEffect(() => () => {
|
|
33357
|
+
clearTimeout(foldingTimerRef.current);
|
|
33358
|
+
}, []);
|
|
33359
|
+
const setFold = React126.useCallback((spanId, fold) => {
|
|
33360
|
+
setFolding(true);
|
|
33361
|
+
clearTimeout(foldingTimerRef.current);
|
|
33362
|
+
foldingTimerRef.current = setTimeout(() => {
|
|
33363
|
+
setFolding(false);
|
|
33364
|
+
}, SLIDE_MS + 100);
|
|
33365
|
+
setFolded((previous) => {
|
|
33366
|
+
const next = new Set(previous);
|
|
33367
|
+
if (fold) next.add(spanId);
|
|
33368
|
+
else next.delete(spanId);
|
|
33369
|
+
return next;
|
|
33370
|
+
});
|
|
33371
|
+
}, []);
|
|
33372
|
+
const handleKeyDown = React126.useCallback((event, message) => {
|
|
33373
|
+
if (event.target !== event.currentTarget) return;
|
|
33374
|
+
const spanId = message.span.span_id;
|
|
33375
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
33376
|
+
event.preventDefault();
|
|
33377
|
+
select(spanId, "details");
|
|
33378
|
+
} else if (event.key === "ArrowRight" && message.folded) setFold(spanId, false);
|
|
33379
|
+
else if (event.key === "ArrowLeft" && message.descendantCount > 0 && !message.folded) setFold(spanId, true);
|
|
33380
|
+
}, [select, setFold]);
|
|
33381
|
+
const [shown, setShown] = React126.useState(() => ({ messages, revealed: /* @__PURE__ */ new Set() }));
|
|
33382
|
+
if (shown.messages !== messages) {
|
|
33383
|
+
const previous = new Set(shown.messages.map((message) => message.span.span_id));
|
|
33384
|
+
const continued = messages.some((message) => previous.has(message.span.span_id));
|
|
33385
|
+
setShown({ messages, revealed: new Set(continued ? messages.filter((message) => !previous.has(message.span.span_id)).map((message) => message.span.span_id) : []) });
|
|
33386
|
+
}
|
|
33387
|
+
const isEntering = React126.useCallback((spanId) => shown.revealed.has(spanId), [shown]);
|
|
33388
|
+
const geometry = React126.useMemo(() => {
|
|
33389
|
+
const participant2 = (index) => participants[index] ?? { key: "", label: "", resource: "", service: "" };
|
|
33390
|
+
const width2 = participants.length * COLUMN_WIDTH;
|
|
33391
|
+
const rowHeights2 = endings.map((count2) => rowHeight(count2));
|
|
33392
|
+
const rowTops = rowHeights2.map((_height, row) => rowHeights2.slice(0, row).reduce((sum2, height) => sum2 + height, 0));
|
|
33393
|
+
const bodyHeight2 = rowHeights2.reduce((sum2, height) => sum2 + height, 0);
|
|
33394
|
+
const top2 = (row) => rowTops[row] ?? 0;
|
|
33395
|
+
const activeDepth2 = (lifeline, row) => Math.max(0, ...messages.slice(0, row + 1).filter((message) => message.to === lifeline && message.endRow >= row).map((message) => message.depth));
|
|
33396
|
+
const endY2 = (message) => top2(message.endRow) + ARROW_Y + BLOCK_TAIL + message.returnLevel * RETURN_GAP;
|
|
33397
|
+
const rowOf = new Map(messages.map((message, index) => [message.span.span_id, index]));
|
|
33398
|
+
const blockY2 = (message) => top2(rowOf.get(message.span.span_id) ?? 0) + ARROW_Y - BLOCK_OVERHANG;
|
|
33399
|
+
const mergedBlocks2 = [];
|
|
33400
|
+
if (merged) {
|
|
33401
|
+
for (const message of messages.toSorted((left, right) => left.to - right.to || blockY2(left) - blockY2(right))) {
|
|
33402
|
+
const last = mergedBlocks2.at(-1);
|
|
33403
|
+
if (last?.members[0]?.to === message.to && blockY2(message) <= last.bottom) {
|
|
33404
|
+
last.bottom = Math.max(last.bottom, endY2(message));
|
|
33405
|
+
last.members.push(message);
|
|
33406
|
+
} else mergedBlocks2.push({ bottom: endY2(message), members: [message], top: blockY2(message) });
|
|
33407
|
+
}
|
|
33408
|
+
}
|
|
33409
|
+
return { activeDepth: activeDepth2, blockY: blockY2, bodyHeight: bodyHeight2, endY: endY2, mergedBlocks: mergedBlocks2, participant: participant2, rowHeights: rowHeights2, top: top2, width: width2 };
|
|
33410
|
+
}, [endings, merged, messages, participants]);
|
|
33411
|
+
const { activeDepth, blockY, bodyHeight, endY, mergedBlocks, participant, rowHeights, top, width } = geometry;
|
|
33412
|
+
const hoveredMessage = hover && messages.find((message) => message.span.span_id === hover.message.span.span_id);
|
|
33413
|
+
const arrowHoverProps = React126.useCallback((message, kind) => {
|
|
33414
|
+
if (!hoverCard) return {};
|
|
33415
|
+
const [from, to] = kind === "response" ? [message.to, message.from] : [message.from, message.to];
|
|
33416
|
+
return {
|
|
33417
|
+
onMouseLeave: () => {
|
|
33418
|
+
setHover(void 0);
|
|
33419
|
+
},
|
|
33420
|
+
onMouseMove: (event) => {
|
|
33421
|
+
setHover({ from: lifelineName(participant(from)), kind, message, to: lifelineName(participant(to)), x: event.clientX, y: event.clientY });
|
|
33422
|
+
}
|
|
33423
|
+
};
|
|
33424
|
+
}, [hoverCard, participant]);
|
|
33425
|
+
const drawing = React126.useMemo(() => /* @__PURE__ */ jsxs138(Fragment15, { children: [
|
|
33426
|
+
/* @__PURE__ */ jsx151(Box22, { sx: { "&:has(> :hover) > :not(:hover)": { opacity: 0.4 }, "& > *": { transition: "opacity 150ms" }, "backgroundColor": "background.paper", "borderBottom": 1, "borderColor": "divider", "display": "flex", "height": HEADER_HEIGHT, "position": "sticky", "top": 0, "zIndex": 3 }, children: participants.map((participant2) => (
|
|
33427
|
+
// A subtle box per lifeline, its identity as in every other view: icon, service, resource below.
|
|
33428
|
+
/* @__PURE__ */ jsx151(
|
|
33429
|
+
Box22,
|
|
33430
|
+
{
|
|
33431
|
+
"data-testid": SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID,
|
|
33432
|
+
sx: {
|
|
33433
|
+
// As in Flow: a hovered box grows to show its whole name, over its neighbours, without moving them.
|
|
33434
|
+
"&:hover": { "& > *": { width: "max-content" }, "zIndex": 1 },
|
|
33435
|
+
"alignItems": "center",
|
|
33436
|
+
"display": "flex",
|
|
33437
|
+
"flex": "none",
|
|
33438
|
+
"justifyContent": "flex-start",
|
|
33439
|
+
"position": "relative",
|
|
33440
|
+
"px": "4px",
|
|
33441
|
+
"width": COLUMN_WIDTH
|
|
33442
|
+
},
|
|
33443
|
+
title: [participant2.service, participant2.resource].filter(Boolean).join(" \xB7 ") || "Caller",
|
|
33444
|
+
children: /* @__PURE__ */ jsx151(
|
|
33445
|
+
Box22,
|
|
33446
|
+
{
|
|
33447
|
+
sx: { alignItems: "center", background: `linear-gradient(${theme.palette.action.hover}, ${theme.palette.action.hover}), ${theme.palette.background.paper}`, border: 1, borderColor: "divider", borderRadius: 1, display: "flex", flex: "none", height: HEADER_HEIGHT - 12, justifyContent: participant2.service === "" ? "center" : "flex-start", minWidth: "100%", px: "6px", width: "100%" },
|
|
33448
|
+
children: participant2.service === "" ? /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", sx: { fontSize: 12 }, children: "Caller" }) : /* @__PURE__ */ jsx151(OperationIdentity, { density: "stacked", iconSize: 24, resourceName: participant2.label, service: participant2.service })
|
|
33449
|
+
}
|
|
33450
|
+
)
|
|
33451
|
+
},
|
|
33452
|
+
participant2.key
|
|
33453
|
+
)
|
|
33454
|
+
)) }),
|
|
33455
|
+
/* @__PURE__ */ jsxs138(Box22, { sx: { backgroundColor: "background.paper", height: bodyHeight, position: "relative" }, children: [
|
|
33456
|
+
messages.map((message, index) => {
|
|
33457
|
+
const { span } = message;
|
|
33458
|
+
const selected = span.span_id === selectedSpanId;
|
|
33459
|
+
const self2 = message.from === message.to;
|
|
33460
|
+
const lane = Math.min(message.from, message.to);
|
|
33461
|
+
const labelLeft = self2 ? blockX(message.to, Math.max(message.depth, message.fromDepth), blockOffset) + BLOCK_WIDTH / 2 + SELF_LOOP + 4 : blockX(lane, activeDepth(lane, index), blockOffset) + BLOCK_WIDTH / 2 + 4;
|
|
33462
|
+
return /* @__PURE__ */ jsxs138(
|
|
33463
|
+
Box22,
|
|
33464
|
+
{
|
|
33465
|
+
"aria-selected": selected,
|
|
33466
|
+
"data-span-id": span.span_id,
|
|
33467
|
+
"data-testid": SEQUENCE_DIAGRAM_MESSAGE_TEST_ID,
|
|
33468
|
+
onClick: arrowTargets ? void 0 : () => {
|
|
33469
|
+
select(span.span_id, "details");
|
|
33470
|
+
},
|
|
33471
|
+
onKeyDown: (event) => {
|
|
33472
|
+
handleKeyDown(event, message);
|
|
33473
|
+
},
|
|
33474
|
+
role: "listitem",
|
|
33475
|
+
sx: {
|
|
33476
|
+
"&:focus-visible": { boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}` },
|
|
33477
|
+
"&:hover": arrowTargets ? void 0 : { "--row-tint": selected ? alpha8(theme.palette.primary.main, 0.16) : alpha8(theme.palette.text.primary, 0.04) },
|
|
33478
|
+
// Opaque, so a label repeating it hides the lifelines behind it.
|
|
33479
|
+
"--row-bg": `linear-gradient(var(--row-tint), var(--row-tint)), ${theme.palette.background.paper}`,
|
|
33480
|
+
"--row-tint": selected ? alpha8(theme.palette.primary.main, 0.12) : "transparent",
|
|
33481
|
+
"animation": isEntering(span.span_id) ? ENTER_ANIMATION : void 0,
|
|
33482
|
+
// Only the tint: the drawing shows through the row, under its label.
|
|
33483
|
+
"background": "var(--row-tint)",
|
|
33484
|
+
"cursor": arrowTargets ? void 0 : "pointer",
|
|
33485
|
+
"height": rowHeights[index],
|
|
33486
|
+
"left": 0,
|
|
33487
|
+
"outline": 0,
|
|
33488
|
+
"position": "absolute",
|
|
33489
|
+
"right": 0,
|
|
33490
|
+
"scrollMarginTop": HEADER_HEIGHT,
|
|
33491
|
+
"top": 0,
|
|
33492
|
+
"transform": `translateY(${String(top(index))}px)`,
|
|
33493
|
+
// Only the transform: a height transition would re-lay out every row on every frame.
|
|
33494
|
+
"transition": `transform ${SLIDE}`,
|
|
33495
|
+
// The transform makes the row a stacking context: over the drawing, so its label covers the blocks and lines it crosses.
|
|
33496
|
+
"zIndex": 1
|
|
33497
|
+
},
|
|
33498
|
+
tabIndex: 0,
|
|
33499
|
+
children: [
|
|
33500
|
+
(arrowTargets || hoverCard) && /* @__PURE__ */ jsx151(
|
|
33501
|
+
Box22,
|
|
33502
|
+
{
|
|
33503
|
+
"data-testid": SEQUENCE_DIAGRAM_ARROW_TEST_ID,
|
|
33504
|
+
onClick: arrowTargets ? () => {
|
|
33505
|
+
select(span.span_id, "payload");
|
|
33506
|
+
} : void 0,
|
|
33507
|
+
...arrowHoverProps(message, "request"),
|
|
33508
|
+
sx: { "&:hover": arrowTargets ? { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) } : void 0, "borderRadius": "4px", "cursor": "pointer", "position": "absolute", ...arrowHitBox(message, blockWidth, blockOffset, ARROW_HIT_HEIGHT) }
|
|
33509
|
+
}
|
|
33510
|
+
),
|
|
33511
|
+
/* @__PURE__ */ jsxs138(
|
|
33512
|
+
Box22,
|
|
33513
|
+
{
|
|
33514
|
+
onClick: arrowTargets ? () => {
|
|
33515
|
+
select(span.span_id, "details");
|
|
33516
|
+
} : void 0,
|
|
33517
|
+
...arrowHoverProps(message, "request"),
|
|
33518
|
+
sx: {
|
|
33519
|
+
alignItems: "center",
|
|
33520
|
+
background: "var(--row-bg)",
|
|
33521
|
+
cursor: arrowTargets ? "pointer" : void 0,
|
|
33522
|
+
display: "flex",
|
|
33523
|
+
gap: "3px",
|
|
33524
|
+
height: LABEL_HEIGHT,
|
|
33525
|
+
left: labelLeft,
|
|
33526
|
+
maxWidth: width - labelLeft - 4,
|
|
33527
|
+
position: "absolute",
|
|
33528
|
+
px: "2px",
|
|
33529
|
+
top: LABEL_TOP,
|
|
33530
|
+
zIndex: 2
|
|
33531
|
+
},
|
|
33532
|
+
children: [
|
|
33533
|
+
message.descendantCount > 0 && /* @__PURE__ */ jsx151(
|
|
33534
|
+
ButtonBase2,
|
|
33535
|
+
{
|
|
33536
|
+
"aria-label": message.folded ? "Expand" : "Collapse",
|
|
33537
|
+
"data-testid": SEQUENCE_DIAGRAM_TOGGLE_TEST_ID,
|
|
33538
|
+
onClick: (event) => {
|
|
33539
|
+
event.stopPropagation();
|
|
33540
|
+
setFold(span.span_id, !message.folded);
|
|
33541
|
+
},
|
|
33542
|
+
sx: { "&:hover": { backgroundColor: alpha8(theme.palette.text.primary, 0.12) }, "borderRadius": "3px", "color": "text.secondary", "flex": "none", "height": 14, "width": 14 },
|
|
33543
|
+
tabIndex: -1,
|
|
33544
|
+
children: message.folded ? /* @__PURE__ */ jsx151(KeyboardArrowRight3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } })
|
|
33545
|
+
}
|
|
33546
|
+
),
|
|
33547
|
+
/* @__PURE__ */ jsx151(Typography15, { color: message.error ? "error" : "text.primary", component: "span", noWrap: true, sx: { flex: "none", fontSize: "inherit", fontWeight: 600 }, children: /* @__PURE__ */ jsx151(OperationName, { span, tooltip: !hoverCard }) }),
|
|
33548
|
+
participant(message.to).resource === "" && message.resource !== "" && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", noWrap: true, sx: { ...RESOURCE_CODE_SX, fontSize: 11, minWidth: 0 }, title: hoverCard ? void 0 : message.resource, children: message.resource }),
|
|
33549
|
+
message.error && /* @__PURE__ */ jsx151(Cancel8, { sx: { color: "error.main", flex: "none", fontSize: 13 } }),
|
|
33550
|
+
message.warning && /* @__PURE__ */ jsx151(GppMaybe9, { sx: { color: "warning.main", flex: "none", fontSize: 13 } }),
|
|
33551
|
+
message.folded && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", sx: { flex: "none", fontSize: 11 }, children: `+${String(message.descendantCount)}` })
|
|
33552
|
+
]
|
|
33553
|
+
}
|
|
33554
|
+
)
|
|
33555
|
+
]
|
|
33556
|
+
},
|
|
33557
|
+
span.span_id
|
|
33558
|
+
);
|
|
33559
|
+
}),
|
|
33560
|
+
messages.filter((message) => hasReturn(message)).map((message) => {
|
|
33561
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33562
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33563
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33564
|
+
return /* @__PURE__ */ jsx151(
|
|
33565
|
+
Box22,
|
|
33566
|
+
{
|
|
33567
|
+
"aria-hidden": "true",
|
|
33568
|
+
"aria-selected": selected,
|
|
33569
|
+
"data-span-id": message.span.span_id,
|
|
33570
|
+
"data-testid": SEQUENCE_DIAGRAM_RETURN_TEST_ID,
|
|
33571
|
+
onClick: () => {
|
|
33572
|
+
select(message.span.span_id, "response");
|
|
33573
|
+
},
|
|
33574
|
+
...arrowHoverProps(message, "response"),
|
|
33575
|
+
sx: {
|
|
33576
|
+
// The selected call's tint, as on its row, so its reply reads as part of it.
|
|
33577
|
+
"&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33578
|
+
"backgroundColor": selected ? alpha8(theme.palette.primary.main, 0.12) : void 0,
|
|
33579
|
+
"borderRadius": "4px",
|
|
33580
|
+
"cursor": "pointer",
|
|
33581
|
+
"height": returnHitHeight,
|
|
33582
|
+
"left": Math.min(fromX, toX),
|
|
33583
|
+
"position": "absolute",
|
|
33584
|
+
"top": 0,
|
|
33585
|
+
"width": Math.abs(toX - fromX),
|
|
33586
|
+
"zIndex": 2,
|
|
33587
|
+
...slideTo(endY(message) - returnHitHeight / 2, isEntering(message.span.span_id))
|
|
33588
|
+
},
|
|
33589
|
+
title: hoverCard ? void 0 : `${getOperationLabel(message.span)}: response`
|
|
33590
|
+
},
|
|
33591
|
+
message.span.span_id
|
|
33592
|
+
);
|
|
33593
|
+
}),
|
|
33594
|
+
segmentTargets && messages.map((message) => {
|
|
33595
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33596
|
+
const boxY = blockY(message);
|
|
33597
|
+
return /* @__PURE__ */ jsx151(
|
|
33598
|
+
Box22,
|
|
33599
|
+
{
|
|
33600
|
+
"aria-hidden": "true",
|
|
33601
|
+
"data-span-id": message.span.span_id,
|
|
33602
|
+
"data-testid": SEQUENCE_DIAGRAM_SEGMENT_TEST_ID,
|
|
33603
|
+
onClick: () => {
|
|
33604
|
+
select(message.span.span_id, "details");
|
|
33605
|
+
},
|
|
33606
|
+
...arrowHoverProps(message, "segment"),
|
|
33607
|
+
sx: {
|
|
33608
|
+
"&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33609
|
+
"borderRadius": "4px",
|
|
33610
|
+
"cursor": "pointer",
|
|
33611
|
+
"height": endY(message) - boxY,
|
|
33612
|
+
"left": blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 - BLOCK_HIT_MARGIN,
|
|
33613
|
+
"position": "absolute",
|
|
33614
|
+
"top": 0,
|
|
33615
|
+
"width": BLOCK_WIDTH + 2 * BLOCK_HIT_MARGIN,
|
|
33616
|
+
"zIndex": 2,
|
|
33617
|
+
// Its height follows a fold too: the slide's transition covers both.
|
|
33618
|
+
...slideTo(boxY, isEntering(message.span.span_id))
|
|
33619
|
+
},
|
|
33620
|
+
title: hoverCard ? void 0 : getOperationLabel(message.span)
|
|
33621
|
+
},
|
|
33622
|
+
message.span.span_id
|
|
33623
|
+
);
|
|
33624
|
+
}),
|
|
33625
|
+
/* @__PURE__ */ jsx151("svg", { "aria-hidden": "true", height: bodyHeight, style: { left: 0, overflow: "visible", pointerEvents: "none", position: "absolute", top: 0, zIndex: 0 }, width, children: /* @__PURE__ */ jsxs138("g", { id: bodyId, children: [
|
|
33626
|
+
/* @__PURE__ */ jsx151("defs", { children: [...new Set(messages.map((message) => getServiceColor(message.span.service_name)))].map((color2) => /* @__PURE__ */ jsx151("pattern", { height: 4, id: hatchId(color2), patternTransform: "rotate(45)", patternUnits: "userSpaceOnUse", width: 4, children: /* @__PURE__ */ jsx151("rect", { fill: alpha8(color2, 0.35), height: 4, width: 2 }) }, color2)) }),
|
|
33627
|
+
participants.map((participant2, index) => /* @__PURE__ */ jsx151("line", { stroke: blockWidth > 0 ? theme.palette.text.disabled : theme.palette.divider, strokeDasharray: blockWidth > 0 ? "2 3" : void 0, x1: lifelineX(index), x2: lifelineX(index), y1: 0, y2: bodyHeight }, participant2.key)),
|
|
33628
|
+
blocks && messages.map((message, index) => {
|
|
33629
|
+
const serviceColor = getServiceColor(message.span.service_name);
|
|
33630
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33631
|
+
const boxY = top(index) + ARROW_Y - BLOCK_OVERHANG;
|
|
33632
|
+
const boxHeight = endY(message) - boxY;
|
|
33633
|
+
const box = { ...blockRect(boxHeight), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x: blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 };
|
|
33634
|
+
const hatch = (earlier) => ({
|
|
33635
|
+
...blockRect(boxHeight + 2 * HATCH_MARGIN),
|
|
33636
|
+
// A pixel wider on each side, over the outer block's border: the hatch has none.
|
|
33637
|
+
width: BLOCK_WIDTH + 2,
|
|
33638
|
+
x: blockX(earlier.to, earlier.depth, blockOffset) - BLOCK_WIDTH / 2 - 1
|
|
33639
|
+
});
|
|
33640
|
+
const outer = hatched ? messages.slice(0, index).filter((earlier) => earlier.to === message.to && earlier.endRow >= index && earlier.depth < message.depth) : [];
|
|
33641
|
+
return (
|
|
33642
|
+
// Paper first, so the tint over it stays opaque to the lifeline.
|
|
33643
|
+
/* @__PURE__ */ jsxs138("g", { style: slideTo(boxY, isEntering(message.span.span_id)), children: [
|
|
33644
|
+
outer.map((earlier) => /* @__PURE__ */ jsxs138("g", { transform: `translate(0 ${String(-HATCH_MARGIN)})`, children: [
|
|
33645
|
+
/* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...hatch(earlier) }),
|
|
33646
|
+
/* @__PURE__ */ jsx151("rect", { fill: `url(#${hatchId(getServiceColor(earlier.span.service_name))})`, rx: BLOCK_RADIUS, ...hatch(earlier) })
|
|
33647
|
+
] }, earlier.span.span_id)),
|
|
33648
|
+
/* @__PURE__ */ jsx151("rect", { ...box, fill: theme.palette.background.paper }),
|
|
33649
|
+
/* @__PURE__ */ jsx151(
|
|
33650
|
+
"rect",
|
|
33651
|
+
{
|
|
33652
|
+
...box,
|
|
33653
|
+
fill: alpha8(serviceColor, selected ? 0.5 : 0.2),
|
|
33654
|
+
stroke: message.error ? theme.palette.error.main : serviceColor,
|
|
33655
|
+
strokeWidth: selected ? 1.5 : 1
|
|
33656
|
+
}
|
|
33657
|
+
)
|
|
33658
|
+
] }, message.span.span_id)
|
|
33659
|
+
);
|
|
33660
|
+
}),
|
|
33661
|
+
merged && mergedBlocks.map(({ bottom, members, top: blockTop }) => {
|
|
33662
|
+
const [firstMember] = members;
|
|
33663
|
+
if (!firstMember) return;
|
|
33664
|
+
const serviceColor = getServiceColor(firstMember.span.service_name);
|
|
33665
|
+
const x = lifelineX(firstMember.to) - BLOCK_WIDTH / 2;
|
|
33666
|
+
const range = (member2) => ({ ...blockRect(endY(member2) - blockY(member2)), transform: `translate(0 ${String(blockY(member2) - blockTop)})`, width: BLOCK_WIDTH, x });
|
|
33667
|
+
return /* @__PURE__ */ jsxs138("g", { style: slideTo(blockTop), children: [
|
|
33668
|
+
/* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x }),
|
|
33669
|
+
/* @__PURE__ */ jsx151("rect", { fill: alpha8(serviceColor, 0.2), ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, stroke: serviceColor, width: BLOCK_WIDTH, x }),
|
|
33670
|
+
members.filter((member2) => member2.span.span_id === selectedSpanId).map((member2) => /* @__PURE__ */ jsx151("rect", { fill: alpha8(serviceColor, 0.35), rx: BLOCK_RADIUS, ...range(member2) }, member2.span.span_id)),
|
|
33671
|
+
members.filter((member2) => member2.error).map((member2) => /* @__PURE__ */ jsx151("rect", { fill: "none", rx: BLOCK_RADIUS, stroke: theme.palette.error.main, ...range(member2) }, member2.span.span_id))
|
|
33672
|
+
] }, firstMember.span.span_id);
|
|
33673
|
+
}),
|
|
33674
|
+
messages.filter((message) => hasReturn(message)).map((message) => /* @__PURE__ */ jsx151(ReturnArrow, { blockOffset, blockWidth, color: message.error ? theme.palette.error.main : theme.palette.text.secondary, entering: isEntering(message.span.span_id), message, y: endY(message) }, message.span.span_id)),
|
|
33675
|
+
messages.map((message, index) => /* @__PURE__ */ jsx151(
|
|
33676
|
+
Arrow,
|
|
33677
|
+
{
|
|
33678
|
+
blockOffset,
|
|
33679
|
+
blockWidth,
|
|
33680
|
+
color: message.error ? theme.palette.error.main : theme.palette.text.secondary,
|
|
33681
|
+
entering: isEntering(message.span.span_id),
|
|
33682
|
+
message,
|
|
33683
|
+
top: top(index)
|
|
33684
|
+
},
|
|
33685
|
+
message.span.span_id
|
|
33686
|
+
))
|
|
33687
|
+
] }) })
|
|
33688
|
+
] })
|
|
33689
|
+
] }), [activeDepth, arrowHoverProps, arrowTargets, blockOffset, blockWidth, blockY, blocks, bodyHeight, bodyId, endY, handleKeyDown, hatched, hoverCard, isEntering, merged, mergedBlocks, messages, participant, participants, returnHitHeight, rowHeights, segmentTargets, select, selectedSpanId, setFold, theme, top, width]);
|
|
33690
|
+
if (spans.length === 0) {
|
|
33691
|
+
return /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { p: 2 }, variant: "body2", children: "No operations in this trace." });
|
|
33692
|
+
}
|
|
33693
|
+
const view = { height: scrollView.height / zoom - HEADER_HEIGHT, width: scrollView.width / zoom, x: scrollView.left / zoom, y: scrollView.top / zoom };
|
|
33694
|
+
const minimapScale = Math.min((MINIMAP_WIDTH - 16) / width, Math.min(MINIMAP_MAX_HEIGHT, scrollView.height * MINIMAP_MAX_VIEW_SHARE) / bodyHeight);
|
|
33695
|
+
const minimap = scrollView.width > 0 && (view.width < width || view.height < bodyHeight) ? { scale: minimapScale, view } : void 0;
|
|
33696
|
+
const panTo = (event) => {
|
|
33697
|
+
const element = scrollRef.current;
|
|
33698
|
+
if (!element) return;
|
|
33699
|
+
const bounds = event.currentTarget.querySelector("svg")?.getBoundingClientRect();
|
|
33700
|
+
if (!bounds) return;
|
|
33701
|
+
element.scrollLeft = ((event.clientX - bounds.left) / minimapScale - view.width / 2) * zoom;
|
|
33702
|
+
element.scrollTop = ((event.clientY - bounds.top) / minimapScale - view.height / 2) * zoom;
|
|
33703
|
+
};
|
|
33704
|
+
const fitWidth = () => {
|
|
33705
|
+
const viewWidth = scrollRef.current?.clientWidth;
|
|
33706
|
+
if (viewWidth) zoomTo(viewWidth / width, 0, 0);
|
|
33707
|
+
};
|
|
33708
|
+
return (
|
|
33709
|
+
// The diagram scrolls in a box of its own, so the zoom controls stay put over it.
|
|
33710
|
+
// Its own stacking context: the header's and the widget's z-indexes order them within the
|
|
33711
|
+
// diagram only, never over the sidebar's resize handles.
|
|
33712
|
+
/* @__PURE__ */ jsxs138(Box22, { ref: areaRef, sx: { flex: 1, height: "100%", isolation: "isolate", minHeight: 0, position: "relative" }, children: [
|
|
33713
|
+
/* @__PURE__ */ jsx151(Box22, { onScroll: measureView, ref: scrollRef, sx: { inset: 0, overflow: "auto", position: "absolute" }, children: /* @__PURE__ */ jsxs138(Box22, { "aria-label": "Sequence diagram", "data-folding": folding || void 0, "data-testid": SEQUENCE_DIAGRAM_TEST_ID, ref: containerRef, role: "list", style: { zoom }, sx: { "&:not([data-folding]) *": { transition: "none !important" }, "@media (prefers-reduced-motion: reduce)": { "& *": { animation: "none !important", transition: "none !important" } }, "fontSize": 12, "minWidth": "100%", "position": "relative", width }, children: [
|
|
33714
|
+
drawing,
|
|
33715
|
+
/* @__PURE__ */ jsx151(Box22, { sx: { height: BOTTOM_ROOM / zoom } })
|
|
33716
|
+
] }) }),
|
|
33717
|
+
/* @__PURE__ */ jsxs138(Paper2, { elevation: 2, ref: widgetRef, sx: { bottom: WIDGET_MARGIN + scrollView.scrollbarHeight, overflow: "hidden", p: 0, position: "absolute", right: WIDGET_MARGIN + scrollView.scrollbarWidth, width: MINIMAP_WIDTH, zIndex: 4 }, children: [
|
|
33718
|
+
minimap && // A thin bar with only a chevron: down folds the minimap away, up brings it back.
|
|
33719
|
+
/* @__PURE__ */ jsx151(
|
|
33720
|
+
ButtonBase2,
|
|
33721
|
+
{
|
|
33722
|
+
"aria-expanded": minimapOpen,
|
|
33723
|
+
"aria-label": minimapOpen ? "Hide the overview" : "Show the overview",
|
|
33724
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID,
|
|
33725
|
+
onClick: () => {
|
|
33726
|
+
setMinimapOpen(!minimapOpen);
|
|
33727
|
+
},
|
|
33728
|
+
sx: { "&:hover": { color: "text.primary" }, "borderBottom": 1, "borderColor": "divider", "color": "text.secondary", "height": 14, "width": "100%" },
|
|
33729
|
+
children: minimapOpen ? /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowUp, { sx: { fontSize: 16 } })
|
|
33730
|
+
}
|
|
33731
|
+
),
|
|
33732
|
+
minimap && /* @__PURE__ */ jsx151(Collapse, { in: minimapOpen, unmountOnExit: true, children: /* @__PURE__ */ jsx151(
|
|
33733
|
+
Box22,
|
|
33734
|
+
{
|
|
33735
|
+
"aria-label": "Minimap",
|
|
33736
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TEST_ID,
|
|
33737
|
+
onPointerDown: (event) => {
|
|
33738
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
33739
|
+
panTo(event);
|
|
33740
|
+
},
|
|
33741
|
+
onPointerMove: (event) => {
|
|
33742
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) panTo(event);
|
|
33743
|
+
},
|
|
33744
|
+
role: "navigation",
|
|
33745
|
+
sx: { backgroundColor: "action.hover", borderBottom: 1, borderColor: "divider", cursor: "pointer", display: "flex", justifyContent: "center", lineHeight: 0, p: 1, touchAction: "none" },
|
|
33746
|
+
children: /* @__PURE__ */ jsxs138("svg", { height: bodyHeight * minimap.scale, style: { backgroundColor: theme.palette.background.paper }, viewBox: `0 0 ${String(width)} ${String(bodyHeight)}`, width: width * minimap.scale, children: [
|
|
33747
|
+
/* @__PURE__ */ jsx151("use", { href: `#${bodyId}` }),
|
|
33748
|
+
/* @__PURE__ */ jsx151("rect", { fill: alpha8(theme.palette.primary.main, 0.08), height: minimap.view.height, stroke: theme.palette.primary.main, strokeWidth: 1.5 / minimap.scale, width: minimap.view.width, x: minimap.view.x, y: minimap.view.y })
|
|
33749
|
+
] })
|
|
33750
|
+
}
|
|
33751
|
+
) }),
|
|
33752
|
+
/* @__PURE__ */ jsxs138(Box22, { sx: { alignItems: "center", display: "flex", justifyContent: "space-between", px: "2px" }, children: [
|
|
33753
|
+
/* @__PURE__ */ jsx151(Tooltip7, { title: "Zoom out (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Zoom out", "data-testid": SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID, disabled: zoom <= MIN_ZOOM, onClick: () => {
|
|
33754
|
+
zoomTo(zoom / ZOOM_STEP);
|
|
33755
|
+
}, size: "small", children: /* @__PURE__ */ jsx151(ZoomOut, { fontSize: "small" }) }) }),
|
|
33756
|
+
/* @__PURE__ */ jsx151(Tooltip7, { title: "Reset zoom", children: /* @__PURE__ */ jsx151(ButtonBase2, { "data-testid": SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID, onClick: () => {
|
|
33757
|
+
zoomTo(1);
|
|
33758
|
+
}, sx: { borderRadius: 1, fontSize: 12, fontVariantNumeric: "tabular-nums", minWidth: 40, py: "2px" }, children: `${String(Math.round(zoom * 100))}%` }) }),
|
|
33759
|
+
/* @__PURE__ */ jsx151(Tooltip7, { title: "Zoom in (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Zoom in", "data-testid": SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID, disabled: zoom >= MAX_ZOOM, onClick: () => {
|
|
33760
|
+
zoomTo(zoom * ZOOM_STEP);
|
|
33761
|
+
}, size: "small", children: /* @__PURE__ */ jsx151(ZoomIn, { fontSize: "small" }) }) }),
|
|
33762
|
+
/* @__PURE__ */ jsx151(Tooltip7, { title: "Fit the width", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Fit the width", "data-testid": SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID, onClick: fitWidth, size: "small", children: /* @__PURE__ */ jsx151(FitScreen2, { fontSize: "small" }) }) })
|
|
33763
|
+
] })
|
|
33764
|
+
] }),
|
|
33765
|
+
hoverCard && hoveredMessage && /* @__PURE__ */ jsx151(ArrowHoverCard, { hover: { ...hover, message: hoveredMessage } })
|
|
33766
|
+
] })
|
|
33767
|
+
);
|
|
33768
|
+
};
|
|
33769
|
+
|
|
32973
33770
|
// src/components/trace-panel/trace-sidebar.tsx
|
|
32974
|
-
import { jsx as
|
|
33771
|
+
import { jsx as jsx152, jsxs as jsxs139 } from "react/jsx-runtime";
|
|
32975
33772
|
var DEFAULT_WIDTH_SHARE = 0.75;
|
|
32976
33773
|
var MAX_WIDTH_SHARE = 0.8;
|
|
32977
33774
|
var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
|
|
@@ -32992,22 +33789,16 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
32992
33789
|
const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
|
|
32993
33790
|
const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
|
|
32994
33791
|
const [storedView, setView] = useLocalStorage(VIEW_STORAGE_KEY, "map");
|
|
32995
|
-
const view = storedView === "waterfall"
|
|
32996
|
-
const sidebarRef =
|
|
32997
|
-
const traceViewRef =
|
|
33792
|
+
const view = storedView === "waterfall" || storedView === "sequence" ? storedView : "map";
|
|
33793
|
+
const sidebarRef = React127.useRef(null);
|
|
33794
|
+
const traceViewRef = React127.useRef(null);
|
|
32998
33795
|
const width = maximized ? 1 : storedWidth;
|
|
32999
|
-
const [
|
|
33000
|
-
|
|
33001
|
-
|
|
33002
|
-
|
|
33003
|
-
|
|
33004
|
-
|
|
33005
|
-
});
|
|
33006
|
-
observer.observe(parent);
|
|
33007
|
-
return () => {
|
|
33008
|
-
observer.disconnect();
|
|
33009
|
-
};
|
|
33010
|
-
}, []);
|
|
33796
|
+
const [requestedTab, setRequestedTab] = React127.useState();
|
|
33797
|
+
const selectFromSequence = React127.useCallback((spanId, view2) => {
|
|
33798
|
+
onSelectSpan(spanId);
|
|
33799
|
+
setRequestedTab({ view: view2 });
|
|
33800
|
+
}, [onSelectSpan]);
|
|
33801
|
+
const parentWidth = useContentWidth(sidebarRef, true);
|
|
33011
33802
|
const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
|
|
33012
33803
|
const resize = (share) => {
|
|
33013
33804
|
const snap = share > SNAP_WIDTH_SHARE;
|
|
@@ -33046,7 +33837,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33046
33837
|
event.preventDefault();
|
|
33047
33838
|
setStoredSplit(clampSplit(storedSplit + delta));
|
|
33048
33839
|
};
|
|
33049
|
-
const { root: root2, selectedSpan, stats } =
|
|
33840
|
+
const { root: root2, selectedSpan, stats } = React127.useMemo(() => {
|
|
33050
33841
|
const tree = buildTraceTree(spans);
|
|
33051
33842
|
const issues = spans.map((span) => getSpanIssues(span));
|
|
33052
33843
|
return {
|
|
@@ -33060,7 +33851,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33060
33851
|
};
|
|
33061
33852
|
}, [spans, selectedSpanId]);
|
|
33062
33853
|
const rootSpanId = root2?.span_id;
|
|
33063
|
-
|
|
33854
|
+
React127.useEffect(() => {
|
|
33064
33855
|
if (!onRequestRendered || rootSpanId === void 0) return;
|
|
33065
33856
|
let frame2 = requestAnimationFrame(() => {
|
|
33066
33857
|
frame2 = requestAnimationFrame(() => {
|
|
@@ -33071,8 +33862,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33071
33862
|
cancelAnimationFrame(frame2);
|
|
33072
33863
|
};
|
|
33073
33864
|
}, [onRequestRendered, rootSpanId, view]);
|
|
33074
|
-
return /* @__PURE__ */
|
|
33075
|
-
|
|
33865
|
+
return /* @__PURE__ */ jsxs139(
|
|
33866
|
+
Box23,
|
|
33076
33867
|
{
|
|
33077
33868
|
"data-testid": TRACE_SIDEBAR_TEST_ID,
|
|
33078
33869
|
ref: sidebarRef,
|
|
@@ -33094,8 +33885,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33094
33885
|
width: `${String(width * 100)}%`
|
|
33095
33886
|
},
|
|
33096
33887
|
children: [
|
|
33097
|
-
/* @__PURE__ */
|
|
33098
|
-
|
|
33888
|
+
/* @__PURE__ */ jsx152(
|
|
33889
|
+
Box23,
|
|
33099
33890
|
{
|
|
33100
33891
|
"aria-label": "Resize the sidebar",
|
|
33101
33892
|
"aria-orientation": "vertical",
|
|
@@ -33123,14 +33914,14 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33123
33914
|
tabIndex: 0
|
|
33124
33915
|
}
|
|
33125
33916
|
),
|
|
33126
|
-
/* @__PURE__ */
|
|
33127
|
-
root2 === void 0 ? /* @__PURE__ */
|
|
33917
|
+
/* @__PURE__ */ jsxs139(Box23, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
|
|
33918
|
+
root2 === void 0 ? /* @__PURE__ */ jsx152(Box23, { sx: { flex: 1 } }) : /* @__PURE__ */ jsx152(
|
|
33128
33919
|
OperationIdentity,
|
|
33129
33920
|
{
|
|
33130
33921
|
arn: root2.arn,
|
|
33131
33922
|
density: "heading",
|
|
33132
33923
|
label: "Request",
|
|
33133
|
-
operation: /* @__PURE__ */
|
|
33924
|
+
operation: /* @__PURE__ */ jsx152(OperationName, { span: root2 }),
|
|
33134
33925
|
resourceName: root2.resource_name,
|
|
33135
33926
|
service: root2.service_name,
|
|
33136
33927
|
sx: { flex: 1 },
|
|
@@ -33144,7 +33935,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33144
33935
|
].join(" \xB7 ")
|
|
33145
33936
|
}
|
|
33146
33937
|
),
|
|
33147
|
-
/* @__PURE__ */
|
|
33938
|
+
/* @__PURE__ */ jsxs139(
|
|
33148
33939
|
ToggleButtonGroup3,
|
|
33149
33940
|
{
|
|
33150
33941
|
"aria-label": "Trace view",
|
|
@@ -33157,28 +33948,33 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33157
33948
|
size: "small",
|
|
33158
33949
|
value: view,
|
|
33159
33950
|
children: [
|
|
33160
|
-
/* @__PURE__ */
|
|
33161
|
-
/* @__PURE__ */
|
|
33951
|
+
/* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
|
|
33952
|
+
/* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" }),
|
|
33953
|
+
/* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "sequence", children: "Sequence" })
|
|
33162
33954
|
]
|
|
33163
33955
|
}
|
|
33164
33956
|
),
|
|
33165
|
-
/* @__PURE__ */
|
|
33957
|
+
/* @__PURE__ */ jsx152(IconButton9, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
|
|
33166
33958
|
setMaximized(!maximized);
|
|
33167
|
-
}, size: "small", children: maximized ? /* @__PURE__ */
|
|
33168
|
-
/* @__PURE__ */
|
|
33959
|
+
}, size: "small", children: maximized ? /* @__PURE__ */ jsx152(CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ jsx152(OpenInFull, { fontSize: "small" }) }),
|
|
33960
|
+
/* @__PURE__ */ jsx152(IconButton9, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ jsx152(Close4, {}) })
|
|
33169
33961
|
] }),
|
|
33170
|
-
/* @__PURE__ */
|
|
33171
|
-
|
|
33172
|
-
{
|
|
33173
|
-
|
|
33174
|
-
|
|
33175
|
-
|
|
33176
|
-
|
|
33177
|
-
|
|
33178
|
-
|
|
33179
|
-
|
|
33180
|
-
|
|
33181
|
-
|
|
33962
|
+
/* @__PURE__ */ jsxs139(Box23, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: [
|
|
33963
|
+
view === "waterfall" && /* @__PURE__ */ jsx152(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }),
|
|
33964
|
+
view === "sequence" && /* @__PURE__ */ jsx152(SequenceDiagram, { onSelectSpan: selectFromSequence, selectedSpanId, spans }),
|
|
33965
|
+
view === "map" && /* @__PURE__ */ jsx152(Box23, { sx: { height: "100%" }, children: /* @__PURE__ */ jsx152(ReactFlowProvider, { children: /* @__PURE__ */ jsx152(
|
|
33966
|
+
TraceGraph,
|
|
33967
|
+
{
|
|
33968
|
+
hideMiniMap: true,
|
|
33969
|
+
initialFocusEventId: selectedSpanId,
|
|
33970
|
+
onEventSelect: onSelectSpan,
|
|
33971
|
+
onRefresh: noop,
|
|
33972
|
+
spans: { data: spans, error: void 0, loading: false }
|
|
33973
|
+
}
|
|
33974
|
+
) }) })
|
|
33975
|
+
] }),
|
|
33976
|
+
/* @__PURE__ */ jsx152(Box23, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ jsx152(
|
|
33977
|
+
Box23,
|
|
33182
33978
|
{
|
|
33183
33979
|
"aria-label": "Resize the operation details",
|
|
33184
33980
|
"aria-orientation": "horizontal",
|
|
@@ -33206,7 +34002,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33206
34002
|
tabIndex: 0
|
|
33207
34003
|
}
|
|
33208
34004
|
) }),
|
|
33209
|
-
/* @__PURE__ */
|
|
34005
|
+
/* @__PURE__ */ jsx152(Box23, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ jsx152(EventDetails, { onOperationShown, requestedTab, selectedEvent: selectedSpan }) : /* @__PURE__ */ jsx152(Typography16, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33210
34006
|
]
|
|
33211
34007
|
}
|
|
33212
34008
|
);
|
|
@@ -33214,10 +34010,10 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33214
34010
|
|
|
33215
34011
|
// src/components/worker-error-message/worker-error-message.tsx
|
|
33216
34012
|
import { ErrorOutline as ErrorOutline2 } from "@mui/icons-material";
|
|
33217
|
-
import { Alert as Alert6, AlertTitle as AlertTitle2, Box as
|
|
33218
|
-
import { jsx as
|
|
33219
|
-
var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */
|
|
33220
|
-
|
|
34013
|
+
import { Alert as Alert6, AlertTitle as AlertTitle2, Box as Box24, Button as Button7, Typography as Typography17 } from "@mui/material";
|
|
34014
|
+
import { jsx as jsx153, jsxs as jsxs140 } from "react/jsx-runtime";
|
|
34015
|
+
var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx153(
|
|
34016
|
+
Box24,
|
|
33221
34017
|
{
|
|
33222
34018
|
sx: {
|
|
33223
34019
|
alignItems: "center",
|
|
@@ -33227,17 +34023,17 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
|
|
|
33227
34023
|
justifyContent: "center",
|
|
33228
34024
|
p: 4
|
|
33229
34025
|
},
|
|
33230
|
-
children: /* @__PURE__ */
|
|
34026
|
+
children: /* @__PURE__ */ jsxs140(
|
|
33231
34027
|
Alert6,
|
|
33232
34028
|
{
|
|
33233
|
-
icon: /* @__PURE__ */
|
|
34029
|
+
icon: /* @__PURE__ */ jsx153(ErrorOutline2, { fontSize: "large" }),
|
|
33234
34030
|
severity: "error",
|
|
33235
34031
|
sx: { maxWidth: 600, width: "100%" },
|
|
33236
34032
|
children: [
|
|
33237
|
-
/* @__PURE__ */
|
|
33238
|
-
/* @__PURE__ */
|
|
33239
|
-
/* @__PURE__ */
|
|
33240
|
-
onRetry && /* @__PURE__ */
|
|
34033
|
+
/* @__PURE__ */ jsx153(AlertTitle2, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
|
|
34034
|
+
/* @__PURE__ */ jsx153(Typography17, { sx: { mb: 2 }, variant: "body2", children: "App Inspector couldn't start the background worker that filters and sorts operations. This is usually caused by a Content-Security-Policy blocking Web Workers in this environment." }),
|
|
34035
|
+
/* @__PURE__ */ jsx153(Typography17, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
|
|
34036
|
+
onRetry && /* @__PURE__ */ jsx153(Box24, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsx153(
|
|
33241
34037
|
Button7,
|
|
33242
34038
|
{
|
|
33243
34039
|
"aria-label": "Retry starting the spans filter worker",
|
|
@@ -33253,7 +34049,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
|
|
|
33253
34049
|
);
|
|
33254
34050
|
|
|
33255
34051
|
// src/hooks/use-filter-used-analytics.ts
|
|
33256
|
-
import { useEffect as
|
|
34052
|
+
import { useEffect as useEffect23, useRef as useRef19, useState as useState22 } from "react";
|
|
33257
34053
|
var FILTER_KEYS = {
|
|
33258
34054
|
consumer: "service",
|
|
33259
34055
|
producer: "producer",
|
|
@@ -33280,11 +34076,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
|
|
|
33280
34076
|
var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
|
|
33281
34077
|
const api = useAppInspectorApi();
|
|
33282
34078
|
const { deploymentContainer } = useAppInspector();
|
|
33283
|
-
const previousQueryRef =
|
|
33284
|
-
const pendingRef =
|
|
33285
|
-
const changeCountRef =
|
|
33286
|
-
const [settledChange, setSettledChange] =
|
|
33287
|
-
|
|
34079
|
+
const previousQueryRef = useRef19(query2);
|
|
34080
|
+
const pendingRef = useRef19();
|
|
34081
|
+
const changeCountRef = useRef19(0);
|
|
34082
|
+
const [settledChange, setSettledChange] = useState22(0);
|
|
34083
|
+
useEffect23(() => {
|
|
33288
34084
|
const previous = parseQuery(previousQueryRef.current);
|
|
33289
34085
|
const next = parseQuery(query2);
|
|
33290
34086
|
previousQueryRef.current = query2;
|
|
@@ -33307,7 +34103,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33307
34103
|
clearTimeout(timer);
|
|
33308
34104
|
};
|
|
33309
34105
|
}, [query2]);
|
|
33310
|
-
|
|
34106
|
+
useEffect23(() => {
|
|
33311
34107
|
const pending = pendingRef.current;
|
|
33312
34108
|
if (pending === void 0 || filteredCount === void 0) {
|
|
33313
34109
|
return;
|
|
@@ -33353,7 +34149,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33353
34149
|
};
|
|
33354
34150
|
|
|
33355
34151
|
// src/hooks/use-operation-open-analytics.ts
|
|
33356
|
-
import { useEffect as
|
|
34152
|
+
import { useEffect as useEffect24, useRef as useRef20 } from "react";
|
|
33357
34153
|
|
|
33358
34154
|
// src/utils/request-id.ts
|
|
33359
34155
|
var getRequestId = (spans) => {
|
|
@@ -33373,8 +34169,8 @@ var getRequestId = (spans) => {
|
|
|
33373
34169
|
var useOperationOpenAnalytics = ({ open, shown, spans }) => {
|
|
33374
34170
|
const api = useAppInspectorApi();
|
|
33375
34171
|
const { deploymentContainer } = useAppInspector();
|
|
33376
|
-
const shownKeyRef =
|
|
33377
|
-
|
|
34172
|
+
const shownKeyRef = useRef20();
|
|
34173
|
+
useEffect24(() => {
|
|
33378
34174
|
const shownKey = open && shown ? `${shown.span.span_id}
|
|
33379
34175
|
${shown.view}` : void 0;
|
|
33380
34176
|
const previousKey = shownKeyRef.current;
|
|
@@ -33400,12 +34196,12 @@ ${shown.view}` : void 0;
|
|
|
33400
34196
|
};
|
|
33401
34197
|
|
|
33402
34198
|
// src/hooks/use-request-open-analytics.ts
|
|
33403
|
-
import { useEffect as
|
|
34199
|
+
import { useEffect as useEffect25, useRef as useRef21 } from "react";
|
|
33404
34200
|
var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
33405
34201
|
const api = useAppInspectorApi();
|
|
33406
34202
|
const { deploymentContainer } = useAppInspector();
|
|
33407
|
-
const firedForRef =
|
|
33408
|
-
|
|
34203
|
+
const firedForRef = useRef21();
|
|
34204
|
+
useEffect25(() => {
|
|
33409
34205
|
if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
|
|
33410
34206
|
return;
|
|
33411
34207
|
}
|
|
@@ -33436,7 +34232,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
|
33436
34232
|
};
|
|
33437
34233
|
|
|
33438
34234
|
// src/hooks/use-spans.ts
|
|
33439
|
-
import { useCallback as
|
|
34235
|
+
import { useCallback as useCallback13, useEffect as useEffect28, useRef as useRef24, useState as useState25 } from "react";
|
|
33440
34236
|
import { unstable_batchedUpdates as batchedUpdates } from "react-dom";
|
|
33441
34237
|
|
|
33442
34238
|
// src/utils/pagination-buffer.ts
|
|
@@ -33691,7 +34487,7 @@ var toSpanFilterProjection = (span) => ({
|
|
|
33691
34487
|
});
|
|
33692
34488
|
|
|
33693
34489
|
// src/hooks/use-spans-compute.ts
|
|
33694
|
-
import { useCallback as
|
|
34490
|
+
import { useCallback as useCallback11, useEffect as useEffect26, useRef as useRef22, useState as useState23 } from "react";
|
|
33695
34491
|
|
|
33696
34492
|
// inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
|
|
33697
34493
|
var source = '(() => {\n // src/utils/query.ts\n var EXTERNAL_PRODUCER = "external";\n var QUERY_KEYS = ["service", "producer", "status", "op", "resource", "client", "region", "account", "dur", "trace"];\n var isQueryKey = (value) => QUERY_KEYS.includes(value);\n var TOKEN_PATTERN = /(?:[^\\s"]+|"[^"]*"?)+/g;\n var unquote = (value) => value.replaceAll(\'"\', "");\n var isExclusion = (token) => token.length > 1 && token.startsWith("-");\n var splitTerm = (token) => {\n const unquoted = unquote(isExclusion(token) ? token.slice(1) : token);\n const separator = unquoted.indexOf(":");\n if (separator <= 0) {\n return void 0;\n }\n const key = unquoted.slice(0, separator).toLowerCase();\n const value = unquoted.slice(separator + 1);\n return isQueryKey(key) && value !== "" ? [key, value] : void 0;\n };\n var parseQuery = (query) => {\n const parsed = { excludedTerms: {}, excludedWords: [], terms: {}, words: [] };\n for (const token of query.match(TOKEN_PATTERN) ?? []) {\n const excluded = isExclusion(token);\n const term = splitTerm(token);\n if (term) {\n const [key, value] = term;\n ((excluded ? parsed.excludedTerms : parsed.terms)[key] ??= []).push(value);\n } else {\n const word = unquote(excluded ? token.slice(1) : token).toLowerCase();\n if (word !== "") {\n (excluded ? parsed.excludedWords : parsed.words).push(word);\n }\n }\n }\n return parsed;\n };\n var hasExclusions = (parsed) => parsed.excludedWords.length > 0 || Object.keys(parsed.excludedTerms).length > 0;\n var isQueryEmpty = (parsed) => parsed.words.length === 0 && Object.keys(parsed.terms).length === 0 && !hasExclusions(parsed);\n var UNIT_TO_MS = { m: 6e4, ms: 1, s: 1e3, us: 1e-3 };\n var parseDuration = (value) => {\n const match = /^(>=|<=|>|<|=)?\\s*(\\d+(?:\\.\\d+)?)\\s*(us|ms|s|m)?$/i.exec(value.trim());\n if (!match) {\n return void 0;\n }\n const [, operator = ">=", amount = "0", unit = "ms"] = match;\n const threshold = Number(amount) * (UNIT_TO_MS[unit.toLowerCase()] ?? 1);\n switch (operator) {\n case "<": {\n return (durationMs) => durationMs < threshold;\n }\n case "<=": {\n return (durationMs) => durationMs <= threshold;\n }\n case "=": {\n return (durationMs) => Math.round(durationMs) === Math.round(threshold);\n }\n case ">": {\n return (durationMs) => durationMs > threshold;\n }\n default: {\n return (durationMs) => durationMs >= threshold;\n }\n }\n };\n var includesIgnoreCase = (haystack, needle) => haystack.toLowerCase().includes(needle.toLowerCase());\n var matchesTerm = (span, key, value) => {\n switch (key) {\n case "account": {\n return span.accountId === value;\n }\n case "client": {\n return span.triggerKind === value.toLowerCase();\n }\n case "dur": {\n const predicate = parseDuration(value);\n return predicate !== void 0 && span.durationMs !== void 0 && predicate(span.durationMs);\n }\n case "op": {\n return includesIgnoreCase(span.operationName, value);\n }\n case "producer": {\n return span.producer.toLowerCase() === value.toLowerCase();\n }\n case "region": {\n return span.region.toLowerCase() === value.toLowerCase();\n }\n case "resource": {\n return includesIgnoreCase(span.resourceName, value) || includesIgnoreCase(span.arn, value);\n }\n case "service": {\n return span.serviceName.toLowerCase() === value.toLowerCase();\n }\n case "status": {\n const status = value.toLowerCase();\n if (status === "error") return span.error;\n if (status === "warning" || status === "warn") return span.warning;\n if (status === "ok") return !span.error && !span.warning;\n return span.statusMessage?.includes(value) ?? false;\n }\n case "trace": {\n return span.traceId.startsWith(value.toLowerCase());\n }\n }\n };\n var matchesExclusion = (span, parsed) => Object.entries(parsed.excludedTerms).some(([key, values]) => values.some((value) => matchesTerm(span, key, value))) || parsed.excludedWords.some((word) => span.haystack.includes(word));\n var matchesQuery = (span, parsed, textMatches) => {\n if (matchesExclusion(span, parsed)) {\n return false;\n }\n for (const [key, values] of Object.entries(parsed.terms)) {\n if (!values.some((value) => matchesTerm(span, key, value))) {\n return false;\n }\n }\n if (parsed.words.length > 0 && !textMatches?.has(span.spanId)) {\n return parsed.words.every((word) => span.haystack.includes(word));\n }\n return true;\n };\n\n // src/utils/iam-utils.ts\n function determinePermissionStatus(payload) {\n if (payload.explicit_deny_count && payload.explicit_deny_count > 0) {\n return "explicitly_denied";\n }\n if (payload.is_allowed) {\n return "explicitly_allowed";\n }\n return "implicitly_denied";\n }\n function parseIAMEvent(payloadString) {\n try {\n const payload = JSON.parse(payloadString);\n const permission = determinePermissionStatus(payload);\n const actions = [];\n const resources = [];\n if (payload.explicit_allows) {\n for (const allow of payload.explicit_allows) {\n if (!actions.includes(allow.action)) actions.push(allow.action);\n if (!resources.includes(allow.resource)) resources.push(allow.resource);\n }\n }\n if (payload.explicit_denies) {\n for (const deny of payload.explicit_denies) {\n if (!actions.includes(deny.action)) actions.push(deny.action);\n if (!resources.includes(deny.resource)) resources.push(deny.resource);\n }\n }\n if (payload.implicit_denies) {\n for (const deny of payload.implicit_denies) {\n if (!actions.includes(deny.action)) actions.push(deny.action);\n if (!resources.includes(deny.resource)) resources.push(deny.resource);\n }\n }\n return {\n details: {\n actions,\n explicitAllows: payload.explicit_allow_count,\n explicitDenies: payload.explicit_deny_count,\n implicitDenies: payload.implicit_deny_count,\n resources\n },\n enforcement: payload.enforcement,\n operation: payload.operation,\n permission,\n principal: payload.principal_arn,\n service: payload.service\n };\n } catch (error) {\n console.error("Error parsing IAM event payload:", error);\n return void 0;\n }\n }\n var getIamEvents = (span) => span.events.flatMap((event) => {\n const payload = event.attributes?.payload;\n if (!event.event_type?.toLowerCase().includes("iam") || typeof payload !== "string") return [];\n return parseIAMEvent(payload) ?? [];\n });\n var getIamEnforcement = (span, events = getIamEvents(span)) => {\n const enforcements = new Set(events.map((event) => event.enforcement).filter(Boolean));\n if (enforcements.size > 0) {\n if (enforcements.has("deny")) return "deny";\n if (enforcements.has("allow_with_warning")) return "allow_with_warning";\n return void 0;\n }\n return getIamEnforcementFromOperationStatus(span);\n };\n var getIamEnforcementFromOperationStatus = (span) => {\n const status = span.operation_status;\n if (status === "iam_explicit_deny" || status === "iam_implicit_deny") return "deny";\n if (status === "iam_explicit_warn" || status === "iam_implicit_warn") return "allow_with_warning";\n return void 0;\n };\n\n // src/utils/span-issues.ts\n var firstText = (...values) => values.find((value) => !!value) ?? void 0;\n var getExceptionCode = (span) => {\n const raw = span.attributes?.["localstack.aws.service.exception"];\n if (typeof raw !== "string") return void 0;\n try {\n const exception = JSON.parse(raw);\n const code = exception.code ?? exception.Code;\n return typeof code === "string" ? code : void 0;\n } catch {\n return void 0;\n }\n };\n var OTEL_STATUS_ERROR = 2;\n var getIamOutcome = (span) => {\n const iamEvents = getIamEvents(span);\n const enforcement = getIamEnforcement(span, iamEvents);\n const iamDenied = enforcement === "deny";\n const denials = iamEvents.flatMap((event) => {\n if (event.permission === "explicitly_denied") return ["explicit"];\n if (event.permission === "implicitly_denied") return ["implicit"];\n return [];\n });\n return {\n denials,\n iamDenied,\n iamWarned: enforcement === "allow_with_warning",\n unenforcedDenial: !iamDenied && (denials.length > 0 || span.attributes?.["localstack.has_iam_deny_event"] === true)\n };\n };\n var getSpanIssues = (span) => {\n const status = span.operation_status;\n const { denials, iamDenied, iamWarned, unenforcedDenial } = getIamOutcome(span);\n const errorMessages = (span.errors ?? []).filter((item) => item.level === "error");\n const warningMessages = (span.errors ?? []).filter((item) => item.level === "warning");\n const error = status === "error" || iamDenied || span.status_code === OTEL_STATUS_ERROR || errorMessages.length > 0;\n const warning = iamWarned || warningMessages.length > 0 || unenforcedDenial;\n const denialCount = unenforcedDenial ? Math.max(1, denials.length) : 0;\n return {\n error,\n errorType: error ? firstText(span.status_message, errorMessages[0]?.message, getExceptionCode(span)) ?? (iamDenied ? "AccessDenied" : "Error") : void 0,\n warning,\n warningCount: warning ? Math.max(1, warningMessages.length + denialCount) : 0,\n warningType: warning ? firstText(warningMessages[0]?.message) ?? (unenforcedDenial ? `IAM ${denials[0] ?? "implicit"} deny` : iamWarned ? "IAM permission warning" : "Warning") : void 0\n };\n };\n\n // src/utils/span-parents.ts\n var resolveParents = (spans) => {\n const byId = new Map(spans.map((span) => [span.span_id, span]));\n const parentOf = /* @__PURE__ */ new Map();\n for (const span of spans) {\n const parent = span.parent_span_id === null ? void 0 : byId.get(span.parent_span_id);\n if (parent && parent.span_id !== span.span_id && parent.trace_id === span.trace_id) {\n parentOf.set(span.span_id, parent.span_id);\n }\n }\n const causes = /* @__PURE__ */ new Map();\n const addCause = (spanId, causeId) => {\n const list = causes.get(spanId);\n if (list) list.push(causeId);\n else causes.set(spanId, [causeId]);\n };\n for (const span of spans) {\n for (const causeId of span.outgoing_link_span_ids ?? []) addCause(span.span_id, causeId);\n for (const effectId of span.incoming_link_span_ids ?? []) addCause(effectId, span.span_id);\n }\n const isAncestorOrSelf = (candidateId, spanId) => {\n let current = spanId;\n for (let hops = 0; current !== void 0 && hops <= spans.length; hops++) {\n if (current === candidateId) return true;\n current = parentOf.get(current);\n }\n return false;\n };\n for (const span of spans) {\n if (parentOf.has(span.span_id)) continue;\n const cause = causes.get(span.span_id)?.find((causeId) => byId.has(causeId) && !isAncestorOrSelf(span.span_id, causeId));\n if (cause !== void 0) parentOf.set(span.span_id, cause);\n }\n return parentOf;\n };\n\n // src/utils/trigger.ts\n var getTriggerKind = (span) => span.isInternal ? "internal" : "client";\n\n // src/workers/spans-reducer.ts\n var nanosToMilliseconds = (start, end) => {\n if (!end) return void 0;\n return Number(BigInt(end) - BigInt(start)) / 1e6;\n };\n var toCorpusEntry = (projection, arrivedAt) => {\n const issues = getSpanIssues(projection);\n return {\n accountId: projection.account_id,\n arn: projection.arn,\n arrivedAt,\n durationMs: nanosToMilliseconds(projection.start_time_unix_nano, projection.end_time_unix_nano),\n error: issues.error,\n haystack: [\n projection.service_name,\n projection.operation_name,\n projection.operation_label,\n projection.resource_name,\n projection.arn,\n projection.status_message,\n projection.region,\n projection.account_id,\n projection.trace_id,\n projection.span_id,\n ...(projection.errors ?? []).map((error) => error.message)\n ].filter(Boolean).join("\\n").toLowerCase(),\n issues,\n operationName: projection.operation_name,\n parents: projection,\n producer: projection.parent_service_name ?? EXTERNAL_PRODUCER,\n region: projection.region,\n resourceName: projection.resource_name,\n serviceName: projection.service_name,\n spanId: projection.span_id,\n startTime: projection.start_time_unix_nano,\n statusMessage: projection.status_message,\n traceId: projection.trace_id,\n triggerKind: getTriggerKind({ isInternal: projection.is_internal }),\n warning: issues.warning\n };\n };\n var compareByStartTime = (left, right) => {\n if (left.startTime.length !== right.startTime.length) {\n return left.startTime.length - right.startTime.length;\n }\n return left.startTime.localeCompare(right.startTime, "en");\n };\n var countFacet = (requests, value, rootSpanId) => {\n const set = requests.get(value);\n if (set) set.add(rootSpanId);\n else requests.set(value, /* @__PURE__ */ new Set([rootSpanId]));\n };\n var toFacetValues = (requests) => [...requests].map(([value, set]) => ({ count: set.size, value })).toSorted((left, right) => left.value.localeCompare(right.value));\n var createSpansReducer = ({ now = Date.now, orphanGraceMs = 0 } = {}) => {\n const corpus = /* @__PURE__ */ new Map();\n let parsedQuery = parseQuery("");\n let textMatches;\n let nextReveal;\n const computeResult = () => {\n const sorted = [...corpus.values()].toSorted(compareByStartTime);\n const queryActive = !isQueryEmpty(parsedQuery);\n const parentOf = resolveParents(sorted.map((entry) => entry.parents));\n const time = now();\n nextReveal = void 0;\n const waiting = /* @__PURE__ */ new Map();\n const isOrphanWaiting = (root) => {\n if (root.parents.parent_span_id === null && (root.parents.outgoing_link_span_ids?.length ?? 0) === 0) return false;\n const revealAt = root.arrivedAt + orphanGraceMs;\n if (time >= revealAt) return false;\n nextReveal = Math.min(nextReveal ?? revealAt, revealAt);\n return true;\n };\n const isWaiting = (entry) => {\n const chain = [];\n let current = entry;\n let result = false;\n while (current) {\n const known = waiting.get(current.spanId);\n if (known !== void 0) {\n result = known;\n break;\n }\n chain.push(current);\n const parent = corpus.get(parentOf.get(current.spanId) ?? "");\n if (!parent) result = isOrphanWaiting(current);\n current = parent;\n }\n for (const item of chain) waiting.set(item.spanId, result);\n return result;\n };\n const entries = orphanGraceMs > 0 ? sorted.filter((entry) => !isWaiting(entry)) : sorted;\n const children = /* @__PURE__ */ new Map();\n const topLevel = [];\n for (const entry of entries) {\n const parentId = parentOf.get(entry.spanId);\n if (parentId === void 0) {\n topLevel.push(entry);\n continue;\n }\n const siblings = children.get(parentId);\n if (siblings) siblings.push(entry);\n else children.set(parentId, [entry]);\n }\n const rows = {};\n const visit = (root) => {\n const stack = [{ entry: root, expanded: false }];\n while (stack.length > 0) {\n const frame = stack.at(-1);\n const kids = children.get(frame.entry.spanId) ?? [];\n if (!frame.expanded) {\n frame.expanded = true;\n for (const kid of kids) {\n if (!(kid.spanId in rows)) stack.push({ entry: kid, expanded: false });\n }\n continue;\n }\n stack.pop();\n const matches = !queryActive || matchesQuery(frame.entry, parsedQuery, textMatches);\n const row = {\n ...frame.entry.issues,\n downstream: { count: 0, errors: 0, warnings: 0 },\n matches,\n parentServiceName: corpus.get(parentOf.get(frame.entry.spanId) ?? "")?.serviceName,\n rootSpanId: root.spanId,\n treeMatches: matches ? 1 : 0,\n treeSize: 1\n };\n for (const kid of kids) {\n const kidRow = rows[kid.spanId];\n if (!kidRow) continue;\n row.downstream.count += kidRow.downstream.count + 1;\n row.downstream.errors += kidRow.downstream.errors + (kidRow.error ? 1 : 0);\n row.downstream.warnings += kidRow.downstream.warnings + (kidRow.warning ? 1 : 0);\n row.treeMatches += kidRow.treeMatches;\n row.treeSize += kidRow.treeSize;\n }\n rows[frame.entry.spanId] = row;\n }\n return rows[root.spanId]?.treeMatches ?? 0;\n };\n const topLevelIds = [];\n for (const entry of topLevel) {\n if (visit(entry) > 0) {\n topLevelIds.push(entry.spanId);\n }\n }\n const allIds = [];\n let excludedCount = 0;\n const excluding = hasExclusions(parsedQuery);\n const producers = /* @__PURE__ */ new Map();\n const services = /* @__PURE__ */ new Map();\n const regions = /* @__PURE__ */ new Map();\n const accounts = /* @__PURE__ */ new Map();\n const clients = /* @__PURE__ */ new Map();\n const issues = /* @__PURE__ */ new Map();\n for (const entry of entries) {\n const row = rows[entry.spanId];\n if (!row) continue;\n if (row.matches) allIds.push(entry.spanId);\n if (excluding && matchesExclusion(entry, parsedQuery)) excludedCount++;\n countFacet(producers, entry.producer, row.rootSpanId);\n countFacet(services, entry.serviceName, row.rootSpanId);\n countFacet(regions, entry.region, row.rootSpanId);\n countFacet(accounts, entry.accountId, row.rootSpanId);\n countFacet(clients, entry.triggerKind, row.rootSpanId);\n if (entry.error) countFacet(issues, "error", row.rootSpanId);\n if (entry.warning) countFacet(issues, "warning", row.rootSpanId);\n if (!entry.error && !entry.warning) countFacet(issues, "ok", row.rootSpanId);\n }\n return {\n allIds: allIds.toReversed(),\n excludedCount,\n facets: {\n account: toFacetValues(accounts),\n client: toFacetValues(clients),\n issues: ["error", "warning", "ok"].map((value) => ({ count: issues.get(value)?.size ?? 0, value })),\n producer: toFacetValues(producers),\n region: toFacetValues(regions),\n service: toFacetValues(services)\n },\n queryActive,\n rows,\n topLevelIds: topLevelIds.toReversed(),\n totalCount: topLevel.length\n };\n };\n return {\n addPage: (_direction, projections) => {\n for (const projection of projections) {\n corpus.set(projection.span_id, toCorpusEntry(projection, corpus.get(projection.span_id)?.arrivedAt ?? now()));\n }\n return computeResult();\n },\n clear: () => {\n corpus.clear();\n return computeResult();\n },\n nextReveal: () => nextReveal,\n refresh: computeResult,\n setQuery: (query, matches) => {\n parsedQuery = parseQuery(query);\n textMatches = matches ? new Set(matches) : void 0;\n return computeResult();\n }\n };\n };\n\n // src/workers/spans-worker.worker.ts\n var context = globalThis;\n var reducer = createSpansReducer({ orphanGraceMs: 3e3 });\n var revealTimer;\n var post = (result, seq) => {\n context.postMessage({ result, seq });\n clearTimeout(revealTimer);\n const revealAt = reducer.nextReveal();\n if (revealAt !== void 0) {\n revealTimer = setTimeout(() => {\n post(reducer.refresh(), seq);\n }, Math.max(0, revealAt - Date.now()));\n }\n };\n context.addEventListener("message", (event) => {\n const request = event.data;\n let result;\n switch (request.op) {\n case "addPage": {\n result = reducer.addPage(request.direction, request.projections);\n break;\n }\n case "clear": {\n result = reducer.clear();\n break;\n }\n case "setQuery": {\n result = reducer.setQuery(request.query, request.textMatches);\n break;\n }\n }\n post(result, request.seq);\n });\n})();\n';
|
|
@@ -33716,15 +34512,15 @@ var EMPTY_RESULT = {
|
|
|
33716
34512
|
};
|
|
33717
34513
|
var useSpansCompute = () => {
|
|
33718
34514
|
const { spansWorkerUrl } = useAppInspector();
|
|
33719
|
-
const [computeState, setComputeState] =
|
|
34515
|
+
const [computeState, setComputeState] = useState23({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
|
|
33720
34516
|
const { loaded, result, resultVersion } = computeState;
|
|
33721
|
-
const [workerError, setWorkerError] =
|
|
33722
|
-
const [retryCount, setRetryCount] =
|
|
33723
|
-
const workerRef =
|
|
33724
|
-
const seqRef =
|
|
33725
|
-
const lastAppliedRef =
|
|
33726
|
-
const firstPageSeqRef =
|
|
33727
|
-
|
|
34517
|
+
const [workerError, setWorkerError] = useState23();
|
|
34518
|
+
const [retryCount, setRetryCount] = useState23(0);
|
|
34519
|
+
const workerRef = useRef22();
|
|
34520
|
+
const seqRef = useRef22(0);
|
|
34521
|
+
const lastAppliedRef = useRef22(0);
|
|
34522
|
+
const firstPageSeqRef = useRef22();
|
|
34523
|
+
useEffect26(() => {
|
|
33728
34524
|
try {
|
|
33729
34525
|
const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
|
|
33730
34526
|
worker.addEventListener("message", (event) => {
|
|
@@ -33751,26 +34547,26 @@ var useSpansCompute = () => {
|
|
|
33751
34547
|
return;
|
|
33752
34548
|
}
|
|
33753
34549
|
}, [retryCount, spansWorkerUrl]);
|
|
33754
|
-
const retryWorker =
|
|
34550
|
+
const retryWorker = useCallback11(() => {
|
|
33755
34551
|
setWorkerError(void 0);
|
|
33756
34552
|
setRetryCount((count2) => count2 + 1);
|
|
33757
34553
|
}, []);
|
|
33758
|
-
const addPage =
|
|
34554
|
+
const addPage = useCallback11((direction, projections) => {
|
|
33759
34555
|
const seq = ++seqRef.current;
|
|
33760
34556
|
firstPageSeqRef.current ??= seq;
|
|
33761
34557
|
workerRef.current?.postMessage({ direction, op: "addPage", projections, seq });
|
|
33762
34558
|
}, []);
|
|
33763
|
-
const setQuery =
|
|
34559
|
+
const setQuery = useCallback11((query2, textMatches) => {
|
|
33764
34560
|
workerRef.current?.postMessage({ op: "setQuery", query: query2, seq: ++seqRef.current, textMatches });
|
|
33765
34561
|
}, []);
|
|
33766
|
-
const clear =
|
|
34562
|
+
const clear = useCallback11(() => {
|
|
33767
34563
|
workerRef.current?.postMessage({ op: "clear", seq: ++seqRef.current });
|
|
33768
34564
|
}, []);
|
|
33769
34565
|
return { addPage, clear, loaded, result, resultVersion, retryWorker, setQuery, workerError };
|
|
33770
34566
|
};
|
|
33771
34567
|
|
|
33772
34568
|
// src/hooks/use-spans-ws.tsx
|
|
33773
|
-
import { useCallback as
|
|
34569
|
+
import { useCallback as useCallback12, useEffect as useEffect27, useRef as useRef23, useState as useState24 } from "react";
|
|
33774
34570
|
var wsLogger = createScopedLogger("WS");
|
|
33775
34571
|
var isLegacySpanFields = (value) => {
|
|
33776
34572
|
return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
|
|
@@ -33802,22 +34598,22 @@ var parseSpansWebSocketMessage = (raw) => {
|
|
|
33802
34598
|
};
|
|
33803
34599
|
function useSpansWebSocket(options) {
|
|
33804
34600
|
const { enabled, onClose, onMessage, onOpen } = options;
|
|
33805
|
-
const onMessageRef =
|
|
33806
|
-
const onOpenRef =
|
|
33807
|
-
const onCloseRef =
|
|
33808
|
-
|
|
34601
|
+
const onMessageRef = useRef23(onMessage);
|
|
34602
|
+
const onOpenRef = useRef23(onOpen);
|
|
34603
|
+
const onCloseRef = useRef23(onClose);
|
|
34604
|
+
useEffect27(() => {
|
|
33809
34605
|
onMessageRef.current = onMessage;
|
|
33810
34606
|
}, [onMessage]);
|
|
33811
|
-
|
|
34607
|
+
useEffect27(() => {
|
|
33812
34608
|
onOpenRef.current = onOpen;
|
|
33813
34609
|
}, [onOpen]);
|
|
33814
|
-
|
|
34610
|
+
useEffect27(() => {
|
|
33815
34611
|
onCloseRef.current = onClose;
|
|
33816
34612
|
}, [onClose]);
|
|
33817
|
-
const [connected, setConnected] =
|
|
33818
|
-
const wsRef =
|
|
34613
|
+
const [connected, setConnected] = useState24(false);
|
|
34614
|
+
const wsRef = useRef23(void 0);
|
|
33819
34615
|
const { localstackEndpoint } = useAppInspector();
|
|
33820
|
-
const connect =
|
|
34616
|
+
const connect = useCallback12(() => {
|
|
33821
34617
|
if (wsRef.current !== void 0) return;
|
|
33822
34618
|
const url = new URL(getAppInspectorApiUrl(localstackEndpoint, API_ENDPOINTS.WEBSOCKET_SPANS));
|
|
33823
34619
|
url.protocol = globalThis.location.protocol === "https:" ? "wss" : "ws";
|
|
@@ -33858,7 +34654,7 @@ function useSpansWebSocket(options) {
|
|
|
33858
34654
|
}
|
|
33859
34655
|
});
|
|
33860
34656
|
}, [localstackEndpoint]);
|
|
33861
|
-
|
|
34657
|
+
useEffect27(() => {
|
|
33862
34658
|
if (!enabled) {
|
|
33863
34659
|
if (wsRef.current !== void 0) {
|
|
33864
34660
|
wsRef.current.close();
|
|
@@ -33901,42 +34697,42 @@ var useSpans = () => {
|
|
|
33901
34697
|
const api = useAppInspectorApi();
|
|
33902
34698
|
const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
|
|
33903
34699
|
const { addPage, clear: clearCompute, loaded: spansLoaded, result: computeResult, resultVersion, retryWorker, setQuery: setComputeQuery, workerError } = useSpansCompute();
|
|
33904
|
-
const spanMapRef =
|
|
33905
|
-
const newSpanIdsRef =
|
|
33906
|
-
const caughtUpRef =
|
|
33907
|
-
const [fetchError, setFetchError] =
|
|
33908
|
-
const [fetchingForward, setFetchingForward] =
|
|
33909
|
-
const [fetchingBackward, setFetchingBackward] =
|
|
33910
|
-
const [query2, setQueryState] =
|
|
33911
|
-
const [searching, setSearching] =
|
|
33912
|
-
const paginationBufferRef =
|
|
33913
|
-
const [totalCount, setTotalCount] =
|
|
33914
|
-
const [licenseLimit, setLicenseLimit] =
|
|
33915
|
-
const [systemLimit, setSystemLimit] =
|
|
33916
|
-
const [errorCount, setErrorCount] =
|
|
33917
|
-
const [warningCount, setWarningCount] =
|
|
33918
|
-
const [hasMoreBackward, setHasMoreBackward] =
|
|
33919
|
-
const [hasMoreForward, setHasMoreForward] =
|
|
33920
|
-
const fetchForward =
|
|
34700
|
+
const spanMapRef = useRef24(/* @__PURE__ */ new Map());
|
|
34701
|
+
const newSpanIdsRef = useRef24(/* @__PURE__ */ new Set());
|
|
34702
|
+
const caughtUpRef = useRef24(false);
|
|
34703
|
+
const [fetchError, setFetchError] = useState25();
|
|
34704
|
+
const [fetchingForward, setFetchingForward] = useState25(false);
|
|
34705
|
+
const [fetchingBackward, setFetchingBackward] = useState25(false);
|
|
34706
|
+
const [query2, setQueryState] = useState25("");
|
|
34707
|
+
const [searching, setSearching] = useState25(false);
|
|
34708
|
+
const paginationBufferRef = useRef24();
|
|
34709
|
+
const [totalCount, setTotalCount] = useState25();
|
|
34710
|
+
const [licenseLimit, setLicenseLimit] = useState25();
|
|
34711
|
+
const [systemLimit, setSystemLimit] = useState25();
|
|
34712
|
+
const [errorCount, setErrorCount] = useState25();
|
|
34713
|
+
const [warningCount, setWarningCount] = useState25();
|
|
34714
|
+
const [hasMoreBackward, setHasMoreBackward] = useState25();
|
|
34715
|
+
const [hasMoreForward, setHasMoreForward] = useState25();
|
|
34716
|
+
const fetchForward = useCallback13(() => {
|
|
33921
34717
|
void paginationBufferRef.current?.fetchForward();
|
|
33922
34718
|
}, []);
|
|
33923
|
-
const fetchBackward =
|
|
34719
|
+
const fetchBackward = useCallback13(() => {
|
|
33924
34720
|
void paginationBufferRef.current?.fetchBackward();
|
|
33925
34721
|
}, []);
|
|
33926
|
-
const resetCorpus =
|
|
34722
|
+
const resetCorpus = useCallback13(() => {
|
|
33927
34723
|
spanMapRef.current.clear();
|
|
33928
34724
|
newSpanIdsRef.current.clear();
|
|
33929
34725
|
caughtUpRef.current = false;
|
|
33930
34726
|
clearCompute();
|
|
33931
34727
|
}, [clearCompute]);
|
|
33932
|
-
const [epoch, setEpoch] =
|
|
33933
|
-
const onEpochSeen =
|
|
34728
|
+
const [epoch, setEpoch] = useState25();
|
|
34729
|
+
const onEpochSeen = useCallback13((observedEpoch) => {
|
|
33934
34730
|
if (observedEpoch === null || observedEpoch === void 0) {
|
|
33935
34731
|
return;
|
|
33936
34732
|
}
|
|
33937
34733
|
setEpoch(observedEpoch);
|
|
33938
34734
|
}, []);
|
|
33939
|
-
const clearCache =
|
|
34735
|
+
const clearCache = useCallback13(() => {
|
|
33940
34736
|
paginationBufferRef.current?.clear();
|
|
33941
34737
|
resetCorpus();
|
|
33942
34738
|
setTotalCount(void 0);
|
|
@@ -33944,9 +34740,9 @@ var useSpans = () => {
|
|
|
33944
34740
|
setWarningCount(void 0);
|
|
33945
34741
|
void paginationBufferRef.current?.fetchForward();
|
|
33946
34742
|
}, [resetCorpus]);
|
|
33947
|
-
const hasFetchedWithoutEpochRef =
|
|
33948
|
-
const previousEpochRef =
|
|
33949
|
-
|
|
34743
|
+
const hasFetchedWithoutEpochRef = useRef24(false);
|
|
34744
|
+
const previousEpochRef = useRef24();
|
|
34745
|
+
useEffect28(() => {
|
|
33950
34746
|
if (epoch === void 0) {
|
|
33951
34747
|
return;
|
|
33952
34748
|
}
|
|
@@ -33959,11 +34755,11 @@ var useSpans = () => {
|
|
|
33959
34755
|
}, [epoch, clearCache]);
|
|
33960
34756
|
const searchSupported = emulatorSupportsSearch(status?.localstackVersion);
|
|
33961
34757
|
const freeText = parseQuery(query2).words.join(" ");
|
|
33962
|
-
const setQuery =
|
|
34758
|
+
const setQuery = useCallback13((next) => {
|
|
33963
34759
|
setQueryState(next);
|
|
33964
34760
|
setComputeQuery(next);
|
|
33965
34761
|
}, [setComputeQuery]);
|
|
33966
|
-
|
|
34762
|
+
useEffect28(() => {
|
|
33967
34763
|
if (!searchSupported || freeText === "") {
|
|
33968
34764
|
return;
|
|
33969
34765
|
}
|
|
@@ -33984,7 +34780,7 @@ var useSpans = () => {
|
|
|
33984
34780
|
setSearching(false);
|
|
33985
34781
|
};
|
|
33986
34782
|
}, [api, freeText, query2, searchSupported, setComputeQuery]);
|
|
33987
|
-
|
|
34783
|
+
useEffect28(() => {
|
|
33988
34784
|
const buffer = createPaginationBuffer({
|
|
33989
34785
|
async fetchPage(token, signal) {
|
|
33990
34786
|
const requestPage = async (paginationToken) => {
|
|
@@ -34055,8 +34851,8 @@ var useSpans = () => {
|
|
|
34055
34851
|
paginationBufferRef.current = buffer;
|
|
34056
34852
|
void buffer.fetchForward();
|
|
34057
34853
|
}, [api, addPage, onEpochSeen, resetCorpus]);
|
|
34058
|
-
const [clearingSpans, setClearingSpans] =
|
|
34059
|
-
const clearSpans =
|
|
34854
|
+
const [clearingSpans, setClearingSpans] = useState25(false);
|
|
34855
|
+
const clearSpans = useCallback13(async () => {
|
|
34060
34856
|
if (clearingSpans) {
|
|
34061
34857
|
return;
|
|
34062
34858
|
}
|
|
@@ -34074,17 +34870,17 @@ var useSpans = () => {
|
|
|
34074
34870
|
setClearingSpans(false);
|
|
34075
34871
|
}
|
|
34076
34872
|
}, [clearingSpans, api, resetCorpus]);
|
|
34077
|
-
|
|
34873
|
+
useEffect28(() => {
|
|
34078
34874
|
if (hasMoreForward === true && !fetchingForward) {
|
|
34079
34875
|
void paginationBufferRef.current?.fetchForward();
|
|
34080
34876
|
}
|
|
34081
34877
|
}, [hasMoreForward, fetchingForward]);
|
|
34082
|
-
|
|
34878
|
+
useEffect28(() => {
|
|
34083
34879
|
if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
|
|
34084
34880
|
void paginationBufferRef.current?.fetchBackward();
|
|
34085
34881
|
}
|
|
34086
34882
|
}, [hasMoreBackward, fetchingBackward, fetchingForward]);
|
|
34087
|
-
const [previousStatusEpoch, setPreviousStatusEpoch] =
|
|
34883
|
+
const [previousStatusEpoch, setPreviousStatusEpoch] = useState25();
|
|
34088
34884
|
if (status !== void 0 && status.epoch !== previousStatusEpoch) {
|
|
34089
34885
|
setPreviousStatusEpoch(status.epoch);
|
|
34090
34886
|
onEpochSeen(status.epoch);
|
|
@@ -34109,10 +34905,10 @@ var useSpans = () => {
|
|
|
34109
34905
|
fetchForward();
|
|
34110
34906
|
}
|
|
34111
34907
|
});
|
|
34112
|
-
const clearFetchError =
|
|
34908
|
+
const clearFetchError = useCallback13(() => {
|
|
34113
34909
|
setFetchError(void 0);
|
|
34114
34910
|
}, []);
|
|
34115
|
-
const getSpan =
|
|
34911
|
+
const getSpan = useCallback13((spanId) => spanMapRef.current.get(spanId), []);
|
|
34116
34912
|
const newSpanIds = newSpanIdsRef.current;
|
|
34117
34913
|
return {
|
|
34118
34914
|
clearFetchError,
|
|
@@ -34144,7 +34940,8 @@ var useSpans = () => {
|
|
|
34144
34940
|
};
|
|
34145
34941
|
|
|
34146
34942
|
// src/pages/spans-list-page.tsx
|
|
34147
|
-
import { jsx as
|
|
34943
|
+
import { jsx as jsx154, jsxs as jsxs141 } from "react/jsx-runtime";
|
|
34944
|
+
var ANALYTICS_REQUEST_VIEWS = { map: "flow_graph", sequence: "sequence_graph", waterfall: "operations" };
|
|
34148
34945
|
var SpansListPage = () => {
|
|
34149
34946
|
const api = useAppInspectorApi();
|
|
34150
34947
|
const {
|
|
@@ -34177,49 +34974,49 @@ var SpansListPage = () => {
|
|
|
34177
34974
|
resultVersion,
|
|
34178
34975
|
searching
|
|
34179
34976
|
});
|
|
34180
|
-
const clearSpansSync =
|
|
34977
|
+
const clearSpansSync = useCallback14(() => {
|
|
34181
34978
|
void clearSpans();
|
|
34182
34979
|
}, [clearSpans]);
|
|
34183
34980
|
const localstackVersion = status?.localstackVersion ?? (statusError instanceof AppInspectorNotFoundError ? statusError.localstackVersion : void 0);
|
|
34184
34981
|
const versionCompatibility = checkEmulatorVersion(localstackVersion);
|
|
34185
|
-
const [bannerDismissed, setBannerDismissed] =
|
|
34982
|
+
const [bannerDismissed, setBannerDismissed] = useState26(false);
|
|
34186
34983
|
const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
|
|
34187
|
-
const [selectedSpanId, setSelectedSpanId] =
|
|
34188
|
-
const getTreeSpans =
|
|
34189
|
-
const latestRef =
|
|
34190
|
-
|
|
34984
|
+
const [selectedSpanId, setSelectedSpanId] = useState26();
|
|
34985
|
+
const getTreeSpans = useCallback14((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
|
|
34986
|
+
const latestRef = useRef25({ compute, getTreeSpans });
|
|
34987
|
+
useEffect29(() => {
|
|
34191
34988
|
latestRef.current = { compute, getTreeSpans };
|
|
34192
34989
|
}, [compute, getTreeSpans]);
|
|
34193
|
-
const openedAtRef =
|
|
34194
|
-
const navigateToSpan =
|
|
34990
|
+
const openedAtRef = useRef25();
|
|
34991
|
+
const navigateToSpan = useCallback14((span) => {
|
|
34195
34992
|
openedAtRef.current = performance.now();
|
|
34196
34993
|
const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
|
|
34197
34994
|
const rootSpanId2 = rows[span.span_id]?.rootSpanId;
|
|
34198
34995
|
const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
|
|
34199
34996
|
setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
|
|
34200
34997
|
}, []);
|
|
34201
|
-
const [shownOperation, setShownOperation] =
|
|
34202
|
-
const closeSidebar =
|
|
34998
|
+
const [shownOperation, setShownOperation] = useState26();
|
|
34999
|
+
const closeSidebar = useCallback14(() => {
|
|
34203
35000
|
setSelectedSpanId(void 0);
|
|
34204
35001
|
setShownOperation(void 0);
|
|
34205
35002
|
}, []);
|
|
34206
35003
|
const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
|
|
34207
|
-
const treeSpans =
|
|
34208
|
-
const spanMatches =
|
|
35004
|
+
const treeSpans = useMemo14(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
|
|
35005
|
+
const spanMatches = useMemo14(
|
|
34209
35006
|
() => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
|
|
34210
35007
|
[compute]
|
|
34211
35008
|
);
|
|
34212
|
-
const treeSpansRef =
|
|
34213
|
-
|
|
35009
|
+
const treeSpansRef = useRef25(treeSpans);
|
|
35010
|
+
useEffect29(() => {
|
|
34214
35011
|
treeSpansRef.current = treeSpans;
|
|
34215
35012
|
}, [treeSpans]);
|
|
34216
|
-
const [renderedRequest, setRenderedRequest] =
|
|
34217
|
-
const handleRequestRendered =
|
|
35013
|
+
const [renderedRequest, setRenderedRequest] = useState26();
|
|
35014
|
+
const handleRequestRendered = useCallback14((view) => {
|
|
34218
35015
|
const openedAt = openedAtRef.current;
|
|
34219
35016
|
if (openedAt === void 0) return;
|
|
34220
|
-
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: view
|
|
35017
|
+
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: ANALYTICS_REQUEST_VIEWS[view] });
|
|
34221
35018
|
}, []);
|
|
34222
|
-
const handleViewChange =
|
|
35019
|
+
const handleViewChange = useCallback14(() => {
|
|
34223
35020
|
openedAtRef.current = performance.now();
|
|
34224
35021
|
}, []);
|
|
34225
35022
|
useRequestOpenAnalytics({
|
|
@@ -34228,28 +35025,28 @@ var SpansListPage = () => {
|
|
|
34228
35025
|
view: renderedRequest?.view ?? "operations"
|
|
34229
35026
|
});
|
|
34230
35027
|
const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
|
|
34231
|
-
const handleOperationShown =
|
|
35028
|
+
const handleOperationShown = useCallback14((spanId, view) => {
|
|
34232
35029
|
setShownOperation({ spanId, view });
|
|
34233
35030
|
}, []);
|
|
34234
|
-
const shown =
|
|
35031
|
+
const shown = useMemo14(() => {
|
|
34235
35032
|
if (shownOperation === void 0) return;
|
|
34236
35033
|
const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
|
|
34237
35034
|
return span && { span, view: shownOperation.view };
|
|
34238
35035
|
}, [shownOperation, treeSpans]);
|
|
34239
35036
|
useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
|
|
34240
|
-
const handleRetry =
|
|
35037
|
+
const handleRetry = useCallback14(() => {
|
|
34241
35038
|
checkStatus();
|
|
34242
35039
|
fetchForward();
|
|
34243
35040
|
}, [checkStatus, fetchForward]);
|
|
34244
|
-
const handleEnable =
|
|
35041
|
+
const handleEnable = useCallback14(async () => {
|
|
34245
35042
|
await api.setStatus({ status: "ENABLED" });
|
|
34246
35043
|
clearFetchError();
|
|
34247
35044
|
checkStatus();
|
|
34248
35045
|
}, [api, checkStatus, clearFetchError]);
|
|
34249
|
-
const isDelayedRefetchRef =
|
|
34250
|
-
const delayedRefetchTimerRef =
|
|
34251
|
-
const prevFetchingForwardRef =
|
|
34252
|
-
|
|
35046
|
+
const isDelayedRefetchRef = useRef25(false);
|
|
35047
|
+
const delayedRefetchTimerRef = useRef25();
|
|
35048
|
+
const prevFetchingForwardRef = useRef25(false);
|
|
35049
|
+
useEffect29(() => {
|
|
34253
35050
|
const wasFetching = prevFetchingForwardRef.current;
|
|
34254
35051
|
prevFetchingForwardRef.current = fetchingForward;
|
|
34255
35052
|
if (wasFetching && !fetchingForward) {
|
|
@@ -34270,10 +35067,10 @@ var SpansListPage = () => {
|
|
|
34270
35067
|
switch (phase) {
|
|
34271
35068
|
case "CHECKING_STATUS":
|
|
34272
35069
|
case "CONNECTING_WS": {
|
|
34273
|
-
return /* @__PURE__ */
|
|
35070
|
+
return /* @__PURE__ */ jsx154(StatusMessage, { phase });
|
|
34274
35071
|
}
|
|
34275
35072
|
case "DISABLED": {
|
|
34276
|
-
return /* @__PURE__ */
|
|
35073
|
+
return /* @__PURE__ */ jsx154(
|
|
34277
35074
|
StatusMessage,
|
|
34278
35075
|
{
|
|
34279
35076
|
onEnable: handleEnable,
|
|
@@ -34282,7 +35079,7 @@ var SpansListPage = () => {
|
|
|
34282
35079
|
);
|
|
34283
35080
|
}
|
|
34284
35081
|
case "INCOMPATIBLE": {
|
|
34285
|
-
return /* @__PURE__ */
|
|
35082
|
+
return /* @__PURE__ */ jsx154(
|
|
34286
35083
|
StatusMessage,
|
|
34287
35084
|
{
|
|
34288
35085
|
localstackVersion,
|
|
@@ -34293,12 +35090,12 @@ var SpansListPage = () => {
|
|
|
34293
35090
|
}
|
|
34294
35091
|
case "LIVE": {
|
|
34295
35092
|
if (workerError) {
|
|
34296
|
-
return /* @__PURE__ */
|
|
35093
|
+
return /* @__PURE__ */ jsx154(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
|
|
34297
35094
|
}
|
|
34298
35095
|
break;
|
|
34299
35096
|
}
|
|
34300
35097
|
case "UNREACHABLE": {
|
|
34301
|
-
return /* @__PURE__ */
|
|
35098
|
+
return /* @__PURE__ */ jsx154(
|
|
34302
35099
|
StatusMessage,
|
|
34303
35100
|
{
|
|
34304
35101
|
onRetry: handleRetry,
|
|
@@ -34307,9 +35104,9 @@ var SpansListPage = () => {
|
|
|
34307
35104
|
);
|
|
34308
35105
|
}
|
|
34309
35106
|
}
|
|
34310
|
-
return /* @__PURE__ */
|
|
34311
|
-
/* @__PURE__ */
|
|
34312
|
-
|
|
35107
|
+
return /* @__PURE__ */ jsxs141(Paper3, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
|
|
35108
|
+
/* @__PURE__ */ jsxs141(
|
|
35109
|
+
Box25,
|
|
34313
35110
|
{
|
|
34314
35111
|
"data-testid": SPANS_LIST_PAGE_TEST_ID,
|
|
34315
35112
|
sx: {
|
|
@@ -34322,7 +35119,7 @@ var SpansListPage = () => {
|
|
|
34322
35119
|
overflow: "hidden"
|
|
34323
35120
|
},
|
|
34324
35121
|
children: [
|
|
34325
|
-
/* @__PURE__ */
|
|
35122
|
+
/* @__PURE__ */ jsx154(
|
|
34326
35123
|
EmulatorVersionBanner,
|
|
34327
35124
|
{
|
|
34328
35125
|
compatibility: bannerDismissed && versionCompatibility === "warning" ? "ok" : versionCompatibility,
|
|
@@ -34332,7 +35129,7 @@ var SpansListPage = () => {
|
|
|
34332
35129
|
} : void 0
|
|
34333
35130
|
}
|
|
34334
35131
|
),
|
|
34335
|
-
/* @__PURE__ */
|
|
35132
|
+
/* @__PURE__ */ jsx154(
|
|
34336
35133
|
SpansList,
|
|
34337
35134
|
{
|
|
34338
35135
|
clearingSpans,
|
|
@@ -34359,7 +35156,7 @@ var SpansListPage = () => {
|
|
|
34359
35156
|
]
|
|
34360
35157
|
}
|
|
34361
35158
|
),
|
|
34362
|
-
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */
|
|
35159
|
+
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ jsx154(
|
|
34363
35160
|
TraceSidebar,
|
|
34364
35161
|
{
|
|
34365
35162
|
onClose: closeSidebar,
|