@localstack/appinspector-ui 1.0.211 → 1.0.213
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 +48 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +106 -79
- package/dist/index.js.map +1 -1
- package/dist/spans-worker.js +18 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2422,7 +2422,7 @@ var init_event_streams = __esm({
|
|
|
2422
2422
|
|
|
2423
2423
|
// src/pages/spans-list-page.tsx
|
|
2424
2424
|
import { Box as Box23, Paper as Paper2 } from "@mui/material";
|
|
2425
|
-
import { useCallback as useCallback12, useEffect as
|
|
2425
|
+
import { useCallback as useCallback12, useEffect as useEffect28, useMemo as useMemo13, useRef as useRef24, useState as useState24 } from "react";
|
|
2426
2426
|
|
|
2427
2427
|
// src/api/errors.ts
|
|
2428
2428
|
var AppInspectorDisabledError = class extends Error {
|
|
@@ -16909,7 +16909,7 @@ import * as React125 from "react";
|
|
|
16909
16909
|
// src/components/event-details/event-details.tsx
|
|
16910
16910
|
import { Cancel as Cancel5, Close as Close3, GppBad as GppBad2, GppMaybe as GppMaybe6 } from "@mui/icons-material";
|
|
16911
16911
|
import { Alert as Alert4, Box as Box17, FormControlLabel, IconButton as IconButton6, Stack as Stack4, Switch, Tab, Tabs, Typography as Typography13 } from "@mui/material";
|
|
16912
|
-
import { useMemo as useMemo10, useState as useState14 } from "react";
|
|
16912
|
+
import { useEffect as useEffect17, useMemo as useMemo10, useRef as useRef13, useState as useState14 } from "react";
|
|
16913
16913
|
|
|
16914
16914
|
// src/dev-settings.tsx
|
|
16915
16915
|
import * as React122 from "react";
|
|
@@ -31729,6 +31729,12 @@ var checkIsSqsSendMessage = (span) => {
|
|
|
31729
31729
|
var PERMISSION_SEVERITY = ["explicitly_denied", "implicitly_denied", "explicitly_allowed"];
|
|
31730
31730
|
var getWorstPermission = (events) => PERMISSION_SEVERITY.find((permission) => events.some((event) => event.permission === permission));
|
|
31731
31731
|
var IAM_OUTCOME = { allowed: "allowed", error: "denied", none: void 0, warning: "warning" };
|
|
31732
|
+
var OPTIONAL_TABS = ["error", "logs", "permissions"];
|
|
31733
|
+
var getOptionalTabs = (span, eventGroups) => ({
|
|
31734
|
+
error: getSpanIssues(span).error,
|
|
31735
|
+
logs: checkIsLambdaInvoke(span) && typeof span.attributes?.["localstack.request_id"] === "string",
|
|
31736
|
+
permissions: span.iam_errors_suppressed === true || eventGroups.permissions !== void 0
|
|
31737
|
+
});
|
|
31732
31738
|
var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PURE__ */ jsxs132(Box17, { children: [
|
|
31733
31739
|
/* @__PURE__ */ jsx144(Typography13, { sx: { fontWeight: 600 }, variant: "caption", children: label }),
|
|
31734
31740
|
/* @__PURE__ */ jsxs132(Stack4, { alignItems: "center", "data-testid": testIdOn === "row" ? testId : void 0, direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
|
|
@@ -31737,7 +31743,7 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
|
|
|
31737
31743
|
] })
|
|
31738
31744
|
] });
|
|
31739
31745
|
var EmptyTab = ({ children }) => /* @__PURE__ */ jsx144(Typography13, { color: "text.secondary", variant: "body2", children });
|
|
31740
|
-
var EventDetails = ({ onClose, selectedEvent }) => {
|
|
31746
|
+
var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
31741
31747
|
const eventGroups = useMemo10(
|
|
31742
31748
|
() => getEventGroupsByType(selectedEvent?.events ?? []),
|
|
31743
31749
|
[selectedEvent?.events]
|
|
@@ -31745,6 +31751,18 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31745
31751
|
const [parseNestedJson, setParseNestedJson] = useState14(true);
|
|
31746
31752
|
const [tab, setTab] = useState14("details");
|
|
31747
31753
|
const { operationStatus: variant } = useDevSettings();
|
|
31754
|
+
const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
|
|
31755
|
+
const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
|
|
31756
|
+
const onOperationShownRef = useRef13(onOperationShown);
|
|
31757
|
+
useEffect17(() => {
|
|
31758
|
+
onOperationShownRef.current = onOperationShown;
|
|
31759
|
+
}, [onOperationShown]);
|
|
31760
|
+
const shownSpanId = selectedEvent?.span_id;
|
|
31761
|
+
useEffect17(() => {
|
|
31762
|
+
if (shownSpanId !== void 0) {
|
|
31763
|
+
onOperationShownRef.current?.(shownSpanId, activeTab);
|
|
31764
|
+
}
|
|
31765
|
+
}, [shownSpanId, activeTab]);
|
|
31748
31766
|
if (!selectedEvent) {
|
|
31749
31767
|
return /* @__PURE__ */ jsx144(Box17, { sx: { p: 3, textAlign: "center" }, children: /* @__PURE__ */ jsx144(Typography13, { color: "text.secondary", variant: "body2", children: "Select an operation to view graph" }) });
|
|
31750
31768
|
}
|
|
@@ -31776,10 +31794,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31776
31794
|
const errorType = functionError?.errorType ?? issues.errorType;
|
|
31777
31795
|
const duration = selectedEvent.end_time_unix_nano ? ((BigInt(selectedEvent.end_time_unix_nano) - BigInt(selectedEvent.start_time_unix_nano)) / BigInt("1000000")).toString() : void 0;
|
|
31778
31796
|
const resource = shortResourceName(selectedEvent.resource_name, selectedEvent.arn);
|
|
31779
|
-
const showError =
|
|
31780
|
-
const showPermissions = selectedEvent.iam_errors_suppressed === true || eventGroups.permissions !== void 0;
|
|
31781
|
-
const showLogs = isLambdaInvoke && requestId !== void 0;
|
|
31782
|
-
const activeTab = tab === "error" && !showError || tab === "permissions" && !showPermissions || tab === "logs" && !showLogs ? "details" : tab;
|
|
31797
|
+
const { error: showError, logs: showLogs, permissions: showPermissions } = getOptionalTabs(selectedEvent, eventGroups);
|
|
31783
31798
|
const errorMessages = functionError?.errorMessage === void 0 ? [.../* @__PURE__ */ new Set([selectedEvent.status_message, ...(selectedEvent.errors ?? []).filter((item) => item.level === "error").map((item) => item.message)])].filter((message) => Boolean(message) && message !== errorType) : [functionError.errorMessage];
|
|
31784
31799
|
const iamEvents = getIamEvents(selectedEvent);
|
|
31785
31800
|
const iamPermission = getWorstPermission(iamEvents);
|
|
@@ -31860,7 +31875,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31860
31875
|
variant: "scrollable",
|
|
31861
31876
|
children: [
|
|
31862
31877
|
/* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, label: "Details", value: "details" }),
|
|
31863
|
-
/* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "
|
|
31878
|
+
/* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "payload" }),
|
|
31864
31879
|
/* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, label: "Response", value: "response" }),
|
|
31865
31880
|
showError && /* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_ERROR_TEST_ID, icon: /* @__PURE__ */ jsx144(Cancel5, { color: "error", sx: { fontSize: 16 } }), iconPosition: "end", label: "Error", value: "error" }),
|
|
31866
31881
|
showPermissions && /* @__PURE__ */ jsx144(Tab, { "data-testid": DETAIL_TAB_PERMISSIONS_TEST_ID, icon: permissionsIcon, iconPosition: "end", label: "Permissions", value: "permissions" }),
|
|
@@ -31906,7 +31921,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31906
31921
|
eventGroups.warnings && /* @__PURE__ */ jsx144(EventDetail, { displayText: "Warning", events: eventGroups.warnings, type: "warning" }),
|
|
31907
31922
|
eventGroups.info && /* @__PURE__ */ jsx144(EventDetail, { displayText: "Info", events: eventGroups.info, type: "info" })
|
|
31908
31923
|
] }),
|
|
31909
|
-
activeTab === "
|
|
31924
|
+
activeTab === "payload" && (requestPayload === void 0 ? /* @__PURE__ */ jsx144(EmptyTab, { children: "No request payload recorded." }) : /* @__PURE__ */ jsxs132(Fragment11, { children: [
|
|
31910
31925
|
rawDataSwitch,
|
|
31911
31926
|
/* @__PURE__ */ jsx144(PayloadViewer, { testId: EVENT_DETAILS_REQUEST_PAYLOAD, value: requestPayload })
|
|
31912
31927
|
] })),
|
|
@@ -31971,7 +31986,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31971
31986
|
import "@xyflow/react/dist/base.css";
|
|
31972
31987
|
import { Alert as Alert5, Button as Button6, useTheme as useTheme6 } from "@mui/material";
|
|
31973
31988
|
import { Background, MarkerType, MiniMap, Position as Position2, ReactFlow, useEdgesState, useNodesState, useStore as useStore4 } from "@xyflow/react";
|
|
31974
|
-
import { useCallback as useCallback7, useEffect as
|
|
31989
|
+
import { useCallback as useCallback7, useEffect as useEffect18, useRef as useRef15, useState as useState16 } from "react";
|
|
31975
31990
|
|
|
31976
31991
|
// src/components/trace-graph/service-node.tsx
|
|
31977
31992
|
import { Cancel as Cancel6, GppMaybe as GppMaybe7 } from "@mui/icons-material";
|
|
@@ -31979,7 +31994,7 @@ import { Box as Box18, Divider as Divider4, Stack as Stack5, Tooltip as Tooltip7
|
|
|
31979
31994
|
import { Handle, Position } from "@xyflow/react";
|
|
31980
31995
|
import "@xyflow/react/dist/style.css";
|
|
31981
31996
|
import "react";
|
|
31982
|
-
import { memo as memo11, useRef as
|
|
31997
|
+
import { memo as memo11, useRef as useRef14, useState as useState15 } from "react";
|
|
31983
31998
|
import { Fragment as Fragment12, jsx as jsx145, jsxs as jsxs133 } from "react/jsx-runtime";
|
|
31984
31999
|
var handleStyle = {
|
|
31985
32000
|
backgroundColor: "white",
|
|
@@ -32065,7 +32080,7 @@ var NodeContent = ({ event, expanded, issues }) => {
|
|
|
32065
32080
|
var ServiceNode = memo11(({ data, selected }) => {
|
|
32066
32081
|
const theme = useTheme4();
|
|
32067
32082
|
const [isHovered, setIsHovered] = useState15(false);
|
|
32068
|
-
const nodeRef =
|
|
32083
|
+
const nodeRef = useRef14(null);
|
|
32069
32084
|
const issues = getSpanIssues(data.event);
|
|
32070
32085
|
const outlineColor = issues.error ? theme.palette.error.main : issues.warning ? theme.palette.warning.main : void 0;
|
|
32071
32086
|
const paper = theme.palette.background.paper;
|
|
@@ -32380,7 +32395,7 @@ var ExtentUpdater = ({ onUpdate, viewportRef }) => {
|
|
|
32380
32395
|
const zoom = useStore4((s) => s.transform[2]);
|
|
32381
32396
|
const width = useStore4((s) => s.width);
|
|
32382
32397
|
const height = useStore4((s) => s.height);
|
|
32383
|
-
|
|
32398
|
+
useEffect18(() => {
|
|
32384
32399
|
viewportRef.current = { height, width, zoom };
|
|
32385
32400
|
onUpdate();
|
|
32386
32401
|
}, [zoom, width, height, onUpdate, viewportRef]);
|
|
@@ -32396,8 +32411,8 @@ var TraceGraph = ({
|
|
|
32396
32411
|
const [nodes2, setNodes, onNodesChange] = useNodesState([]);
|
|
32397
32412
|
const [edges, setEdges] = useEdgesState([]);
|
|
32398
32413
|
const [translateExtent, setTranslateExtent] = useState16();
|
|
32399
|
-
const nodeBoundsRef =
|
|
32400
|
-
const viewportRef =
|
|
32414
|
+
const nodeBoundsRef = useRef15(null);
|
|
32415
|
+
const viewportRef = useRef15({ height: 0, width: 0, zoom: 1 });
|
|
32401
32416
|
const updateExtent = useCallback7(() => {
|
|
32402
32417
|
const bounds = nodeBoundsRef.current;
|
|
32403
32418
|
const { height, width, zoom } = viewportRef.current;
|
|
@@ -32411,7 +32426,7 @@ var TraceGraph = ({
|
|
|
32411
32426
|
[bounds.maxX + hMargin, bounds.maxY + vMargin]
|
|
32412
32427
|
]);
|
|
32413
32428
|
}, []);
|
|
32414
|
-
|
|
32429
|
+
useEffect18(() => {
|
|
32415
32430
|
const allNodes = [];
|
|
32416
32431
|
const allEdges = [];
|
|
32417
32432
|
for (const span of spans.data ?? []) {
|
|
@@ -32544,7 +32559,7 @@ var TraceGraph = ({
|
|
|
32544
32559
|
};
|
|
32545
32560
|
|
|
32546
32561
|
// src/hooks/use-local-storage.tsx
|
|
32547
|
-
import { useCallback as useCallback8, useEffect as
|
|
32562
|
+
import { useCallback as useCallback8, useEffect as useEffect19, useState as useState17 } from "react";
|
|
32548
32563
|
function useLocalStorage(key, initialValue) {
|
|
32549
32564
|
const [storedValue, setStoredValue] = useState17(() => {
|
|
32550
32565
|
try {
|
|
@@ -32570,7 +32585,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
32570
32585
|
console.error(`Error setting localStorage key "${key}":`, error);
|
|
32571
32586
|
}
|
|
32572
32587
|
}, [key]);
|
|
32573
|
-
|
|
32588
|
+
useEffect19(() => {
|
|
32574
32589
|
const handleStorageChange = (event) => {
|
|
32575
32590
|
if (event.key === key && event.newValue !== null) {
|
|
32576
32591
|
try {
|
|
@@ -32982,7 +32997,7 @@ var SPLIT_STORAGE_KEY = "appinspector-trace-sidebar-split";
|
|
|
32982
32997
|
var VIEW_STORAGE_KEY = "appinspector-trace-sidebar-view";
|
|
32983
32998
|
var clampSplit = (split2) => Math.min(MAX_SPLIT, Math.max(MIN_SPLIT, split2));
|
|
32984
32999
|
var noop = () => void 0;
|
|
32985
|
-
var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
|
|
33000
|
+
var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
|
|
32986
33001
|
const [storedWidth, setStoredWidth] = useLocalStorage(WIDTH_STORAGE_KEY, DEFAULT_WIDTH_SHARE);
|
|
32987
33002
|
const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
|
|
32988
33003
|
const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
|
|
@@ -33196,7 +33211,7 @@ var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, se
|
|
|
33196
33211
|
tabIndex: 0
|
|
33197
33212
|
}
|
|
33198
33213
|
) }),
|
|
33199
|
-
/* @__PURE__ */ jsx150(Box21, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ jsx150(EventDetails, { selectedEvent: selectedSpan }) : /* @__PURE__ */ jsx150(Typography16, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33214
|
+
/* @__PURE__ */ jsx150(Box21, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ jsx150(EventDetails, { onOperationShown, selectedEvent: selectedSpan }) : /* @__PURE__ */ jsx150(Typography16, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33200
33215
|
]
|
|
33201
33216
|
}
|
|
33202
33217
|
);
|
|
@@ -33243,7 +33258,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx151(
|
|
|
33243
33258
|
);
|
|
33244
33259
|
|
|
33245
33260
|
// src/hooks/use-filter-used-analytics.ts
|
|
33246
|
-
import { useEffect as
|
|
33261
|
+
import { useEffect as useEffect22, useRef as useRef18, useState as useState20 } from "react";
|
|
33247
33262
|
var FILTER_KEYS = {
|
|
33248
33263
|
consumer: "service",
|
|
33249
33264
|
producer: "producer",
|
|
@@ -33270,11 +33285,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
|
|
|
33270
33285
|
var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
|
|
33271
33286
|
const api = useAppInspectorApi();
|
|
33272
33287
|
const { deploymentContainer } = useAppInspector();
|
|
33273
|
-
const previousQueryRef =
|
|
33274
|
-
const pendingRef =
|
|
33275
|
-
const changeCountRef =
|
|
33288
|
+
const previousQueryRef = useRef18(query2);
|
|
33289
|
+
const pendingRef = useRef18();
|
|
33290
|
+
const changeCountRef = useRef18(0);
|
|
33276
33291
|
const [settledChange, setSettledChange] = useState20(0);
|
|
33277
|
-
|
|
33292
|
+
useEffect22(() => {
|
|
33278
33293
|
const previous = parseQuery(previousQueryRef.current);
|
|
33279
33294
|
const next = parseQuery(query2);
|
|
33280
33295
|
previousQueryRef.current = query2;
|
|
@@ -33297,7 +33312,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33297
33312
|
clearTimeout(timer);
|
|
33298
33313
|
};
|
|
33299
33314
|
}, [query2]);
|
|
33300
|
-
|
|
33315
|
+
useEffect22(() => {
|
|
33301
33316
|
const pending = pendingRef.current;
|
|
33302
33317
|
if (pending === void 0 || filteredCount === void 0) {
|
|
33303
33318
|
return;
|
|
@@ -33343,7 +33358,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
|
|
|
33343
33358
|
};
|
|
33344
33359
|
|
|
33345
33360
|
// src/hooks/use-operation-open-analytics.ts
|
|
33346
|
-
import { useEffect as
|
|
33361
|
+
import { useEffect as useEffect23, useRef as useRef19 } from "react";
|
|
33347
33362
|
|
|
33348
33363
|
// src/utils/request-id.ts
|
|
33349
33364
|
var getRequestId = (spans) => {
|
|
@@ -33360,15 +33375,16 @@ var getRequestId = (spans) => {
|
|
|
33360
33375
|
};
|
|
33361
33376
|
|
|
33362
33377
|
// src/hooks/use-operation-open-analytics.ts
|
|
33363
|
-
var useOperationOpenAnalytics = ({ open,
|
|
33378
|
+
var useOperationOpenAnalytics = ({ open, shown, spans }) => {
|
|
33364
33379
|
const api = useAppInspectorApi();
|
|
33365
33380
|
const { deploymentContainer } = useAppInspector();
|
|
33366
|
-
const
|
|
33367
|
-
|
|
33368
|
-
const
|
|
33369
|
-
|
|
33370
|
-
|
|
33371
|
-
|
|
33381
|
+
const shownKeyRef = useRef19();
|
|
33382
|
+
useEffect23(() => {
|
|
33383
|
+
const shownKey = open && shown ? `${shown.span.span_id}
|
|
33384
|
+
${shown.view}` : void 0;
|
|
33385
|
+
const previousKey = shownKeyRef.current;
|
|
33386
|
+
shownKeyRef.current = shownKey;
|
|
33387
|
+
if (shownKey === void 0 || shownKey === previousKey || shown === void 0) {
|
|
33372
33388
|
return;
|
|
33373
33389
|
}
|
|
33374
33390
|
const requestId = getRequestId(spans ?? []);
|
|
@@ -33379,21 +33395,22 @@ var useOperationOpenAnalytics = ({ open, selectedEvent, spans }) => {
|
|
|
33379
33395
|
event: "appinspector_operation_open",
|
|
33380
33396
|
payload: {
|
|
33381
33397
|
...buildAnalyticsPayload(deploymentContainer),
|
|
33382
|
-
metrics: buildProblemMetrics([
|
|
33383
|
-
request_id: requestId
|
|
33398
|
+
metrics: buildProblemMetrics([shown.span]),
|
|
33399
|
+
request_id: requestId,
|
|
33400
|
+
view: shown.view
|
|
33384
33401
|
}
|
|
33385
33402
|
}).catch(() => {
|
|
33386
33403
|
});
|
|
33387
|
-
}, [api, deploymentContainer, open,
|
|
33404
|
+
}, [api, deploymentContainer, open, shown, spans]);
|
|
33388
33405
|
};
|
|
33389
33406
|
|
|
33390
33407
|
// src/hooks/use-request-open-analytics.ts
|
|
33391
|
-
import { useEffect as
|
|
33408
|
+
import { useEffect as useEffect24, useRef as useRef20 } from "react";
|
|
33392
33409
|
var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
33393
33410
|
const api = useAppInspectorApi();
|
|
33394
33411
|
const { deploymentContainer } = useAppInspector();
|
|
33395
|
-
const firedForRef =
|
|
33396
|
-
|
|
33412
|
+
const firedForRef = useRef20();
|
|
33413
|
+
useEffect24(() => {
|
|
33397
33414
|
if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
|
|
33398
33415
|
return;
|
|
33399
33416
|
}
|
|
@@ -33424,7 +33441,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
|
|
|
33424
33441
|
};
|
|
33425
33442
|
|
|
33426
33443
|
// src/hooks/use-spans.ts
|
|
33427
|
-
import { useCallback as useCallback11, useEffect as
|
|
33444
|
+
import { useCallback as useCallback11, useEffect as useEffect27, useRef as useRef23, useState as useState23 } from "react";
|
|
33428
33445
|
import { unstable_batchedUpdates as batchedUpdates } from "react-dom";
|
|
33429
33446
|
|
|
33430
33447
|
// src/utils/pagination-buffer.ts
|
|
@@ -33679,10 +33696,10 @@ var toSpanFilterProjection = (span) => ({
|
|
|
33679
33696
|
});
|
|
33680
33697
|
|
|
33681
33698
|
// src/hooks/use-spans-compute.ts
|
|
33682
|
-
import { useCallback as useCallback9, useEffect as
|
|
33699
|
+
import { useCallback as useCallback9, useEffect as useEffect25, useRef as useRef21, useState as useState21 } from "react";
|
|
33683
33700
|
|
|
33684
33701
|
// inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
|
|
33685
|
-
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 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) ?? (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 = (counts, value) => {\n counts.set(value, (counts.get(value) ?? 0) + 1);\n };\n var toFacetValues = (counts) => [...counts].map(([value, count]) => ({ count, 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 if (rows[entry.spanId]?.matches) allIds.push(entry.spanId);\n if (excluding && matchesExclusion(entry, parsedQuery)) excludedCount++;\n countFacet(producers, entry.producer);\n countFacet(services, entry.serviceName);\n countFacet(regions, entry.region);\n countFacet(accounts, entry.accountId);\n countFacet(clients, entry.triggerKind);\n if (entry.error) countFacet(issues, "error");\n if (entry.warning) countFacet(issues, "warning");\n if (!entry.error && !entry.warning) countFacet(issues, "ok");\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) ?? 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: entries.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';
|
|
33702
|
+
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 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) ?? (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';
|
|
33686
33703
|
function createInlineWorker() {
|
|
33687
33704
|
const url = URL.createObjectURL(new Blob([source], { type: "text/javascript" }));
|
|
33688
33705
|
try {
|
|
@@ -33708,11 +33725,11 @@ var useSpansCompute = () => {
|
|
|
33708
33725
|
const { loaded, result, resultVersion } = computeState;
|
|
33709
33726
|
const [workerError, setWorkerError] = useState21();
|
|
33710
33727
|
const [retryCount, setRetryCount] = useState21(0);
|
|
33711
|
-
const workerRef =
|
|
33712
|
-
const seqRef =
|
|
33713
|
-
const lastAppliedRef =
|
|
33714
|
-
const firstPageSeqRef =
|
|
33715
|
-
|
|
33728
|
+
const workerRef = useRef21();
|
|
33729
|
+
const seqRef = useRef21(0);
|
|
33730
|
+
const lastAppliedRef = useRef21(0);
|
|
33731
|
+
const firstPageSeqRef = useRef21();
|
|
33732
|
+
useEffect25(() => {
|
|
33716
33733
|
try {
|
|
33717
33734
|
const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
|
|
33718
33735
|
worker.addEventListener("message", (event) => {
|
|
@@ -33758,7 +33775,7 @@ var useSpansCompute = () => {
|
|
|
33758
33775
|
};
|
|
33759
33776
|
|
|
33760
33777
|
// src/hooks/use-spans-ws.tsx
|
|
33761
|
-
import { useCallback as useCallback10, useEffect as
|
|
33778
|
+
import { useCallback as useCallback10, useEffect as useEffect26, useRef as useRef22, useState as useState22 } from "react";
|
|
33762
33779
|
var wsLogger = createScopedLogger("WS");
|
|
33763
33780
|
var isLegacySpanFields = (value) => {
|
|
33764
33781
|
return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
|
|
@@ -33790,20 +33807,20 @@ var parseSpansWebSocketMessage = (raw) => {
|
|
|
33790
33807
|
};
|
|
33791
33808
|
function useSpansWebSocket(options) {
|
|
33792
33809
|
const { enabled, onClose, onMessage, onOpen } = options;
|
|
33793
|
-
const onMessageRef =
|
|
33794
|
-
const onOpenRef =
|
|
33795
|
-
const onCloseRef =
|
|
33796
|
-
|
|
33810
|
+
const onMessageRef = useRef22(onMessage);
|
|
33811
|
+
const onOpenRef = useRef22(onOpen);
|
|
33812
|
+
const onCloseRef = useRef22(onClose);
|
|
33813
|
+
useEffect26(() => {
|
|
33797
33814
|
onMessageRef.current = onMessage;
|
|
33798
33815
|
}, [onMessage]);
|
|
33799
|
-
|
|
33816
|
+
useEffect26(() => {
|
|
33800
33817
|
onOpenRef.current = onOpen;
|
|
33801
33818
|
}, [onOpen]);
|
|
33802
|
-
|
|
33819
|
+
useEffect26(() => {
|
|
33803
33820
|
onCloseRef.current = onClose;
|
|
33804
33821
|
}, [onClose]);
|
|
33805
33822
|
const [connected, setConnected] = useState22(false);
|
|
33806
|
-
const wsRef =
|
|
33823
|
+
const wsRef = useRef22(void 0);
|
|
33807
33824
|
const { localstackEndpoint } = useAppInspector();
|
|
33808
33825
|
const connect = useCallback10(() => {
|
|
33809
33826
|
if (wsRef.current !== void 0) return;
|
|
@@ -33846,7 +33863,7 @@ function useSpansWebSocket(options) {
|
|
|
33846
33863
|
}
|
|
33847
33864
|
});
|
|
33848
33865
|
}, [localstackEndpoint]);
|
|
33849
|
-
|
|
33866
|
+
useEffect26(() => {
|
|
33850
33867
|
if (!enabled) {
|
|
33851
33868
|
if (wsRef.current !== void 0) {
|
|
33852
33869
|
wsRef.current.close();
|
|
@@ -33889,15 +33906,15 @@ var useSpans = () => {
|
|
|
33889
33906
|
const api = useAppInspectorApi();
|
|
33890
33907
|
const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
|
|
33891
33908
|
const { addPage, clear: clearCompute, loaded: spansLoaded, result: computeResult, resultVersion, retryWorker, setQuery: setComputeQuery, workerError } = useSpansCompute();
|
|
33892
|
-
const spanMapRef =
|
|
33893
|
-
const newSpanIdsRef =
|
|
33894
|
-
const caughtUpRef =
|
|
33909
|
+
const spanMapRef = useRef23(/* @__PURE__ */ new Map());
|
|
33910
|
+
const newSpanIdsRef = useRef23(/* @__PURE__ */ new Set());
|
|
33911
|
+
const caughtUpRef = useRef23(false);
|
|
33895
33912
|
const [fetchError, setFetchError] = useState23();
|
|
33896
33913
|
const [fetchingForward, setFetchingForward] = useState23(false);
|
|
33897
33914
|
const [fetchingBackward, setFetchingBackward] = useState23(false);
|
|
33898
33915
|
const [query2, setQueryState] = useState23("");
|
|
33899
33916
|
const [searching, setSearching] = useState23(false);
|
|
33900
|
-
const paginationBufferRef =
|
|
33917
|
+
const paginationBufferRef = useRef23();
|
|
33901
33918
|
const [totalCount, setTotalCount] = useState23();
|
|
33902
33919
|
const [licenseLimit, setLicenseLimit] = useState23();
|
|
33903
33920
|
const [systemLimit, setSystemLimit] = useState23();
|
|
@@ -33932,9 +33949,9 @@ var useSpans = () => {
|
|
|
33932
33949
|
setWarningCount(void 0);
|
|
33933
33950
|
void paginationBufferRef.current?.fetchForward();
|
|
33934
33951
|
}, [resetCorpus]);
|
|
33935
|
-
const hasFetchedWithoutEpochRef =
|
|
33936
|
-
const previousEpochRef =
|
|
33937
|
-
|
|
33952
|
+
const hasFetchedWithoutEpochRef = useRef23(false);
|
|
33953
|
+
const previousEpochRef = useRef23();
|
|
33954
|
+
useEffect27(() => {
|
|
33938
33955
|
if (epoch === void 0) {
|
|
33939
33956
|
return;
|
|
33940
33957
|
}
|
|
@@ -33951,7 +33968,7 @@ var useSpans = () => {
|
|
|
33951
33968
|
setQueryState(next);
|
|
33952
33969
|
setComputeQuery(next);
|
|
33953
33970
|
}, [setComputeQuery]);
|
|
33954
|
-
|
|
33971
|
+
useEffect27(() => {
|
|
33955
33972
|
if (!searchSupported || freeText === "") {
|
|
33956
33973
|
return;
|
|
33957
33974
|
}
|
|
@@ -33972,7 +33989,7 @@ var useSpans = () => {
|
|
|
33972
33989
|
setSearching(false);
|
|
33973
33990
|
};
|
|
33974
33991
|
}, [api, freeText, query2, searchSupported, setComputeQuery]);
|
|
33975
|
-
|
|
33992
|
+
useEffect27(() => {
|
|
33976
33993
|
const buffer = createPaginationBuffer({
|
|
33977
33994
|
async fetchPage(token, signal) {
|
|
33978
33995
|
const requestPage = async (paginationToken) => {
|
|
@@ -34062,12 +34079,12 @@ var useSpans = () => {
|
|
|
34062
34079
|
setClearingSpans(false);
|
|
34063
34080
|
}
|
|
34064
34081
|
}, [clearingSpans, api, resetCorpus]);
|
|
34065
|
-
|
|
34082
|
+
useEffect27(() => {
|
|
34066
34083
|
if (hasMoreForward === true && !fetchingForward) {
|
|
34067
34084
|
void paginationBufferRef.current?.fetchForward();
|
|
34068
34085
|
}
|
|
34069
34086
|
}, [hasMoreForward, fetchingForward]);
|
|
34070
|
-
|
|
34087
|
+
useEffect27(() => {
|
|
34071
34088
|
if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
|
|
34072
34089
|
void paginationBufferRef.current?.fetchBackward();
|
|
34073
34090
|
}
|
|
@@ -34174,11 +34191,11 @@ var SpansListPage = () => {
|
|
|
34174
34191
|
const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
|
|
34175
34192
|
const [selectedSpanId, setSelectedSpanId] = useState24();
|
|
34176
34193
|
const getTreeSpans = useCallback12((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
|
|
34177
|
-
const latestRef =
|
|
34178
|
-
|
|
34194
|
+
const latestRef = useRef24({ compute, getTreeSpans });
|
|
34195
|
+
useEffect28(() => {
|
|
34179
34196
|
latestRef.current = { compute, getTreeSpans };
|
|
34180
34197
|
}, [compute, getTreeSpans]);
|
|
34181
|
-
const openedAtRef =
|
|
34198
|
+
const openedAtRef = useRef24();
|
|
34182
34199
|
const navigateToSpan = useCallback12((span) => {
|
|
34183
34200
|
openedAtRef.current = performance.now();
|
|
34184
34201
|
const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
|
|
@@ -34186,8 +34203,10 @@ var SpansListPage = () => {
|
|
|
34186
34203
|
const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
|
|
34187
34204
|
setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
|
|
34188
34205
|
}, []);
|
|
34206
|
+
const [shownOperation, setShownOperation] = useState24();
|
|
34189
34207
|
const closeSidebar = useCallback12(() => {
|
|
34190
34208
|
setSelectedSpanId(void 0);
|
|
34209
|
+
setShownOperation(void 0);
|
|
34191
34210
|
}, []);
|
|
34192
34211
|
const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
|
|
34193
34212
|
const treeSpans = useMemo13(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
|
|
@@ -34195,8 +34214,8 @@ var SpansListPage = () => {
|
|
|
34195
34214
|
() => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
|
|
34196
34215
|
[compute]
|
|
34197
34216
|
);
|
|
34198
|
-
const treeSpansRef =
|
|
34199
|
-
|
|
34217
|
+
const treeSpansRef = useRef24(treeSpans);
|
|
34218
|
+
useEffect28(() => {
|
|
34200
34219
|
treeSpansRef.current = treeSpans;
|
|
34201
34220
|
}, [treeSpans]);
|
|
34202
34221
|
const [renderedRequest, setRenderedRequest] = useState24();
|
|
@@ -34214,8 +34233,15 @@ var SpansListPage = () => {
|
|
|
34214
34233
|
view: renderedRequest?.view ?? "operations"
|
|
34215
34234
|
});
|
|
34216
34235
|
const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
|
|
34217
|
-
const
|
|
34218
|
-
|
|
34236
|
+
const handleOperationShown = useCallback12((spanId, view) => {
|
|
34237
|
+
setShownOperation({ spanId, view });
|
|
34238
|
+
}, []);
|
|
34239
|
+
const shown = useMemo13(() => {
|
|
34240
|
+
if (shownOperation === void 0) return;
|
|
34241
|
+
const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
|
|
34242
|
+
return span && { span, view: shownOperation.view };
|
|
34243
|
+
}, [shownOperation, treeSpans]);
|
|
34244
|
+
useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
|
|
34219
34245
|
const handleRetry = useCallback12(() => {
|
|
34220
34246
|
checkStatus();
|
|
34221
34247
|
fetchForward();
|
|
@@ -34225,10 +34251,10 @@ var SpansListPage = () => {
|
|
|
34225
34251
|
clearFetchError();
|
|
34226
34252
|
checkStatus();
|
|
34227
34253
|
}, [api, checkStatus, clearFetchError]);
|
|
34228
|
-
const isDelayedRefetchRef =
|
|
34229
|
-
const delayedRefetchTimerRef =
|
|
34230
|
-
const prevFetchingForwardRef =
|
|
34231
|
-
|
|
34254
|
+
const isDelayedRefetchRef = useRef24(false);
|
|
34255
|
+
const delayedRefetchTimerRef = useRef24();
|
|
34256
|
+
const prevFetchingForwardRef = useRef24(false);
|
|
34257
|
+
useEffect28(() => {
|
|
34232
34258
|
const wasFetching = prevFetchingForwardRef.current;
|
|
34233
34259
|
prevFetchingForwardRef.current = fetchingForward;
|
|
34234
34260
|
if (wasFetching && !fetchingForward) {
|
|
@@ -34342,6 +34368,7 @@ var SpansListPage = () => {
|
|
|
34342
34368
|
TraceSidebar,
|
|
34343
34369
|
{
|
|
34344
34370
|
onClose: closeSidebar,
|
|
34371
|
+
onOperationShown: handleOperationShown,
|
|
34345
34372
|
onRequestRendered: handleRequestRendered,
|
|
34346
34373
|
onSelectSpan: setSelectedSpanId,
|
|
34347
34374
|
onViewChange: handleViewChange,
|