1111)
1212
1313from opentelemetry import trace
14- from opentelemetry .instrumentation .instrumentor import ( # type: ignore[attr-defined]
15- BaseInstrumentor ,
16- )
1714from typing_extensions import override
1815from uipath .core import UiPathTraceManager
1916
@@ -101,10 +98,6 @@ async def stream(
10198 # Without it, the function wouldn't match the AsyncGenerator return type
10299 yield
103100
104- def get_instrumentor (self ) -> Optional [BaseInstrumentor ]:
105- """Get instrumentor for this runtime. If no instrumentor is available, return None."""
106- return None
107-
108101 @abstractmethod
109102 async def cleanup (self ):
110103 """Cleaup runtime resources."""
@@ -138,15 +131,12 @@ async def execute(
138131 input : dict [str , Any ],
139132 ) -> UiPathRuntimeResult :
140133 """Execute runtime with context."""
141- instrumentor = self .delegate .get_instrumentor ()
142134 if self .log_handler :
143135 log_interceptor = UiPathRuntimeLogsInterceptor (
144136 execution_id = self .execution_id , log_handler = self .log_handler
145137 )
146138 log_interceptor .setup ()
147139
148- if instrumentor is not None :
149- instrumentor .instrument (tracer_provider = self .trace_manager .tracer_provider )
150140 try :
151141 if self .execution_id :
152142 with self .trace_manager .start_execution_span (
@@ -157,8 +147,6 @@ async def execute(
157147 return await self .delegate .execute (input )
158148 finally :
159149 self .trace_manager .flush_spans ()
160- if instrumentor is not None :
161- instrumentor .uninstrument ()
162150 if self .log_handler :
163151 log_interceptor .teardown ()
164152
@@ -179,9 +167,6 @@ async def stream(
179167 Raises:
180168 UiPathRuntimeStreamNotSupportedError: If the runtime doesn't support streaming
181169 """
182- instrumentor = self .delegate .get_instrumentor ()
183- if instrumentor is not None :
184- instrumentor .instrument (tracer_provider = self .trace_manager .tracer_provider )
185170 try :
186171 tracer = trace .get_tracer ("uipath-runtime" )
187172 span_attributes : dict [str , Any ] = {}
@@ -194,8 +179,6 @@ async def stream(
194179 yield event
195180 finally :
196181 self .trace_manager .flush_spans ()
197- if instrumentor is not None :
198- instrumentor .uninstrument ()
199182
200183 def cleanup (self ) -> None :
201184 """Close runtime resources."""
0 commit comments