@localstack/appinspector-ui 1.0.220 → 1.0.221
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 +1006 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1002 -207
- 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
|
|
|
@@ -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);
|
|
@@ -32551,10 +32571,40 @@ var TraceGraph = ({
|
|
|
32551
32571
|
] });
|
|
32552
32572
|
};
|
|
32553
32573
|
|
|
32574
|
+
// src/hooks/use-content-width.ts
|
|
32575
|
+
import * as React124 from "react";
|
|
32576
|
+
var contentWidth = (element) => {
|
|
32577
|
+
const style = getComputedStyle(element);
|
|
32578
|
+
const edges = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"];
|
|
32579
|
+
return edges.reduce((width, edge) => width - (Number.parseFloat(style[edge]) || 0), element.getBoundingClientRect().width);
|
|
32580
|
+
};
|
|
32581
|
+
var useContentWidth = (elementRef, parent = false) => {
|
|
32582
|
+
const [width, setWidth] = React124.useState(0);
|
|
32583
|
+
React124.useLayoutEffect(() => {
|
|
32584
|
+
const element = parent ? elementRef.current?.parentElement : elementRef.current;
|
|
32585
|
+
if (!element) return;
|
|
32586
|
+
setWidth(contentWidth(element));
|
|
32587
|
+
let frame2 = 0;
|
|
32588
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
32589
|
+
if (!entry) return;
|
|
32590
|
+
cancelAnimationFrame(frame2);
|
|
32591
|
+
frame2 = requestAnimationFrame(() => {
|
|
32592
|
+
setWidth(entry.contentRect.width);
|
|
32593
|
+
});
|
|
32594
|
+
});
|
|
32595
|
+
observer.observe(element);
|
|
32596
|
+
return () => {
|
|
32597
|
+
cancelAnimationFrame(frame2);
|
|
32598
|
+
observer.disconnect();
|
|
32599
|
+
};
|
|
32600
|
+
}, [elementRef, parent]);
|
|
32601
|
+
return width;
|
|
32602
|
+
};
|
|
32603
|
+
|
|
32554
32604
|
// src/hooks/use-local-storage.tsx
|
|
32555
|
-
import { useCallback as useCallback8, useEffect as useEffect19, useState as
|
|
32605
|
+
import { useCallback as useCallback8, useEffect as useEffect19, useState as useState18 } from "react";
|
|
32556
32606
|
function useLocalStorage(key, initialValue) {
|
|
32557
|
-
const [storedValue, setStoredValue] =
|
|
32607
|
+
const [storedValue, setStoredValue] = useState18(() => {
|
|
32558
32608
|
try {
|
|
32559
32609
|
const item = globalThis.localStorage.getItem(key);
|
|
32560
32610
|
return item ? JSON.parse(item) : initialValue;
|
|
@@ -32596,11 +32646,118 @@ function useLocalStorage(key, initialValue) {
|
|
|
32596
32646
|
return [storedValue, setValue];
|
|
32597
32647
|
}
|
|
32598
32648
|
|
|
32649
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
32650
|
+
import { keyframes as keyframes3 } from "@emotion/react";
|
|
32651
|
+
import { Cancel as Cancel8, FitScreen as FitScreen2, GppMaybe as GppMaybe9, KeyboardArrowDown as KeyboardArrowDown3, KeyboardArrowRight as KeyboardArrowRight3, KeyboardArrowUp, ZoomIn, ZoomOut } from "@mui/icons-material";
|
|
32652
|
+
import { Box as Box22, ButtonBase as ButtonBase2, Collapse, IconButton as IconButton8, Paper as Paper2, Popper, Tooltip as Tooltip7, Typography as Typography15 } from "@mui/material";
|
|
32653
|
+
import { alpha as alpha8, useTheme as useTheme7 } from "@mui/material/styles";
|
|
32654
|
+
import * as React126 from "react";
|
|
32655
|
+
|
|
32656
|
+
// src/components/trace-panel/sequence-layout.ts
|
|
32657
|
+
var CALLER_KEY = "";
|
|
32658
|
+
var resourceOf = (span) => {
|
|
32659
|
+
const resource = shortResourceName(span.resource_name, span.arn);
|
|
32660
|
+
return resource === "*" ? "" : resource;
|
|
32661
|
+
};
|
|
32662
|
+
var participantOf = (span, mode, callers) => {
|
|
32663
|
+
const resource = mode === "resource" || mode === "caller" && callers.has(`${span.service_name}/${resourceOf(span)}`) ? resourceOf(span) : "";
|
|
32664
|
+
return { key: `${span.service_name}/${resource}`, label: resource, resource, service: span.service_name };
|
|
32665
|
+
};
|
|
32666
|
+
var countDescendants = (node) => node.children.reduce((sum2, child) => sum2 + 1 + countDescendants(child), 0);
|
|
32667
|
+
var layoutSequence = (spans, mode, folded) => {
|
|
32668
|
+
const tree = buildTraceTree(spans);
|
|
32669
|
+
const visible = [];
|
|
32670
|
+
const visit = (nodes2, parent) => {
|
|
32671
|
+
for (const node of nodes2) {
|
|
32672
|
+
visible.push({ node, parent });
|
|
32673
|
+
if (!folded.has(node.span.span_id)) visit(node.children, node.span);
|
|
32674
|
+
}
|
|
32675
|
+
};
|
|
32676
|
+
visit(tree.roots);
|
|
32677
|
+
visible.sort((left, right) => compareNano(left.node.span.start_time_unix_nano, right.node.span.start_time_unix_nano));
|
|
32678
|
+
const callers = new Set(spans.filter((span) => tree.parentOf.has(span.span_id)).flatMap((span) => {
|
|
32679
|
+
const parent = spans.find((candidate) => candidate.span_id === tree.parentOf.get(span.span_id));
|
|
32680
|
+
return parent ? [`${parent.service_name}/${resourceOf(parent)}`] : [];
|
|
32681
|
+
}));
|
|
32682
|
+
const participants = [{ key: CALLER_KEY, label: "", resource: "", service: "" }];
|
|
32683
|
+
const indexOf = /* @__PURE__ */ new Map([[CALLER_KEY, 0]]);
|
|
32684
|
+
const place = (participant) => {
|
|
32685
|
+
const known = indexOf.get(participant.key);
|
|
32686
|
+
if (known !== void 0) return known;
|
|
32687
|
+
participants.push(participant);
|
|
32688
|
+
indexOf.set(participant.key, participants.length - 1);
|
|
32689
|
+
return participants.length - 1;
|
|
32690
|
+
};
|
|
32691
|
+
const rowOf = /* @__PURE__ */ new Map();
|
|
32692
|
+
const parentRows = [];
|
|
32693
|
+
const messages = [];
|
|
32694
|
+
for (const [row, { node, parent }] of visible.entries()) {
|
|
32695
|
+
const { span } = node;
|
|
32696
|
+
const issues = getSpanIssues(span);
|
|
32697
|
+
const from = parent ? place(participantOf(parent, mode, callers)) : 0;
|
|
32698
|
+
const hasChildren = node.children.length > 0;
|
|
32699
|
+
parentRows.push(parent ? rowOf.get(parent.span_id) : void 0);
|
|
32700
|
+
messages.push({
|
|
32701
|
+
async: parent !== void 0 && span.parent_span_id !== parent.span_id,
|
|
32702
|
+
depth: 0,
|
|
32703
|
+
descendantCount: countDescendants(node),
|
|
32704
|
+
endRow: row,
|
|
32705
|
+
error: issues.error,
|
|
32706
|
+
folded: hasChildren && folded.has(span.span_id),
|
|
32707
|
+
from,
|
|
32708
|
+
fromDepth: 0,
|
|
32709
|
+
resource: resourceOf(span),
|
|
32710
|
+
returnLevel: 0,
|
|
32711
|
+
span,
|
|
32712
|
+
to: place(participantOf(span, mode, callers)),
|
|
32713
|
+
warning: issues.warning
|
|
32714
|
+
});
|
|
32715
|
+
rowOf.set(span.span_id, row);
|
|
32716
|
+
}
|
|
32717
|
+
for (let row = messages.length - 1; row >= 0; row--) {
|
|
32718
|
+
const message = messages[row];
|
|
32719
|
+
const parent = messages[parentRows[row] ?? -1];
|
|
32720
|
+
if (message && parent && !message.async) parent.endRow = Math.max(parent.endRow, message.endRow);
|
|
32721
|
+
}
|
|
32722
|
+
const endings = messages.map(() => 0);
|
|
32723
|
+
for (const message of messages.toReversed()) {
|
|
32724
|
+
message.returnLevel = endings[message.endRow] ?? 0;
|
|
32725
|
+
endings[message.endRow] = message.returnLevel + 1;
|
|
32726
|
+
}
|
|
32727
|
+
for (const [row, message] of messages.entries()) {
|
|
32728
|
+
message.depth = messages.slice(0, row).filter((earlier) => earlier.to === message.to && earlier.endRow >= row).length;
|
|
32729
|
+
message.fromDepth = messages[parentRows[row] ?? -1]?.depth ?? 0;
|
|
32730
|
+
}
|
|
32731
|
+
const prefix = sharedPrefix(participants.map((participant) => participant.resource));
|
|
32732
|
+
const strip2 = (name) => name.startsWith(prefix) ? name.slice(prefix.length) : name;
|
|
32733
|
+
return {
|
|
32734
|
+
endings,
|
|
32735
|
+
messages: messages.map((message) => ({ ...message, resource: strip2(message.resource) })),
|
|
32736
|
+
participants: participants.map((participant) => ({ ...participant, label: strip2(participant.resource) }))
|
|
32737
|
+
};
|
|
32738
|
+
};
|
|
32739
|
+
var sharedPrefix = (names2) => {
|
|
32740
|
+
const counts = /* @__PURE__ */ new Map();
|
|
32741
|
+
for (const name of new Set(names2)) {
|
|
32742
|
+
for (let index = 0; index < name.length - 1; index++) {
|
|
32743
|
+
if ("-_/.".includes(name.charAt(index))) {
|
|
32744
|
+
const prefix = name.slice(0, index + 1);
|
|
32745
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
32746
|
+
}
|
|
32747
|
+
}
|
|
32748
|
+
}
|
|
32749
|
+
let best = "";
|
|
32750
|
+
for (const [prefix, count2] of counts) {
|
|
32751
|
+
if (count2 >= 2 && count2 * prefix.length > (counts.get(best) ?? 0) * best.length) best = prefix;
|
|
32752
|
+
}
|
|
32753
|
+
return best;
|
|
32754
|
+
};
|
|
32755
|
+
|
|
32599
32756
|
// src/components/trace-panel/waterfall.tsx
|
|
32600
32757
|
import { AccountTreeOutlined, Cancel as Cancel7, FormatListBulleted, GppMaybe as GppMaybe8, KeyboardArrowDown as KeyboardArrowDown2, KeyboardArrowRight as KeyboardArrowRight2 } from "@mui/icons-material";
|
|
32601
32758
|
import { Box as Box21, ButtonBase, ToggleButton as ToggleButton2, ToggleButtonGroup as ToggleButtonGroup2, Typography as Typography14 } from "@mui/material";
|
|
32602
32759
|
import { alpha as alpha7 } from "@mui/material/styles";
|
|
32603
|
-
import * as
|
|
32760
|
+
import * as React125 from "react";
|
|
32604
32761
|
|
|
32605
32762
|
// src/components/trace-panel/axis-ticks.ts
|
|
32606
32763
|
var getAxisTicks = (durationMs, maxIntervals) => {
|
|
@@ -32692,25 +32849,10 @@ var Line = ({ height, left, top = 0, width = 1 }) => /* @__PURE__ */ jsx150(
|
|
|
32692
32849
|
);
|
|
32693
32850
|
var AXIS_HEIGHT = 22;
|
|
32694
32851
|
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
32852
|
var LABEL_TRANSFORMS = { center: "translateX(-50%)", end: "translateX(-100%)", start: void 0 };
|
|
32711
32853
|
var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
32712
|
-
const trackRef =
|
|
32713
|
-
const width =
|
|
32854
|
+
const trackRef = React125.useRef(null);
|
|
32855
|
+
const width = useContentWidth(trackRef);
|
|
32714
32856
|
const { labels: labels2, marks } = layoutAxis(durationMs, width);
|
|
32715
32857
|
return /* @__PURE__ */ jsxs137(
|
|
32716
32858
|
Box21,
|
|
@@ -32778,15 +32920,15 @@ var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
|
32778
32920
|
);
|
|
32779
32921
|
};
|
|
32780
32922
|
var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
32781
|
-
const [collapsed, setCollapsed] =
|
|
32782
|
-
const containerRef =
|
|
32783
|
-
const tree =
|
|
32784
|
-
const bounds =
|
|
32923
|
+
const [collapsed, setCollapsed] = React125.useState(() => /* @__PURE__ */ new Set());
|
|
32924
|
+
const containerRef = React125.useRef(null);
|
|
32925
|
+
const tree = React125.useMemo(() => buildTraceTree(spans), [spans]);
|
|
32926
|
+
const bounds = React125.useMemo(() => getTraceBounds(spans), [spans]);
|
|
32785
32927
|
const { waterfallLayout } = useDevSettings();
|
|
32786
|
-
const [toggledFlat, setToggledFlat] =
|
|
32928
|
+
const [toggledFlat, setToggledFlat] = React125.useState(false);
|
|
32787
32929
|
const flat = waterfallLayout === "list" || waterfallLayout === "toggle" && toggledFlat;
|
|
32788
|
-
const rows =
|
|
32789
|
-
const [revealed, setRevealed] =
|
|
32930
|
+
const rows = React125.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
|
|
32931
|
+
const [revealed, setRevealed] = React125.useState();
|
|
32790
32932
|
if (selectedSpanId !== revealed) {
|
|
32791
32933
|
setRevealed(selectedSpanId);
|
|
32792
32934
|
const ancestors = /* @__PURE__ */ new Set();
|
|
@@ -32795,7 +32937,7 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32795
32937
|
setCollapsed((current) => new Set([...current].filter((id2) => !ancestors.has(id2))));
|
|
32796
32938
|
}
|
|
32797
32939
|
}
|
|
32798
|
-
|
|
32940
|
+
React125.useEffect(() => {
|
|
32799
32941
|
if (selectedSpanId === void 0) return;
|
|
32800
32942
|
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest" });
|
|
32801
32943
|
}, [selectedSpanId]);
|
|
@@ -32970,8 +33112,661 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32970
33112
|
] });
|
|
32971
33113
|
};
|
|
32972
33114
|
|
|
33115
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
33116
|
+
import { Fragment as Fragment15, jsx as jsx151, jsxs as jsxs138 } from "react/jsx-runtime";
|
|
33117
|
+
var COLUMN_WIDTH = 136;
|
|
33118
|
+
var HEADER_HEIGHT = 52;
|
|
33119
|
+
var LABEL_TOP = 1;
|
|
33120
|
+
var LABEL_HEIGHT = 18;
|
|
33121
|
+
var ARROW_Y = 24;
|
|
33122
|
+
var ARROW_HEAD = 5;
|
|
33123
|
+
var SELF_LOOP = 22;
|
|
33124
|
+
var BLOCK_WIDTH = 8;
|
|
33125
|
+
var BLOCK_OFFSET = BLOCK_WIDTH + 6;
|
|
33126
|
+
var BLOCK_OVERLAP_OFFSET = BLOCK_WIDTH * 3 / 4;
|
|
33127
|
+
var HATCH_MARGIN = 4;
|
|
33128
|
+
var BLOCK_OVERHANG = 4;
|
|
33129
|
+
var BLOCK_MIN_HEIGHT = 24;
|
|
33130
|
+
var BLOCK_TAIL = BLOCK_MIN_HEIGHT - BLOCK_OVERHANG;
|
|
33131
|
+
var BLOCK_RADIUS = 2;
|
|
33132
|
+
var RETURN_GAP = 10;
|
|
33133
|
+
var ROW_GAP = 8;
|
|
33134
|
+
var rowHeight = (endings) => ARROW_Y + (endings === 0 ? 0 : BLOCK_TAIL + (endings - 1) * RETURN_GAP) + ROW_GAP;
|
|
33135
|
+
var SLIDE_MS = 200;
|
|
33136
|
+
var SLIDE = `${String(SLIDE_MS)}ms cubic-bezier(0.4, 0, 0.2, 1)`;
|
|
33137
|
+
var SLIDE_TRANSITION = `transform ${SLIDE}, height ${SLIDE}`;
|
|
33138
|
+
var RETURN_HIT_HEIGHT = 9;
|
|
33139
|
+
var ARROW_HIT_HEIGHT = 15;
|
|
33140
|
+
var BLOCK_HIT_MARGIN = 3;
|
|
33141
|
+
var enter = keyframes3`from { opacity: 0 }`;
|
|
33142
|
+
var ENTER_ANIMATION = `${enter} ${SLIDE}`;
|
|
33143
|
+
var slideTo = (y, entering = false) => ({
|
|
33144
|
+
animation: entering ? ENTER_ANIMATION : void 0,
|
|
33145
|
+
transform: `translateY(${String(y)}px)`,
|
|
33146
|
+
transition: SLIDE_TRANSITION
|
|
33147
|
+
});
|
|
33148
|
+
var blockRect = (height) => ({ height, style: { height, transition: SLIDE_TRANSITION }, y: 0 });
|
|
33149
|
+
var hatchId = (color2) => `sequence-hatch-${color2.replace("#", "")}`;
|
|
33150
|
+
var lifelineX = (index) => index * COLUMN_WIDTH + COLUMN_WIDTH / 2;
|
|
33151
|
+
var blockX = (index, depth, offset) => lifelineX(index) + depth * offset;
|
|
33152
|
+
var Arrow = ({ blockOffset, blockWidth, color: color2, entering, message, top }) => {
|
|
33153
|
+
const y = ARROW_Y;
|
|
33154
|
+
const dash = message.async ? "4 3" : void 0;
|
|
33155
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33156
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33157
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33158
|
+
if (message.from === message.to) {
|
|
33159
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33160
|
+
const endX2 = toX + blockWidth / 2;
|
|
33161
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33162
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(fromX + fromHalf)} ${String(y - 6)}H${String(loopX)}v8H${String(endX2 + ARROW_HEAD)}`, fill: "none", strokeDasharray: dash }),
|
|
33163
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(endX2)} ${String(y + 2)}l${String(ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33164
|
+
] });
|
|
33165
|
+
}
|
|
33166
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33167
|
+
const startX = fromX + direction * fromHalf;
|
|
33168
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33169
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33170
|
+
/* @__PURE__ */ jsx151("line", { strokeDasharray: dash, x1: startX, x2: endX - direction * ARROW_HEAD, y1: y, y2: y }),
|
|
33171
|
+
/* @__PURE__ */ jsx151("path", { d: `M${String(endX)} ${String(y)}l${String(-direction * ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33172
|
+
] });
|
|
33173
|
+
};
|
|
33174
|
+
var arrowHitBox = (message, blockWidth, blockOffset, height) => {
|
|
33175
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33176
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33177
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33178
|
+
if (message.from === message.to) {
|
|
33179
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33180
|
+
const left = Math.min(fromX + fromHalf, toX + blockWidth / 2);
|
|
33181
|
+
return { height, left, top: ARROW_Y - 2 - height / 2, width: loopX - left };
|
|
33182
|
+
}
|
|
33183
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33184
|
+
const startX = fromX + direction * fromHalf;
|
|
33185
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33186
|
+
return { height, left: Math.min(startX, endX), top: ARROW_Y - height / 2, width: Math.abs(endX - startX) };
|
|
33187
|
+
};
|
|
33188
|
+
var hasReturn = (message) => !message.async && message.from !== message.to;
|
|
33189
|
+
var ReturnArrow = ({ blockOffset, blockWidth, color: color2, entering, message, y: lineY }) => {
|
|
33190
|
+
const y = 0;
|
|
33191
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33192
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33193
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33194
|
+
const startX = fromX + direction * blockWidth / 2;
|
|
33195
|
+
const endX = toX - direction * (message.from === 0 ? 0 : blockWidth / 2);
|
|
33196
|
+
return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(lineY, entering), children: [
|
|
33197
|
+
/* @__PURE__ */ jsx151("line", { strokeDasharray: "3 3", x1: startX, x2: endX, y1: y, y2: y }),
|
|
33198
|
+
/* @__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" })
|
|
33199
|
+
] });
|
|
33200
|
+
};
|
|
33201
|
+
var MIN_ZOOM = 0.25;
|
|
33202
|
+
var MAX_ZOOM = 1;
|
|
33203
|
+
var ZOOM_STEP = 1.25;
|
|
33204
|
+
var WHEEL_ZOOM_SPEED = 0.01;
|
|
33205
|
+
var MINIMAP_WIDTH = 168;
|
|
33206
|
+
var MINIMAP_MAX_HEIGHT = 160;
|
|
33207
|
+
var MINIMAP_MAX_VIEW_SHARE = 1 / 3;
|
|
33208
|
+
var WIDGET_MARGIN = 16;
|
|
33209
|
+
var BOTTOM_ROOM = 44 + WIDGET_MARGIN + 16;
|
|
33210
|
+
var MINIMAP_OPEN_STORAGE_KEY = "appinspector-sequence-minimap-open";
|
|
33211
|
+
var bodyIds = 0;
|
|
33212
|
+
var useBodyId = () => {
|
|
33213
|
+
const [id2] = React126.useState(() => `sequence-body-${String(++bodyIds)}`);
|
|
33214
|
+
return id2;
|
|
33215
|
+
};
|
|
33216
|
+
var clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
|
|
33217
|
+
var useZoom = (scrollRef, areaRef, widgetRef, enabled) => {
|
|
33218
|
+
const [zoom, setZoom] = React126.useState(1);
|
|
33219
|
+
const zoomRef = React126.useRef(zoom);
|
|
33220
|
+
const anchorRef = React126.useRef();
|
|
33221
|
+
const zoomTo = React126.useCallback((next, x, y) => {
|
|
33222
|
+
const element = scrollRef.current;
|
|
33223
|
+
const clamped = clampZoom(next);
|
|
33224
|
+
if (!element || clamped === zoomRef.current) return;
|
|
33225
|
+
anchorRef.current = { ratio: clamped / zoomRef.current, x: x ?? element.clientWidth / 2, y: y ?? element.clientHeight / 2 };
|
|
33226
|
+
zoomRef.current = clamped;
|
|
33227
|
+
setZoom(clamped);
|
|
33228
|
+
}, [scrollRef]);
|
|
33229
|
+
React126.useLayoutEffect(() => {
|
|
33230
|
+
const element = scrollRef.current;
|
|
33231
|
+
const anchor = anchorRef.current;
|
|
33232
|
+
if (!element || !anchor) return;
|
|
33233
|
+
element.scrollLeft = (element.scrollLeft + anchor.x) * anchor.ratio - anchor.x;
|
|
33234
|
+
element.scrollTop = (element.scrollTop + anchor.y) * anchor.ratio - anchor.y;
|
|
33235
|
+
anchorRef.current = void 0;
|
|
33236
|
+
}, [scrollRef, zoom]);
|
|
33237
|
+
React126.useEffect(() => {
|
|
33238
|
+
const element = scrollRef.current;
|
|
33239
|
+
const area = areaRef.current;
|
|
33240
|
+
if (!element || !area || !enabled) return;
|
|
33241
|
+
const pointer = (event) => {
|
|
33242
|
+
if (event.target instanceof Node && widgetRef.current?.contains(event.target)) return [];
|
|
33243
|
+
const bounds = element.getBoundingClientRect();
|
|
33244
|
+
return [event.clientX - bounds.left, event.clientY - bounds.top];
|
|
33245
|
+
};
|
|
33246
|
+
const handleWheel = (event) => {
|
|
33247
|
+
if (!event.ctrlKey && !event.metaKey) return;
|
|
33248
|
+
event.preventDefault();
|
|
33249
|
+
zoomTo(zoomRef.current * Math.exp(-event.deltaY * WHEEL_ZOOM_SPEED), ...pointer(event));
|
|
33250
|
+
};
|
|
33251
|
+
let gestureStart = 1;
|
|
33252
|
+
const handleGestureStart = (event) => {
|
|
33253
|
+
event.preventDefault();
|
|
33254
|
+
gestureStart = zoomRef.current;
|
|
33255
|
+
};
|
|
33256
|
+
const handleGestureChange = (event) => {
|
|
33257
|
+
event.preventDefault();
|
|
33258
|
+
const { scale: scale2 } = event;
|
|
33259
|
+
zoomTo(gestureStart * scale2, ...pointer(event));
|
|
33260
|
+
};
|
|
33261
|
+
area.addEventListener("wheel", handleWheel, { passive: false });
|
|
33262
|
+
area.addEventListener("gesturestart", handleGestureStart);
|
|
33263
|
+
area.addEventListener("gesturechange", handleGestureChange);
|
|
33264
|
+
return () => {
|
|
33265
|
+
area.removeEventListener("wheel", handleWheel);
|
|
33266
|
+
area.removeEventListener("gesturestart", handleGestureStart);
|
|
33267
|
+
area.removeEventListener("gesturechange", handleGestureChange);
|
|
33268
|
+
};
|
|
33269
|
+
}, [scrollRef, areaRef, widgetRef, enabled, zoomTo]);
|
|
33270
|
+
return { zoom, zoomTo };
|
|
33271
|
+
};
|
|
33272
|
+
var lifelineName = (participant) => participant.service === "" ? "Caller" : [getServiceDisplayName(participant.service), participant.label].filter(Boolean).join(" ");
|
|
33273
|
+
var hoverDirection = (hover) => {
|
|
33274
|
+
if (hover.kind === "segment") return `Active on ${hover.to}`;
|
|
33275
|
+
const kind = hover.kind === "response" ? "Response" : hover.message.async ? "Async request" : "Request";
|
|
33276
|
+
return `${kind} \xB7 ${hover.from} \u2192 ${hover.to}`;
|
|
33277
|
+
};
|
|
33278
|
+
var ArrowHoverCard = ({ hover }) => {
|
|
33279
|
+
const { span } = hover.message;
|
|
33280
|
+
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);
|
|
33281
|
+
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;
|
|
33282
|
+
const anchor = { getBoundingClientRect: () => new DOMRect(hover.x, hover.y, 0, 0) };
|
|
33283
|
+
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: [
|
|
33284
|
+
/* @__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 }),
|
|
33285
|
+
getOperationLabel(span) !== span.operation_name && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: `Action: ${span.operation_name}` }),
|
|
33286
|
+
/* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: [hoverDirection(hover), duration].filter(Boolean).join(" \xB7 ") }),
|
|
33287
|
+
issue !== void 0 && issue !== "" && /* @__PURE__ */ jsx151(Typography15, { color: hover.message.error ? "error" : "warning.main", sx: { fontSize: 12 }, children: issue })
|
|
33288
|
+
] }) });
|
|
33289
|
+
};
|
|
33290
|
+
var SequenceDiagram = ({ onSelectSpan, participantMode = "caller", selectedSpanId, spans }) => {
|
|
33291
|
+
const theme = useTheme7();
|
|
33292
|
+
const [folded, setFolded] = React126.useState(() => /* @__PURE__ */ new Set());
|
|
33293
|
+
const containerRef = React126.useRef(null);
|
|
33294
|
+
const scrollRef = React126.useRef(null);
|
|
33295
|
+
const areaRef = React126.useRef(null);
|
|
33296
|
+
const widgetRef = React126.useRef(null);
|
|
33297
|
+
const { zoom, zoomTo } = useZoom(scrollRef, areaRef, widgetRef, spans.length > 0);
|
|
33298
|
+
const bodyId = useBodyId();
|
|
33299
|
+
const [minimapOpen, setMinimapOpen] = useLocalStorage(MINIMAP_OPEN_STORAGE_KEY, true);
|
|
33300
|
+
const [scrollView, setScrollView] = React126.useState({ height: 0, left: 0, scrollbarHeight: 0, scrollbarWidth: 0, top: 0, width: 0 });
|
|
33301
|
+
const measureView = React126.useCallback(() => {
|
|
33302
|
+
const element = scrollRef.current;
|
|
33303
|
+
if (element) setScrollView({
|
|
33304
|
+
height: element.clientHeight,
|
|
33305
|
+
left: element.scrollLeft,
|
|
33306
|
+
// Classic scrollbars take room; overlay ones (macOS by default) measure 0.
|
|
33307
|
+
scrollbarHeight: element.offsetHeight - element.clientHeight,
|
|
33308
|
+
scrollbarWidth: element.offsetWidth - element.clientWidth,
|
|
33309
|
+
top: element.scrollTop,
|
|
33310
|
+
width: element.clientWidth
|
|
33311
|
+
});
|
|
33312
|
+
}, []);
|
|
33313
|
+
React126.useLayoutEffect(() => {
|
|
33314
|
+
const element = scrollRef.current;
|
|
33315
|
+
if (!element) return;
|
|
33316
|
+
measureView();
|
|
33317
|
+
let frame2 = 0;
|
|
33318
|
+
const observer = new ResizeObserver(() => {
|
|
33319
|
+
cancelAnimationFrame(frame2);
|
|
33320
|
+
frame2 = requestAnimationFrame(measureView);
|
|
33321
|
+
});
|
|
33322
|
+
observer.observe(element);
|
|
33323
|
+
return () => {
|
|
33324
|
+
cancelAnimationFrame(frame2);
|
|
33325
|
+
observer.disconnect();
|
|
33326
|
+
};
|
|
33327
|
+
}, [measureView, zoom, spans.length]);
|
|
33328
|
+
const { sequenceBlocks, sequenceClickTargets, sequenceHoverCard } = useDevSettings();
|
|
33329
|
+
const arrowTargets = sequenceClickTargets === "arrows-and-segments";
|
|
33330
|
+
const returnHitHeight = arrowTargets ? ARROW_HIT_HEIGHT : RETURN_HIT_HEIGHT;
|
|
33331
|
+
const hoverCard = sequenceHoverCard === "on";
|
|
33332
|
+
const [hover, setHover] = React126.useState();
|
|
33333
|
+
const blocks = sequenceBlocks === "detached" || sequenceBlocks === "overlapped";
|
|
33334
|
+
const hatched = sequenceBlocks === "detached";
|
|
33335
|
+
const blockOffset = sequenceBlocks === "overlapped" ? BLOCK_OVERLAP_OFFSET : BLOCK_OFFSET;
|
|
33336
|
+
const merged = sequenceBlocks === "merged";
|
|
33337
|
+
const blockWidth = sequenceBlocks === "off" ? 0 : BLOCK_WIDTH;
|
|
33338
|
+
const segmentTargets = (arrowTargets || hoverCard) && blockWidth > 0;
|
|
33339
|
+
const { endings, messages, participants } = React126.useMemo(() => {
|
|
33340
|
+
const layout = layoutSequence(spans, participantMode, folded);
|
|
33341
|
+
return blocks ? layout : { ...layout, messages: layout.messages.map((message) => ({ ...message, depth: 0, fromDepth: 0 })) };
|
|
33342
|
+
}, [spans, participantMode, folded, blocks]);
|
|
33343
|
+
const pickedHereRef = React126.useRef();
|
|
33344
|
+
const select = React126.useCallback((spanId, view2) => {
|
|
33345
|
+
pickedHereRef.current = spanId;
|
|
33346
|
+
onSelectSpan(spanId, view2);
|
|
33347
|
+
}, [onSelectSpan]);
|
|
33348
|
+
React126.useEffect(() => {
|
|
33349
|
+
if (selectedSpanId === void 0 || selectedSpanId === pickedHereRef.current) return;
|
|
33350
|
+
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
33351
|
+
}, [selectedSpanId]);
|
|
33352
|
+
const [folding, setFolding] = React126.useState(false);
|
|
33353
|
+
const foldingTimerRef = React126.useRef();
|
|
33354
|
+
React126.useEffect(() => () => {
|
|
33355
|
+
clearTimeout(foldingTimerRef.current);
|
|
33356
|
+
}, []);
|
|
33357
|
+
const setFold = React126.useCallback((spanId, fold) => {
|
|
33358
|
+
setFolding(true);
|
|
33359
|
+
clearTimeout(foldingTimerRef.current);
|
|
33360
|
+
foldingTimerRef.current = setTimeout(() => {
|
|
33361
|
+
setFolding(false);
|
|
33362
|
+
}, SLIDE_MS + 100);
|
|
33363
|
+
setFolded((previous) => {
|
|
33364
|
+
const next = new Set(previous);
|
|
33365
|
+
if (fold) next.add(spanId);
|
|
33366
|
+
else next.delete(spanId);
|
|
33367
|
+
return next;
|
|
33368
|
+
});
|
|
33369
|
+
}, []);
|
|
33370
|
+
const handleKeyDown = React126.useCallback((event, message) => {
|
|
33371
|
+
if (event.target !== event.currentTarget) return;
|
|
33372
|
+
const spanId = message.span.span_id;
|
|
33373
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
33374
|
+
event.preventDefault();
|
|
33375
|
+
select(spanId, "details");
|
|
33376
|
+
} else if (event.key === "ArrowRight" && message.folded) setFold(spanId, false);
|
|
33377
|
+
else if (event.key === "ArrowLeft" && message.descendantCount > 0 && !message.folded) setFold(spanId, true);
|
|
33378
|
+
}, [select, setFold]);
|
|
33379
|
+
const [shown, setShown] = React126.useState(() => ({ messages, revealed: /* @__PURE__ */ new Set() }));
|
|
33380
|
+
if (shown.messages !== messages) {
|
|
33381
|
+
const previous = new Set(shown.messages.map((message) => message.span.span_id));
|
|
33382
|
+
const continued = messages.some((message) => previous.has(message.span.span_id));
|
|
33383
|
+
setShown({ messages, revealed: new Set(continued ? messages.filter((message) => !previous.has(message.span.span_id)).map((message) => message.span.span_id) : []) });
|
|
33384
|
+
}
|
|
33385
|
+
const isEntering = React126.useCallback((spanId) => shown.revealed.has(spanId), [shown]);
|
|
33386
|
+
const geometry = React126.useMemo(() => {
|
|
33387
|
+
const participant2 = (index) => participants[index] ?? { key: "", label: "", resource: "", service: "" };
|
|
33388
|
+
const width2 = participants.length * COLUMN_WIDTH;
|
|
33389
|
+
const rowHeights2 = endings.map((count2) => rowHeight(count2));
|
|
33390
|
+
const rowTops = rowHeights2.map((_height, row) => rowHeights2.slice(0, row).reduce((sum2, height) => sum2 + height, 0));
|
|
33391
|
+
const bodyHeight2 = rowHeights2.reduce((sum2, height) => sum2 + height, 0);
|
|
33392
|
+
const top2 = (row) => rowTops[row] ?? 0;
|
|
33393
|
+
const activeDepth2 = (lifeline, row) => Math.max(0, ...messages.slice(0, row + 1).filter((message) => message.to === lifeline && message.endRow >= row).map((message) => message.depth));
|
|
33394
|
+
const endY2 = (message) => top2(message.endRow) + ARROW_Y + BLOCK_TAIL + message.returnLevel * RETURN_GAP;
|
|
33395
|
+
const rowOf = new Map(messages.map((message, index) => [message.span.span_id, index]));
|
|
33396
|
+
const blockY2 = (message) => top2(rowOf.get(message.span.span_id) ?? 0) + ARROW_Y - BLOCK_OVERHANG;
|
|
33397
|
+
const mergedBlocks2 = [];
|
|
33398
|
+
if (merged) {
|
|
33399
|
+
for (const message of messages.toSorted((left, right) => left.to - right.to || blockY2(left) - blockY2(right))) {
|
|
33400
|
+
const last = mergedBlocks2.at(-1);
|
|
33401
|
+
if (last?.members[0]?.to === message.to && blockY2(message) <= last.bottom) {
|
|
33402
|
+
last.bottom = Math.max(last.bottom, endY2(message));
|
|
33403
|
+
last.members.push(message);
|
|
33404
|
+
} else mergedBlocks2.push({ bottom: endY2(message), members: [message], top: blockY2(message) });
|
|
33405
|
+
}
|
|
33406
|
+
}
|
|
33407
|
+
return { activeDepth: activeDepth2, blockY: blockY2, bodyHeight: bodyHeight2, endY: endY2, mergedBlocks: mergedBlocks2, participant: participant2, rowHeights: rowHeights2, top: top2, width: width2 };
|
|
33408
|
+
}, [endings, merged, messages, participants]);
|
|
33409
|
+
const { activeDepth, blockY, bodyHeight, endY, mergedBlocks, participant, rowHeights, top, width } = geometry;
|
|
33410
|
+
const hoveredMessage = hover && messages.find((message) => message.span.span_id === hover.message.span.span_id);
|
|
33411
|
+
const arrowHoverProps = React126.useCallback((message, kind) => {
|
|
33412
|
+
if (!hoverCard) return {};
|
|
33413
|
+
const [from, to] = kind === "response" ? [message.to, message.from] : [message.from, message.to];
|
|
33414
|
+
return {
|
|
33415
|
+
onMouseLeave: () => {
|
|
33416
|
+
setHover(void 0);
|
|
33417
|
+
},
|
|
33418
|
+
onMouseMove: (event) => {
|
|
33419
|
+
setHover({ from: lifelineName(participant(from)), kind, message, to: lifelineName(participant(to)), x: event.clientX, y: event.clientY });
|
|
33420
|
+
}
|
|
33421
|
+
};
|
|
33422
|
+
}, [hoverCard, participant]);
|
|
33423
|
+
const drawing = React126.useMemo(() => /* @__PURE__ */ jsxs138(Fragment15, { children: [
|
|
33424
|
+
/* @__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) => (
|
|
33425
|
+
// A subtle box per lifeline, its identity as in every other view: icon, service, resource below.
|
|
33426
|
+
/* @__PURE__ */ jsx151(
|
|
33427
|
+
Box22,
|
|
33428
|
+
{
|
|
33429
|
+
"data-testid": SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID,
|
|
33430
|
+
sx: {
|
|
33431
|
+
// As in Flow: a hovered box grows to show its whole name, over its neighbours, without moving them.
|
|
33432
|
+
"&:hover": { "& > *": { width: "max-content" }, "zIndex": 1 },
|
|
33433
|
+
"alignItems": "center",
|
|
33434
|
+
"display": "flex",
|
|
33435
|
+
"flex": "none",
|
|
33436
|
+
"justifyContent": "flex-start",
|
|
33437
|
+
"position": "relative",
|
|
33438
|
+
"px": "4px",
|
|
33439
|
+
"width": COLUMN_WIDTH
|
|
33440
|
+
},
|
|
33441
|
+
title: [participant2.service, participant2.resource].filter(Boolean).join(" \xB7 ") || "Caller",
|
|
33442
|
+
children: /* @__PURE__ */ jsx151(
|
|
33443
|
+
Box22,
|
|
33444
|
+
{
|
|
33445
|
+
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%" },
|
|
33446
|
+
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 })
|
|
33447
|
+
}
|
|
33448
|
+
)
|
|
33449
|
+
},
|
|
33450
|
+
participant2.key
|
|
33451
|
+
)
|
|
33452
|
+
)) }),
|
|
33453
|
+
/* @__PURE__ */ jsxs138(Box22, { sx: { backgroundColor: "background.paper", height: bodyHeight, position: "relative" }, children: [
|
|
33454
|
+
messages.map((message, index) => {
|
|
33455
|
+
const { span } = message;
|
|
33456
|
+
const selected = span.span_id === selectedSpanId;
|
|
33457
|
+
const self2 = message.from === message.to;
|
|
33458
|
+
const lane = Math.min(message.from, message.to);
|
|
33459
|
+
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;
|
|
33460
|
+
return /* @__PURE__ */ jsxs138(
|
|
33461
|
+
Box22,
|
|
33462
|
+
{
|
|
33463
|
+
"aria-selected": selected,
|
|
33464
|
+
"data-span-id": span.span_id,
|
|
33465
|
+
"data-testid": SEQUENCE_DIAGRAM_MESSAGE_TEST_ID,
|
|
33466
|
+
onClick: arrowTargets ? void 0 : () => {
|
|
33467
|
+
select(span.span_id, "details");
|
|
33468
|
+
},
|
|
33469
|
+
onKeyDown: (event) => {
|
|
33470
|
+
handleKeyDown(event, message);
|
|
33471
|
+
},
|
|
33472
|
+
role: "listitem",
|
|
33473
|
+
sx: {
|
|
33474
|
+
"&:focus-visible": { boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}` },
|
|
33475
|
+
"&:hover": arrowTargets ? void 0 : { "--row-tint": selected ? alpha8(theme.palette.primary.main, 0.16) : alpha8(theme.palette.text.primary, 0.04) },
|
|
33476
|
+
// Opaque, so a label repeating it hides the lifelines behind it.
|
|
33477
|
+
"--row-bg": `linear-gradient(var(--row-tint), var(--row-tint)), ${theme.palette.background.paper}`,
|
|
33478
|
+
"--row-tint": selected ? alpha8(theme.palette.primary.main, 0.12) : "transparent",
|
|
33479
|
+
"animation": isEntering(span.span_id) ? ENTER_ANIMATION : void 0,
|
|
33480
|
+
// Only the tint: the drawing shows through the row, under its label.
|
|
33481
|
+
"background": "var(--row-tint)",
|
|
33482
|
+
"cursor": arrowTargets ? void 0 : "pointer",
|
|
33483
|
+
"height": rowHeights[index],
|
|
33484
|
+
"left": 0,
|
|
33485
|
+
"outline": 0,
|
|
33486
|
+
"position": "absolute",
|
|
33487
|
+
"right": 0,
|
|
33488
|
+
"scrollMarginTop": HEADER_HEIGHT,
|
|
33489
|
+
"top": 0,
|
|
33490
|
+
"transform": `translateY(${String(top(index))}px)`,
|
|
33491
|
+
// Only the transform: a height transition would re-lay out every row on every frame.
|
|
33492
|
+
"transition": `transform ${SLIDE}`,
|
|
33493
|
+
// The transform makes the row a stacking context: over the drawing, so its label covers the blocks and lines it crosses.
|
|
33494
|
+
"zIndex": 1
|
|
33495
|
+
},
|
|
33496
|
+
tabIndex: 0,
|
|
33497
|
+
children: [
|
|
33498
|
+
(arrowTargets || hoverCard) && /* @__PURE__ */ jsx151(
|
|
33499
|
+
Box22,
|
|
33500
|
+
{
|
|
33501
|
+
"data-testid": SEQUENCE_DIAGRAM_ARROW_TEST_ID,
|
|
33502
|
+
onClick: arrowTargets ? () => {
|
|
33503
|
+
select(span.span_id, "payload");
|
|
33504
|
+
} : void 0,
|
|
33505
|
+
...arrowHoverProps(message, "request"),
|
|
33506
|
+
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) }
|
|
33507
|
+
}
|
|
33508
|
+
),
|
|
33509
|
+
/* @__PURE__ */ jsxs138(
|
|
33510
|
+
Box22,
|
|
33511
|
+
{
|
|
33512
|
+
onClick: arrowTargets ? () => {
|
|
33513
|
+
select(span.span_id, "details");
|
|
33514
|
+
} : void 0,
|
|
33515
|
+
...arrowHoverProps(message, "request"),
|
|
33516
|
+
sx: {
|
|
33517
|
+
alignItems: "center",
|
|
33518
|
+
background: "var(--row-bg)",
|
|
33519
|
+
cursor: arrowTargets ? "pointer" : void 0,
|
|
33520
|
+
display: "flex",
|
|
33521
|
+
gap: "3px",
|
|
33522
|
+
height: LABEL_HEIGHT,
|
|
33523
|
+
left: labelLeft,
|
|
33524
|
+
maxWidth: width - labelLeft - 4,
|
|
33525
|
+
position: "absolute",
|
|
33526
|
+
px: "2px",
|
|
33527
|
+
top: LABEL_TOP,
|
|
33528
|
+
zIndex: 2
|
|
33529
|
+
},
|
|
33530
|
+
children: [
|
|
33531
|
+
message.descendantCount > 0 && /* @__PURE__ */ jsx151(
|
|
33532
|
+
ButtonBase2,
|
|
33533
|
+
{
|
|
33534
|
+
"aria-label": message.folded ? "Expand" : "Collapse",
|
|
33535
|
+
"data-testid": SEQUENCE_DIAGRAM_TOGGLE_TEST_ID,
|
|
33536
|
+
onClick: (event) => {
|
|
33537
|
+
event.stopPropagation();
|
|
33538
|
+
setFold(span.span_id, !message.folded);
|
|
33539
|
+
},
|
|
33540
|
+
sx: { "&:hover": { backgroundColor: alpha8(theme.palette.text.primary, 0.12) }, "borderRadius": "3px", "color": "text.secondary", "flex": "none", "height": 14, "width": 14 },
|
|
33541
|
+
tabIndex: -1,
|
|
33542
|
+
children: message.folded ? /* @__PURE__ */ jsx151(KeyboardArrowRight3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } })
|
|
33543
|
+
}
|
|
33544
|
+
),
|
|
33545
|
+
/* @__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 }) }),
|
|
33546
|
+
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 }),
|
|
33547
|
+
message.error && /* @__PURE__ */ jsx151(Cancel8, { sx: { color: "error.main", flex: "none", fontSize: 13 } }),
|
|
33548
|
+
message.warning && /* @__PURE__ */ jsx151(GppMaybe9, { sx: { color: "warning.main", flex: "none", fontSize: 13 } }),
|
|
33549
|
+
message.folded && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", sx: { flex: "none", fontSize: 11 }, children: `+${String(message.descendantCount)}` })
|
|
33550
|
+
]
|
|
33551
|
+
}
|
|
33552
|
+
)
|
|
33553
|
+
]
|
|
33554
|
+
},
|
|
33555
|
+
span.span_id
|
|
33556
|
+
);
|
|
33557
|
+
}),
|
|
33558
|
+
messages.filter((message) => hasReturn(message)).map((message) => {
|
|
33559
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33560
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33561
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33562
|
+
return /* @__PURE__ */ jsx151(
|
|
33563
|
+
Box22,
|
|
33564
|
+
{
|
|
33565
|
+
"aria-hidden": "true",
|
|
33566
|
+
"aria-selected": selected,
|
|
33567
|
+
"data-span-id": message.span.span_id,
|
|
33568
|
+
"data-testid": SEQUENCE_DIAGRAM_RETURN_TEST_ID,
|
|
33569
|
+
onClick: () => {
|
|
33570
|
+
select(message.span.span_id, "response");
|
|
33571
|
+
},
|
|
33572
|
+
...arrowHoverProps(message, "response"),
|
|
33573
|
+
sx: {
|
|
33574
|
+
// The selected call's tint, as on its row, so its reply reads as part of it.
|
|
33575
|
+
"&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33576
|
+
"backgroundColor": selected ? alpha8(theme.palette.primary.main, 0.12) : void 0,
|
|
33577
|
+
"borderRadius": "4px",
|
|
33578
|
+
"cursor": "pointer",
|
|
33579
|
+
"height": returnHitHeight,
|
|
33580
|
+
"left": Math.min(fromX, toX),
|
|
33581
|
+
"position": "absolute",
|
|
33582
|
+
"top": 0,
|
|
33583
|
+
"width": Math.abs(toX - fromX),
|
|
33584
|
+
"zIndex": 2,
|
|
33585
|
+
...slideTo(endY(message) - returnHitHeight / 2, isEntering(message.span.span_id))
|
|
33586
|
+
},
|
|
33587
|
+
title: hoverCard ? void 0 : `${getOperationLabel(message.span)}: response`
|
|
33588
|
+
},
|
|
33589
|
+
message.span.span_id
|
|
33590
|
+
);
|
|
33591
|
+
}),
|
|
33592
|
+
segmentTargets && messages.map((message) => {
|
|
33593
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33594
|
+
const boxY = blockY(message);
|
|
33595
|
+
return /* @__PURE__ */ jsx151(
|
|
33596
|
+
Box22,
|
|
33597
|
+
{
|
|
33598
|
+
"aria-hidden": "true",
|
|
33599
|
+
"data-span-id": message.span.span_id,
|
|
33600
|
+
"data-testid": SEQUENCE_DIAGRAM_SEGMENT_TEST_ID,
|
|
33601
|
+
onClick: () => {
|
|
33602
|
+
select(message.span.span_id, "details");
|
|
33603
|
+
},
|
|
33604
|
+
...arrowHoverProps(message, "segment"),
|
|
33605
|
+
sx: {
|
|
33606
|
+
"&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33607
|
+
"borderRadius": "4px",
|
|
33608
|
+
"cursor": "pointer",
|
|
33609
|
+
"height": endY(message) - boxY,
|
|
33610
|
+
"left": blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 - BLOCK_HIT_MARGIN,
|
|
33611
|
+
"position": "absolute",
|
|
33612
|
+
"top": 0,
|
|
33613
|
+
"width": BLOCK_WIDTH + 2 * BLOCK_HIT_MARGIN,
|
|
33614
|
+
"zIndex": 2,
|
|
33615
|
+
// Its height follows a fold too: the slide's transition covers both.
|
|
33616
|
+
...slideTo(boxY, isEntering(message.span.span_id))
|
|
33617
|
+
},
|
|
33618
|
+
title: hoverCard ? void 0 : getOperationLabel(message.span)
|
|
33619
|
+
},
|
|
33620
|
+
message.span.span_id
|
|
33621
|
+
);
|
|
33622
|
+
}),
|
|
33623
|
+
/* @__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: [
|
|
33624
|
+
/* @__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)) }),
|
|
33625
|
+
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)),
|
|
33626
|
+
blocks && messages.map((message, index) => {
|
|
33627
|
+
const serviceColor = getServiceColor(message.span.service_name);
|
|
33628
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33629
|
+
const boxY = top(index) + ARROW_Y - BLOCK_OVERHANG;
|
|
33630
|
+
const boxHeight = endY(message) - boxY;
|
|
33631
|
+
const box = { ...blockRect(boxHeight), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x: blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 };
|
|
33632
|
+
const hatch = (earlier) => ({
|
|
33633
|
+
...blockRect(boxHeight + 2 * HATCH_MARGIN),
|
|
33634
|
+
// A pixel wider on each side, over the outer block's border: the hatch has none.
|
|
33635
|
+
width: BLOCK_WIDTH + 2,
|
|
33636
|
+
x: blockX(earlier.to, earlier.depth, blockOffset) - BLOCK_WIDTH / 2 - 1
|
|
33637
|
+
});
|
|
33638
|
+
const outer = hatched ? messages.slice(0, index).filter((earlier) => earlier.to === message.to && earlier.endRow >= index && earlier.depth < message.depth) : [];
|
|
33639
|
+
return (
|
|
33640
|
+
// Paper first, so the tint over it stays opaque to the lifeline.
|
|
33641
|
+
/* @__PURE__ */ jsxs138("g", { style: slideTo(boxY, isEntering(message.span.span_id)), children: [
|
|
33642
|
+
outer.map((earlier) => /* @__PURE__ */ jsxs138("g", { transform: `translate(0 ${String(-HATCH_MARGIN)})`, children: [
|
|
33643
|
+
/* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...hatch(earlier) }),
|
|
33644
|
+
/* @__PURE__ */ jsx151("rect", { fill: `url(#${hatchId(getServiceColor(earlier.span.service_name))})`, rx: BLOCK_RADIUS, ...hatch(earlier) })
|
|
33645
|
+
] }, earlier.span.span_id)),
|
|
33646
|
+
/* @__PURE__ */ jsx151("rect", { ...box, fill: theme.palette.background.paper }),
|
|
33647
|
+
/* @__PURE__ */ jsx151(
|
|
33648
|
+
"rect",
|
|
33649
|
+
{
|
|
33650
|
+
...box,
|
|
33651
|
+
fill: alpha8(serviceColor, selected ? 0.5 : 0.2),
|
|
33652
|
+
stroke: message.error ? theme.palette.error.main : serviceColor,
|
|
33653
|
+
strokeWidth: selected ? 1.5 : 1
|
|
33654
|
+
}
|
|
33655
|
+
)
|
|
33656
|
+
] }, message.span.span_id)
|
|
33657
|
+
);
|
|
33658
|
+
}),
|
|
33659
|
+
merged && mergedBlocks.map(({ bottom, members, top: blockTop }) => {
|
|
33660
|
+
const [firstMember] = members;
|
|
33661
|
+
if (!firstMember) return;
|
|
33662
|
+
const serviceColor = getServiceColor(firstMember.span.service_name);
|
|
33663
|
+
const x = lifelineX(firstMember.to) - BLOCK_WIDTH / 2;
|
|
33664
|
+
const range = (member2) => ({ ...blockRect(endY(member2) - blockY(member2)), transform: `translate(0 ${String(blockY(member2) - blockTop)})`, width: BLOCK_WIDTH, x });
|
|
33665
|
+
return /* @__PURE__ */ jsxs138("g", { style: slideTo(blockTop), children: [
|
|
33666
|
+
/* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x }),
|
|
33667
|
+
/* @__PURE__ */ jsx151("rect", { fill: alpha8(serviceColor, 0.2), ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, stroke: serviceColor, width: BLOCK_WIDTH, x }),
|
|
33668
|
+
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)),
|
|
33669
|
+
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))
|
|
33670
|
+
] }, firstMember.span.span_id);
|
|
33671
|
+
}),
|
|
33672
|
+
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)),
|
|
33673
|
+
messages.map((message, index) => /* @__PURE__ */ jsx151(
|
|
33674
|
+
Arrow,
|
|
33675
|
+
{
|
|
33676
|
+
blockOffset,
|
|
33677
|
+
blockWidth,
|
|
33678
|
+
color: message.error ? theme.palette.error.main : theme.palette.text.secondary,
|
|
33679
|
+
entering: isEntering(message.span.span_id),
|
|
33680
|
+
message,
|
|
33681
|
+
top: top(index)
|
|
33682
|
+
},
|
|
33683
|
+
message.span.span_id
|
|
33684
|
+
))
|
|
33685
|
+
] }) })
|
|
33686
|
+
] })
|
|
33687
|
+
] }), [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]);
|
|
33688
|
+
if (spans.length === 0) {
|
|
33689
|
+
return /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { p: 2 }, variant: "body2", children: "No operations in this trace." });
|
|
33690
|
+
}
|
|
33691
|
+
const view = { height: scrollView.height / zoom - HEADER_HEIGHT, width: scrollView.width / zoom, x: scrollView.left / zoom, y: scrollView.top / zoom };
|
|
33692
|
+
const minimapScale = Math.min((MINIMAP_WIDTH - 16) / width, Math.min(MINIMAP_MAX_HEIGHT, scrollView.height * MINIMAP_MAX_VIEW_SHARE) / bodyHeight);
|
|
33693
|
+
const minimap = scrollView.width > 0 && (view.width < width || view.height < bodyHeight) ? { scale: minimapScale, view } : void 0;
|
|
33694
|
+
const panTo = (event) => {
|
|
33695
|
+
const element = scrollRef.current;
|
|
33696
|
+
if (!element) return;
|
|
33697
|
+
const bounds = event.currentTarget.querySelector("svg")?.getBoundingClientRect();
|
|
33698
|
+
if (!bounds) return;
|
|
33699
|
+
element.scrollLeft = ((event.clientX - bounds.left) / minimapScale - view.width / 2) * zoom;
|
|
33700
|
+
element.scrollTop = ((event.clientY - bounds.top) / minimapScale - view.height / 2) * zoom;
|
|
33701
|
+
};
|
|
33702
|
+
const fitWidth = () => {
|
|
33703
|
+
const viewWidth = scrollRef.current?.clientWidth;
|
|
33704
|
+
if (viewWidth) zoomTo(viewWidth / width, 0, 0);
|
|
33705
|
+
};
|
|
33706
|
+
return (
|
|
33707
|
+
// The diagram scrolls in a box of its own, so the zoom controls stay put over it.
|
|
33708
|
+
// Its own stacking context: the header's and the widget's z-indexes order them within the
|
|
33709
|
+
// diagram only, never over the sidebar's resize handles.
|
|
33710
|
+
/* @__PURE__ */ jsxs138(Box22, { ref: areaRef, sx: { flex: 1, height: "100%", isolation: "isolate", minHeight: 0, position: "relative" }, children: [
|
|
33711
|
+
/* @__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: [
|
|
33712
|
+
drawing,
|
|
33713
|
+
/* @__PURE__ */ jsx151(Box22, { sx: { height: BOTTOM_ROOM / zoom } })
|
|
33714
|
+
] }) }),
|
|
33715
|
+
/* @__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: [
|
|
33716
|
+
minimap && // A thin bar with only a chevron: down folds the minimap away, up brings it back.
|
|
33717
|
+
/* @__PURE__ */ jsx151(
|
|
33718
|
+
ButtonBase2,
|
|
33719
|
+
{
|
|
33720
|
+
"aria-expanded": minimapOpen,
|
|
33721
|
+
"aria-label": minimapOpen ? "Hide the overview" : "Show the overview",
|
|
33722
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID,
|
|
33723
|
+
onClick: () => {
|
|
33724
|
+
setMinimapOpen(!minimapOpen);
|
|
33725
|
+
},
|
|
33726
|
+
sx: { "&:hover": { color: "text.primary" }, "borderBottom": 1, "borderColor": "divider", "color": "text.secondary", "height": 14, "width": "100%" },
|
|
33727
|
+
children: minimapOpen ? /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowUp, { sx: { fontSize: 16 } })
|
|
33728
|
+
}
|
|
33729
|
+
),
|
|
33730
|
+
minimap && /* @__PURE__ */ jsx151(Collapse, { in: minimapOpen, unmountOnExit: true, children: /* @__PURE__ */ jsx151(
|
|
33731
|
+
Box22,
|
|
33732
|
+
{
|
|
33733
|
+
"aria-label": "Minimap",
|
|
33734
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TEST_ID,
|
|
33735
|
+
onPointerDown: (event) => {
|
|
33736
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
33737
|
+
panTo(event);
|
|
33738
|
+
},
|
|
33739
|
+
onPointerMove: (event) => {
|
|
33740
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) panTo(event);
|
|
33741
|
+
},
|
|
33742
|
+
role: "navigation",
|
|
33743
|
+
sx: { backgroundColor: "action.hover", borderBottom: 1, borderColor: "divider", cursor: "pointer", display: "flex", justifyContent: "center", lineHeight: 0, p: 1, touchAction: "none" },
|
|
33744
|
+
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: [
|
|
33745
|
+
/* @__PURE__ */ jsx151("use", { href: `#${bodyId}` }),
|
|
33746
|
+
/* @__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 })
|
|
33747
|
+
] })
|
|
33748
|
+
}
|
|
33749
|
+
) }),
|
|
33750
|
+
/* @__PURE__ */ jsxs138(Box22, { sx: { alignItems: "center", display: "flex", justifyContent: "space-between", px: "2px" }, children: [
|
|
33751
|
+
/* @__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: () => {
|
|
33752
|
+
zoomTo(zoom / ZOOM_STEP);
|
|
33753
|
+
}, size: "small", children: /* @__PURE__ */ jsx151(ZoomOut, { fontSize: "small" }) }) }),
|
|
33754
|
+
/* @__PURE__ */ jsx151(Tooltip7, { title: "Reset zoom", children: /* @__PURE__ */ jsx151(ButtonBase2, { "data-testid": SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID, onClick: () => {
|
|
33755
|
+
zoomTo(1);
|
|
33756
|
+
}, sx: { borderRadius: 1, fontSize: 12, fontVariantNumeric: "tabular-nums", minWidth: 40, py: "2px" }, children: `${String(Math.round(zoom * 100))}%` }) }),
|
|
33757
|
+
/* @__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: () => {
|
|
33758
|
+
zoomTo(zoom * ZOOM_STEP);
|
|
33759
|
+
}, size: "small", children: /* @__PURE__ */ jsx151(ZoomIn, { fontSize: "small" }) }) }),
|
|
33760
|
+
/* @__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" }) }) })
|
|
33761
|
+
] })
|
|
33762
|
+
] }),
|
|
33763
|
+
hoverCard && hoveredMessage && /* @__PURE__ */ jsx151(ArrowHoverCard, { hover: { ...hover, message: hoveredMessage } })
|
|
33764
|
+
] })
|
|
33765
|
+
);
|
|
33766
|
+
};
|
|
33767
|
+
|
|
32973
33768
|
// src/components/trace-panel/trace-sidebar.tsx
|
|
32974
|
-
import { jsx as
|
|
33769
|
+
import { jsx as jsx152, jsxs as jsxs139 } from "react/jsx-runtime";
|
|
32975
33770
|
var DEFAULT_WIDTH_SHARE = 0.75;
|
|
32976
33771
|
var MAX_WIDTH_SHARE = 0.8;
|
|
32977
33772
|
var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
|
|
@@ -32992,22 +33787,16 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
32992
33787
|
const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
|
|
32993
33788
|
const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
|
|
32994
33789
|
const [storedView, setView] = useLocalStorage(VIEW_STORAGE_KEY, "map");
|
|
32995
|
-
const view = storedView === "waterfall"
|
|
32996
|
-
const sidebarRef =
|
|
32997
|
-
const traceViewRef =
|
|
33790
|
+
const view = storedView === "waterfall" || storedView === "sequence" ? storedView : "map";
|
|
33791
|
+
const sidebarRef = React127.useRef(null);
|
|
33792
|
+
const traceViewRef = React127.useRef(null);
|
|
32998
33793
|
const width = maximized ? 1 : storedWidth;
|
|
32999
|
-
const [
|
|
33000
|
-
|
|
33001
|
-
|
|
33002
|
-
|
|
33003
|
-
|
|
33004
|
-
|
|
33005
|
-
});
|
|
33006
|
-
observer.observe(parent);
|
|
33007
|
-
return () => {
|
|
33008
|
-
observer.disconnect();
|
|
33009
|
-
};
|
|
33010
|
-
}, []);
|
|
33794
|
+
const [requestedTab, setRequestedTab] = React127.useState();
|
|
33795
|
+
const selectFromSequence = React127.useCallback((spanId, view2) => {
|
|
33796
|
+
onSelectSpan(spanId);
|
|
33797
|
+
setRequestedTab({ view: view2 });
|
|
33798
|
+
}, [onSelectSpan]);
|
|
33799
|
+
const parentWidth = useContentWidth(sidebarRef, true);
|
|
33011
33800
|
const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
|
|
33012
33801
|
const resize = (share) => {
|
|
33013
33802
|
const snap = share > SNAP_WIDTH_SHARE;
|
|
@@ -33046,7 +33835,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33046
33835
|
event.preventDefault();
|
|
33047
33836
|
setStoredSplit(clampSplit(storedSplit + delta));
|
|
33048
33837
|
};
|
|
33049
|
-
const { root: root2, selectedSpan, stats } =
|
|
33838
|
+
const { root: root2, selectedSpan, stats } = React127.useMemo(() => {
|
|
33050
33839
|
const tree = buildTraceTree(spans);
|
|
33051
33840
|
const issues = spans.map((span) => getSpanIssues(span));
|
|
33052
33841
|
return {
|
|
@@ -33060,7 +33849,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33060
33849
|
};
|
|
33061
33850
|
}, [spans, selectedSpanId]);
|
|
33062
33851
|
const rootSpanId = root2?.span_id;
|
|
33063
|
-
|
|
33852
|
+
React127.useEffect(() => {
|
|
33064
33853
|
if (!onRequestRendered || rootSpanId === void 0) return;
|
|
33065
33854
|
let frame2 = requestAnimationFrame(() => {
|
|
33066
33855
|
frame2 = requestAnimationFrame(() => {
|
|
@@ -33071,8 +33860,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33071
33860
|
cancelAnimationFrame(frame2);
|
|
33072
33861
|
};
|
|
33073
33862
|
}, [onRequestRendered, rootSpanId, view]);
|
|
33074
|
-
return /* @__PURE__ */
|
|
33075
|
-
|
|
33863
|
+
return /* @__PURE__ */ jsxs139(
|
|
33864
|
+
Box23,
|
|
33076
33865
|
{
|
|
33077
33866
|
"data-testid": TRACE_SIDEBAR_TEST_ID,
|
|
33078
33867
|
ref: sidebarRef,
|
|
@@ -33094,8 +33883,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33094
33883
|
width: `${String(width * 100)}%`
|
|
33095
33884
|
},
|
|
33096
33885
|
children: [
|
|
33097
|
-
/* @__PURE__ */
|
|
33098
|
-
|
|
33886
|
+
/* @__PURE__ */ jsx152(
|
|
33887
|
+
Box23,
|
|
33099
33888
|
{
|
|
33100
33889
|
"aria-label": "Resize the sidebar",
|
|
33101
33890
|
"aria-orientation": "vertical",
|
|
@@ -33123,14 +33912,14 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33123
33912
|
tabIndex: 0
|
|
33124
33913
|
}
|
|
33125
33914
|
),
|
|
33126
|
-
/* @__PURE__ */
|
|
33127
|
-
root2 === void 0 ? /* @__PURE__ */
|
|
33915
|
+
/* @__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: [
|
|
33916
|
+
root2 === void 0 ? /* @__PURE__ */ jsx152(Box23, { sx: { flex: 1 } }) : /* @__PURE__ */ jsx152(
|
|
33128
33917
|
OperationIdentity,
|
|
33129
33918
|
{
|
|
33130
33919
|
arn: root2.arn,
|
|
33131
33920
|
density: "heading",
|
|
33132
33921
|
label: "Request",
|
|
33133
|
-
operation: /* @__PURE__ */
|
|
33922
|
+
operation: /* @__PURE__ */ jsx152(OperationName, { span: root2 }),
|
|
33134
33923
|
resourceName: root2.resource_name,
|
|
33135
33924
|
service: root2.service_name,
|
|
33136
33925
|
sx: { flex: 1 },
|
|
@@ -33144,7 +33933,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33144
33933
|
].join(" \xB7 ")
|
|
33145
33934
|
}
|
|
33146
33935
|
),
|
|
33147
|
-
/* @__PURE__ */
|
|
33936
|
+
/* @__PURE__ */ jsxs139(
|
|
33148
33937
|
ToggleButtonGroup3,
|
|
33149
33938
|
{
|
|
33150
33939
|
"aria-label": "Trace view",
|
|
@@ -33157,28 +33946,33 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33157
33946
|
size: "small",
|
|
33158
33947
|
value: view,
|
|
33159
33948
|
children: [
|
|
33160
|
-
/* @__PURE__ */
|
|
33161
|
-
/* @__PURE__ */
|
|
33949
|
+
/* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
|
|
33950
|
+
/* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" }),
|
|
33951
|
+
/* @__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
33952
|
]
|
|
33163
33953
|
}
|
|
33164
33954
|
),
|
|
33165
|
-
/* @__PURE__ */
|
|
33955
|
+
/* @__PURE__ */ jsx152(IconButton9, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
|
|
33166
33956
|
setMaximized(!maximized);
|
|
33167
|
-
}, size: "small", children: maximized ? /* @__PURE__ */
|
|
33168
|
-
/* @__PURE__ */
|
|
33957
|
+
}, size: "small", children: maximized ? /* @__PURE__ */ jsx152(CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ jsx152(OpenInFull, { fontSize: "small" }) }),
|
|
33958
|
+
/* @__PURE__ */ jsx152(IconButton9, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ jsx152(Close4, {}) })
|
|
33169
33959
|
] }),
|
|
33170
|
-
/* @__PURE__ */
|
|
33171
|
-
|
|
33172
|
-
{
|
|
33173
|
-
|
|
33174
|
-
|
|
33175
|
-
|
|
33176
|
-
|
|
33177
|
-
|
|
33178
|
-
|
|
33179
|
-
|
|
33180
|
-
|
|
33181
|
-
|
|
33960
|
+
/* @__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: [
|
|
33961
|
+
view === "waterfall" && /* @__PURE__ */ jsx152(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }),
|
|
33962
|
+
view === "sequence" && /* @__PURE__ */ jsx152(SequenceDiagram, { onSelectSpan: selectFromSequence, selectedSpanId, spans }),
|
|
33963
|
+
view === "map" && /* @__PURE__ */ jsx152(Box23, { sx: { height: "100%" }, children: /* @__PURE__ */ jsx152(ReactFlowProvider, { children: /* @__PURE__ */ jsx152(
|
|
33964
|
+
TraceGraph,
|
|
33965
|
+
{
|
|
33966
|
+
hideMiniMap: true,
|
|
33967
|
+
initialFocusEventId: selectedSpanId,
|
|
33968
|
+
onEventSelect: onSelectSpan,
|
|
33969
|
+
onRefresh: noop,
|
|
33970
|
+
spans: { data: spans, error: void 0, loading: false }
|
|
33971
|
+
}
|
|
33972
|
+
) }) })
|
|
33973
|
+
] }),
|
|
33974
|
+
/* @__PURE__ */ jsx152(Box23, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ jsx152(
|
|
33975
|
+
Box23,
|
|
33182
33976
|
{
|
|
33183
33977
|
"aria-label": "Resize the operation details",
|
|
33184
33978
|
"aria-orientation": "horizontal",
|
|
@@ -33206,7 +34000,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33206
34000
|
tabIndex: 0
|
|
33207
34001
|
}
|
|
33208
34002
|
) }),
|
|
33209
|
-
/* @__PURE__ */
|
|
34003
|
+
/* @__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
34004
|
]
|
|
33211
34005
|
}
|
|
33212
34006
|
);
|
|
@@ -33214,10 +34008,10 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33214
34008
|
|
|
33215
34009
|
// src/components/worker-error-message/worker-error-message.tsx
|
|
33216
34010
|
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
|
-
|
|
34011
|
+
import { Alert as Alert6, AlertTitle as AlertTitle2, Box as Box24, Button as Button7, Typography as Typography17 } from "@mui/material";
|
|
34012
|
+
import { jsx as jsx153, jsxs as jsxs140 } from "react/jsx-runtime";
|
|
34013
|
+
var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx153(
|
|
34014
|
+
Box24,
|
|
33221
34015
|
{
|
|
33222
34016
|
sx: {
|
|
33223
34017
|
alignItems: "center",
|
|
@@ -33227,17 +34021,17 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
|
|
|
33227
34021
|
justifyContent: "center",
|
|
33228
34022
|
p: 4
|
|
33229
34023
|
},
|
|
33230
|
-
children: /* @__PURE__ */
|
|
34024
|
+
children: /* @__PURE__ */ jsxs140(
|
|
33231
34025
|
Alert6,
|
|
33232
34026
|
{
|
|
33233
|
-
icon: /* @__PURE__ */
|
|
34027
|
+
icon: /* @__PURE__ */ jsx153(ErrorOutline2, { fontSize: "large" }),
|
|
33234
34028
|
severity: "error",
|
|
33235
34029
|
sx: { maxWidth: 600, width: "100%" },
|
|
33236
34030
|
children: [
|
|
33237
|
-
/* @__PURE__ */
|
|
33238
|
-
/* @__PURE__ */
|
|
33239
|
-
/* @__PURE__ */
|
|
33240
|
-
onRetry && /* @__PURE__ */
|
|
34031
|
+
/* @__PURE__ */ jsx153(AlertTitle2, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
|
|
34032
|
+
/* @__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." }),
|
|
34033
|
+
/* @__PURE__ */ jsx153(Typography17, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
|
|
34034
|
+
onRetry && /* @__PURE__ */ jsx153(Box24, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsx153(
|
|
33241
34035
|
Button7,
|
|
33242
34036
|
{
|
|
33243
34037
|
"aria-label": "Retry starting the spans filter worker",
|
|
@@ -33253,7 +34047,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
|
|
|
33253
34047
|
);
|
|
33254
34048
|
|
|
33255
34049
|
// src/hooks/use-filter-used-analytics.ts
|
|
33256
|
-
import { useEffect as
|
|
34050
|
+
import { useEffect as useEffect23, useRef as useRef19, useState as useState22 } from "react";
|
|
33257
34051
|
var FILTER_KEYS = {
|
|
33258
34052
|
consumer: "service",
|
|
33259
34053
|
producer: "producer",
|
|
@@ -33280,11 +34074,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
|
|
|
33280
34074
|
var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
|
|
33281
34075
|
const api = useAppInspectorApi();
|
|
33282
34076
|
const { deploymentContainer } = useAppInspector();
|
|
33283
|
-
const previousQueryRef =
|
|
33284
|
-
const pendingRef =
|
|
33285
|
-
const changeCountRef =
|
|
33286
|
-
const [settledChange, setSettledChange] =
|
|
33287
|
-
|
|
34077
|
+
const previousQueryRef = useRef19(query2);
|
|
34078
|
+
const pendingRef = useRef19();
|
|
34079
|
+
const changeCountRef = useRef19(0);
|
|
34080
|
+
const [settledChange, setSettledChange] = useState22(0);
|
|
34081
|
+
useEffect23(() => {
|
|
33288
34082
|
const previous = parseQuery(previousQueryRef.current);
|
|
33289
34083
|
const next = parseQuery(query2);
|
|
33290
34084
|
previousQueryRef.current = query2;
|
|
@@ -33307,7 +34101,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33307
34101
|
clearTimeout(timer);
|
|
33308
34102
|
};
|
|
33309
34103
|
}, [query2]);
|
|
33310
|
-
|
|
34104
|
+
useEffect23(() => {
|
|
33311
34105
|
const pending = pendingRef.current;
|
|
33312
34106
|
if (pending === void 0 || filteredCount === void 0) {
|
|
33313
34107
|
return;
|
|
@@ -33353,7 +34147,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33353
34147
|
};
|
|
33354
34148
|
|
|
33355
34149
|
// src/hooks/use-operation-open-analytics.ts
|
|
33356
|
-
import { useEffect as
|
|
34150
|
+
import { useEffect as useEffect24, useRef as useRef20 } from "react";
|
|
33357
34151
|
|
|
33358
34152
|
// src/utils/request-id.ts
|
|
33359
34153
|
var getRequestId = (spans) => {
|
|
@@ -33373,8 +34167,8 @@ var getRequestId = (spans) => {
|
|
|
33373
34167
|
var useOperationOpenAnalytics = ({ open, shown, spans }) => {
|
|
33374
34168
|
const api = useAppInspectorApi();
|
|
33375
34169
|
const { deploymentContainer } = useAppInspector();
|
|
33376
|
-
const shownKeyRef =
|
|
33377
|
-
|
|
34170
|
+
const shownKeyRef = useRef20();
|
|
34171
|
+
useEffect24(() => {
|
|
33378
34172
|
const shownKey = open && shown ? `${shown.span.span_id}
|
|
33379
34173
|
${shown.view}` : void 0;
|
|
33380
34174
|
const previousKey = shownKeyRef.current;
|
|
@@ -33400,12 +34194,12 @@ ${shown.view}` : void 0;
|
|
|
33400
34194
|
};
|
|
33401
34195
|
|
|
33402
34196
|
// src/hooks/use-request-open-analytics.ts
|
|
33403
|
-
import { useEffect as
|
|
34197
|
+
import { useEffect as useEffect25, useRef as useRef21 } from "react";
|
|
33404
34198
|
var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
33405
34199
|
const api = useAppInspectorApi();
|
|
33406
34200
|
const { deploymentContainer } = useAppInspector();
|
|
33407
|
-
const firedForRef =
|
|
33408
|
-
|
|
34201
|
+
const firedForRef = useRef21();
|
|
34202
|
+
useEffect25(() => {
|
|
33409
34203
|
if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
|
|
33410
34204
|
return;
|
|
33411
34205
|
}
|
|
@@ -33436,7 +34230,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
|
33436
34230
|
};
|
|
33437
34231
|
|
|
33438
34232
|
// src/hooks/use-spans.ts
|
|
33439
|
-
import { useCallback as
|
|
34233
|
+
import { useCallback as useCallback13, useEffect as useEffect28, useRef as useRef24, useState as useState25 } from "react";
|
|
33440
34234
|
import { unstable_batchedUpdates as batchedUpdates } from "react-dom";
|
|
33441
34235
|
|
|
33442
34236
|
// src/utils/pagination-buffer.ts
|
|
@@ -33691,7 +34485,7 @@ var toSpanFilterProjection = (span) => ({
|
|
|
33691
34485
|
});
|
|
33692
34486
|
|
|
33693
34487
|
// src/hooks/use-spans-compute.ts
|
|
33694
|
-
import { useCallback as
|
|
34488
|
+
import { useCallback as useCallback11, useEffect as useEffect26, useRef as useRef22, useState as useState23 } from "react";
|
|
33695
34489
|
|
|
33696
34490
|
// inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
|
|
33697
34491
|
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 +34510,15 @@ var EMPTY_RESULT = {
|
|
|
33716
34510
|
};
|
|
33717
34511
|
var useSpansCompute = () => {
|
|
33718
34512
|
const { spansWorkerUrl } = useAppInspector();
|
|
33719
|
-
const [computeState, setComputeState] =
|
|
34513
|
+
const [computeState, setComputeState] = useState23({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
|
|
33720
34514
|
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
|
-
|
|
34515
|
+
const [workerError, setWorkerError] = useState23();
|
|
34516
|
+
const [retryCount, setRetryCount] = useState23(0);
|
|
34517
|
+
const workerRef = useRef22();
|
|
34518
|
+
const seqRef = useRef22(0);
|
|
34519
|
+
const lastAppliedRef = useRef22(0);
|
|
34520
|
+
const firstPageSeqRef = useRef22();
|
|
34521
|
+
useEffect26(() => {
|
|
33728
34522
|
try {
|
|
33729
34523
|
const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
|
|
33730
34524
|
worker.addEventListener("message", (event) => {
|
|
@@ -33751,26 +34545,26 @@ var useSpansCompute = () => {
|
|
|
33751
34545
|
return;
|
|
33752
34546
|
}
|
|
33753
34547
|
}, [retryCount, spansWorkerUrl]);
|
|
33754
|
-
const retryWorker =
|
|
34548
|
+
const retryWorker = useCallback11(() => {
|
|
33755
34549
|
setWorkerError(void 0);
|
|
33756
34550
|
setRetryCount((count2) => count2 + 1);
|
|
33757
34551
|
}, []);
|
|
33758
|
-
const addPage =
|
|
34552
|
+
const addPage = useCallback11((direction, projections) => {
|
|
33759
34553
|
const seq = ++seqRef.current;
|
|
33760
34554
|
firstPageSeqRef.current ??= seq;
|
|
33761
34555
|
workerRef.current?.postMessage({ direction, op: "addPage", projections, seq });
|
|
33762
34556
|
}, []);
|
|
33763
|
-
const setQuery =
|
|
34557
|
+
const setQuery = useCallback11((query2, textMatches) => {
|
|
33764
34558
|
workerRef.current?.postMessage({ op: "setQuery", query: query2, seq: ++seqRef.current, textMatches });
|
|
33765
34559
|
}, []);
|
|
33766
|
-
const clear =
|
|
34560
|
+
const clear = useCallback11(() => {
|
|
33767
34561
|
workerRef.current?.postMessage({ op: "clear", seq: ++seqRef.current });
|
|
33768
34562
|
}, []);
|
|
33769
34563
|
return { addPage, clear, loaded, result, resultVersion, retryWorker, setQuery, workerError };
|
|
33770
34564
|
};
|
|
33771
34565
|
|
|
33772
34566
|
// src/hooks/use-spans-ws.tsx
|
|
33773
|
-
import { useCallback as
|
|
34567
|
+
import { useCallback as useCallback12, useEffect as useEffect27, useRef as useRef23, useState as useState24 } from "react";
|
|
33774
34568
|
var wsLogger = createScopedLogger("WS");
|
|
33775
34569
|
var isLegacySpanFields = (value) => {
|
|
33776
34570
|
return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
|
|
@@ -33802,22 +34596,22 @@ var parseSpansWebSocketMessage = (raw) => {
|
|
|
33802
34596
|
};
|
|
33803
34597
|
function useSpansWebSocket(options) {
|
|
33804
34598
|
const { enabled, onClose, onMessage, onOpen } = options;
|
|
33805
|
-
const onMessageRef =
|
|
33806
|
-
const onOpenRef =
|
|
33807
|
-
const onCloseRef =
|
|
33808
|
-
|
|
34599
|
+
const onMessageRef = useRef23(onMessage);
|
|
34600
|
+
const onOpenRef = useRef23(onOpen);
|
|
34601
|
+
const onCloseRef = useRef23(onClose);
|
|
34602
|
+
useEffect27(() => {
|
|
33809
34603
|
onMessageRef.current = onMessage;
|
|
33810
34604
|
}, [onMessage]);
|
|
33811
|
-
|
|
34605
|
+
useEffect27(() => {
|
|
33812
34606
|
onOpenRef.current = onOpen;
|
|
33813
34607
|
}, [onOpen]);
|
|
33814
|
-
|
|
34608
|
+
useEffect27(() => {
|
|
33815
34609
|
onCloseRef.current = onClose;
|
|
33816
34610
|
}, [onClose]);
|
|
33817
|
-
const [connected, setConnected] =
|
|
33818
|
-
const wsRef =
|
|
34611
|
+
const [connected, setConnected] = useState24(false);
|
|
34612
|
+
const wsRef = useRef23(void 0);
|
|
33819
34613
|
const { localstackEndpoint } = useAppInspector();
|
|
33820
|
-
const connect =
|
|
34614
|
+
const connect = useCallback12(() => {
|
|
33821
34615
|
if (wsRef.current !== void 0) return;
|
|
33822
34616
|
const url = new URL(getAppInspectorApiUrl(localstackEndpoint, API_ENDPOINTS.WEBSOCKET_SPANS));
|
|
33823
34617
|
url.protocol = globalThis.location.protocol === "https:" ? "wss" : "ws";
|
|
@@ -33858,7 +34652,7 @@ function useSpansWebSocket(options) {
|
|
|
33858
34652
|
}
|
|
33859
34653
|
});
|
|
33860
34654
|
}, [localstackEndpoint]);
|
|
33861
|
-
|
|
34655
|
+
useEffect27(() => {
|
|
33862
34656
|
if (!enabled) {
|
|
33863
34657
|
if (wsRef.current !== void 0) {
|
|
33864
34658
|
wsRef.current.close();
|
|
@@ -33901,42 +34695,42 @@ var useSpans = () => {
|
|
|
33901
34695
|
const api = useAppInspectorApi();
|
|
33902
34696
|
const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
|
|
33903
34697
|
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 =
|
|
34698
|
+
const spanMapRef = useRef24(/* @__PURE__ */ new Map());
|
|
34699
|
+
const newSpanIdsRef = useRef24(/* @__PURE__ */ new Set());
|
|
34700
|
+
const caughtUpRef = useRef24(false);
|
|
34701
|
+
const [fetchError, setFetchError] = useState25();
|
|
34702
|
+
const [fetchingForward, setFetchingForward] = useState25(false);
|
|
34703
|
+
const [fetchingBackward, setFetchingBackward] = useState25(false);
|
|
34704
|
+
const [query2, setQueryState] = useState25("");
|
|
34705
|
+
const [searching, setSearching] = useState25(false);
|
|
34706
|
+
const paginationBufferRef = useRef24();
|
|
34707
|
+
const [totalCount, setTotalCount] = useState25();
|
|
34708
|
+
const [licenseLimit, setLicenseLimit] = useState25();
|
|
34709
|
+
const [systemLimit, setSystemLimit] = useState25();
|
|
34710
|
+
const [errorCount, setErrorCount] = useState25();
|
|
34711
|
+
const [warningCount, setWarningCount] = useState25();
|
|
34712
|
+
const [hasMoreBackward, setHasMoreBackward] = useState25();
|
|
34713
|
+
const [hasMoreForward, setHasMoreForward] = useState25();
|
|
34714
|
+
const fetchForward = useCallback13(() => {
|
|
33921
34715
|
void paginationBufferRef.current?.fetchForward();
|
|
33922
34716
|
}, []);
|
|
33923
|
-
const fetchBackward =
|
|
34717
|
+
const fetchBackward = useCallback13(() => {
|
|
33924
34718
|
void paginationBufferRef.current?.fetchBackward();
|
|
33925
34719
|
}, []);
|
|
33926
|
-
const resetCorpus =
|
|
34720
|
+
const resetCorpus = useCallback13(() => {
|
|
33927
34721
|
spanMapRef.current.clear();
|
|
33928
34722
|
newSpanIdsRef.current.clear();
|
|
33929
34723
|
caughtUpRef.current = false;
|
|
33930
34724
|
clearCompute();
|
|
33931
34725
|
}, [clearCompute]);
|
|
33932
|
-
const [epoch, setEpoch] =
|
|
33933
|
-
const onEpochSeen =
|
|
34726
|
+
const [epoch, setEpoch] = useState25();
|
|
34727
|
+
const onEpochSeen = useCallback13((observedEpoch) => {
|
|
33934
34728
|
if (observedEpoch === null || observedEpoch === void 0) {
|
|
33935
34729
|
return;
|
|
33936
34730
|
}
|
|
33937
34731
|
setEpoch(observedEpoch);
|
|
33938
34732
|
}, []);
|
|
33939
|
-
const clearCache =
|
|
34733
|
+
const clearCache = useCallback13(() => {
|
|
33940
34734
|
paginationBufferRef.current?.clear();
|
|
33941
34735
|
resetCorpus();
|
|
33942
34736
|
setTotalCount(void 0);
|
|
@@ -33944,9 +34738,9 @@ var useSpans = () => {
|
|
|
33944
34738
|
setWarningCount(void 0);
|
|
33945
34739
|
void paginationBufferRef.current?.fetchForward();
|
|
33946
34740
|
}, [resetCorpus]);
|
|
33947
|
-
const hasFetchedWithoutEpochRef =
|
|
33948
|
-
const previousEpochRef =
|
|
33949
|
-
|
|
34741
|
+
const hasFetchedWithoutEpochRef = useRef24(false);
|
|
34742
|
+
const previousEpochRef = useRef24();
|
|
34743
|
+
useEffect28(() => {
|
|
33950
34744
|
if (epoch === void 0) {
|
|
33951
34745
|
return;
|
|
33952
34746
|
}
|
|
@@ -33959,11 +34753,11 @@ var useSpans = () => {
|
|
|
33959
34753
|
}, [epoch, clearCache]);
|
|
33960
34754
|
const searchSupported = emulatorSupportsSearch(status?.localstackVersion);
|
|
33961
34755
|
const freeText = parseQuery(query2).words.join(" ");
|
|
33962
|
-
const setQuery =
|
|
34756
|
+
const setQuery = useCallback13((next) => {
|
|
33963
34757
|
setQueryState(next);
|
|
33964
34758
|
setComputeQuery(next);
|
|
33965
34759
|
}, [setComputeQuery]);
|
|
33966
|
-
|
|
34760
|
+
useEffect28(() => {
|
|
33967
34761
|
if (!searchSupported || freeText === "") {
|
|
33968
34762
|
return;
|
|
33969
34763
|
}
|
|
@@ -33984,7 +34778,7 @@ var useSpans = () => {
|
|
|
33984
34778
|
setSearching(false);
|
|
33985
34779
|
};
|
|
33986
34780
|
}, [api, freeText, query2, searchSupported, setComputeQuery]);
|
|
33987
|
-
|
|
34781
|
+
useEffect28(() => {
|
|
33988
34782
|
const buffer = createPaginationBuffer({
|
|
33989
34783
|
async fetchPage(token, signal) {
|
|
33990
34784
|
const requestPage = async (paginationToken) => {
|
|
@@ -34055,8 +34849,8 @@ var useSpans = () => {
|
|
|
34055
34849
|
paginationBufferRef.current = buffer;
|
|
34056
34850
|
void buffer.fetchForward();
|
|
34057
34851
|
}, [api, addPage, onEpochSeen, resetCorpus]);
|
|
34058
|
-
const [clearingSpans, setClearingSpans] =
|
|
34059
|
-
const clearSpans =
|
|
34852
|
+
const [clearingSpans, setClearingSpans] = useState25(false);
|
|
34853
|
+
const clearSpans = useCallback13(async () => {
|
|
34060
34854
|
if (clearingSpans) {
|
|
34061
34855
|
return;
|
|
34062
34856
|
}
|
|
@@ -34074,17 +34868,17 @@ var useSpans = () => {
|
|
|
34074
34868
|
setClearingSpans(false);
|
|
34075
34869
|
}
|
|
34076
34870
|
}, [clearingSpans, api, resetCorpus]);
|
|
34077
|
-
|
|
34871
|
+
useEffect28(() => {
|
|
34078
34872
|
if (hasMoreForward === true && !fetchingForward) {
|
|
34079
34873
|
void paginationBufferRef.current?.fetchForward();
|
|
34080
34874
|
}
|
|
34081
34875
|
}, [hasMoreForward, fetchingForward]);
|
|
34082
|
-
|
|
34876
|
+
useEffect28(() => {
|
|
34083
34877
|
if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
|
|
34084
34878
|
void paginationBufferRef.current?.fetchBackward();
|
|
34085
34879
|
}
|
|
34086
34880
|
}, [hasMoreBackward, fetchingBackward, fetchingForward]);
|
|
34087
|
-
const [previousStatusEpoch, setPreviousStatusEpoch] =
|
|
34881
|
+
const [previousStatusEpoch, setPreviousStatusEpoch] = useState25();
|
|
34088
34882
|
if (status !== void 0 && status.epoch !== previousStatusEpoch) {
|
|
34089
34883
|
setPreviousStatusEpoch(status.epoch);
|
|
34090
34884
|
onEpochSeen(status.epoch);
|
|
@@ -34109,10 +34903,10 @@ var useSpans = () => {
|
|
|
34109
34903
|
fetchForward();
|
|
34110
34904
|
}
|
|
34111
34905
|
});
|
|
34112
|
-
const clearFetchError =
|
|
34906
|
+
const clearFetchError = useCallback13(() => {
|
|
34113
34907
|
setFetchError(void 0);
|
|
34114
34908
|
}, []);
|
|
34115
|
-
const getSpan =
|
|
34909
|
+
const getSpan = useCallback13((spanId) => spanMapRef.current.get(spanId), []);
|
|
34116
34910
|
const newSpanIds = newSpanIdsRef.current;
|
|
34117
34911
|
return {
|
|
34118
34912
|
clearFetchError,
|
|
@@ -34144,7 +34938,8 @@ var useSpans = () => {
|
|
|
34144
34938
|
};
|
|
34145
34939
|
|
|
34146
34940
|
// src/pages/spans-list-page.tsx
|
|
34147
|
-
import { jsx as
|
|
34941
|
+
import { jsx as jsx154, jsxs as jsxs141 } from "react/jsx-runtime";
|
|
34942
|
+
var ANALYTICS_REQUEST_VIEWS = { map: "flow_graph", sequence: "sequence_graph", waterfall: "operations" };
|
|
34148
34943
|
var SpansListPage = () => {
|
|
34149
34944
|
const api = useAppInspectorApi();
|
|
34150
34945
|
const {
|
|
@@ -34177,49 +34972,49 @@ var SpansListPage = () => {
|
|
|
34177
34972
|
resultVersion,
|
|
34178
34973
|
searching
|
|
34179
34974
|
});
|
|
34180
|
-
const clearSpansSync =
|
|
34975
|
+
const clearSpansSync = useCallback14(() => {
|
|
34181
34976
|
void clearSpans();
|
|
34182
34977
|
}, [clearSpans]);
|
|
34183
34978
|
const localstackVersion = status?.localstackVersion ?? (statusError instanceof AppInspectorNotFoundError ? statusError.localstackVersion : void 0);
|
|
34184
34979
|
const versionCompatibility = checkEmulatorVersion(localstackVersion);
|
|
34185
|
-
const [bannerDismissed, setBannerDismissed] =
|
|
34980
|
+
const [bannerDismissed, setBannerDismissed] = useState26(false);
|
|
34186
34981
|
const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
|
|
34187
|
-
const [selectedSpanId, setSelectedSpanId] =
|
|
34188
|
-
const getTreeSpans =
|
|
34189
|
-
const latestRef =
|
|
34190
|
-
|
|
34982
|
+
const [selectedSpanId, setSelectedSpanId] = useState26();
|
|
34983
|
+
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]);
|
|
34984
|
+
const latestRef = useRef25({ compute, getTreeSpans });
|
|
34985
|
+
useEffect29(() => {
|
|
34191
34986
|
latestRef.current = { compute, getTreeSpans };
|
|
34192
34987
|
}, [compute, getTreeSpans]);
|
|
34193
|
-
const openedAtRef =
|
|
34194
|
-
const navigateToSpan =
|
|
34988
|
+
const openedAtRef = useRef25();
|
|
34989
|
+
const navigateToSpan = useCallback14((span) => {
|
|
34195
34990
|
openedAtRef.current = performance.now();
|
|
34196
34991
|
const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
|
|
34197
34992
|
const rootSpanId2 = rows[span.span_id]?.rootSpanId;
|
|
34198
34993
|
const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
|
|
34199
34994
|
setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
|
|
34200
34995
|
}, []);
|
|
34201
|
-
const [shownOperation, setShownOperation] =
|
|
34202
|
-
const closeSidebar =
|
|
34996
|
+
const [shownOperation, setShownOperation] = useState26();
|
|
34997
|
+
const closeSidebar = useCallback14(() => {
|
|
34203
34998
|
setSelectedSpanId(void 0);
|
|
34204
34999
|
setShownOperation(void 0);
|
|
34205
35000
|
}, []);
|
|
34206
35001
|
const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
|
|
34207
|
-
const treeSpans =
|
|
34208
|
-
const spanMatches =
|
|
35002
|
+
const treeSpans = useMemo14(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
|
|
35003
|
+
const spanMatches = useMemo14(
|
|
34209
35004
|
() => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
|
|
34210
35005
|
[compute]
|
|
34211
35006
|
);
|
|
34212
|
-
const treeSpansRef =
|
|
34213
|
-
|
|
35007
|
+
const treeSpansRef = useRef25(treeSpans);
|
|
35008
|
+
useEffect29(() => {
|
|
34214
35009
|
treeSpansRef.current = treeSpans;
|
|
34215
35010
|
}, [treeSpans]);
|
|
34216
|
-
const [renderedRequest, setRenderedRequest] =
|
|
34217
|
-
const handleRequestRendered =
|
|
35011
|
+
const [renderedRequest, setRenderedRequest] = useState26();
|
|
35012
|
+
const handleRequestRendered = useCallback14((view) => {
|
|
34218
35013
|
const openedAt = openedAtRef.current;
|
|
34219
35014
|
if (openedAt === void 0) return;
|
|
34220
|
-
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: view
|
|
35015
|
+
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: ANALYTICS_REQUEST_VIEWS[view] });
|
|
34221
35016
|
}, []);
|
|
34222
|
-
const handleViewChange =
|
|
35017
|
+
const handleViewChange = useCallback14(() => {
|
|
34223
35018
|
openedAtRef.current = performance.now();
|
|
34224
35019
|
}, []);
|
|
34225
35020
|
useRequestOpenAnalytics({
|
|
@@ -34228,28 +35023,28 @@ var SpansListPage = () => {
|
|
|
34228
35023
|
view: renderedRequest?.view ?? "operations"
|
|
34229
35024
|
});
|
|
34230
35025
|
const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
|
|
34231
|
-
const handleOperationShown =
|
|
35026
|
+
const handleOperationShown = useCallback14((spanId, view) => {
|
|
34232
35027
|
setShownOperation({ spanId, view });
|
|
34233
35028
|
}, []);
|
|
34234
|
-
const shown =
|
|
35029
|
+
const shown = useMemo14(() => {
|
|
34235
35030
|
if (shownOperation === void 0) return;
|
|
34236
35031
|
const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
|
|
34237
35032
|
return span && { span, view: shownOperation.view };
|
|
34238
35033
|
}, [shownOperation, treeSpans]);
|
|
34239
35034
|
useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
|
|
34240
|
-
const handleRetry =
|
|
35035
|
+
const handleRetry = useCallback14(() => {
|
|
34241
35036
|
checkStatus();
|
|
34242
35037
|
fetchForward();
|
|
34243
35038
|
}, [checkStatus, fetchForward]);
|
|
34244
|
-
const handleEnable =
|
|
35039
|
+
const handleEnable = useCallback14(async () => {
|
|
34245
35040
|
await api.setStatus({ status: "ENABLED" });
|
|
34246
35041
|
clearFetchError();
|
|
34247
35042
|
checkStatus();
|
|
34248
35043
|
}, [api, checkStatus, clearFetchError]);
|
|
34249
|
-
const isDelayedRefetchRef =
|
|
34250
|
-
const delayedRefetchTimerRef =
|
|
34251
|
-
const prevFetchingForwardRef =
|
|
34252
|
-
|
|
35044
|
+
const isDelayedRefetchRef = useRef25(false);
|
|
35045
|
+
const delayedRefetchTimerRef = useRef25();
|
|
35046
|
+
const prevFetchingForwardRef = useRef25(false);
|
|
35047
|
+
useEffect29(() => {
|
|
34253
35048
|
const wasFetching = prevFetchingForwardRef.current;
|
|
34254
35049
|
prevFetchingForwardRef.current = fetchingForward;
|
|
34255
35050
|
if (wasFetching && !fetchingForward) {
|
|
@@ -34270,10 +35065,10 @@ var SpansListPage = () => {
|
|
|
34270
35065
|
switch (phase) {
|
|
34271
35066
|
case "CHECKING_STATUS":
|
|
34272
35067
|
case "CONNECTING_WS": {
|
|
34273
|
-
return /* @__PURE__ */
|
|
35068
|
+
return /* @__PURE__ */ jsx154(StatusMessage, { phase });
|
|
34274
35069
|
}
|
|
34275
35070
|
case "DISABLED": {
|
|
34276
|
-
return /* @__PURE__ */
|
|
35071
|
+
return /* @__PURE__ */ jsx154(
|
|
34277
35072
|
StatusMessage,
|
|
34278
35073
|
{
|
|
34279
35074
|
onEnable: handleEnable,
|
|
@@ -34282,7 +35077,7 @@ var SpansListPage = () => {
|
|
|
34282
35077
|
);
|
|
34283
35078
|
}
|
|
34284
35079
|
case "INCOMPATIBLE": {
|
|
34285
|
-
return /* @__PURE__ */
|
|
35080
|
+
return /* @__PURE__ */ jsx154(
|
|
34286
35081
|
StatusMessage,
|
|
34287
35082
|
{
|
|
34288
35083
|
localstackVersion,
|
|
@@ -34293,12 +35088,12 @@ var SpansListPage = () => {
|
|
|
34293
35088
|
}
|
|
34294
35089
|
case "LIVE": {
|
|
34295
35090
|
if (workerError) {
|
|
34296
|
-
return /* @__PURE__ */
|
|
35091
|
+
return /* @__PURE__ */ jsx154(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
|
|
34297
35092
|
}
|
|
34298
35093
|
break;
|
|
34299
35094
|
}
|
|
34300
35095
|
case "UNREACHABLE": {
|
|
34301
|
-
return /* @__PURE__ */
|
|
35096
|
+
return /* @__PURE__ */ jsx154(
|
|
34302
35097
|
StatusMessage,
|
|
34303
35098
|
{
|
|
34304
35099
|
onRetry: handleRetry,
|
|
@@ -34307,9 +35102,9 @@ var SpansListPage = () => {
|
|
|
34307
35102
|
);
|
|
34308
35103
|
}
|
|
34309
35104
|
}
|
|
34310
|
-
return /* @__PURE__ */
|
|
34311
|
-
/* @__PURE__ */
|
|
34312
|
-
|
|
35105
|
+
return /* @__PURE__ */ jsxs141(Paper3, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
|
|
35106
|
+
/* @__PURE__ */ jsxs141(
|
|
35107
|
+
Box25,
|
|
34313
35108
|
{
|
|
34314
35109
|
"data-testid": SPANS_LIST_PAGE_TEST_ID,
|
|
34315
35110
|
sx: {
|
|
@@ -34322,7 +35117,7 @@ var SpansListPage = () => {
|
|
|
34322
35117
|
overflow: "hidden"
|
|
34323
35118
|
},
|
|
34324
35119
|
children: [
|
|
34325
|
-
/* @__PURE__ */
|
|
35120
|
+
/* @__PURE__ */ jsx154(
|
|
34326
35121
|
EmulatorVersionBanner,
|
|
34327
35122
|
{
|
|
34328
35123
|
compatibility: bannerDismissed && versionCompatibility === "warning" ? "ok" : versionCompatibility,
|
|
@@ -34332,7 +35127,7 @@ var SpansListPage = () => {
|
|
|
34332
35127
|
} : void 0
|
|
34333
35128
|
}
|
|
34334
35129
|
),
|
|
34335
|
-
/* @__PURE__ */
|
|
35130
|
+
/* @__PURE__ */ jsx154(
|
|
34336
35131
|
SpansList,
|
|
34337
35132
|
{
|
|
34338
35133
|
clearingSpans,
|
|
@@ -34359,7 +35154,7 @@ var SpansListPage = () => {
|
|
|
34359
35154
|
]
|
|
34360
35155
|
}
|
|
34361
35156
|
),
|
|
34362
|
-
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */
|
|
35157
|
+
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ jsx154(
|
|
34363
35158
|
TraceSidebar,
|
|
34364
35159
|
{
|
|
34365
35160
|
onClose: closeSidebar,
|