@localstack/appinspector-ui 1.0.0-dev-f55daae2 → 1.0.0-dev-c7a4c87a
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 +70 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3454,7 +3454,7 @@ var SpansListPage = () => {
|
|
|
3454
3454
|
);
|
|
3455
3455
|
};
|
|
3456
3456
|
|
|
3457
|
-
// src/pages/trace-graph.tsx
|
|
3457
|
+
// src/pages/trace-graph-page.tsx
|
|
3458
3458
|
var import_material14 = require("@mui/material");
|
|
3459
3459
|
var import_styles = require("@mui/material/styles");
|
|
3460
3460
|
var import_react15 = require("@xyflow/react");
|
|
@@ -3875,17 +3875,15 @@ var nodeTypes = {
|
|
|
3875
3875
|
var TraceGraph = ({
|
|
3876
3876
|
initialFocusEventId,
|
|
3877
3877
|
onEventSelect,
|
|
3878
|
-
|
|
3878
|
+
onRefresh,
|
|
3879
|
+
spans,
|
|
3879
3880
|
viewPortPixelWidth
|
|
3880
3881
|
}) => {
|
|
3881
3882
|
const [nodes, setNodes] = (0, import_react14.useState)([]);
|
|
3882
3883
|
const [edges, setEdges] = (0, import_react14.useState)([]);
|
|
3883
|
-
const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
|
|
3884
3884
|
const [initialViewSet, setInitialViewSet] = (0, import_react14.useState)(false);
|
|
3885
3885
|
const { fitView, setCenter } = (0, import_react13.useReactFlow)();
|
|
3886
3886
|
const store = (0, import_react13.useStoreApi)();
|
|
3887
|
-
const api = useAppInspectorApi();
|
|
3888
|
-
const [fetchError, setFetchError] = (0, import_react14.useState)();
|
|
3889
3887
|
const updateSelectedNode = (0, import_react14.useCallback)(
|
|
3890
3888
|
(nodeId) => {
|
|
3891
3889
|
const { addSelectedNodes } = store.getState();
|
|
@@ -3898,57 +3896,40 @@ var TraceGraph = ({
|
|
|
3898
3896
|
},
|
|
3899
3897
|
[nodes, store]
|
|
3900
3898
|
);
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
const
|
|
3912
|
-
if (
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
if (parentSpan) {
|
|
3916
|
-
parentSpan.children ??= [];
|
|
3917
|
-
parentSpan.children.push(currentSpan);
|
|
3918
|
-
}
|
|
3919
|
-
} else {
|
|
3920
|
-
rootSpans.push(currentSpan);
|
|
3899
|
+
(0, import_react14.useEffect)(() => {
|
|
3900
|
+
const spansMap = /* @__PURE__ */ new Map();
|
|
3901
|
+
const rootSpans = [];
|
|
3902
|
+
for (const span of spans.data ?? []) {
|
|
3903
|
+
spansMap.set(span.span_id, { ...span, children: [] });
|
|
3904
|
+
}
|
|
3905
|
+
for (const span of spans.data ?? []) {
|
|
3906
|
+
const currentSpan = spansMap.get(span.span_id);
|
|
3907
|
+
if (!currentSpan) continue;
|
|
3908
|
+
if (span.parent_span_id && spansMap.has(span.parent_span_id)) {
|
|
3909
|
+
const parentSpan = spansMap.get(span.parent_span_id);
|
|
3910
|
+
if (parentSpan) {
|
|
3911
|
+
parentSpan.children ??= [];
|
|
3912
|
+
parentSpan.children.push(currentSpan);
|
|
3921
3913
|
}
|
|
3914
|
+
} else {
|
|
3915
|
+
rootSpans.push(currentSpan);
|
|
3922
3916
|
}
|
|
3923
|
-
let allNodes = [];
|
|
3924
|
-
let allEdges = [];
|
|
3925
|
-
for (const rootSpan of rootSpans) {
|
|
3926
|
-
const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan, (event) => {
|
|
3927
|
-
onEventSelect(event);
|
|
3928
|
-
});
|
|
3929
|
-
allNodes = [...allNodes, ...newNodes];
|
|
3930
|
-
allEdges = [...allEdges, ...newEdges];
|
|
3931
|
-
}
|
|
3932
|
-
const { edges: layoutedEdges, nodes: layoutedNodes } = getLayoutedNodesAndEdges(allNodes, allEdges);
|
|
3933
|
-
setNodes(layoutedNodes);
|
|
3934
|
-
setEdges(layoutedEdges);
|
|
3935
|
-
setIsLoading(false);
|
|
3936
|
-
setFetchError(void 0);
|
|
3937
|
-
} catch (error) {
|
|
3938
|
-
console.error("Error fetching trace:", error);
|
|
3939
|
-
setFetchError(error instanceof Error ? error : new Error("Unknown error", { cause: error }));
|
|
3940
|
-
} finally {
|
|
3941
|
-
setIsLoading(false);
|
|
3942
3917
|
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3918
|
+
let allNodes = [];
|
|
3919
|
+
let allEdges = [];
|
|
3920
|
+
for (const rootSpan of rootSpans) {
|
|
3921
|
+
const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan, (event) => {
|
|
3922
|
+
onEventSelect(event);
|
|
3923
|
+
});
|
|
3924
|
+
allNodes = [...allNodes, ...newNodes];
|
|
3925
|
+
allEdges = [...allEdges, ...newEdges];
|
|
3926
|
+
}
|
|
3927
|
+
const { edges: layoutedEdges, nodes: layoutedNodes } = getLayoutedNodesAndEdges(allNodes, allEdges);
|
|
3928
|
+
setNodes(layoutedNodes);
|
|
3929
|
+
setEdges(layoutedEdges);
|
|
3930
|
+
}, [onEventSelect, spans.data]);
|
|
3950
3931
|
(0, import_react14.useEffect)(() => {
|
|
3951
|
-
const shouldSetInitialView = !
|
|
3932
|
+
const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
|
|
3952
3933
|
if (shouldSetInitialView) {
|
|
3953
3934
|
if (initialFocusEventId) {
|
|
3954
3935
|
const focusNode = nodes.find((node) => node.id === initialFocusEventId);
|
|
@@ -3966,7 +3947,7 @@ var TraceGraph = ({
|
|
|
3966
3947
|
}
|
|
3967
3948
|
setInitialViewSet(true);
|
|
3968
3949
|
}
|
|
3969
|
-
}, [
|
|
3950
|
+
}, [spans.loading, nodes, initialFocusEventId, viewPortPixelWidth, setCenter, fitView, onEventSelect, initialViewSet]);
|
|
3970
3951
|
(0, import_react14.useEffect)(() => {
|
|
3971
3952
|
if (initialFocusEventId) {
|
|
3972
3953
|
updateSelectedNode(initialFocusEventId);
|
|
@@ -3977,15 +3958,17 @@ var TraceGraph = ({
|
|
|
3977
3958
|
updateSelectedNode(node.id);
|
|
3978
3959
|
}, [onEventSelect, updateSelectedNode]);
|
|
3979
3960
|
return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [
|
|
3980
|
-
|
|
3961
|
+
spans.error && /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
|
|
3981
3962
|
import_material13.Alert,
|
|
3982
3963
|
{
|
|
3983
|
-
action: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_material13.Button, { onClick:
|
|
3964
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_material13.Button, { onClick: () => {
|
|
3965
|
+
onRefresh();
|
|
3966
|
+
}, children: "Retry" }),
|
|
3984
3967
|
severity: "error",
|
|
3985
3968
|
children: [
|
|
3986
3969
|
"Unexpected error:",
|
|
3987
3970
|
" ",
|
|
3988
|
-
|
|
3971
|
+
spans.error.message
|
|
3989
3972
|
]
|
|
3990
3973
|
}
|
|
3991
3974
|
),
|
|
@@ -4011,7 +3994,7 @@ var TraceGraph = ({
|
|
|
4011
3994
|
] });
|
|
4012
3995
|
};
|
|
4013
3996
|
|
|
4014
|
-
// src/pages/trace-graph.tsx
|
|
3997
|
+
// src/pages/trace-graph-page.tsx
|
|
4015
3998
|
var import_jsx_runtime135 = require("react/jsx-runtime");
|
|
4016
3999
|
var HEADER_HEIGHT = 56;
|
|
4017
4000
|
var DRAWER_WIDTH = "35%";
|
|
@@ -4032,7 +4015,6 @@ var Main = (0, import_styles.styled)("main", { shouldForwardProp: (property) =>
|
|
|
4032
4015
|
}));
|
|
4033
4016
|
var StyledDrawer = (0, import_styles.styled)(import_material14.Drawer)(() => ({
|
|
4034
4017
|
"& .MuiDrawer-paper": {
|
|
4035
|
-
backgroundColor: "#ffffff",
|
|
4036
4018
|
bottom: 0,
|
|
4037
4019
|
boxSizing: "border-box",
|
|
4038
4020
|
height: `calc(100% - ${HEADER_HEIGHT.toString()}px)`,
|
|
@@ -4048,6 +4030,28 @@ var TraceGraphPage = () => {
|
|
|
4048
4030
|
const { traceId } = (0, import_react_router_dom2.useParams)();
|
|
4049
4031
|
const [searchParameters] = (0, import_react_router_dom2.useSearchParams)();
|
|
4050
4032
|
const spanId = searchParameters.get("spanId");
|
|
4033
|
+
const api = useAppInspectorApi();
|
|
4034
|
+
const [spans, setSpans] = (0, import_react16.useState)();
|
|
4035
|
+
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
4036
|
+
const [fetchError, setFetchError] = (0, import_react16.useState)();
|
|
4037
|
+
const fetchSpans = (0, import_react16.useCallback)(async () => {
|
|
4038
|
+
setLoading(true);
|
|
4039
|
+
try {
|
|
4040
|
+
const response = await api.getSpans({
|
|
4041
|
+
trace_id: traceId
|
|
4042
|
+
});
|
|
4043
|
+
setSpans(response.spans);
|
|
4044
|
+
setFetchError(void 0);
|
|
4045
|
+
} catch (error) {
|
|
4046
|
+
console.error(error);
|
|
4047
|
+
setFetchError(error instanceof Error ? error : new Error("Unknown error", { cause: error }));
|
|
4048
|
+
} finally {
|
|
4049
|
+
setLoading(false);
|
|
4050
|
+
}
|
|
4051
|
+
}, [api, traceId]);
|
|
4052
|
+
(0, import_react16.useEffect)(() => {
|
|
4053
|
+
void fetchSpans();
|
|
4054
|
+
}, [fetchSpans]);
|
|
4051
4055
|
const [open, setOpen] = (0, import_react16.useState)(true);
|
|
4052
4056
|
const [selectedEvent, setSelectedEvent] = (0, import_react16.useState)();
|
|
4053
4057
|
const [viewPortPixelWidth, setViewPortPixelWidth] = (0, import_react16.useState)(0);
|
|
@@ -4123,7 +4127,14 @@ var TraceGraphPage = () => {
|
|
|
4123
4127
|
{
|
|
4124
4128
|
initialFocusEventId: spanId,
|
|
4125
4129
|
onEventSelect: handleEventSelect,
|
|
4126
|
-
|
|
4130
|
+
onRefresh: () => {
|
|
4131
|
+
void fetchSpans();
|
|
4132
|
+
},
|
|
4133
|
+
spans: {
|
|
4134
|
+
data: spans,
|
|
4135
|
+
error: fetchError,
|
|
4136
|
+
loading
|
|
4137
|
+
},
|
|
4127
4138
|
viewPortPixelWidth
|
|
4128
4139
|
}
|
|
4129
4140
|
) })
|