diff --git a/agenta-cli/agenta/sdk/decorators/tracing.py b/agenta-cli/agenta/sdk/decorators/tracing.py index b7571477c8..a99e91558c 100644 --- a/agenta-cli/agenta/sdk/decorators/tracing.py +++ b/agenta-cli/agenta/sdk/decorators/tracing.py @@ -66,11 +66,15 @@ async def async_wrapper(*args, **kwargs): return result except Exception as e: + result = { + "message": str(e), + "stacktrace": traceback.format_exc(), + } self.tracing.set_span_attribute( {"traceback_exception": traceback.format_exc()} ) self.tracing.update_span_status(span=span, value="ERROR") - self.tracing.end_span(outputs={}) + self.tracing.end_span(outputs=result) raise e @wraps(func) @@ -98,11 +102,15 @@ def sync_wrapper(*args, **kwargs): return result except Exception as e: + result = { + "message": str(e), + "stacktrace": traceback.format_exc(), + } self.tracing.set_span_attribute( {"traceback_exception": traceback.format_exc()} ) self.tracing.update_span_status(span=span, value="ERROR") - self.tracing.end_span(outputs={}) + self.tracing.end_span(outputs=result) raise e return async_wrapper if is_coroutine_function else sync_wrapper