@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.cjs
CHANGED
|
@@ -31703,6 +31703,12 @@ var checkIsSqsSendMessage = (span) => {
|
|
|
31703
31703
|
var PERMISSION_SEVERITY = ["explicitly_denied", "implicitly_denied", "explicitly_allowed"];
|
|
31704
31704
|
var getWorstPermission = (events) => PERMISSION_SEVERITY.find((permission) => events.some((event) => event.permission === permission));
|
|
31705
31705
|
var IAM_OUTCOME = { allowed: "allowed", error: "denied", none: void 0, warning: "warning" };
|
|
31706
|
+
var OPTIONAL_TABS = ["error", "logs", "permissions"];
|
|
31707
|
+
var getOptionalTabs = (span, eventGroups) => ({
|
|
31708
|
+
error: getSpanIssues(span).error,
|
|
31709
|
+
logs: checkIsLambdaInvoke(span) && typeof span.attributes?.["localstack.request_id"] === "string",
|
|
31710
|
+
permissions: span.iam_errors_suppressed === true || eventGroups.permissions !== void 0
|
|
31711
|
+
});
|
|
31706
31712
|
var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_material20.Box, { children: [
|
|
31707
31713
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: label }),
|
|
31708
31714
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_material20.Stack, { alignItems: "center", "data-testid": testIdOn === "row" ? testId : void 0, direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
|
|
@@ -31711,7 +31717,7 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
|
|
|
31711
31717
|
] })
|
|
31712
31718
|
] });
|
|
31713
31719
|
var EmptyTab = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { color: "text.secondary", variant: "body2", children });
|
|
31714
|
-
var EventDetails = ({ onClose, selectedEvent }) => {
|
|
31720
|
+
var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
|
|
31715
31721
|
const eventGroups = (0, import_react52.useMemo)(
|
|
31716
31722
|
() => getEventGroupsByType(selectedEvent?.events ?? []),
|
|
31717
31723
|
[selectedEvent?.events]
|
|
@@ -31719,6 +31725,18 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31719
31725
|
const [parseNestedJson, setParseNestedJson] = (0, import_react52.useState)(true);
|
|
31720
31726
|
const [tab, setTab] = (0, import_react52.useState)("details");
|
|
31721
31727
|
const { operationStatus: variant } = useDevSettings();
|
|
31728
|
+
const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
|
|
31729
|
+
const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
|
|
31730
|
+
const onOperationShownRef = (0, import_react52.useRef)(onOperationShown);
|
|
31731
|
+
(0, import_react52.useEffect)(() => {
|
|
31732
|
+
onOperationShownRef.current = onOperationShown;
|
|
31733
|
+
}, [onOperationShown]);
|
|
31734
|
+
const shownSpanId = selectedEvent?.span_id;
|
|
31735
|
+
(0, import_react52.useEffect)(() => {
|
|
31736
|
+
if (shownSpanId !== void 0) {
|
|
31737
|
+
onOperationShownRef.current?.(shownSpanId, activeTab);
|
|
31738
|
+
}
|
|
31739
|
+
}, [shownSpanId, activeTab]);
|
|
31722
31740
|
if (!selectedEvent) {
|
|
31723
31741
|
return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Box, { sx: { p: 3, textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { color: "text.secondary", variant: "body2", children: "Select an operation to view graph" }) });
|
|
31724
31742
|
}
|
|
@@ -31750,10 +31768,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31750
31768
|
const errorType = functionError?.errorType ?? issues.errorType;
|
|
31751
31769
|
const duration = selectedEvent.end_time_unix_nano ? ((BigInt(selectedEvent.end_time_unix_nano) - BigInt(selectedEvent.start_time_unix_nano)) / BigInt("1000000")).toString() : void 0;
|
|
31752
31770
|
const resource = shortResourceName(selectedEvent.resource_name, selectedEvent.arn);
|
|
31753
|
-
const showError =
|
|
31754
|
-
const showPermissions = selectedEvent.iam_errors_suppressed === true || eventGroups.permissions !== void 0;
|
|
31755
|
-
const showLogs = isLambdaInvoke && requestId !== void 0;
|
|
31756
|
-
const activeTab = tab === "error" && !showError || tab === "permissions" && !showPermissions || tab === "logs" && !showLogs ? "details" : tab;
|
|
31771
|
+
const { error: showError, logs: showLogs, permissions: showPermissions } = getOptionalTabs(selectedEvent, eventGroups);
|
|
31757
31772
|
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];
|
|
31758
31773
|
const iamEvents = getIamEvents(selectedEvent);
|
|
31759
31774
|
const iamPermission = getWorstPermission(iamEvents);
|
|
@@ -31834,7 +31849,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31834
31849
|
variant: "scrollable",
|
|
31835
31850
|
children: [
|
|
31836
31851
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, label: "Details", value: "details" }),
|
|
31837
|
-
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "
|
|
31852
|
+
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "payload" }),
|
|
31838
31853
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, label: "Response", value: "response" }),
|
|
31839
31854
|
showError && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_ERROR_TEST_ID, icon: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_icons_material11.Cancel, { color: "error", sx: { fontSize: 16 } }), iconPosition: "end", label: "Error", value: "error" }),
|
|
31840
31855
|
showPermissions && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_PERMISSIONS_TEST_ID, icon: permissionsIcon, iconPosition: "end", label: "Permissions", value: "permissions" }),
|
|
@@ -31880,7 +31895,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
|
|
|
31880
31895
|
eventGroups.warnings && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EventDetail, { displayText: "Warning", events: eventGroups.warnings, type: "warning" }),
|
|
31881
31896
|
eventGroups.info && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EventDetail, { displayText: "Info", events: eventGroups.info, type: "info" })
|
|
31882
31897
|
] }),
|
|
31883
|
-
activeTab === "
|
|
31898
|
+
activeTab === "payload" && (requestPayload === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EmptyTab, { children: "No request payload recorded." }) : /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [
|
|
31884
31899
|
rawDataSwitch,
|
|
31885
31900
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(PayloadViewer, { testId: EVENT_DETAILS_REQUEST_PAYLOAD, value: requestPayload })
|
|
31886
31901
|
] })),
|
|
@@ -32956,7 +32971,7 @@ var SPLIT_STORAGE_KEY = "appinspector-trace-sidebar-split";
|
|
|
32956
32971
|
var VIEW_STORAGE_KEY = "appinspector-trace-sidebar-view";
|
|
32957
32972
|
var clampSplit = (split2) => Math.min(MAX_SPLIT, Math.max(MIN_SPLIT, split2));
|
|
32958
32973
|
var noop = () => void 0;
|
|
32959
|
-
var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
|
|
32974
|
+
var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
|
|
32960
32975
|
const [storedWidth, setStoredWidth] = useLocalStorage(WIDTH_STORAGE_KEY, DEFAULT_WIDTH_SHARE);
|
|
32961
32976
|
const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
|
|
32962
32977
|
const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
|
|
@@ -33170,7 +33185,7 @@ var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, se
|
|
|
33170
33185
|
tabIndex: 0
|
|
33171
33186
|
}
|
|
33172
33187
|
) }),
|
|
33173
|
-
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(EventDetails, { selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33188
|
+
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(EventDetails, { onOperationShown, selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
|
|
33174
33189
|
]
|
|
33175
33190
|
}
|
|
33176
33191
|
);
|
|
@@ -33334,15 +33349,16 @@ var getRequestId = (spans) => {
|
|
|
33334
33349
|
};
|
|
33335
33350
|
|
|
33336
33351
|
// src/hooks/use-operation-open-analytics.ts
|
|
33337
|
-
var useOperationOpenAnalytics = ({ open,
|
|
33352
|
+
var useOperationOpenAnalytics = ({ open, shown, spans }) => {
|
|
33338
33353
|
const api = useAppInspectorApi();
|
|
33339
33354
|
const { deploymentContainer } = useAppInspector();
|
|
33340
|
-
const
|
|
33355
|
+
const shownKeyRef = (0, import_react64.useRef)();
|
|
33341
33356
|
(0, import_react64.useEffect)(() => {
|
|
33342
|
-
const
|
|
33343
|
-
|
|
33344
|
-
|
|
33345
|
-
|
|
33357
|
+
const shownKey = open && shown ? `${shown.span.span_id}
|
|
33358
|
+
${shown.view}` : void 0;
|
|
33359
|
+
const previousKey = shownKeyRef.current;
|
|
33360
|
+
shownKeyRef.current = shownKey;
|
|
33361
|
+
if (shownKey === void 0 || shownKey === previousKey || shown === void 0) {
|
|
33346
33362
|
return;
|
|
33347
33363
|
}
|
|
33348
33364
|
const requestId = getRequestId(spans ?? []);
|
|
@@ -33353,12 +33369,13 @@ var useOperationOpenAnalytics = ({ open, selectedEvent, spans }) => {
|
|
|
33353
33369
|
event: "appinspector_operation_open",
|
|
33354
33370
|
payload: {
|
|
33355
33371
|
...buildAnalyticsPayload(deploymentContainer),
|
|
33356
|
-
metrics: buildProblemMetrics([
|
|
33357
|
-
request_id: requestId
|
|
33372
|
+
metrics: buildProblemMetrics([shown.span]),
|
|
33373
|
+
request_id: requestId,
|
|
33374
|
+
view: shown.view
|
|
33358
33375
|
}
|
|
33359
33376
|
}).catch(() => {
|
|
33360
33377
|
});
|
|
33361
|
-
}, [api, deploymentContainer, open,
|
|
33378
|
+
}, [api, deploymentContainer, open, shown, spans]);
|
|
33362
33379
|
};
|
|
33363
33380
|
|
|
33364
33381
|
// src/hooks/use-request-open-analytics.ts
|
|
@@ -33656,7 +33673,7 @@ var toSpanFilterProjection = (span) => ({
|
|
|
33656
33673
|
var import_react66 = require("react");
|
|
33657
33674
|
|
|
33658
33675
|
// inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
|
|
33659
|
-
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';
|
|
33676
|
+
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';
|
|
33660
33677
|
function createInlineWorker() {
|
|
33661
33678
|
const url = URL.createObjectURL(new Blob([source], { type: "text/javascript" }));
|
|
33662
33679
|
try {
|
|
@@ -34160,8 +34177,10 @@ var SpansListPage = () => {
|
|
|
34160
34177
|
const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
|
|
34161
34178
|
setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
|
|
34162
34179
|
}, []);
|
|
34180
|
+
const [shownOperation, setShownOperation] = (0, import_react69.useState)();
|
|
34163
34181
|
const closeSidebar = (0, import_react69.useCallback)(() => {
|
|
34164
34182
|
setSelectedSpanId(void 0);
|
|
34183
|
+
setShownOperation(void 0);
|
|
34165
34184
|
}, []);
|
|
34166
34185
|
const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
|
|
34167
34186
|
const treeSpans = (0, import_react69.useMemo)(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
|
|
@@ -34188,8 +34207,15 @@ var SpansListPage = () => {
|
|
|
34188
34207
|
view: renderedRequest?.view ?? "operations"
|
|
34189
34208
|
});
|
|
34190
34209
|
const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
|
|
34191
|
-
const
|
|
34192
|
-
|
|
34210
|
+
const handleOperationShown = (0, import_react69.useCallback)((spanId, view) => {
|
|
34211
|
+
setShownOperation({ spanId, view });
|
|
34212
|
+
}, []);
|
|
34213
|
+
const shown = (0, import_react69.useMemo)(() => {
|
|
34214
|
+
if (shownOperation === void 0) return;
|
|
34215
|
+
const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
|
|
34216
|
+
return span && { span, view: shownOperation.view };
|
|
34217
|
+
}, [shownOperation, treeSpans]);
|
|
34218
|
+
useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
|
|
34193
34219
|
const handleRetry = (0, import_react69.useCallback)(() => {
|
|
34194
34220
|
checkStatus();
|
|
34195
34221
|
fetchForward();
|
|
@@ -34316,6 +34342,7 @@ var SpansListPage = () => {
|
|
|
34316
34342
|
TraceSidebar,
|
|
34317
34343
|
{
|
|
34318
34344
|
onClose: closeSidebar,
|
|
34345
|
+
onOperationShown: handleOperationShown,
|
|
34319
34346
|
onRequestRendered: handleRequestRendered,
|
|
34320
34347
|
onSelectSpan: setSelectedSpanId,
|
|
34321
34348
|
onViewChange: handleViewChange,
|