Skip to content

Commit be5cd76

Browse files
AAgnihotryclaude
andcommitted
refactor: extract execution_id from log_handler
Simplified UiPathExecutionRuntime API by removing the execution_id parameter. The execution_id is now extracted from the log_handler when needed, reducing parameter duplication and making the API cleaner. Changes: - Removed execution_id parameter from __init__ - Get execution_id from log_handler.execution_id when needed - Updated execute() and stream() methods to use log_handler.execution_id 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a1c2f35 commit be5cd76

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/uipath/runtime/base.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ def __init__(
148148
root_span: str = "root",
149149
span_attributes: dict[str, str] | None = None,
150150
log_handler: UiPathRuntimeExecutionLogHandler | None = None,
151-
execution_id: str | None = None,
152151
create_root_span: bool = True,
153152
):
154153
"""Initialize the executor.
@@ -159,7 +158,6 @@ def __init__(
159158
root_span: Name of the root span to create (if create_root_span=True)
160159
span_attributes: Attributes to add to the root span
161160
log_handler: Optional log handler for this execution
162-
execution_id: Execution ID for logging context and span propagation
163161
create_root_span: Whether to create a root span (default: True).
164162
When False, only logging context is set up, allowing child
165163
spans to inherit execution.id from parent spans in the call stack.
@@ -168,11 +166,8 @@ def __init__(
168166
self.trace_manager = trace_manager
169167
self.root_span = root_span
170168
self.span_attributes = span_attributes
171-
self.execution_id = execution_id
172169
self.log_handler = log_handler
173170
self.create_root_span = create_root_span
174-
if execution_id is not None and log_handler is None:
175-
self.log_handler = UiPathRuntimeExecutionLogHandler(execution_id)
176171

177172
async def execute(
178173
self,
@@ -182,15 +177,15 @@ async def execute(
182177
"""Execute runtime with context."""
183178
if self.log_handler:
184179
log_interceptor = UiPathRuntimeLogsInterceptor(
185-
execution_id=self.execution_id, log_handler=self.log_handler
180+
execution_id=self.log_handler.execution_id, log_handler=self.log_handler
186181
)
187182
log_interceptor.setup()
188183

189184
try:
190-
if self.create_root_span and self.execution_id:
185+
if self.create_root_span and self.log_handler:
191186
with self.trace_manager.start_execution_span(
192187
self.root_span,
193-
execution_id=self.execution_id,
188+
execution_id=self.log_handler.execution_id,
194189
attributes=self.span_attributes,
195190
):
196191
return await self.delegate.execute(input, options=options)
@@ -220,14 +215,14 @@ async def stream(
220215
"""
221216
if self.log_handler:
222217
log_interceptor = UiPathRuntimeLogsInterceptor(
223-
execution_id=self.execution_id, log_handler=self.log_handler
218+
execution_id=self.log_handler.execution_id, log_handler=self.log_handler
224219
)
225220
log_interceptor.setup()
226221
try:
227-
if self.create_root_span and self.execution_id:
222+
if self.create_root_span and self.log_handler:
228223
with self.trace_manager.start_execution_span(
229224
self.root_span,
230-
execution_id=self.execution_id,
225+
execution_id=self.log_handler.execution_id,
231226
attributes=self.span_attributes,
232227
):
233228
async for event in self.delegate.stream(input, options=options):

0 commit comments

Comments
 (0)