MCPcopy
hub / github.com/getsentry/sentry / build_tree

Function build_tree

src/sentry/issue_detection/performance_detection.py:815–833  ·  view source on GitHub ↗
(spans: Sequence[dict[str, Any]])

Source from the content-addressed store, hash-verified

813
814
815def build_tree(spans: Sequence[dict[str, Any]]) -> tuple[dict[str, Any], str | None]:
816 span_tree: dict[str, tuple[dict[str, Any], list[dict[str, Any]]]] = {}
817 segment_id = None
818
819 for span in spans:
820 span_id = span["span_id"]
821 is_root = span.get("is_segment", False)
822 if is_root:
823 segment_id = span_id
824 if span_id not in span_tree:
825 span_tree[span_id] = (span, [])
826
827 for span, _ in span_tree.values():
828 parent_id = span.get("parent_span_id")
829 if parent_id is not None and parent_id in span_tree:
830 _, children = span_tree[parent_id]
831 children.append(span)
832
833 return span_tree, segment_id
834
835
836def dfs(

Callers 1

Calls 3

getMethod · 0.65
appendMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected