Skip to content

Commit 6194d20

Browse files
authored
Merge pull request #41 from UiPath/fix/tracing_outside_run
fix(trace): running traced functions outside graph can cause issues
2 parents 08d8e0d + 8ca9bf9 commit 6194d20

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/uipath_langchain/tracers/_instrument_traceable.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,24 @@ def dispatch_trace_event(
3232
metadata: Optional[Dict[str, Any]] = None,
3333
):
3434
"""Dispatch trace event to our server."""
35+
try:
36+
event_data = FunctionCallEventData(
37+
function_name=func_name,
38+
event_type=event_type,
39+
inputs=inputs,
40+
call_uuid=call_uuid,
41+
output=result,
42+
error=str(exception) if exception else None,
43+
run_type=run_type,
44+
tags=tags,
45+
metadata=metadata,
46+
)
3547

36-
event_data = FunctionCallEventData(
37-
function_name=func_name,
38-
event_type=event_type,
39-
inputs=inputs,
40-
call_uuid=call_uuid,
41-
output=result,
42-
error=str(exception) if exception else None,
43-
run_type=run_type,
44-
tags=tags,
45-
metadata=metadata,
46-
)
47-
dispatch_custom_event(CustomTraceEvents.UIPATH_TRACE_FUNCTION_CALL, event_data)
48+
dispatch_custom_event(CustomTraceEvents.UIPATH_TRACE_FUNCTION_CALL, event_data)
49+
except Exception as e:
50+
logger.debug(
51+
f"Error dispatching trace event: {e}. Function name: {func_name} Event type: {event_type}"
52+
)
4853

4954

5055
def format_args_for_trace(

0 commit comments

Comments
 (0)