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