@localstack/appinspector-ui 1.0.53 → 1.0.55

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 CHANGED
@@ -13101,10 +13101,16 @@ var buildSpansEndpoint = (request) => {
13101
13101
  queryParameters.set("pagination_token", request.pagination_token);
13102
13102
  }
13103
13103
  for (const [key, value] of Object.entries(request)) {
13104
- if (value !== void 0 && key !== "limit" && key !== "pagination_token" && value !== null) {
13104
+ if (value !== void 0 && key !== "limit" && key !== "linked_span_ids" && key !== "linking_span_ids" && key !== "pagination_token" && value !== null) {
13105
13105
  queryParameters.set(key, String(value));
13106
13106
  }
13107
13107
  }
13108
+ if (request.linked_span_ids) {
13109
+ queryParameters.set("linked_span_ids", request.linked_span_ids.join(","));
13110
+ }
13111
+ if (request.linking_span_ids) {
13112
+ queryParameters.set("linking_span_ids", request.linking_span_ids.join(","));
13113
+ }
13108
13114
  const queryString = queryParameters.toString();
13109
13115
  return queryString ? `${API_ENDPOINTS.SPANS}?${queryString}` : API_ENDPOINTS.SPANS;
13110
13116
  };
@@ -14570,6 +14576,13 @@ var TraceGraph = ({
14570
14576
  } else {
14571
14577
  rootSpans.push(currentSpan);
14572
14578
  }
14579
+ for (const linkedSpanId of span.linked_span_ids ?? []) {
14580
+ const linkedSpan = spansMap.get(linkedSpanId);
14581
+ if (linkedSpan) {
14582
+ linkedSpan.children ??= [];
14583
+ linkedSpan.children.push(currentSpan);
14584
+ }
14585
+ }
14573
14586
  }
14574
14587
  let allNodes = [];
14575
14588
  let allEdges = [];
@@ -14753,6 +14766,40 @@ var TraceGraphView = ({
14753
14766
  }
14754
14767
  );
14755
14768
  };
14769
+ async function fetchConnectedTraces(api, traceIds, allSpans = /* @__PURE__ */ new Map(), processedTraceIds = /* @__PURE__ */ new Set()) {
14770
+ const newTraceIds = traceIds.filter((id2) => !processedTraceIds.has(id2));
14771
+ if (newTraceIds.length === 0) {
14772
+ return [...allSpans.values()];
14773
+ }
14774
+ for (const id2 of newTraceIds) processedTraceIds.add(id2);
14775
+ const traceResponses = await Promise.all(
14776
+ newTraceIds.map((id2) => api.getSpans({ trace_id: id2 }))
14777
+ );
14778
+ const currentBatchSpans = traceResponses.flatMap((r) => r.spans);
14779
+ const currentSpanIds = currentBatchSpans.map((s) => s.span_id);
14780
+ for (const span of currentBatchSpans) {
14781
+ allSpans.set(span.span_id, span);
14782
+ }
14783
+ const [linkedSpans, linkingSpans] = await Promise.all([
14784
+ api.getSpans({ linked_span_ids: currentSpanIds }),
14785
+ api.getSpans({ linking_span_ids: currentSpanIds })
14786
+ ]);
14787
+ const discoveredTraceIds = /* @__PURE__ */ new Set();
14788
+ for (const span of [...linkedSpans.spans, ...linkingSpans.spans]) {
14789
+ if (!processedTraceIds.has(span.trace_id)) {
14790
+ discoveredTraceIds.add(span.trace_id);
14791
+ }
14792
+ }
14793
+ if (discoveredTraceIds.size > 0) {
14794
+ return fetchConnectedTraces(
14795
+ api,
14796
+ [...discoveredTraceIds],
14797
+ allSpans,
14798
+ processedTraceIds
14799
+ );
14800
+ }
14801
+ return [...allSpans.values()];
14802
+ }
14756
14803
  var TraceGraphPage = ({ onClose, spanId, traceId }) => {
14757
14804
  const api = useAppInspectorApi();
14758
14805
  const [spans, setSpans] = (0, import_react60.useState)();
@@ -14761,10 +14808,8 @@ var TraceGraphPage = ({ onClose, spanId, traceId }) => {
14761
14808
  const fetchSpans = (0, import_react60.useCallback)(async () => {
14762
14809
  setLoading(true);
14763
14810
  try {
14764
- const response = await api.getSpans({
14765
- trace_id: traceId
14766
- });
14767
- setSpans(response.spans);
14811
+ const spans2 = await fetchConnectedTraces(api, [traceId]);
14812
+ setSpans(spans2);
14768
14813
  setFetchError(void 0);
14769
14814
  } catch (error) {
14770
14815
  console.error(error);