From 32a24862189d2e1ce633402b9adf74ceac5b8010 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Fri, 5 Jul 2024 13:05:27 +0200 Subject: [PATCH] fix(sdk): Add func error and stacktrace to result --- agenta-cli/agenta/sdk/decorators/tracing.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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