@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.cjs
CHANGED
|
@@ -2425,8 +2425,8 @@ __export(index_exports, {
|
|
|
2425
2425
|
module.exports = __toCommonJS(index_exports);
|
|
2426
2426
|
|
|
2427
2427
|
// src/pages/spans-list-page.tsx
|
|
2428
|
-
var
|
|
2429
|
-
var
|
|
2428
|
+
var import_material30 = require("@mui/material");
|
|
2429
|
+
var import_react71 = require("react");
|
|
2430
2430
|
|
|
2431
2431
|
// src/api/errors.ts
|
|
2432
2432
|
var AppInspectorDisabledError = class extends Error {
|
|
@@ -2552,6 +2552,21 @@ var WATERFALL_AXIS_LABEL_TEST_ID = "waterfall-axis-label";
|
|
|
2552
2552
|
var WATERFALL_TREE_VIEW_BUTTON_TEST_ID = "waterfall-tree-view-button";
|
|
2553
2553
|
var WATERFALL_LIST_VIEW_BUTTON_TEST_ID = "waterfall-list-view-button";
|
|
2554
2554
|
var WATERFALL_ROW_OFFSET_TEST_ID = "waterfall-row-offset";
|
|
2555
|
+
var TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID = "trace-sidebar-sequence-button";
|
|
2556
|
+
var SEQUENCE_DIAGRAM_TEST_ID = "sequence-diagram";
|
|
2557
|
+
var SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID = "sequence-diagram-participant";
|
|
2558
|
+
var SEQUENCE_DIAGRAM_MESSAGE_TEST_ID = "sequence-diagram-message";
|
|
2559
|
+
var SEQUENCE_DIAGRAM_RETURN_TEST_ID = "sequence-diagram-return";
|
|
2560
|
+
var SEQUENCE_DIAGRAM_ARROW_TEST_ID = "sequence-diagram-arrow";
|
|
2561
|
+
var SEQUENCE_DIAGRAM_SEGMENT_TEST_ID = "sequence-diagram-segment";
|
|
2562
|
+
var SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID = "sequence-diagram-hover-card";
|
|
2563
|
+
var SEQUENCE_DIAGRAM_TOGGLE_TEST_ID = "sequence-diagram-toggle";
|
|
2564
|
+
var SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID = "sequence-diagram-zoom-in-button";
|
|
2565
|
+
var SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID = "sequence-diagram-zoom-out-button";
|
|
2566
|
+
var SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID = "sequence-diagram-zoom-reset-button";
|
|
2567
|
+
var SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID = "sequence-diagram-zoom-fit-button";
|
|
2568
|
+
var SEQUENCE_DIAGRAM_MINIMAP_TEST_ID = "sequence-diagram-minimap";
|
|
2569
|
+
var SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID = "sequence-diagram-minimap-toggle";
|
|
2555
2570
|
|
|
2556
2571
|
// src/utils/emulator-version.ts
|
|
2557
2572
|
var import_semver = __toESM(require_semver2(), 1);
|
|
@@ -7157,12 +7172,12 @@ var isColorString = (type, testProp) => (v) => {
|
|
|
7157
7172
|
var splitColor = (aName, bName, cName) => (v) => {
|
|
7158
7173
|
if (!isString(v))
|
|
7159
7174
|
return v;
|
|
7160
|
-
const [a3, b3, c3,
|
|
7175
|
+
const [a3, b3, c3, alpha9] = v.match(floatRegex);
|
|
7161
7176
|
return {
|
|
7162
7177
|
[aName]: parseFloat(a3),
|
|
7163
7178
|
[bName]: parseFloat(b3),
|
|
7164
7179
|
[cName]: parseFloat(c3),
|
|
7165
|
-
alpha:
|
|
7180
|
+
alpha: alpha9 !== void 0 ? parseFloat(alpha9) : 1
|
|
7166
7181
|
};
|
|
7167
7182
|
};
|
|
7168
7183
|
|
|
@@ -8276,7 +8291,7 @@ function hueToRgb(p, q, t) {
|
|
|
8276
8291
|
return p + (q - p) * (2 / 3 - t) * 6;
|
|
8277
8292
|
return p;
|
|
8278
8293
|
}
|
|
8279
|
-
function hslaToRgba({ hue, saturation, lightness, alpha:
|
|
8294
|
+
function hslaToRgba({ hue, saturation, lightness, alpha: alpha9 }) {
|
|
8280
8295
|
hue /= 360;
|
|
8281
8296
|
saturation /= 100;
|
|
8282
8297
|
lightness /= 100;
|
|
@@ -8296,7 +8311,7 @@ function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
|
|
|
8296
8311
|
red: Math.round(red * 255),
|
|
8297
8312
|
green: Math.round(green * 255),
|
|
8298
8313
|
blue: Math.round(blue * 255),
|
|
8299
|
-
alpha:
|
|
8314
|
+
alpha: alpha9
|
|
8300
8315
|
};
|
|
8301
8316
|
}
|
|
8302
8317
|
|
|
@@ -13147,10 +13162,10 @@ var getOperationLabel = (span) => {
|
|
|
13147
13162
|
|
|
13148
13163
|
// src/components/operation-name.tsx
|
|
13149
13164
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
13150
|
-
var OperationName = ({ span }) => {
|
|
13165
|
+
var OperationName = ({ span, tooltip = true }) => {
|
|
13151
13166
|
const label = getOperationLabel(span);
|
|
13152
|
-
if (label === span.operation_name) {
|
|
13153
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: label, children: label });
|
|
13167
|
+
if (label === span.operation_name || !tooltip) {
|
|
13168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: tooltip ? label : void 0, children: label });
|
|
13154
13169
|
}
|
|
13155
13170
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
13156
13171
|
import_material2.Tooltip,
|
|
@@ -16962,10 +16977,10 @@ var getTraceBounds = (spans) => {
|
|
|
16962
16977
|
};
|
|
16963
16978
|
|
|
16964
16979
|
// src/components/trace-panel/trace-sidebar.tsx
|
|
16965
|
-
var
|
|
16966
|
-
var
|
|
16967
|
-
var
|
|
16968
|
-
var
|
|
16980
|
+
var import_icons_material16 = require("@mui/icons-material");
|
|
16981
|
+
var import_material28 = require("@mui/material");
|
|
16982
|
+
var import_react64 = require("@xyflow/react");
|
|
16983
|
+
var React127 = __toESM(require("react"), 1);
|
|
16969
16984
|
|
|
16970
16985
|
// src/components/event-details/event-details.tsx
|
|
16971
16986
|
var import_icons_material11 = require("@mui/icons-material");
|
|
@@ -16974,7 +16989,7 @@ var import_react53 = require("react");
|
|
|
16974
16989
|
|
|
16975
16990
|
// src/dev-settings.tsx
|
|
16976
16991
|
var React122 = __toESM(require("react"), 1);
|
|
16977
|
-
var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", succeededIconColor: "green", waterfallLayout: "tree" };
|
|
16992
|
+
var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", sequenceBlocks: "detached", sequenceClickTargets: "arrows-and-segments", sequenceHoverCard: "on", succeededIconColor: "green", waterfallLayout: "tree" };
|
|
16978
16993
|
var DevSettingsContext = React122.createContext(DEFAULT_DEV_SETTINGS);
|
|
16979
16994
|
var useDevSettings = () => React122.useContext(DevSettingsContext);
|
|
16980
16995
|
|
|
@@ -31771,14 +31786,19 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
|
|
|
31771
31786
|
] })
|
|
31772
31787
|
] });
|
|
31773
31788
|
var EmptyTab = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { color: "text.secondary", variant: "body2", children });
|
|
31774
|
-
var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
31789
|
+
var EventDetails = ({ onClose, onOperationShown, requestedTab, selectedEvent }) => {
|
|
31775
31790
|
const eventGroups = (0, import_react53.useMemo)(
|
|
31776
31791
|
() => getEventGroupsByType(selectedEvent?.events ?? []),
|
|
31777
31792
|
[selectedEvent?.events]
|
|
31778
31793
|
);
|
|
31779
31794
|
const { headingPills } = useDevSettings();
|
|
31780
31795
|
const [parseNestedJson, setParseNestedJson] = (0, import_react53.useState)(true);
|
|
31781
|
-
const [tab, setTab] = (0, import_react53.useState)("details");
|
|
31796
|
+
const [tab, setTab] = (0, import_react53.useState)(requestedTab?.view ?? "details");
|
|
31797
|
+
const [appliedRequest, setAppliedRequest] = (0, import_react53.useState)(requestedTab);
|
|
31798
|
+
if (requestedTab !== appliedRequest) {
|
|
31799
|
+
setAppliedRequest(requestedTab);
|
|
31800
|
+
if (requestedTab) setTab(requestedTab.view);
|
|
31801
|
+
}
|
|
31782
31802
|
const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
|
|
31783
31803
|
const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
|
|
31784
31804
|
const onOperationShownRef = (0, import_react53.useRef)(onOperationShown);
|
|
@@ -32525,6 +32545,36 @@ var TraceGraph = ({
|
|
|
32525
32545
|
] });
|
|
32526
32546
|
};
|
|
32527
32547
|
|
|
32548
|
+
// src/hooks/use-content-width.ts
|
|
32549
|
+
var React124 = __toESM(require("react"), 1);
|
|
32550
|
+
var contentWidth = (element) => {
|
|
32551
|
+
const style = getComputedStyle(element);
|
|
32552
|
+
const edges = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"];
|
|
32553
|
+
return edges.reduce((width, edge) => width - (Number.parseFloat(style[edge]) || 0), element.getBoundingClientRect().width);
|
|
32554
|
+
};
|
|
32555
|
+
var useContentWidth = (elementRef, parent = false) => {
|
|
32556
|
+
const [width, setWidth] = React124.useState(0);
|
|
32557
|
+
React124.useLayoutEffect(() => {
|
|
32558
|
+
const element = parent ? elementRef.current?.parentElement : elementRef.current;
|
|
32559
|
+
if (!element) return;
|
|
32560
|
+
setWidth(contentWidth(element));
|
|
32561
|
+
let frame2 = 0;
|
|
32562
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
32563
|
+
if (!entry) return;
|
|
32564
|
+
cancelAnimationFrame(frame2);
|
|
32565
|
+
frame2 = requestAnimationFrame(() => {
|
|
32566
|
+
setWidth(entry.contentRect.width);
|
|
32567
|
+
});
|
|
32568
|
+
});
|
|
32569
|
+
observer.observe(element);
|
|
32570
|
+
return () => {
|
|
32571
|
+
cancelAnimationFrame(frame2);
|
|
32572
|
+
observer.disconnect();
|
|
32573
|
+
};
|
|
32574
|
+
}, [elementRef, parent]);
|
|
32575
|
+
return width;
|
|
32576
|
+
};
|
|
32577
|
+
|
|
32528
32578
|
// src/hooks/use-local-storage.tsx
|
|
32529
32579
|
var import_react62 = require("react");
|
|
32530
32580
|
function useLocalStorage(key, initialValue) {
|
|
@@ -32570,11 +32620,118 @@ function useLocalStorage(key, initialValue) {
|
|
|
32570
32620
|
return [storedValue, setValue];
|
|
32571
32621
|
}
|
|
32572
32622
|
|
|
32623
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
32624
|
+
var import_react63 = require("@emotion/react");
|
|
32625
|
+
var import_icons_material15 = require("@mui/icons-material");
|
|
32626
|
+
var import_material27 = require("@mui/material");
|
|
32627
|
+
var import_styles5 = require("@mui/material/styles");
|
|
32628
|
+
var React126 = __toESM(require("react"), 1);
|
|
32629
|
+
|
|
32630
|
+
// src/components/trace-panel/sequence-layout.ts
|
|
32631
|
+
var CALLER_KEY = "";
|
|
32632
|
+
var resourceOf = (span) => {
|
|
32633
|
+
const resource = shortResourceName(span.resource_name, span.arn);
|
|
32634
|
+
return resource === "*" ? "" : resource;
|
|
32635
|
+
};
|
|
32636
|
+
var participantOf = (span, mode, callers) => {
|
|
32637
|
+
const resource = mode === "resource" || mode === "caller" && callers.has(`${span.service_name}/${resourceOf(span)}`) ? resourceOf(span) : "";
|
|
32638
|
+
return { key: `${span.service_name}/${resource}`, label: resource, resource, service: span.service_name };
|
|
32639
|
+
};
|
|
32640
|
+
var countDescendants = (node) => node.children.reduce((sum2, child) => sum2 + 1 + countDescendants(child), 0);
|
|
32641
|
+
var layoutSequence = (spans, mode, folded) => {
|
|
32642
|
+
const tree = buildTraceTree(spans);
|
|
32643
|
+
const visible = [];
|
|
32644
|
+
const visit = (nodes2, parent) => {
|
|
32645
|
+
for (const node of nodes2) {
|
|
32646
|
+
visible.push({ node, parent });
|
|
32647
|
+
if (!folded.has(node.span.span_id)) visit(node.children, node.span);
|
|
32648
|
+
}
|
|
32649
|
+
};
|
|
32650
|
+
visit(tree.roots);
|
|
32651
|
+
visible.sort((left, right) => compareNano(left.node.span.start_time_unix_nano, right.node.span.start_time_unix_nano));
|
|
32652
|
+
const callers = new Set(spans.filter((span) => tree.parentOf.has(span.span_id)).flatMap((span) => {
|
|
32653
|
+
const parent = spans.find((candidate) => candidate.span_id === tree.parentOf.get(span.span_id));
|
|
32654
|
+
return parent ? [`${parent.service_name}/${resourceOf(parent)}`] : [];
|
|
32655
|
+
}));
|
|
32656
|
+
const participants = [{ key: CALLER_KEY, label: "", resource: "", service: "" }];
|
|
32657
|
+
const indexOf = /* @__PURE__ */ new Map([[CALLER_KEY, 0]]);
|
|
32658
|
+
const place = (participant) => {
|
|
32659
|
+
const known = indexOf.get(participant.key);
|
|
32660
|
+
if (known !== void 0) return known;
|
|
32661
|
+
participants.push(participant);
|
|
32662
|
+
indexOf.set(participant.key, participants.length - 1);
|
|
32663
|
+
return participants.length - 1;
|
|
32664
|
+
};
|
|
32665
|
+
const rowOf = /* @__PURE__ */ new Map();
|
|
32666
|
+
const parentRows = [];
|
|
32667
|
+
const messages = [];
|
|
32668
|
+
for (const [row, { node, parent }] of visible.entries()) {
|
|
32669
|
+
const { span } = node;
|
|
32670
|
+
const issues = getSpanIssues(span);
|
|
32671
|
+
const from = parent ? place(participantOf(parent, mode, callers)) : 0;
|
|
32672
|
+
const hasChildren = node.children.length > 0;
|
|
32673
|
+
parentRows.push(parent ? rowOf.get(parent.span_id) : void 0);
|
|
32674
|
+
messages.push({
|
|
32675
|
+
async: parent !== void 0 && span.parent_span_id !== parent.span_id,
|
|
32676
|
+
depth: 0,
|
|
32677
|
+
descendantCount: countDescendants(node),
|
|
32678
|
+
endRow: row,
|
|
32679
|
+
error: issues.error,
|
|
32680
|
+
folded: hasChildren && folded.has(span.span_id),
|
|
32681
|
+
from,
|
|
32682
|
+
fromDepth: 0,
|
|
32683
|
+
resource: resourceOf(span),
|
|
32684
|
+
returnLevel: 0,
|
|
32685
|
+
span,
|
|
32686
|
+
to: place(participantOf(span, mode, callers)),
|
|
32687
|
+
warning: issues.warning
|
|
32688
|
+
});
|
|
32689
|
+
rowOf.set(span.span_id, row);
|
|
32690
|
+
}
|
|
32691
|
+
for (let row = messages.length - 1; row >= 0; row--) {
|
|
32692
|
+
const message = messages[row];
|
|
32693
|
+
const parent = messages[parentRows[row] ?? -1];
|
|
32694
|
+
if (message && parent && !message.async) parent.endRow = Math.max(parent.endRow, message.endRow);
|
|
32695
|
+
}
|
|
32696
|
+
const endings = messages.map(() => 0);
|
|
32697
|
+
for (const message of messages.toReversed()) {
|
|
32698
|
+
message.returnLevel = endings[message.endRow] ?? 0;
|
|
32699
|
+
endings[message.endRow] = message.returnLevel + 1;
|
|
32700
|
+
}
|
|
32701
|
+
for (const [row, message] of messages.entries()) {
|
|
32702
|
+
message.depth = messages.slice(0, row).filter((earlier) => earlier.to === message.to && earlier.endRow >= row).length;
|
|
32703
|
+
message.fromDepth = messages[parentRows[row] ?? -1]?.depth ?? 0;
|
|
32704
|
+
}
|
|
32705
|
+
const prefix = sharedPrefix(participants.map((participant) => participant.resource));
|
|
32706
|
+
const strip2 = (name) => name.startsWith(prefix) ? name.slice(prefix.length) : name;
|
|
32707
|
+
return {
|
|
32708
|
+
endings,
|
|
32709
|
+
messages: messages.map((message) => ({ ...message, resource: strip2(message.resource) })),
|
|
32710
|
+
participants: participants.map((participant) => ({ ...participant, label: strip2(participant.resource) }))
|
|
32711
|
+
};
|
|
32712
|
+
};
|
|
32713
|
+
var sharedPrefix = (names2) => {
|
|
32714
|
+
const counts = /* @__PURE__ */ new Map();
|
|
32715
|
+
for (const name of new Set(names2)) {
|
|
32716
|
+
for (let index = 0; index < name.length - 1; index++) {
|
|
32717
|
+
if ("-_/.".includes(name.charAt(index))) {
|
|
32718
|
+
const prefix = name.slice(0, index + 1);
|
|
32719
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
32720
|
+
}
|
|
32721
|
+
}
|
|
32722
|
+
}
|
|
32723
|
+
let best = "";
|
|
32724
|
+
for (const [prefix, count2] of counts) {
|
|
32725
|
+
if (count2 >= 2 && count2 * prefix.length > (counts.get(best) ?? 0) * best.length) best = prefix;
|
|
32726
|
+
}
|
|
32727
|
+
return best;
|
|
32728
|
+
};
|
|
32729
|
+
|
|
32573
32730
|
// src/components/trace-panel/waterfall.tsx
|
|
32574
32731
|
var import_icons_material14 = require("@mui/icons-material");
|
|
32575
32732
|
var import_material26 = require("@mui/material");
|
|
32576
32733
|
var import_styles4 = require("@mui/material/styles");
|
|
32577
|
-
var
|
|
32734
|
+
var React125 = __toESM(require("react"), 1);
|
|
32578
32735
|
|
|
32579
32736
|
// src/components/trace-panel/axis-ticks.ts
|
|
32580
32737
|
var getAxisTicks = (durationMs, maxIntervals) => {
|
|
@@ -32666,25 +32823,10 @@ var Line = ({ height, left, top = 0, width = 1 }) => /* @__PURE__ */ (0, import_
|
|
|
32666
32823
|
);
|
|
32667
32824
|
var AXIS_HEIGHT = 22;
|
|
32668
32825
|
var TRACK_INSET = 1.5;
|
|
32669
|
-
var useWidth = (elementRef) => {
|
|
32670
|
-
const [width, setWidth] = React124.useState(0);
|
|
32671
|
-
React124.useLayoutEffect(() => {
|
|
32672
|
-
const element = elementRef.current;
|
|
32673
|
-
if (!element) return;
|
|
32674
|
-
const observer = new ResizeObserver(([entry]) => {
|
|
32675
|
-
if (entry) setWidth(entry.contentRect.width);
|
|
32676
|
-
});
|
|
32677
|
-
observer.observe(element);
|
|
32678
|
-
return () => {
|
|
32679
|
-
observer.disconnect();
|
|
32680
|
-
};
|
|
32681
|
-
}, [elementRef]);
|
|
32682
|
-
return width;
|
|
32683
|
-
};
|
|
32684
32826
|
var LABEL_TRANSFORMS = { center: "translateX(-50%)", end: "translateX(-100%)", start: void 0 };
|
|
32685
32827
|
var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
32686
|
-
const trackRef =
|
|
32687
|
-
const width =
|
|
32828
|
+
const trackRef = React125.useRef(null);
|
|
32829
|
+
const width = useContentWidth(trackRef);
|
|
32688
32830
|
const { labels: labels2, marks } = layoutAxis(durationMs, width);
|
|
32689
32831
|
return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
|
|
32690
32832
|
import_material26.Box,
|
|
@@ -32752,15 +32894,15 @@ var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
|
|
|
32752
32894
|
);
|
|
32753
32895
|
};
|
|
32754
32896
|
var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
32755
|
-
const [collapsed, setCollapsed] =
|
|
32756
|
-
const containerRef =
|
|
32757
|
-
const tree =
|
|
32758
|
-
const bounds =
|
|
32897
|
+
const [collapsed, setCollapsed] = React125.useState(() => /* @__PURE__ */ new Set());
|
|
32898
|
+
const containerRef = React125.useRef(null);
|
|
32899
|
+
const tree = React125.useMemo(() => buildTraceTree(spans), [spans]);
|
|
32900
|
+
const bounds = React125.useMemo(() => getTraceBounds(spans), [spans]);
|
|
32759
32901
|
const { waterfallLayout } = useDevSettings();
|
|
32760
|
-
const [toggledFlat, setToggledFlat] =
|
|
32902
|
+
const [toggledFlat, setToggledFlat] = React125.useState(false);
|
|
32761
32903
|
const flat = waterfallLayout === "list" || waterfallLayout === "toggle" && toggledFlat;
|
|
32762
|
-
const rows =
|
|
32763
|
-
const [revealed, setRevealed] =
|
|
32904
|
+
const rows = React125.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
|
|
32905
|
+
const [revealed, setRevealed] = React125.useState();
|
|
32764
32906
|
if (selectedSpanId !== revealed) {
|
|
32765
32907
|
setRevealed(selectedSpanId);
|
|
32766
32908
|
const ancestors = /* @__PURE__ */ new Set();
|
|
@@ -32769,7 +32911,7 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32769
32911
|
setCollapsed((current) => new Set([...current].filter((id2) => !ancestors.has(id2))));
|
|
32770
32912
|
}
|
|
32771
32913
|
}
|
|
32772
|
-
|
|
32914
|
+
React125.useEffect(() => {
|
|
32773
32915
|
if (selectedSpanId === void 0) return;
|
|
32774
32916
|
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest" });
|
|
32775
32917
|
}, [selectedSpanId]);
|
|
@@ -32944,8 +33086,661 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
|
|
|
32944
33086
|
] });
|
|
32945
33087
|
};
|
|
32946
33088
|
|
|
32947
|
-
// src/components/trace-panel/
|
|
33089
|
+
// src/components/trace-panel/sequence-diagram.tsx
|
|
32948
33090
|
var import_jsx_runtime151 = require("react/jsx-runtime");
|
|
33091
|
+
var COLUMN_WIDTH = 136;
|
|
33092
|
+
var HEADER_HEIGHT = 52;
|
|
33093
|
+
var LABEL_TOP = 1;
|
|
33094
|
+
var LABEL_HEIGHT = 18;
|
|
33095
|
+
var ARROW_Y = 24;
|
|
33096
|
+
var ARROW_HEAD = 5;
|
|
33097
|
+
var SELF_LOOP = 22;
|
|
33098
|
+
var BLOCK_WIDTH = 8;
|
|
33099
|
+
var BLOCK_OFFSET = BLOCK_WIDTH + 6;
|
|
33100
|
+
var BLOCK_OVERLAP_OFFSET = BLOCK_WIDTH * 3 / 4;
|
|
33101
|
+
var HATCH_MARGIN = 4;
|
|
33102
|
+
var BLOCK_OVERHANG = 4;
|
|
33103
|
+
var BLOCK_MIN_HEIGHT = 24;
|
|
33104
|
+
var BLOCK_TAIL = BLOCK_MIN_HEIGHT - BLOCK_OVERHANG;
|
|
33105
|
+
var BLOCK_RADIUS = 2;
|
|
33106
|
+
var RETURN_GAP = 10;
|
|
33107
|
+
var ROW_GAP = 8;
|
|
33108
|
+
var rowHeight = (endings) => ARROW_Y + (endings === 0 ? 0 : BLOCK_TAIL + (endings - 1) * RETURN_GAP) + ROW_GAP;
|
|
33109
|
+
var SLIDE_MS = 200;
|
|
33110
|
+
var SLIDE = `${String(SLIDE_MS)}ms cubic-bezier(0.4, 0, 0.2, 1)`;
|
|
33111
|
+
var SLIDE_TRANSITION = `transform ${SLIDE}, height ${SLIDE}`;
|
|
33112
|
+
var RETURN_HIT_HEIGHT = 9;
|
|
33113
|
+
var ARROW_HIT_HEIGHT = 15;
|
|
33114
|
+
var BLOCK_HIT_MARGIN = 3;
|
|
33115
|
+
var enter = import_react63.keyframes`from { opacity: 0 }`;
|
|
33116
|
+
var ENTER_ANIMATION = `${enter} ${SLIDE}`;
|
|
33117
|
+
var slideTo = (y, entering = false) => ({
|
|
33118
|
+
animation: entering ? ENTER_ANIMATION : void 0,
|
|
33119
|
+
transform: `translateY(${String(y)}px)`,
|
|
33120
|
+
transition: SLIDE_TRANSITION
|
|
33121
|
+
});
|
|
33122
|
+
var blockRect = (height) => ({ height, style: { height, transition: SLIDE_TRANSITION }, y: 0 });
|
|
33123
|
+
var hatchId = (color2) => `sequence-hatch-${color2.replace("#", "")}`;
|
|
33124
|
+
var lifelineX = (index) => index * COLUMN_WIDTH + COLUMN_WIDTH / 2;
|
|
33125
|
+
var blockX = (index, depth, offset) => lifelineX(index) + depth * offset;
|
|
33126
|
+
var Arrow = ({ blockOffset, blockWidth, color: color2, entering, message, top }) => {
|
|
33127
|
+
const y = ARROW_Y;
|
|
33128
|
+
const dash = message.async ? "4 3" : void 0;
|
|
33129
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33130
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33131
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33132
|
+
if (message.from === message.to) {
|
|
33133
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33134
|
+
const endX2 = toX + blockWidth / 2;
|
|
33135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33136
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(fromX + fromHalf)} ${String(y - 6)}H${String(loopX)}v8H${String(endX2 + ARROW_HEAD)}`, fill: "none", strokeDasharray: dash }),
|
|
33137
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(endX2)} ${String(y + 2)}l${String(ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33138
|
+
] });
|
|
33139
|
+
}
|
|
33140
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33141
|
+
const startX = fromX + direction * fromHalf;
|
|
33142
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(top, entering), children: [
|
|
33144
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("line", { strokeDasharray: dash, x1: startX, x2: endX - direction * ARROW_HEAD, y1: y, y2: y }),
|
|
33145
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(endX)} ${String(y)}l${String(-direction * ARROW_HEAD)} -3v6z`, fill: color2 })
|
|
33146
|
+
] });
|
|
33147
|
+
};
|
|
33148
|
+
var arrowHitBox = (message, blockWidth, blockOffset, height) => {
|
|
33149
|
+
const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
|
|
33150
|
+
const fromX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33151
|
+
const toX = blockX(message.to, message.depth, blockOffset);
|
|
33152
|
+
if (message.from === message.to) {
|
|
33153
|
+
const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
|
|
33154
|
+
const left = Math.min(fromX + fromHalf, toX + blockWidth / 2);
|
|
33155
|
+
return { height, left, top: ARROW_Y - 2 - height / 2, width: loopX - left };
|
|
33156
|
+
}
|
|
33157
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33158
|
+
const startX = fromX + direction * fromHalf;
|
|
33159
|
+
const endX = toX - direction * blockWidth / 2;
|
|
33160
|
+
return { height, left: Math.min(startX, endX), top: ARROW_Y - height / 2, width: Math.abs(endX - startX) };
|
|
33161
|
+
};
|
|
33162
|
+
var hasReturn = (message) => !message.async && message.from !== message.to;
|
|
33163
|
+
var ReturnArrow = ({ blockOffset, blockWidth, color: color2, entering, message, y: lineY }) => {
|
|
33164
|
+
const y = 0;
|
|
33165
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33166
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33167
|
+
const direction = toX > fromX ? 1 : -1;
|
|
33168
|
+
const startX = fromX + direction * blockWidth / 2;
|
|
33169
|
+
const endX = toX - direction * (message.from === 0 ? 0 : blockWidth / 2);
|
|
33170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(lineY, entering), children: [
|
|
33171
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("line", { strokeDasharray: "3 3", x1: startX, x2: endX, y1: y, y2: y }),
|
|
33172
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("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" })
|
|
33173
|
+
] });
|
|
33174
|
+
};
|
|
33175
|
+
var MIN_ZOOM = 0.25;
|
|
33176
|
+
var MAX_ZOOM = 1;
|
|
33177
|
+
var ZOOM_STEP = 1.25;
|
|
33178
|
+
var WHEEL_ZOOM_SPEED = 0.01;
|
|
33179
|
+
var MINIMAP_WIDTH = 168;
|
|
33180
|
+
var MINIMAP_MAX_HEIGHT = 160;
|
|
33181
|
+
var MINIMAP_MAX_VIEW_SHARE = 1 / 3;
|
|
33182
|
+
var WIDGET_MARGIN = 16;
|
|
33183
|
+
var BOTTOM_ROOM = 44 + WIDGET_MARGIN + 16;
|
|
33184
|
+
var MINIMAP_OPEN_STORAGE_KEY = "appinspector-sequence-minimap-open";
|
|
33185
|
+
var bodyIds = 0;
|
|
33186
|
+
var useBodyId = () => {
|
|
33187
|
+
const [id2] = React126.useState(() => `sequence-body-${String(++bodyIds)}`);
|
|
33188
|
+
return id2;
|
|
33189
|
+
};
|
|
33190
|
+
var clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
|
|
33191
|
+
var useZoom = (scrollRef, areaRef, widgetRef, enabled) => {
|
|
33192
|
+
const [zoom, setZoom] = React126.useState(1);
|
|
33193
|
+
const zoomRef = React126.useRef(zoom);
|
|
33194
|
+
const anchorRef = React126.useRef();
|
|
33195
|
+
const zoomTo = React126.useCallback((next, x, y) => {
|
|
33196
|
+
const element = scrollRef.current;
|
|
33197
|
+
const clamped = clampZoom(next);
|
|
33198
|
+
if (!element || clamped === zoomRef.current) return;
|
|
33199
|
+
anchorRef.current = { ratio: clamped / zoomRef.current, x: x ?? element.clientWidth / 2, y: y ?? element.clientHeight / 2 };
|
|
33200
|
+
zoomRef.current = clamped;
|
|
33201
|
+
setZoom(clamped);
|
|
33202
|
+
}, [scrollRef]);
|
|
33203
|
+
React126.useLayoutEffect(() => {
|
|
33204
|
+
const element = scrollRef.current;
|
|
33205
|
+
const anchor = anchorRef.current;
|
|
33206
|
+
if (!element || !anchor) return;
|
|
33207
|
+
element.scrollLeft = (element.scrollLeft + anchor.x) * anchor.ratio - anchor.x;
|
|
33208
|
+
element.scrollTop = (element.scrollTop + anchor.y) * anchor.ratio - anchor.y;
|
|
33209
|
+
anchorRef.current = void 0;
|
|
33210
|
+
}, [scrollRef, zoom]);
|
|
33211
|
+
React126.useEffect(() => {
|
|
33212
|
+
const element = scrollRef.current;
|
|
33213
|
+
const area = areaRef.current;
|
|
33214
|
+
if (!element || !area || !enabled) return;
|
|
33215
|
+
const pointer = (event) => {
|
|
33216
|
+
if (event.target instanceof Node && widgetRef.current?.contains(event.target)) return [];
|
|
33217
|
+
const bounds = element.getBoundingClientRect();
|
|
33218
|
+
return [event.clientX - bounds.left, event.clientY - bounds.top];
|
|
33219
|
+
};
|
|
33220
|
+
const handleWheel = (event) => {
|
|
33221
|
+
if (!event.ctrlKey && !event.metaKey) return;
|
|
33222
|
+
event.preventDefault();
|
|
33223
|
+
zoomTo(zoomRef.current * Math.exp(-event.deltaY * WHEEL_ZOOM_SPEED), ...pointer(event));
|
|
33224
|
+
};
|
|
33225
|
+
let gestureStart = 1;
|
|
33226
|
+
const handleGestureStart = (event) => {
|
|
33227
|
+
event.preventDefault();
|
|
33228
|
+
gestureStart = zoomRef.current;
|
|
33229
|
+
};
|
|
33230
|
+
const handleGestureChange = (event) => {
|
|
33231
|
+
event.preventDefault();
|
|
33232
|
+
const { scale: scale2 } = event;
|
|
33233
|
+
zoomTo(gestureStart * scale2, ...pointer(event));
|
|
33234
|
+
};
|
|
33235
|
+
area.addEventListener("wheel", handleWheel, { passive: false });
|
|
33236
|
+
area.addEventListener("gesturestart", handleGestureStart);
|
|
33237
|
+
area.addEventListener("gesturechange", handleGestureChange);
|
|
33238
|
+
return () => {
|
|
33239
|
+
area.removeEventListener("wheel", handleWheel);
|
|
33240
|
+
area.removeEventListener("gesturestart", handleGestureStart);
|
|
33241
|
+
area.removeEventListener("gesturechange", handleGestureChange);
|
|
33242
|
+
};
|
|
33243
|
+
}, [scrollRef, areaRef, widgetRef, enabled, zoomTo]);
|
|
33244
|
+
return { zoom, zoomTo };
|
|
33245
|
+
};
|
|
33246
|
+
var lifelineName = (participant) => participant.service === "" ? "Caller" : [getServiceDisplayName(participant.service), participant.label].filter(Boolean).join(" ");
|
|
33247
|
+
var hoverDirection = (hover) => {
|
|
33248
|
+
if (hover.kind === "segment") return `Active on ${hover.to}`;
|
|
33249
|
+
const kind = hover.kind === "response" ? "Response" : hover.message.async ? "Async request" : "Request";
|
|
33250
|
+
return `${kind} \xB7 ${hover.from} \u2192 ${hover.to}`;
|
|
33251
|
+
};
|
|
33252
|
+
var ArrowHoverCard = ({ hover }) => {
|
|
33253
|
+
const { span } = hover.message;
|
|
33254
|
+
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);
|
|
33255
|
+
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;
|
|
33256
|
+
const anchor = { getBoundingClientRect: () => new DOMRect(hover.x, hover.y, 0, 0) };
|
|
33257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.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__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Paper, { elevation: 6, sx: { display: "flex", flexDirection: "column", gap: 0.75, maxWidth: 360, px: 1.5, py: 1 }, children: [
|
|
33258
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationIdentity, { arn: span.arn, density: "stacked", iconSize: 24, operation: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationName, { span, tooltip: false }), resourceName: span.resource_name, service: span.service_name }),
|
|
33259
|
+
getOperationLabel(span) !== span.operation_name && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: `Action: ${span.operation_name}` }),
|
|
33260
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: [hoverDirection(hover), duration].filter(Boolean).join(" \xB7 ") }),
|
|
33261
|
+
issue !== void 0 && issue !== "" && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: hover.message.error ? "error" : "warning.main", sx: { fontSize: 12 }, children: issue })
|
|
33262
|
+
] }) });
|
|
33263
|
+
};
|
|
33264
|
+
var SequenceDiagram = ({ onSelectSpan, participantMode = "caller", selectedSpanId, spans }) => {
|
|
33265
|
+
const theme = (0, import_styles5.useTheme)();
|
|
33266
|
+
const [folded, setFolded] = React126.useState(() => /* @__PURE__ */ new Set());
|
|
33267
|
+
const containerRef = React126.useRef(null);
|
|
33268
|
+
const scrollRef = React126.useRef(null);
|
|
33269
|
+
const areaRef = React126.useRef(null);
|
|
33270
|
+
const widgetRef = React126.useRef(null);
|
|
33271
|
+
const { zoom, zoomTo } = useZoom(scrollRef, areaRef, widgetRef, spans.length > 0);
|
|
33272
|
+
const bodyId = useBodyId();
|
|
33273
|
+
const [minimapOpen, setMinimapOpen] = useLocalStorage(MINIMAP_OPEN_STORAGE_KEY, true);
|
|
33274
|
+
const [scrollView, setScrollView] = React126.useState({ height: 0, left: 0, scrollbarHeight: 0, scrollbarWidth: 0, top: 0, width: 0 });
|
|
33275
|
+
const measureView = React126.useCallback(() => {
|
|
33276
|
+
const element = scrollRef.current;
|
|
33277
|
+
if (element) setScrollView({
|
|
33278
|
+
height: element.clientHeight,
|
|
33279
|
+
left: element.scrollLeft,
|
|
33280
|
+
// Classic scrollbars take room; overlay ones (macOS by default) measure 0.
|
|
33281
|
+
scrollbarHeight: element.offsetHeight - element.clientHeight,
|
|
33282
|
+
scrollbarWidth: element.offsetWidth - element.clientWidth,
|
|
33283
|
+
top: element.scrollTop,
|
|
33284
|
+
width: element.clientWidth
|
|
33285
|
+
});
|
|
33286
|
+
}, []);
|
|
33287
|
+
React126.useLayoutEffect(() => {
|
|
33288
|
+
const element = scrollRef.current;
|
|
33289
|
+
if (!element) return;
|
|
33290
|
+
measureView();
|
|
33291
|
+
let frame2 = 0;
|
|
33292
|
+
const observer = new ResizeObserver(() => {
|
|
33293
|
+
cancelAnimationFrame(frame2);
|
|
33294
|
+
frame2 = requestAnimationFrame(measureView);
|
|
33295
|
+
});
|
|
33296
|
+
observer.observe(element);
|
|
33297
|
+
return () => {
|
|
33298
|
+
cancelAnimationFrame(frame2);
|
|
33299
|
+
observer.disconnect();
|
|
33300
|
+
};
|
|
33301
|
+
}, [measureView, zoom, spans.length]);
|
|
33302
|
+
const { sequenceBlocks, sequenceClickTargets, sequenceHoverCard } = useDevSettings();
|
|
33303
|
+
const arrowTargets = sequenceClickTargets === "arrows-and-segments";
|
|
33304
|
+
const returnHitHeight = arrowTargets ? ARROW_HIT_HEIGHT : RETURN_HIT_HEIGHT;
|
|
33305
|
+
const hoverCard = sequenceHoverCard === "on";
|
|
33306
|
+
const [hover, setHover] = React126.useState();
|
|
33307
|
+
const blocks = sequenceBlocks === "detached" || sequenceBlocks === "overlapped";
|
|
33308
|
+
const hatched = sequenceBlocks === "detached";
|
|
33309
|
+
const blockOffset = sequenceBlocks === "overlapped" ? BLOCK_OVERLAP_OFFSET : BLOCK_OFFSET;
|
|
33310
|
+
const merged = sequenceBlocks === "merged";
|
|
33311
|
+
const blockWidth = sequenceBlocks === "off" ? 0 : BLOCK_WIDTH;
|
|
33312
|
+
const segmentTargets = (arrowTargets || hoverCard) && blockWidth > 0;
|
|
33313
|
+
const { endings, messages, participants } = React126.useMemo(() => {
|
|
33314
|
+
const layout = layoutSequence(spans, participantMode, folded);
|
|
33315
|
+
return blocks ? layout : { ...layout, messages: layout.messages.map((message) => ({ ...message, depth: 0, fromDepth: 0 })) };
|
|
33316
|
+
}, [spans, participantMode, folded, blocks]);
|
|
33317
|
+
const pickedHereRef = React126.useRef();
|
|
33318
|
+
const select = React126.useCallback((spanId, view2) => {
|
|
33319
|
+
pickedHereRef.current = spanId;
|
|
33320
|
+
onSelectSpan(spanId, view2);
|
|
33321
|
+
}, [onSelectSpan]);
|
|
33322
|
+
React126.useEffect(() => {
|
|
33323
|
+
if (selectedSpanId === void 0 || selectedSpanId === pickedHereRef.current) return;
|
|
33324
|
+
containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
33325
|
+
}, [selectedSpanId]);
|
|
33326
|
+
const [folding, setFolding] = React126.useState(false);
|
|
33327
|
+
const foldingTimerRef = React126.useRef();
|
|
33328
|
+
React126.useEffect(() => () => {
|
|
33329
|
+
clearTimeout(foldingTimerRef.current);
|
|
33330
|
+
}, []);
|
|
33331
|
+
const setFold = React126.useCallback((spanId, fold) => {
|
|
33332
|
+
setFolding(true);
|
|
33333
|
+
clearTimeout(foldingTimerRef.current);
|
|
33334
|
+
foldingTimerRef.current = setTimeout(() => {
|
|
33335
|
+
setFolding(false);
|
|
33336
|
+
}, SLIDE_MS + 100);
|
|
33337
|
+
setFolded((previous) => {
|
|
33338
|
+
const next = new Set(previous);
|
|
33339
|
+
if (fold) next.add(spanId);
|
|
33340
|
+
else next.delete(spanId);
|
|
33341
|
+
return next;
|
|
33342
|
+
});
|
|
33343
|
+
}, []);
|
|
33344
|
+
const handleKeyDown = React126.useCallback((event, message) => {
|
|
33345
|
+
if (event.target !== event.currentTarget) return;
|
|
33346
|
+
const spanId = message.span.span_id;
|
|
33347
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
33348
|
+
event.preventDefault();
|
|
33349
|
+
select(spanId, "details");
|
|
33350
|
+
} else if (event.key === "ArrowRight" && message.folded) setFold(spanId, false);
|
|
33351
|
+
else if (event.key === "ArrowLeft" && message.descendantCount > 0 && !message.folded) setFold(spanId, true);
|
|
33352
|
+
}, [select, setFold]);
|
|
33353
|
+
const [shown, setShown] = React126.useState(() => ({ messages, revealed: /* @__PURE__ */ new Set() }));
|
|
33354
|
+
if (shown.messages !== messages) {
|
|
33355
|
+
const previous = new Set(shown.messages.map((message) => message.span.span_id));
|
|
33356
|
+
const continued = messages.some((message) => previous.has(message.span.span_id));
|
|
33357
|
+
setShown({ messages, revealed: new Set(continued ? messages.filter((message) => !previous.has(message.span.span_id)).map((message) => message.span.span_id) : []) });
|
|
33358
|
+
}
|
|
33359
|
+
const isEntering = React126.useCallback((spanId) => shown.revealed.has(spanId), [shown]);
|
|
33360
|
+
const geometry = React126.useMemo(() => {
|
|
33361
|
+
const participant2 = (index) => participants[index] ?? { key: "", label: "", resource: "", service: "" };
|
|
33362
|
+
const width2 = participants.length * COLUMN_WIDTH;
|
|
33363
|
+
const rowHeights2 = endings.map((count2) => rowHeight(count2));
|
|
33364
|
+
const rowTops = rowHeights2.map((_height, row) => rowHeights2.slice(0, row).reduce((sum2, height) => sum2 + height, 0));
|
|
33365
|
+
const bodyHeight2 = rowHeights2.reduce((sum2, height) => sum2 + height, 0);
|
|
33366
|
+
const top2 = (row) => rowTops[row] ?? 0;
|
|
33367
|
+
const activeDepth2 = (lifeline, row) => Math.max(0, ...messages.slice(0, row + 1).filter((message) => message.to === lifeline && message.endRow >= row).map((message) => message.depth));
|
|
33368
|
+
const endY2 = (message) => top2(message.endRow) + ARROW_Y + BLOCK_TAIL + message.returnLevel * RETURN_GAP;
|
|
33369
|
+
const rowOf = new Map(messages.map((message, index) => [message.span.span_id, index]));
|
|
33370
|
+
const blockY2 = (message) => top2(rowOf.get(message.span.span_id) ?? 0) + ARROW_Y - BLOCK_OVERHANG;
|
|
33371
|
+
const mergedBlocks2 = [];
|
|
33372
|
+
if (merged) {
|
|
33373
|
+
for (const message of messages.toSorted((left, right) => left.to - right.to || blockY2(left) - blockY2(right))) {
|
|
33374
|
+
const last = mergedBlocks2.at(-1);
|
|
33375
|
+
if (last?.members[0]?.to === message.to && blockY2(message) <= last.bottom) {
|
|
33376
|
+
last.bottom = Math.max(last.bottom, endY2(message));
|
|
33377
|
+
last.members.push(message);
|
|
33378
|
+
} else mergedBlocks2.push({ bottom: endY2(message), members: [message], top: blockY2(message) });
|
|
33379
|
+
}
|
|
33380
|
+
}
|
|
33381
|
+
return { activeDepth: activeDepth2, blockY: blockY2, bodyHeight: bodyHeight2, endY: endY2, mergedBlocks: mergedBlocks2, participant: participant2, rowHeights: rowHeights2, top: top2, width: width2 };
|
|
33382
|
+
}, [endings, merged, messages, participants]);
|
|
33383
|
+
const { activeDepth, blockY, bodyHeight, endY, mergedBlocks, participant, rowHeights, top, width } = geometry;
|
|
33384
|
+
const hoveredMessage = hover && messages.find((message) => message.span.span_id === hover.message.span.span_id);
|
|
33385
|
+
const arrowHoverProps = React126.useCallback((message, kind) => {
|
|
33386
|
+
if (!hoverCard) return {};
|
|
33387
|
+
const [from, to] = kind === "response" ? [message.to, message.from] : [message.from, message.to];
|
|
33388
|
+
return {
|
|
33389
|
+
onMouseLeave: () => {
|
|
33390
|
+
setHover(void 0);
|
|
33391
|
+
},
|
|
33392
|
+
onMouseMove: (event) => {
|
|
33393
|
+
setHover({ from: lifelineName(participant(from)), kind, message, to: lifelineName(participant(to)), x: event.clientX, y: event.clientY });
|
|
33394
|
+
}
|
|
33395
|
+
};
|
|
33396
|
+
}, [hoverCard, participant]);
|
|
33397
|
+
const drawing = React126.useMemo(() => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_jsx_runtime151.Fragment, { children: [
|
|
33398
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { 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) => (
|
|
33399
|
+
// A subtle box per lifeline, its identity as in every other view: icon, service, resource below.
|
|
33400
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33401
|
+
import_material27.Box,
|
|
33402
|
+
{
|
|
33403
|
+
"data-testid": SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID,
|
|
33404
|
+
sx: {
|
|
33405
|
+
// As in Flow: a hovered box grows to show its whole name, over its neighbours, without moving them.
|
|
33406
|
+
"&:hover": { "& > *": { width: "max-content" }, "zIndex": 1 },
|
|
33407
|
+
"alignItems": "center",
|
|
33408
|
+
"display": "flex",
|
|
33409
|
+
"flex": "none",
|
|
33410
|
+
"justifyContent": "flex-start",
|
|
33411
|
+
"position": "relative",
|
|
33412
|
+
"px": "4px",
|
|
33413
|
+
"width": COLUMN_WIDTH
|
|
33414
|
+
},
|
|
33415
|
+
title: [participant2.service, participant2.resource].filter(Boolean).join(" \xB7 ") || "Caller",
|
|
33416
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33417
|
+
import_material27.Box,
|
|
33418
|
+
{
|
|
33419
|
+
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%" },
|
|
33420
|
+
children: participant2.service === "" ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", sx: { fontSize: 12 }, children: "Caller" }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationIdentity, { density: "stacked", iconSize: 24, resourceName: participant2.label, service: participant2.service })
|
|
33421
|
+
}
|
|
33422
|
+
)
|
|
33423
|
+
},
|
|
33424
|
+
participant2.key
|
|
33425
|
+
)
|
|
33426
|
+
)) }),
|
|
33427
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { sx: { backgroundColor: "background.paper", height: bodyHeight, position: "relative" }, children: [
|
|
33428
|
+
messages.map((message, index) => {
|
|
33429
|
+
const { span } = message;
|
|
33430
|
+
const selected = span.span_id === selectedSpanId;
|
|
33431
|
+
const self2 = message.from === message.to;
|
|
33432
|
+
const lane = Math.min(message.from, message.to);
|
|
33433
|
+
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;
|
|
33434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
|
|
33435
|
+
import_material27.Box,
|
|
33436
|
+
{
|
|
33437
|
+
"aria-selected": selected,
|
|
33438
|
+
"data-span-id": span.span_id,
|
|
33439
|
+
"data-testid": SEQUENCE_DIAGRAM_MESSAGE_TEST_ID,
|
|
33440
|
+
onClick: arrowTargets ? void 0 : () => {
|
|
33441
|
+
select(span.span_id, "details");
|
|
33442
|
+
},
|
|
33443
|
+
onKeyDown: (event) => {
|
|
33444
|
+
handleKeyDown(event, message);
|
|
33445
|
+
},
|
|
33446
|
+
role: "listitem",
|
|
33447
|
+
sx: {
|
|
33448
|
+
"&:focus-visible": { boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}` },
|
|
33449
|
+
"&:hover": arrowTargets ? void 0 : { "--row-tint": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.16) : (0, import_styles5.alpha)(theme.palette.text.primary, 0.04) },
|
|
33450
|
+
// Opaque, so a label repeating it hides the lifelines behind it.
|
|
33451
|
+
"--row-bg": `linear-gradient(var(--row-tint), var(--row-tint)), ${theme.palette.background.paper}`,
|
|
33452
|
+
"--row-tint": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.12) : "transparent",
|
|
33453
|
+
"animation": isEntering(span.span_id) ? ENTER_ANIMATION : void 0,
|
|
33454
|
+
// Only the tint: the drawing shows through the row, under its label.
|
|
33455
|
+
"background": "var(--row-tint)",
|
|
33456
|
+
"cursor": arrowTargets ? void 0 : "pointer",
|
|
33457
|
+
"height": rowHeights[index],
|
|
33458
|
+
"left": 0,
|
|
33459
|
+
"outline": 0,
|
|
33460
|
+
"position": "absolute",
|
|
33461
|
+
"right": 0,
|
|
33462
|
+
"scrollMarginTop": HEADER_HEIGHT,
|
|
33463
|
+
"top": 0,
|
|
33464
|
+
"transform": `translateY(${String(top(index))}px)`,
|
|
33465
|
+
// Only the transform: a height transition would re-lay out every row on every frame.
|
|
33466
|
+
"transition": `transform ${SLIDE}`,
|
|
33467
|
+
// The transform makes the row a stacking context: over the drawing, so its label covers the blocks and lines it crosses.
|
|
33468
|
+
"zIndex": 1
|
|
33469
|
+
},
|
|
33470
|
+
tabIndex: 0,
|
|
33471
|
+
children: [
|
|
33472
|
+
(arrowTargets || hoverCard) && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33473
|
+
import_material27.Box,
|
|
33474
|
+
{
|
|
33475
|
+
"data-testid": SEQUENCE_DIAGRAM_ARROW_TEST_ID,
|
|
33476
|
+
onClick: arrowTargets ? () => {
|
|
33477
|
+
select(span.span_id, "payload");
|
|
33478
|
+
} : void 0,
|
|
33479
|
+
...arrowHoverProps(message, "request"),
|
|
33480
|
+
sx: { "&:hover": arrowTargets ? { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) } : void 0, "borderRadius": "4px", "cursor": "pointer", "position": "absolute", ...arrowHitBox(message, blockWidth, blockOffset, ARROW_HIT_HEIGHT) }
|
|
33481
|
+
}
|
|
33482
|
+
),
|
|
33483
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
|
|
33484
|
+
import_material27.Box,
|
|
33485
|
+
{
|
|
33486
|
+
onClick: arrowTargets ? () => {
|
|
33487
|
+
select(span.span_id, "details");
|
|
33488
|
+
} : void 0,
|
|
33489
|
+
...arrowHoverProps(message, "request"),
|
|
33490
|
+
sx: {
|
|
33491
|
+
alignItems: "center",
|
|
33492
|
+
background: "var(--row-bg)",
|
|
33493
|
+
cursor: arrowTargets ? "pointer" : void 0,
|
|
33494
|
+
display: "flex",
|
|
33495
|
+
gap: "3px",
|
|
33496
|
+
height: LABEL_HEIGHT,
|
|
33497
|
+
left: labelLeft,
|
|
33498
|
+
maxWidth: width - labelLeft - 4,
|
|
33499
|
+
position: "absolute",
|
|
33500
|
+
px: "2px",
|
|
33501
|
+
top: LABEL_TOP,
|
|
33502
|
+
zIndex: 2
|
|
33503
|
+
},
|
|
33504
|
+
children: [
|
|
33505
|
+
message.descendantCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33506
|
+
import_material27.ButtonBase,
|
|
33507
|
+
{
|
|
33508
|
+
"aria-label": message.folded ? "Expand" : "Collapse",
|
|
33509
|
+
"data-testid": SEQUENCE_DIAGRAM_TOGGLE_TEST_ID,
|
|
33510
|
+
onClick: (event) => {
|
|
33511
|
+
event.stopPropagation();
|
|
33512
|
+
setFold(span.span_id, !message.folded);
|
|
33513
|
+
},
|
|
33514
|
+
sx: { "&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.text.primary, 0.12) }, "borderRadius": "3px", "color": "text.secondary", "flex": "none", "height": 14, "width": 14 },
|
|
33515
|
+
tabIndex: -1,
|
|
33516
|
+
children: message.folded ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowRight, { sx: { fontSize: 16 } }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowDown, { sx: { fontSize: 16 } })
|
|
33517
|
+
}
|
|
33518
|
+
),
|
|
33519
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: message.error ? "error" : "text.primary", component: "span", noWrap: true, sx: { flex: "none", fontSize: "inherit", fontWeight: 600 }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationName, { span, tooltip: !hoverCard }) }),
|
|
33520
|
+
participant(message.to).resource === "" && message.resource !== "" && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", noWrap: true, sx: { ...RESOURCE_CODE_SX, fontSize: 11, minWidth: 0 }, title: hoverCard ? void 0 : message.resource, children: message.resource }),
|
|
33521
|
+
message.error && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.Cancel, { sx: { color: "error.main", flex: "none", fontSize: 13 } }),
|
|
33522
|
+
message.warning && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.GppMaybe, { sx: { color: "warning.main", flex: "none", fontSize: 13 } }),
|
|
33523
|
+
message.folded && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", sx: { flex: "none", fontSize: 11 }, children: `+${String(message.descendantCount)}` })
|
|
33524
|
+
]
|
|
33525
|
+
}
|
|
33526
|
+
)
|
|
33527
|
+
]
|
|
33528
|
+
},
|
|
33529
|
+
span.span_id
|
|
33530
|
+
);
|
|
33531
|
+
}),
|
|
33532
|
+
messages.filter((message) => hasReturn(message)).map((message) => {
|
|
33533
|
+
const fromX = blockX(message.to, message.depth, blockOffset);
|
|
33534
|
+
const toX = blockX(message.from, message.fromDepth, blockOffset);
|
|
33535
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33537
|
+
import_material27.Box,
|
|
33538
|
+
{
|
|
33539
|
+
"aria-hidden": "true",
|
|
33540
|
+
"aria-selected": selected,
|
|
33541
|
+
"data-span-id": message.span.span_id,
|
|
33542
|
+
"data-testid": SEQUENCE_DIAGRAM_RETURN_TEST_ID,
|
|
33543
|
+
onClick: () => {
|
|
33544
|
+
select(message.span.span_id, "response");
|
|
33545
|
+
},
|
|
33546
|
+
...arrowHoverProps(message, "response"),
|
|
33547
|
+
sx: {
|
|
33548
|
+
// The selected call's tint, as on its row, so its reply reads as part of it.
|
|
33549
|
+
"&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33550
|
+
"backgroundColor": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.12) : void 0,
|
|
33551
|
+
"borderRadius": "4px",
|
|
33552
|
+
"cursor": "pointer",
|
|
33553
|
+
"height": returnHitHeight,
|
|
33554
|
+
"left": Math.min(fromX, toX),
|
|
33555
|
+
"position": "absolute",
|
|
33556
|
+
"top": 0,
|
|
33557
|
+
"width": Math.abs(toX - fromX),
|
|
33558
|
+
"zIndex": 2,
|
|
33559
|
+
...slideTo(endY(message) - returnHitHeight / 2, isEntering(message.span.span_id))
|
|
33560
|
+
},
|
|
33561
|
+
title: hoverCard ? void 0 : `${getOperationLabel(message.span)}: response`
|
|
33562
|
+
},
|
|
33563
|
+
message.span.span_id
|
|
33564
|
+
);
|
|
33565
|
+
}),
|
|
33566
|
+
segmentTargets && messages.map((message) => {
|
|
33567
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33568
|
+
const boxY = blockY(message);
|
|
33569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33570
|
+
import_material27.Box,
|
|
33571
|
+
{
|
|
33572
|
+
"aria-hidden": "true",
|
|
33573
|
+
"data-span-id": message.span.span_id,
|
|
33574
|
+
"data-testid": SEQUENCE_DIAGRAM_SEGMENT_TEST_ID,
|
|
33575
|
+
onClick: () => {
|
|
33576
|
+
select(message.span.span_id, "details");
|
|
33577
|
+
},
|
|
33578
|
+
...arrowHoverProps(message, "segment"),
|
|
33579
|
+
sx: {
|
|
33580
|
+
"&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) },
|
|
33581
|
+
"borderRadius": "4px",
|
|
33582
|
+
"cursor": "pointer",
|
|
33583
|
+
"height": endY(message) - boxY,
|
|
33584
|
+
"left": blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 - BLOCK_HIT_MARGIN,
|
|
33585
|
+
"position": "absolute",
|
|
33586
|
+
"top": 0,
|
|
33587
|
+
"width": BLOCK_WIDTH + 2 * BLOCK_HIT_MARGIN,
|
|
33588
|
+
"zIndex": 2,
|
|
33589
|
+
// Its height follows a fold too: the slide's transition covers both.
|
|
33590
|
+
...slideTo(boxY, isEntering(message.span.span_id))
|
|
33591
|
+
},
|
|
33592
|
+
title: hoverCard ? void 0 : getOperationLabel(message.span)
|
|
33593
|
+
},
|
|
33594
|
+
message.span.span_id
|
|
33595
|
+
);
|
|
33596
|
+
}),
|
|
33597
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("svg", { "aria-hidden": "true", height: bodyHeight, style: { left: 0, overflow: "visible", pointerEvents: "none", position: "absolute", top: 0, zIndex: 0 }, width, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { id: bodyId, children: [
|
|
33598
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("defs", { children: [...new Set(messages.map((message) => getServiceColor(message.span.service_name)))].map((color2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("pattern", { height: 4, id: hatchId(color2), patternTransform: "rotate(45)", patternUnits: "userSpaceOnUse", width: 4, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(color2, 0.35), height: 4, width: 2 }) }, color2)) }),
|
|
33599
|
+
participants.map((participant2, index) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("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)),
|
|
33600
|
+
blocks && messages.map((message, index) => {
|
|
33601
|
+
const serviceColor = getServiceColor(message.span.service_name);
|
|
33602
|
+
const selected = message.span.span_id === selectedSpanId;
|
|
33603
|
+
const boxY = top(index) + ARROW_Y - BLOCK_OVERHANG;
|
|
33604
|
+
const boxHeight = endY(message) - boxY;
|
|
33605
|
+
const box = { ...blockRect(boxHeight), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x: blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 };
|
|
33606
|
+
const hatch = (earlier) => ({
|
|
33607
|
+
...blockRect(boxHeight + 2 * HATCH_MARGIN),
|
|
33608
|
+
// A pixel wider on each side, over the outer block's border: the hatch has none.
|
|
33609
|
+
width: BLOCK_WIDTH + 2,
|
|
33610
|
+
x: blockX(earlier.to, earlier.depth, blockOffset) - BLOCK_WIDTH / 2 - 1
|
|
33611
|
+
});
|
|
33612
|
+
const outer = hatched ? messages.slice(0, index).filter((earlier) => earlier.to === message.to && earlier.endRow >= index && earlier.depth < message.depth) : [];
|
|
33613
|
+
return (
|
|
33614
|
+
// Paper first, so the tint over it stays opaque to the lifeline.
|
|
33615
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { style: slideTo(boxY, isEntering(message.span.span_id)), children: [
|
|
33616
|
+
outer.map((earlier) => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { transform: `translate(0 ${String(-HATCH_MARGIN)})`, children: [
|
|
33617
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: theme.palette.background.paper, ...hatch(earlier) }),
|
|
33618
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: `url(#${hatchId(getServiceColor(earlier.span.service_name))})`, rx: BLOCK_RADIUS, ...hatch(earlier) })
|
|
33619
|
+
] }, earlier.span.span_id)),
|
|
33620
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { ...box, fill: theme.palette.background.paper }),
|
|
33621
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33622
|
+
"rect",
|
|
33623
|
+
{
|
|
33624
|
+
...box,
|
|
33625
|
+
fill: (0, import_styles5.alpha)(serviceColor, selected ? 0.5 : 0.2),
|
|
33626
|
+
stroke: message.error ? theme.palette.error.main : serviceColor,
|
|
33627
|
+
strokeWidth: selected ? 1.5 : 1
|
|
33628
|
+
}
|
|
33629
|
+
)
|
|
33630
|
+
] }, message.span.span_id)
|
|
33631
|
+
);
|
|
33632
|
+
}),
|
|
33633
|
+
merged && mergedBlocks.map(({ bottom, members, top: blockTop }) => {
|
|
33634
|
+
const [firstMember] = members;
|
|
33635
|
+
if (!firstMember) return;
|
|
33636
|
+
const serviceColor = getServiceColor(firstMember.span.service_name);
|
|
33637
|
+
const x = lifelineX(firstMember.to) - BLOCK_WIDTH / 2;
|
|
33638
|
+
const range = (member2) => ({ ...blockRect(endY(member2) - blockY(member2)), transform: `translate(0 ${String(blockY(member2) - blockTop)})`, width: BLOCK_WIDTH, x });
|
|
33639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { style: slideTo(blockTop), children: [
|
|
33640
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: theme.palette.background.paper, ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x }),
|
|
33641
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(serviceColor, 0.2), ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, stroke: serviceColor, width: BLOCK_WIDTH, x }),
|
|
33642
|
+
members.filter((member2) => member2.span.span_id === selectedSpanId).map((member2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(serviceColor, 0.35), rx: BLOCK_RADIUS, ...range(member2) }, member2.span.span_id)),
|
|
33643
|
+
members.filter((member2) => member2.error).map((member2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: "none", rx: BLOCK_RADIUS, stroke: theme.palette.error.main, ...range(member2) }, member2.span.span_id))
|
|
33644
|
+
] }, firstMember.span.span_id);
|
|
33645
|
+
}),
|
|
33646
|
+
messages.filter((message) => hasReturn(message)).map((message) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(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)),
|
|
33647
|
+
messages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33648
|
+
Arrow,
|
|
33649
|
+
{
|
|
33650
|
+
blockOffset,
|
|
33651
|
+
blockWidth,
|
|
33652
|
+
color: message.error ? theme.palette.error.main : theme.palette.text.secondary,
|
|
33653
|
+
entering: isEntering(message.span.span_id),
|
|
33654
|
+
message,
|
|
33655
|
+
top: top(index)
|
|
33656
|
+
},
|
|
33657
|
+
message.span.span_id
|
|
33658
|
+
))
|
|
33659
|
+
] }) })
|
|
33660
|
+
] })
|
|
33661
|
+
] }), [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]);
|
|
33662
|
+
if (spans.length === 0) {
|
|
33663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { p: 2 }, variant: "body2", children: "No operations in this trace." });
|
|
33664
|
+
}
|
|
33665
|
+
const view = { height: scrollView.height / zoom - HEADER_HEIGHT, width: scrollView.width / zoom, x: scrollView.left / zoom, y: scrollView.top / zoom };
|
|
33666
|
+
const minimapScale = Math.min((MINIMAP_WIDTH - 16) / width, Math.min(MINIMAP_MAX_HEIGHT, scrollView.height * MINIMAP_MAX_VIEW_SHARE) / bodyHeight);
|
|
33667
|
+
const minimap = scrollView.width > 0 && (view.width < width || view.height < bodyHeight) ? { scale: minimapScale, view } : void 0;
|
|
33668
|
+
const panTo = (event) => {
|
|
33669
|
+
const element = scrollRef.current;
|
|
33670
|
+
if (!element) return;
|
|
33671
|
+
const bounds = event.currentTarget.querySelector("svg")?.getBoundingClientRect();
|
|
33672
|
+
if (!bounds) return;
|
|
33673
|
+
element.scrollLeft = ((event.clientX - bounds.left) / minimapScale - view.width / 2) * zoom;
|
|
33674
|
+
element.scrollTop = ((event.clientY - bounds.top) / minimapScale - view.height / 2) * zoom;
|
|
33675
|
+
};
|
|
33676
|
+
const fitWidth = () => {
|
|
33677
|
+
const viewWidth = scrollRef.current?.clientWidth;
|
|
33678
|
+
if (viewWidth) zoomTo(viewWidth / width, 0, 0);
|
|
33679
|
+
};
|
|
33680
|
+
return (
|
|
33681
|
+
// The diagram scrolls in a box of its own, so the zoom controls stay put over it.
|
|
33682
|
+
// Its own stacking context: the header's and the widget's z-indexes order them within the
|
|
33683
|
+
// diagram only, never over the sidebar's resize handles.
|
|
33684
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { ref: areaRef, sx: { flex: 1, height: "100%", isolation: "isolate", minHeight: 0, position: "relative" }, children: [
|
|
33685
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { onScroll: measureView, ref: scrollRef, sx: { inset: 0, overflow: "auto", position: "absolute" }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { "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: [
|
|
33686
|
+
drawing,
|
|
33687
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { height: BOTTOM_ROOM / zoom } })
|
|
33688
|
+
] }) }),
|
|
33689
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Paper, { 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: [
|
|
33690
|
+
minimap && // A thin bar with only a chevron: down folds the minimap away, up brings it back.
|
|
33691
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33692
|
+
import_material27.ButtonBase,
|
|
33693
|
+
{
|
|
33694
|
+
"aria-expanded": minimapOpen,
|
|
33695
|
+
"aria-label": minimapOpen ? "Hide the overview" : "Show the overview",
|
|
33696
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID,
|
|
33697
|
+
onClick: () => {
|
|
33698
|
+
setMinimapOpen(!minimapOpen);
|
|
33699
|
+
},
|
|
33700
|
+
sx: { "&:hover": { color: "text.primary" }, "borderBottom": 1, "borderColor": "divider", "color": "text.secondary", "height": 14, "width": "100%" },
|
|
33701
|
+
children: minimapOpen ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowDown, { sx: { fontSize: 16 } }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowUp, { sx: { fontSize: 16 } })
|
|
33702
|
+
}
|
|
33703
|
+
),
|
|
33704
|
+
minimap && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Collapse, { in: minimapOpen, unmountOnExit: true, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
33705
|
+
import_material27.Box,
|
|
33706
|
+
{
|
|
33707
|
+
"aria-label": "Minimap",
|
|
33708
|
+
"data-testid": SEQUENCE_DIAGRAM_MINIMAP_TEST_ID,
|
|
33709
|
+
onPointerDown: (event) => {
|
|
33710
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
33711
|
+
panTo(event);
|
|
33712
|
+
},
|
|
33713
|
+
onPointerMove: (event) => {
|
|
33714
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) panTo(event);
|
|
33715
|
+
},
|
|
33716
|
+
role: "navigation",
|
|
33717
|
+
sx: { backgroundColor: "action.hover", borderBottom: 1, borderColor: "divider", cursor: "pointer", display: "flex", justifyContent: "center", lineHeight: 0, p: 1, touchAction: "none" },
|
|
33718
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("svg", { height: bodyHeight * minimap.scale, style: { backgroundColor: theme.palette.background.paper }, viewBox: `0 0 ${String(width)} ${String(bodyHeight)}`, width: width * minimap.scale, children: [
|
|
33719
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("use", { href: `#${bodyId}` }),
|
|
33720
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(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 })
|
|
33721
|
+
] })
|
|
33722
|
+
}
|
|
33723
|
+
) }),
|
|
33724
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { sx: { alignItems: "center", display: "flex", justifyContent: "space-between", px: "2px" }, children: [
|
|
33725
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Zoom out (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Zoom out", "data-testid": SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID, disabled: zoom <= MIN_ZOOM, onClick: () => {
|
|
33726
|
+
zoomTo(zoom / ZOOM_STEP);
|
|
33727
|
+
}, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.ZoomOut, { fontSize: "small" }) }) }),
|
|
33728
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Reset zoom", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.ButtonBase, { "data-testid": SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID, onClick: () => {
|
|
33729
|
+
zoomTo(1);
|
|
33730
|
+
}, sx: { borderRadius: 1, fontSize: 12, fontVariantNumeric: "tabular-nums", minWidth: 40, py: "2px" }, children: `${String(Math.round(zoom * 100))}%` }) }),
|
|
33731
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Zoom in (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Zoom in", "data-testid": SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID, disabled: zoom >= MAX_ZOOM, onClick: () => {
|
|
33732
|
+
zoomTo(zoom * ZOOM_STEP);
|
|
33733
|
+
}, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.ZoomIn, { fontSize: "small" }) }) }),
|
|
33734
|
+
/* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Fit the width", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Fit the width", "data-testid": SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID, onClick: fitWidth, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.FitScreen, { fontSize: "small" }) }) })
|
|
33735
|
+
] })
|
|
33736
|
+
] }),
|
|
33737
|
+
hoverCard && hoveredMessage && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ArrowHoverCard, { hover: { ...hover, message: hoveredMessage } })
|
|
33738
|
+
] })
|
|
33739
|
+
);
|
|
33740
|
+
};
|
|
33741
|
+
|
|
33742
|
+
// src/components/trace-panel/trace-sidebar.tsx
|
|
33743
|
+
var import_jsx_runtime152 = require("react/jsx-runtime");
|
|
32949
33744
|
var DEFAULT_WIDTH_SHARE = 0.75;
|
|
32950
33745
|
var MAX_WIDTH_SHARE = 0.8;
|
|
32951
33746
|
var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
|
|
@@ -32966,22 +33761,16 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
32966
33761
|
const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
|
|
32967
33762
|
const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
|
|
32968
33763
|
const [storedView, setView] = useLocalStorage(VIEW_STORAGE_KEY, "map");
|
|
32969
|
-
const view = storedView === "waterfall"
|
|
32970
|
-
const sidebarRef =
|
|
32971
|
-
const traceViewRef =
|
|
33764
|
+
const view = storedView === "waterfall" || storedView === "sequence" ? storedView : "map";
|
|
33765
|
+
const sidebarRef = React127.useRef(null);
|
|
33766
|
+
const traceViewRef = React127.useRef(null);
|
|
32972
33767
|
const width = maximized ? 1 : storedWidth;
|
|
32973
|
-
const [
|
|
32974
|
-
|
|
32975
|
-
|
|
32976
|
-
|
|
32977
|
-
|
|
32978
|
-
|
|
32979
|
-
});
|
|
32980
|
-
observer.observe(parent);
|
|
32981
|
-
return () => {
|
|
32982
|
-
observer.disconnect();
|
|
32983
|
-
};
|
|
32984
|
-
}, []);
|
|
33768
|
+
const [requestedTab, setRequestedTab] = React127.useState();
|
|
33769
|
+
const selectFromSequence = React127.useCallback((spanId, view2) => {
|
|
33770
|
+
onSelectSpan(spanId);
|
|
33771
|
+
setRequestedTab({ view: view2 });
|
|
33772
|
+
}, [onSelectSpan]);
|
|
33773
|
+
const parentWidth = useContentWidth(sidebarRef, true);
|
|
32985
33774
|
const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
|
|
32986
33775
|
const resize = (share) => {
|
|
32987
33776
|
const snap = share > SNAP_WIDTH_SHARE;
|
|
@@ -33020,7 +33809,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33020
33809
|
event.preventDefault();
|
|
33021
33810
|
setStoredSplit(clampSplit(storedSplit + delta));
|
|
33022
33811
|
};
|
|
33023
|
-
const { root: root2, selectedSpan, stats } =
|
|
33812
|
+
const { root: root2, selectedSpan, stats } = React127.useMemo(() => {
|
|
33024
33813
|
const tree = buildTraceTree(spans);
|
|
33025
33814
|
const issues = spans.map((span) => getSpanIssues(span));
|
|
33026
33815
|
return {
|
|
@@ -33034,7 +33823,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33034
33823
|
};
|
|
33035
33824
|
}, [spans, selectedSpanId]);
|
|
33036
33825
|
const rootSpanId = root2?.span_id;
|
|
33037
|
-
|
|
33826
|
+
React127.useEffect(() => {
|
|
33038
33827
|
if (!onRequestRendered || rootSpanId === void 0) return;
|
|
33039
33828
|
let frame2 = requestAnimationFrame(() => {
|
|
33040
33829
|
frame2 = requestAnimationFrame(() => {
|
|
@@ -33045,8 +33834,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33045
33834
|
cancelAnimationFrame(frame2);
|
|
33046
33835
|
};
|
|
33047
33836
|
}, [onRequestRendered, rootSpanId, view]);
|
|
33048
|
-
return /* @__PURE__ */ (0,
|
|
33049
|
-
|
|
33837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
|
|
33838
|
+
import_material28.Box,
|
|
33050
33839
|
{
|
|
33051
33840
|
"data-testid": TRACE_SIDEBAR_TEST_ID,
|
|
33052
33841
|
ref: sidebarRef,
|
|
@@ -33068,8 +33857,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33068
33857
|
width: `${String(width * 100)}%`
|
|
33069
33858
|
},
|
|
33070
33859
|
children: [
|
|
33071
|
-
/* @__PURE__ */ (0,
|
|
33072
|
-
|
|
33860
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
|
|
33861
|
+
import_material28.Box,
|
|
33073
33862
|
{
|
|
33074
33863
|
"aria-label": "Resize the sidebar",
|
|
33075
33864
|
"aria-orientation": "vertical",
|
|
@@ -33097,14 +33886,14 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33097
33886
|
tabIndex: 0
|
|
33098
33887
|
}
|
|
33099
33888
|
),
|
|
33100
|
-
/* @__PURE__ */ (0,
|
|
33101
|
-
root2 === void 0 ? /* @__PURE__ */ (0,
|
|
33889
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_material28.Box, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
|
|
33890
|
+
root2 === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
|
|
33102
33891
|
OperationIdentity,
|
|
33103
33892
|
{
|
|
33104
33893
|
arn: root2.arn,
|
|
33105
33894
|
density: "heading",
|
|
33106
33895
|
label: "Request",
|
|
33107
|
-
operation: /* @__PURE__ */ (0,
|
|
33896
|
+
operation: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(OperationName, { span: root2 }),
|
|
33108
33897
|
resourceName: root2.resource_name,
|
|
33109
33898
|
service: root2.service_name,
|
|
33110
33899
|
sx: { flex: 1 },
|
|
@@ -33118,8 +33907,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33118
33907
|
].join(" \xB7 ")
|
|
33119
33908
|
}
|
|
33120
33909
|
),
|
|
33121
|
-
/* @__PURE__ */ (0,
|
|
33122
|
-
|
|
33910
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
|
|
33911
|
+
import_material28.ToggleButtonGroup,
|
|
33123
33912
|
{
|
|
33124
33913
|
"aria-label": "Trace view",
|
|
33125
33914
|
exclusive: true,
|
|
@@ -33131,28 +33920,33 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33131
33920
|
size: "small",
|
|
33132
33921
|
value: view,
|
|
33133
33922
|
children: [
|
|
33134
|
-
/* @__PURE__ */ (0,
|
|
33135
|
-
/* @__PURE__ */ (0,
|
|
33923
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
|
|
33924
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" }),
|
|
33925
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "sequence", children: "Sequence" })
|
|
33136
33926
|
]
|
|
33137
33927
|
}
|
|
33138
33928
|
),
|
|
33139
|
-
/* @__PURE__ */ (0,
|
|
33929
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.IconButton, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
|
|
33140
33930
|
setMaximized(!maximized);
|
|
33141
|
-
}, size: "small", children: maximized ? /* @__PURE__ */ (0,
|
|
33142
|
-
/* @__PURE__ */ (0,
|
|
33931
|
+
}, size: "small", children: maximized ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.OpenInFull, { fontSize: "small" }) }),
|
|
33932
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.IconButton, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.Close, {}) })
|
|
33143
33933
|
] }),
|
|
33144
|
-
/* @__PURE__ */ (0,
|
|
33145
|
-
|
|
33146
|
-
{
|
|
33147
|
-
|
|
33148
|
-
|
|
33149
|
-
|
|
33150
|
-
|
|
33151
|
-
|
|
33152
|
-
|
|
33153
|
-
|
|
33154
|
-
|
|
33155
|
-
|
|
33934
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_material28.Box, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: [
|
|
33935
|
+
view === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }),
|
|
33936
|
+
view === "sequence" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(SequenceDiagram, { onSelectSpan: selectFromSequence, selectedSpanId, spans }),
|
|
33937
|
+
view === "map" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_react64.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
|
|
33938
|
+
TraceGraph,
|
|
33939
|
+
{
|
|
33940
|
+
hideMiniMap: true,
|
|
33941
|
+
initialFocusEventId: selectedSpanId,
|
|
33942
|
+
onEventSelect: onSelectSpan,
|
|
33943
|
+
onRefresh: noop,
|
|
33944
|
+
spans: { data: spans, error: void 0, loading: false }
|
|
33945
|
+
}
|
|
33946
|
+
) }) })
|
|
33947
|
+
] }),
|
|
33948
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
|
|
33949
|
+
import_material28.Box,
|
|
33156
33950
|
{
|
|
33157
33951
|
"aria-label": "Resize the operation details",
|
|
33158
33952
|
"aria-orientation": "horizontal",
|
|
@@ -33180,18 +33974,18 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
|
|
|
33180
33974
|
tabIndex: 0
|
|
33181
33975
|
}
|
|
33182
33976
|
) }),
|
|
33183
|
-
/* @__PURE__ */ (0,
|
|
33977
|
+
/* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(EventDetails, { onOperationShown, requestedTab, selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33184
33978
|
]
|
|
33185
33979
|
}
|
|
33186
33980
|
);
|
|
33187
33981
|
};
|
|
33188
33982
|
|
|
33189
33983
|
// src/components/worker-error-message/worker-error-message.tsx
|
|
33190
|
-
var
|
|
33191
|
-
var
|
|
33192
|
-
var
|
|
33193
|
-
var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0,
|
|
33194
|
-
|
|
33984
|
+
var import_icons_material17 = require("@mui/icons-material");
|
|
33985
|
+
var import_material29 = require("@mui/material");
|
|
33986
|
+
var import_jsx_runtime153 = require("react/jsx-runtime");
|
|
33987
|
+
var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
|
|
33988
|
+
import_material29.Box,
|
|
33195
33989
|
{
|
|
33196
33990
|
sx: {
|
|
33197
33991
|
alignItems: "center",
|
|
@@ -33201,18 +33995,18 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_
|
|
|
33201
33995
|
justifyContent: "center",
|
|
33202
33996
|
p: 4
|
|
33203
33997
|
},
|
|
33204
|
-
children: /* @__PURE__ */ (0,
|
|
33205
|
-
|
|
33998
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
|
|
33999
|
+
import_material29.Alert,
|
|
33206
34000
|
{
|
|
33207
|
-
icon: /* @__PURE__ */ (0,
|
|
34001
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_icons_material17.ErrorOutline, { fontSize: "large" }),
|
|
33208
34002
|
severity: "error",
|
|
33209
34003
|
sx: { maxWidth: 600, width: "100%" },
|
|
33210
34004
|
children: [
|
|
33211
|
-
/* @__PURE__ */ (0,
|
|
33212
|
-
/* @__PURE__ */ (0,
|
|
33213
|
-
/* @__PURE__ */ (0,
|
|
33214
|
-
onRetry && /* @__PURE__ */ (0,
|
|
33215
|
-
|
|
34005
|
+
/* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.AlertTitle, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
|
|
34006
|
+
/* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Typography, { 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." }),
|
|
34007
|
+
/* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Typography, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
|
|
34008
|
+
onRetry && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Box, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
|
|
34009
|
+
import_material29.Button,
|
|
33216
34010
|
{
|
|
33217
34011
|
"aria-label": "Retry starting the spans filter worker",
|
|
33218
34012
|
onClick: onRetry,
|
|
@@ -33227,7 +34021,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_
|
|
|
33227
34021
|
);
|
|
33228
34022
|
|
|
33229
34023
|
// src/hooks/use-filter-used-analytics.ts
|
|
33230
|
-
var
|
|
34024
|
+
var import_react65 = require("react");
|
|
33231
34025
|
var FILTER_KEYS = {
|
|
33232
34026
|
consumer: "service",
|
|
33233
34027
|
producer: "producer",
|
|
@@ -33254,11 +34048,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
|
|
|
33254
34048
|
var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
|
|
33255
34049
|
const api = useAppInspectorApi();
|
|
33256
34050
|
const { deploymentContainer } = useAppInspector();
|
|
33257
|
-
const previousQueryRef = (0,
|
|
33258
|
-
const pendingRef = (0,
|
|
33259
|
-
const changeCountRef = (0,
|
|
33260
|
-
const [settledChange, setSettledChange] = (0,
|
|
33261
|
-
(0,
|
|
34051
|
+
const previousQueryRef = (0, import_react65.useRef)(query2);
|
|
34052
|
+
const pendingRef = (0, import_react65.useRef)();
|
|
34053
|
+
const changeCountRef = (0, import_react65.useRef)(0);
|
|
34054
|
+
const [settledChange, setSettledChange] = (0, import_react65.useState)(0);
|
|
34055
|
+
(0, import_react65.useEffect)(() => {
|
|
33262
34056
|
const previous = parseQuery(previousQueryRef.current);
|
|
33263
34057
|
const next = parseQuery(query2);
|
|
33264
34058
|
previousQueryRef.current = query2;
|
|
@@ -33281,7 +34075,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33281
34075
|
clearTimeout(timer);
|
|
33282
34076
|
};
|
|
33283
34077
|
}, [query2]);
|
|
33284
|
-
(0,
|
|
34078
|
+
(0, import_react65.useEffect)(() => {
|
|
33285
34079
|
const pending = pendingRef.current;
|
|
33286
34080
|
if (pending === void 0 || filteredCount === void 0) {
|
|
33287
34081
|
return;
|
|
@@ -33327,7 +34121,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33327
34121
|
};
|
|
33328
34122
|
|
|
33329
34123
|
// src/hooks/use-operation-open-analytics.ts
|
|
33330
|
-
var
|
|
34124
|
+
var import_react66 = require("react");
|
|
33331
34125
|
|
|
33332
34126
|
// src/utils/request-id.ts
|
|
33333
34127
|
var getRequestId = (spans) => {
|
|
@@ -33347,8 +34141,8 @@ var getRequestId = (spans) => {
|
|
|
33347
34141
|
var useOperationOpenAnalytics = ({ open, shown, spans }) => {
|
|
33348
34142
|
const api = useAppInspectorApi();
|
|
33349
34143
|
const { deploymentContainer } = useAppInspector();
|
|
33350
|
-
const shownKeyRef = (0,
|
|
33351
|
-
(0,
|
|
34144
|
+
const shownKeyRef = (0, import_react66.useRef)();
|
|
34145
|
+
(0, import_react66.useEffect)(() => {
|
|
33352
34146
|
const shownKey = open && shown ? `${shown.span.span_id}
|
|
33353
34147
|
${shown.view}` : void 0;
|
|
33354
34148
|
const previousKey = shownKeyRef.current;
|
|
@@ -33374,12 +34168,12 @@ ${shown.view}` : void 0;
|
|
|
33374
34168
|
};
|
|
33375
34169
|
|
|
33376
34170
|
// src/hooks/use-request-open-analytics.ts
|
|
33377
|
-
var
|
|
34171
|
+
var import_react67 = require("react");
|
|
33378
34172
|
var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
33379
34173
|
const api = useAppInspectorApi();
|
|
33380
34174
|
const { deploymentContainer } = useAppInspector();
|
|
33381
|
-
const firedForRef = (0,
|
|
33382
|
-
(0,
|
|
34175
|
+
const firedForRef = (0, import_react67.useRef)();
|
|
34176
|
+
(0, import_react67.useEffect)(() => {
|
|
33383
34177
|
if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
|
|
33384
34178
|
return;
|
|
33385
34179
|
}
|
|
@@ -33410,7 +34204,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
|
33410
34204
|
};
|
|
33411
34205
|
|
|
33412
34206
|
// src/hooks/use-spans.ts
|
|
33413
|
-
var
|
|
34207
|
+
var import_react70 = require("react");
|
|
33414
34208
|
var import_react_dom2 = require("react-dom");
|
|
33415
34209
|
|
|
33416
34210
|
// src/utils/pagination-buffer.ts
|
|
@@ -33665,7 +34459,7 @@ var toSpanFilterProjection = (span) => ({
|
|
|
33665
34459
|
});
|
|
33666
34460
|
|
|
33667
34461
|
// src/hooks/use-spans-compute.ts
|
|
33668
|
-
var
|
|
34462
|
+
var import_react68 = require("react");
|
|
33669
34463
|
|
|
33670
34464
|
// inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
|
|
33671
34465
|
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';
|
|
@@ -33690,15 +34484,15 @@ var EMPTY_RESULT = {
|
|
|
33690
34484
|
};
|
|
33691
34485
|
var useSpansCompute = () => {
|
|
33692
34486
|
const { spansWorkerUrl } = useAppInspector();
|
|
33693
|
-
const [computeState, setComputeState] = (0,
|
|
34487
|
+
const [computeState, setComputeState] = (0, import_react68.useState)({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
|
|
33694
34488
|
const { loaded, result, resultVersion } = computeState;
|
|
33695
|
-
const [workerError, setWorkerError] = (0,
|
|
33696
|
-
const [retryCount, setRetryCount] = (0,
|
|
33697
|
-
const workerRef = (0,
|
|
33698
|
-
const seqRef = (0,
|
|
33699
|
-
const lastAppliedRef = (0,
|
|
33700
|
-
const firstPageSeqRef = (0,
|
|
33701
|
-
(0,
|
|
34489
|
+
const [workerError, setWorkerError] = (0, import_react68.useState)();
|
|
34490
|
+
const [retryCount, setRetryCount] = (0, import_react68.useState)(0);
|
|
34491
|
+
const workerRef = (0, import_react68.useRef)();
|
|
34492
|
+
const seqRef = (0, import_react68.useRef)(0);
|
|
34493
|
+
const lastAppliedRef = (0, import_react68.useRef)(0);
|
|
34494
|
+
const firstPageSeqRef = (0, import_react68.useRef)();
|
|
34495
|
+
(0, import_react68.useEffect)(() => {
|
|
33702
34496
|
try {
|
|
33703
34497
|
const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
|
|
33704
34498
|
worker.addEventListener("message", (event) => {
|
|
@@ -33725,26 +34519,26 @@ var useSpansCompute = () => {
|
|
|
33725
34519
|
return;
|
|
33726
34520
|
}
|
|
33727
34521
|
}, [retryCount, spansWorkerUrl]);
|
|
33728
|
-
const retryWorker = (0,
|
|
34522
|
+
const retryWorker = (0, import_react68.useCallback)(() => {
|
|
33729
34523
|
setWorkerError(void 0);
|
|
33730
34524
|
setRetryCount((count2) => count2 + 1);
|
|
33731
34525
|
}, []);
|
|
33732
|
-
const addPage = (0,
|
|
34526
|
+
const addPage = (0, import_react68.useCallback)((direction, projections) => {
|
|
33733
34527
|
const seq = ++seqRef.current;
|
|
33734
34528
|
firstPageSeqRef.current ??= seq;
|
|
33735
34529
|
workerRef.current?.postMessage({ direction, op: "addPage", projections, seq });
|
|
33736
34530
|
}, []);
|
|
33737
|
-
const setQuery = (0,
|
|
34531
|
+
const setQuery = (0, import_react68.useCallback)((query2, textMatches) => {
|
|
33738
34532
|
workerRef.current?.postMessage({ op: "setQuery", query: query2, seq: ++seqRef.current, textMatches });
|
|
33739
34533
|
}, []);
|
|
33740
|
-
const clear = (0,
|
|
34534
|
+
const clear = (0, import_react68.useCallback)(() => {
|
|
33741
34535
|
workerRef.current?.postMessage({ op: "clear", seq: ++seqRef.current });
|
|
33742
34536
|
}, []);
|
|
33743
34537
|
return { addPage, clear, loaded, result, resultVersion, retryWorker, setQuery, workerError };
|
|
33744
34538
|
};
|
|
33745
34539
|
|
|
33746
34540
|
// src/hooks/use-spans-ws.tsx
|
|
33747
|
-
var
|
|
34541
|
+
var import_react69 = require("react");
|
|
33748
34542
|
var wsLogger = createScopedLogger("WS");
|
|
33749
34543
|
var isLegacySpanFields = (value) => {
|
|
33750
34544
|
return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
|
|
@@ -33776,22 +34570,22 @@ var parseSpansWebSocketMessage = (raw) => {
|
|
|
33776
34570
|
};
|
|
33777
34571
|
function useSpansWebSocket(options) {
|
|
33778
34572
|
const { enabled, onClose, onMessage, onOpen } = options;
|
|
33779
|
-
const onMessageRef = (0,
|
|
33780
|
-
const onOpenRef = (0,
|
|
33781
|
-
const onCloseRef = (0,
|
|
33782
|
-
(0,
|
|
34573
|
+
const onMessageRef = (0, import_react69.useRef)(onMessage);
|
|
34574
|
+
const onOpenRef = (0, import_react69.useRef)(onOpen);
|
|
34575
|
+
const onCloseRef = (0, import_react69.useRef)(onClose);
|
|
34576
|
+
(0, import_react69.useEffect)(() => {
|
|
33783
34577
|
onMessageRef.current = onMessage;
|
|
33784
34578
|
}, [onMessage]);
|
|
33785
|
-
(0,
|
|
34579
|
+
(0, import_react69.useEffect)(() => {
|
|
33786
34580
|
onOpenRef.current = onOpen;
|
|
33787
34581
|
}, [onOpen]);
|
|
33788
|
-
(0,
|
|
34582
|
+
(0, import_react69.useEffect)(() => {
|
|
33789
34583
|
onCloseRef.current = onClose;
|
|
33790
34584
|
}, [onClose]);
|
|
33791
|
-
const [connected, setConnected] = (0,
|
|
33792
|
-
const wsRef = (0,
|
|
34585
|
+
const [connected, setConnected] = (0, import_react69.useState)(false);
|
|
34586
|
+
const wsRef = (0, import_react69.useRef)(void 0);
|
|
33793
34587
|
const { localstackEndpoint } = useAppInspector();
|
|
33794
|
-
const connect = (0,
|
|
34588
|
+
const connect = (0, import_react69.useCallback)(() => {
|
|
33795
34589
|
if (wsRef.current !== void 0) return;
|
|
33796
34590
|
const url = new URL(getAppInspectorApiUrl(localstackEndpoint, API_ENDPOINTS.WEBSOCKET_SPANS));
|
|
33797
34591
|
url.protocol = globalThis.location.protocol === "https:" ? "wss" : "ws";
|
|
@@ -33832,7 +34626,7 @@ function useSpansWebSocket(options) {
|
|
|
33832
34626
|
}
|
|
33833
34627
|
});
|
|
33834
34628
|
}, [localstackEndpoint]);
|
|
33835
|
-
(0,
|
|
34629
|
+
(0, import_react69.useEffect)(() => {
|
|
33836
34630
|
if (!enabled) {
|
|
33837
34631
|
if (wsRef.current !== void 0) {
|
|
33838
34632
|
wsRef.current.close();
|
|
@@ -33875,42 +34669,42 @@ var useSpans = () => {
|
|
|
33875
34669
|
const api = useAppInspectorApi();
|
|
33876
34670
|
const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
|
|
33877
34671
|
const { addPage, clear: clearCompute, loaded: spansLoaded, result: computeResult, resultVersion, retryWorker, setQuery: setComputeQuery, workerError } = useSpansCompute();
|
|
33878
|
-
const spanMapRef = (0,
|
|
33879
|
-
const newSpanIdsRef = (0,
|
|
33880
|
-
const caughtUpRef = (0,
|
|
33881
|
-
const [fetchError, setFetchError] = (0,
|
|
33882
|
-
const [fetchingForward, setFetchingForward] = (0,
|
|
33883
|
-
const [fetchingBackward, setFetchingBackward] = (0,
|
|
33884
|
-
const [query2, setQueryState] = (0,
|
|
33885
|
-
const [searching, setSearching] = (0,
|
|
33886
|
-
const paginationBufferRef = (0,
|
|
33887
|
-
const [totalCount, setTotalCount] = (0,
|
|
33888
|
-
const [licenseLimit, setLicenseLimit] = (0,
|
|
33889
|
-
const [systemLimit, setSystemLimit] = (0,
|
|
33890
|
-
const [errorCount, setErrorCount] = (0,
|
|
33891
|
-
const [warningCount, setWarningCount] = (0,
|
|
33892
|
-
const [hasMoreBackward, setHasMoreBackward] = (0,
|
|
33893
|
-
const [hasMoreForward, setHasMoreForward] = (0,
|
|
33894
|
-
const fetchForward = (0,
|
|
34672
|
+
const spanMapRef = (0, import_react70.useRef)(/* @__PURE__ */ new Map());
|
|
34673
|
+
const newSpanIdsRef = (0, import_react70.useRef)(/* @__PURE__ */ new Set());
|
|
34674
|
+
const caughtUpRef = (0, import_react70.useRef)(false);
|
|
34675
|
+
const [fetchError, setFetchError] = (0, import_react70.useState)();
|
|
34676
|
+
const [fetchingForward, setFetchingForward] = (0, import_react70.useState)(false);
|
|
34677
|
+
const [fetchingBackward, setFetchingBackward] = (0, import_react70.useState)(false);
|
|
34678
|
+
const [query2, setQueryState] = (0, import_react70.useState)("");
|
|
34679
|
+
const [searching, setSearching] = (0, import_react70.useState)(false);
|
|
34680
|
+
const paginationBufferRef = (0, import_react70.useRef)();
|
|
34681
|
+
const [totalCount, setTotalCount] = (0, import_react70.useState)();
|
|
34682
|
+
const [licenseLimit, setLicenseLimit] = (0, import_react70.useState)();
|
|
34683
|
+
const [systemLimit, setSystemLimit] = (0, import_react70.useState)();
|
|
34684
|
+
const [errorCount, setErrorCount] = (0, import_react70.useState)();
|
|
34685
|
+
const [warningCount, setWarningCount] = (0, import_react70.useState)();
|
|
34686
|
+
const [hasMoreBackward, setHasMoreBackward] = (0, import_react70.useState)();
|
|
34687
|
+
const [hasMoreForward, setHasMoreForward] = (0, import_react70.useState)();
|
|
34688
|
+
const fetchForward = (0, import_react70.useCallback)(() => {
|
|
33895
34689
|
void paginationBufferRef.current?.fetchForward();
|
|
33896
34690
|
}, []);
|
|
33897
|
-
const fetchBackward = (0,
|
|
34691
|
+
const fetchBackward = (0, import_react70.useCallback)(() => {
|
|
33898
34692
|
void paginationBufferRef.current?.fetchBackward();
|
|
33899
34693
|
}, []);
|
|
33900
|
-
const resetCorpus = (0,
|
|
34694
|
+
const resetCorpus = (0, import_react70.useCallback)(() => {
|
|
33901
34695
|
spanMapRef.current.clear();
|
|
33902
34696
|
newSpanIdsRef.current.clear();
|
|
33903
34697
|
caughtUpRef.current = false;
|
|
33904
34698
|
clearCompute();
|
|
33905
34699
|
}, [clearCompute]);
|
|
33906
|
-
const [epoch, setEpoch] = (0,
|
|
33907
|
-
const onEpochSeen = (0,
|
|
34700
|
+
const [epoch, setEpoch] = (0, import_react70.useState)();
|
|
34701
|
+
const onEpochSeen = (0, import_react70.useCallback)((observedEpoch) => {
|
|
33908
34702
|
if (observedEpoch === null || observedEpoch === void 0) {
|
|
33909
34703
|
return;
|
|
33910
34704
|
}
|
|
33911
34705
|
setEpoch(observedEpoch);
|
|
33912
34706
|
}, []);
|
|
33913
|
-
const clearCache = (0,
|
|
34707
|
+
const clearCache = (0, import_react70.useCallback)(() => {
|
|
33914
34708
|
paginationBufferRef.current?.clear();
|
|
33915
34709
|
resetCorpus();
|
|
33916
34710
|
setTotalCount(void 0);
|
|
@@ -33918,9 +34712,9 @@ var useSpans = () => {
|
|
|
33918
34712
|
setWarningCount(void 0);
|
|
33919
34713
|
void paginationBufferRef.current?.fetchForward();
|
|
33920
34714
|
}, [resetCorpus]);
|
|
33921
|
-
const hasFetchedWithoutEpochRef = (0,
|
|
33922
|
-
const previousEpochRef = (0,
|
|
33923
|
-
(0,
|
|
34715
|
+
const hasFetchedWithoutEpochRef = (0, import_react70.useRef)(false);
|
|
34716
|
+
const previousEpochRef = (0, import_react70.useRef)();
|
|
34717
|
+
(0, import_react70.useEffect)(() => {
|
|
33924
34718
|
if (epoch === void 0) {
|
|
33925
34719
|
return;
|
|
33926
34720
|
}
|
|
@@ -33933,11 +34727,11 @@ var useSpans = () => {
|
|
|
33933
34727
|
}, [epoch, clearCache]);
|
|
33934
34728
|
const searchSupported = emulatorSupportsSearch(status?.localstackVersion);
|
|
33935
34729
|
const freeText = parseQuery(query2).words.join(" ");
|
|
33936
|
-
const setQuery = (0,
|
|
34730
|
+
const setQuery = (0, import_react70.useCallback)((next) => {
|
|
33937
34731
|
setQueryState(next);
|
|
33938
34732
|
setComputeQuery(next);
|
|
33939
34733
|
}, [setComputeQuery]);
|
|
33940
|
-
(0,
|
|
34734
|
+
(0, import_react70.useEffect)(() => {
|
|
33941
34735
|
if (!searchSupported || freeText === "") {
|
|
33942
34736
|
return;
|
|
33943
34737
|
}
|
|
@@ -33958,7 +34752,7 @@ var useSpans = () => {
|
|
|
33958
34752
|
setSearching(false);
|
|
33959
34753
|
};
|
|
33960
34754
|
}, [api, freeText, query2, searchSupported, setComputeQuery]);
|
|
33961
|
-
(0,
|
|
34755
|
+
(0, import_react70.useEffect)(() => {
|
|
33962
34756
|
const buffer = createPaginationBuffer({
|
|
33963
34757
|
async fetchPage(token, signal) {
|
|
33964
34758
|
const requestPage = async (paginationToken) => {
|
|
@@ -34029,8 +34823,8 @@ var useSpans = () => {
|
|
|
34029
34823
|
paginationBufferRef.current = buffer;
|
|
34030
34824
|
void buffer.fetchForward();
|
|
34031
34825
|
}, [api, addPage, onEpochSeen, resetCorpus]);
|
|
34032
|
-
const [clearingSpans, setClearingSpans] = (0,
|
|
34033
|
-
const clearSpans = (0,
|
|
34826
|
+
const [clearingSpans, setClearingSpans] = (0, import_react70.useState)(false);
|
|
34827
|
+
const clearSpans = (0, import_react70.useCallback)(async () => {
|
|
34034
34828
|
if (clearingSpans) {
|
|
34035
34829
|
return;
|
|
34036
34830
|
}
|
|
@@ -34048,17 +34842,17 @@ var useSpans = () => {
|
|
|
34048
34842
|
setClearingSpans(false);
|
|
34049
34843
|
}
|
|
34050
34844
|
}, [clearingSpans, api, resetCorpus]);
|
|
34051
|
-
(0,
|
|
34845
|
+
(0, import_react70.useEffect)(() => {
|
|
34052
34846
|
if (hasMoreForward === true && !fetchingForward) {
|
|
34053
34847
|
void paginationBufferRef.current?.fetchForward();
|
|
34054
34848
|
}
|
|
34055
34849
|
}, [hasMoreForward, fetchingForward]);
|
|
34056
|
-
(0,
|
|
34850
|
+
(0, import_react70.useEffect)(() => {
|
|
34057
34851
|
if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
|
|
34058
34852
|
void paginationBufferRef.current?.fetchBackward();
|
|
34059
34853
|
}
|
|
34060
34854
|
}, [hasMoreBackward, fetchingBackward, fetchingForward]);
|
|
34061
|
-
const [previousStatusEpoch, setPreviousStatusEpoch] = (0,
|
|
34855
|
+
const [previousStatusEpoch, setPreviousStatusEpoch] = (0, import_react70.useState)();
|
|
34062
34856
|
if (status !== void 0 && status.epoch !== previousStatusEpoch) {
|
|
34063
34857
|
setPreviousStatusEpoch(status.epoch);
|
|
34064
34858
|
onEpochSeen(status.epoch);
|
|
@@ -34083,10 +34877,10 @@ var useSpans = () => {
|
|
|
34083
34877
|
fetchForward();
|
|
34084
34878
|
}
|
|
34085
34879
|
});
|
|
34086
|
-
const clearFetchError = (0,
|
|
34880
|
+
const clearFetchError = (0, import_react70.useCallback)(() => {
|
|
34087
34881
|
setFetchError(void 0);
|
|
34088
34882
|
}, []);
|
|
34089
|
-
const getSpan = (0,
|
|
34883
|
+
const getSpan = (0, import_react70.useCallback)((spanId) => spanMapRef.current.get(spanId), []);
|
|
34090
34884
|
const newSpanIds = newSpanIdsRef.current;
|
|
34091
34885
|
return {
|
|
34092
34886
|
clearFetchError,
|
|
@@ -34118,7 +34912,8 @@ var useSpans = () => {
|
|
|
34118
34912
|
};
|
|
34119
34913
|
|
|
34120
34914
|
// src/pages/spans-list-page.tsx
|
|
34121
|
-
var
|
|
34915
|
+
var import_jsx_runtime154 = require("react/jsx-runtime");
|
|
34916
|
+
var ANALYTICS_REQUEST_VIEWS = { map: "flow_graph", sequence: "sequence_graph", waterfall: "operations" };
|
|
34122
34917
|
var SpansListPage = () => {
|
|
34123
34918
|
const api = useAppInspectorApi();
|
|
34124
34919
|
const {
|
|
@@ -34151,49 +34946,49 @@ var SpansListPage = () => {
|
|
|
34151
34946
|
resultVersion,
|
|
34152
34947
|
searching
|
|
34153
34948
|
});
|
|
34154
|
-
const clearSpansSync = (0,
|
|
34949
|
+
const clearSpansSync = (0, import_react71.useCallback)(() => {
|
|
34155
34950
|
void clearSpans();
|
|
34156
34951
|
}, [clearSpans]);
|
|
34157
34952
|
const localstackVersion = status?.localstackVersion ?? (statusError instanceof AppInspectorNotFoundError ? statusError.localstackVersion : void 0);
|
|
34158
34953
|
const versionCompatibility = checkEmulatorVersion(localstackVersion);
|
|
34159
|
-
const [bannerDismissed, setBannerDismissed] = (0,
|
|
34954
|
+
const [bannerDismissed, setBannerDismissed] = (0, import_react71.useState)(false);
|
|
34160
34955
|
const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
|
|
34161
|
-
const [selectedSpanId, setSelectedSpanId] = (0,
|
|
34162
|
-
const getTreeSpans = (0,
|
|
34163
|
-
const latestRef = (0,
|
|
34164
|
-
(0,
|
|
34956
|
+
const [selectedSpanId, setSelectedSpanId] = (0, import_react71.useState)();
|
|
34957
|
+
const getTreeSpans = (0, import_react71.useCallback)((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
|
|
34958
|
+
const latestRef = (0, import_react71.useRef)({ compute, getTreeSpans });
|
|
34959
|
+
(0, import_react71.useEffect)(() => {
|
|
34165
34960
|
latestRef.current = { compute, getTreeSpans };
|
|
34166
34961
|
}, [compute, getTreeSpans]);
|
|
34167
|
-
const openedAtRef = (0,
|
|
34168
|
-
const navigateToSpan = (0,
|
|
34962
|
+
const openedAtRef = (0, import_react71.useRef)();
|
|
34963
|
+
const navigateToSpan = (0, import_react71.useCallback)((span) => {
|
|
34169
34964
|
openedAtRef.current = performance.now();
|
|
34170
34965
|
const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
|
|
34171
34966
|
const rootSpanId2 = rows[span.span_id]?.rootSpanId;
|
|
34172
34967
|
const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
|
|
34173
34968
|
setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
|
|
34174
34969
|
}, []);
|
|
34175
|
-
const [shownOperation, setShownOperation] = (0,
|
|
34176
|
-
const closeSidebar = (0,
|
|
34970
|
+
const [shownOperation, setShownOperation] = (0, import_react71.useState)();
|
|
34971
|
+
const closeSidebar = (0, import_react71.useCallback)(() => {
|
|
34177
34972
|
setSelectedSpanId(void 0);
|
|
34178
34973
|
setShownOperation(void 0);
|
|
34179
34974
|
}, []);
|
|
34180
34975
|
const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
|
|
34181
|
-
const treeSpans = (0,
|
|
34182
|
-
const spanMatches = (0,
|
|
34976
|
+
const treeSpans = (0, import_react71.useMemo)(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
|
|
34977
|
+
const spanMatches = (0, import_react71.useMemo)(
|
|
34183
34978
|
() => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
|
|
34184
34979
|
[compute]
|
|
34185
34980
|
);
|
|
34186
|
-
const treeSpansRef = (0,
|
|
34187
|
-
(0,
|
|
34981
|
+
const treeSpansRef = (0, import_react71.useRef)(treeSpans);
|
|
34982
|
+
(0, import_react71.useEffect)(() => {
|
|
34188
34983
|
treeSpansRef.current = treeSpans;
|
|
34189
34984
|
}, [treeSpans]);
|
|
34190
|
-
const [renderedRequest, setRenderedRequest] = (0,
|
|
34191
|
-
const handleRequestRendered = (0,
|
|
34985
|
+
const [renderedRequest, setRenderedRequest] = (0, import_react71.useState)();
|
|
34986
|
+
const handleRequestRendered = (0, import_react71.useCallback)((view) => {
|
|
34192
34987
|
const openedAt = openedAtRef.current;
|
|
34193
34988
|
if (openedAt === void 0) return;
|
|
34194
|
-
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: view
|
|
34989
|
+
setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: ANALYTICS_REQUEST_VIEWS[view] });
|
|
34195
34990
|
}, []);
|
|
34196
|
-
const handleViewChange = (0,
|
|
34991
|
+
const handleViewChange = (0, import_react71.useCallback)(() => {
|
|
34197
34992
|
openedAtRef.current = performance.now();
|
|
34198
34993
|
}, []);
|
|
34199
34994
|
useRequestOpenAnalytics({
|
|
@@ -34202,28 +34997,28 @@ var SpansListPage = () => {
|
|
|
34202
34997
|
view: renderedRequest?.view ?? "operations"
|
|
34203
34998
|
});
|
|
34204
34999
|
const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
|
|
34205
|
-
const handleOperationShown = (0,
|
|
35000
|
+
const handleOperationShown = (0, import_react71.useCallback)((spanId, view) => {
|
|
34206
35001
|
setShownOperation({ spanId, view });
|
|
34207
35002
|
}, []);
|
|
34208
|
-
const shown = (0,
|
|
35003
|
+
const shown = (0, import_react71.useMemo)(() => {
|
|
34209
35004
|
if (shownOperation === void 0) return;
|
|
34210
35005
|
const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
|
|
34211
35006
|
return span && { span, view: shownOperation.view };
|
|
34212
35007
|
}, [shownOperation, treeSpans]);
|
|
34213
35008
|
useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
|
|
34214
|
-
const handleRetry = (0,
|
|
35009
|
+
const handleRetry = (0, import_react71.useCallback)(() => {
|
|
34215
35010
|
checkStatus();
|
|
34216
35011
|
fetchForward();
|
|
34217
35012
|
}, [checkStatus, fetchForward]);
|
|
34218
|
-
const handleEnable = (0,
|
|
35013
|
+
const handleEnable = (0, import_react71.useCallback)(async () => {
|
|
34219
35014
|
await api.setStatus({ status: "ENABLED" });
|
|
34220
35015
|
clearFetchError();
|
|
34221
35016
|
checkStatus();
|
|
34222
35017
|
}, [api, checkStatus, clearFetchError]);
|
|
34223
|
-
const isDelayedRefetchRef = (0,
|
|
34224
|
-
const delayedRefetchTimerRef = (0,
|
|
34225
|
-
const prevFetchingForwardRef = (0,
|
|
34226
|
-
(0,
|
|
35018
|
+
const isDelayedRefetchRef = (0, import_react71.useRef)(false);
|
|
35019
|
+
const delayedRefetchTimerRef = (0, import_react71.useRef)();
|
|
35020
|
+
const prevFetchingForwardRef = (0, import_react71.useRef)(false);
|
|
35021
|
+
(0, import_react71.useEffect)(() => {
|
|
34227
35022
|
const wasFetching = prevFetchingForwardRef.current;
|
|
34228
35023
|
prevFetchingForwardRef.current = fetchingForward;
|
|
34229
35024
|
if (wasFetching && !fetchingForward) {
|
|
@@ -34244,10 +35039,10 @@ var SpansListPage = () => {
|
|
|
34244
35039
|
switch (phase) {
|
|
34245
35040
|
case "CHECKING_STATUS":
|
|
34246
35041
|
case "CONNECTING_WS": {
|
|
34247
|
-
return /* @__PURE__ */ (0,
|
|
35042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(StatusMessage, { phase });
|
|
34248
35043
|
}
|
|
34249
35044
|
case "DISABLED": {
|
|
34250
|
-
return /* @__PURE__ */ (0,
|
|
35045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34251
35046
|
StatusMessage,
|
|
34252
35047
|
{
|
|
34253
35048
|
onEnable: handleEnable,
|
|
@@ -34256,7 +35051,7 @@ var SpansListPage = () => {
|
|
|
34256
35051
|
);
|
|
34257
35052
|
}
|
|
34258
35053
|
case "INCOMPATIBLE": {
|
|
34259
|
-
return /* @__PURE__ */ (0,
|
|
35054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34260
35055
|
StatusMessage,
|
|
34261
35056
|
{
|
|
34262
35057
|
localstackVersion,
|
|
@@ -34267,12 +35062,12 @@ var SpansListPage = () => {
|
|
|
34267
35062
|
}
|
|
34268
35063
|
case "LIVE": {
|
|
34269
35064
|
if (workerError) {
|
|
34270
|
-
return /* @__PURE__ */ (0,
|
|
35065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
|
|
34271
35066
|
}
|
|
34272
35067
|
break;
|
|
34273
35068
|
}
|
|
34274
35069
|
case "UNREACHABLE": {
|
|
34275
|
-
return /* @__PURE__ */ (0,
|
|
35070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34276
35071
|
StatusMessage,
|
|
34277
35072
|
{
|
|
34278
35073
|
onRetry: handleRetry,
|
|
@@ -34281,9 +35076,9 @@ var SpansListPage = () => {
|
|
|
34281
35076
|
);
|
|
34282
35077
|
}
|
|
34283
35078
|
}
|
|
34284
|
-
return /* @__PURE__ */ (0,
|
|
34285
|
-
/* @__PURE__ */ (0,
|
|
34286
|
-
|
|
35079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_material30.Paper, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
|
|
35080
|
+
/* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(
|
|
35081
|
+
import_material30.Box,
|
|
34287
35082
|
{
|
|
34288
35083
|
"data-testid": SPANS_LIST_PAGE_TEST_ID,
|
|
34289
35084
|
sx: {
|
|
@@ -34296,7 +35091,7 @@ var SpansListPage = () => {
|
|
|
34296
35091
|
overflow: "hidden"
|
|
34297
35092
|
},
|
|
34298
35093
|
children: [
|
|
34299
|
-
/* @__PURE__ */ (0,
|
|
35094
|
+
/* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34300
35095
|
EmulatorVersionBanner,
|
|
34301
35096
|
{
|
|
34302
35097
|
compatibility: bannerDismissed && versionCompatibility === "warning" ? "ok" : versionCompatibility,
|
|
@@ -34306,7 +35101,7 @@ var SpansListPage = () => {
|
|
|
34306
35101
|
} : void 0
|
|
34307
35102
|
}
|
|
34308
35103
|
),
|
|
34309
|
-
/* @__PURE__ */ (0,
|
|
35104
|
+
/* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34310
35105
|
SpansList,
|
|
34311
35106
|
{
|
|
34312
35107
|
clearingSpans,
|
|
@@ -34333,7 +35128,7 @@ var SpansListPage = () => {
|
|
|
34333
35128
|
]
|
|
34334
35129
|
}
|
|
34335
35130
|
),
|
|
34336
|
-
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ (0,
|
|
35131
|
+
selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
|
|
34337
35132
|
TraceSidebar,
|
|
34338
35133
|
{
|
|
34339
35134
|
onClose: closeSidebar,
|