Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit 1e68f32

Browse files
committed
add logging
1 parent 5e12071 commit 1e68f32

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/uipath/core/tracing/manager.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,33 +66,54 @@ def _get_bottom_most_span(current_span: Any, external_span: Any) -> Any:
6666
The span that is deeper (closer to the bottom) in the call hierarchy
6767
"""
6868
ancestor_spans = UiPathTracingManager.get_ancestor_spans()
69+
70+
logger.info(f"ancestor_spans length: {len(ancestor_spans) if ancestor_spans else 0}")
71+
6972
if not ancestor_spans:
73+
logger.info("No ancestor spans, returning external_span")
7074
return external_span
7175

7276
current_span_id = current_span.get_span_context().span_id
7377
external_span_id = external_span.get_span_context().span_id
7478

79+
logger.info(f"current_span_id: {current_span_id:016x}")
80+
logger.info(f"external_span_id: {external_span_id:016x}")
81+
7582
current_index = None
7683
external_index = None
7784

85+
# Log all ancestors in a single line
86+
ancestor_info = ", ".join([
87+
f"[{i}] {ancestor.name} ({ancestor.get_span_context().span_id:016x})"
88+
for i, ancestor in enumerate(ancestor_spans)
89+
])
90+
logger.info(f"Ancestors: {ancestor_info}")
91+
7892
for i, ancestor in enumerate(ancestor_spans):
7993
ancestor_id = ancestor.get_span_context().span_id
8094
if ancestor_id == current_span_id:
8195
current_index = i
8296
if ancestor_id == external_span_id:
8397
external_index = i
8498

99+
logger.info(f"current_index: {current_index}, external_index: {external_index}")
100+
85101
# Both in tree: higher index = deeper
86102
if current_index is not None and external_index is not None:
103+
chosen = "current_span" if current_index > external_index else "external_span"
104+
logger.info(f"Both in tree, choosing {chosen}")
87105
return current_span if current_index > external_index else external_span
88106

89107
# Only one in tree: that one is deeper
90108
if current_index is not None:
109+
logger.info("Only current_span in tree, returning current_span")
91110
return current_span
92111
if external_index is not None:
112+
logger.info("Only external_span in tree, returning external_span")
93113
return external_span
94114

95115
# Neither in tree: default to external
116+
logger.info("Neither in tree, returning external_span")
96117
return external_span
97118

98119
@staticmethod

0 commit comments

Comments
 (0)