11"""Tracing manager for handling tracer implementations and function registry."""
22
33import logging
4- from typing import Any , Callable , Optional
4+ from typing import Any , Callable , List , Optional
55
66from opentelemetry import context , trace
77from opentelemetry .trace import set_span_in_context
@@ -13,6 +13,7 @@ class UiPathTracingManager:
1313 """Static utility class to manage tracing implementations and decorated functions."""
1414
1515 _current_span_provider : Optional [Callable [[], Any ]] = None
16+ _current_span_ancestors_provider : Optional [Callable [[], List [Any ]]] = None
1617
1718 @classmethod
1819 def register_current_span_provider (
@@ -55,5 +56,23 @@ def get_parent_context():
5556
5657 return ctx
5758
59+ @classmethod
60+ def register_current_span_ancestors_provider (
61+ cls , current_span_ancestors_provider : Optional [Callable [[], List [Any ]]]
62+ ):
63+ """Register a custom current span ancestors provider function.
64+
65+ Args:
66+ current_span_ancestors_provider: A function that returns a list of ancestor spans
67+ from an external tracing framework. If None, no custom
68+ span ancestor information will be used.
69+ """
70+ cls ._current_span_ancestors_provider = current_span_ancestors_provider
71+
72+ @classmethod
73+ def get_current_span_ancestors_provider (cls ):
74+ """Get the currently set custom span ancestors provider."""
75+ return cls ._current_span_ancestors_provider
76+
5877
5978__all__ = ["UiPathTracingManager" ]
0 commit comments