Skip to content

Commit

Permalink
fix(sdk): Add func error and stacktrace to result
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-agenta committed Jul 5, 2024
1 parent 0bfc70b commit 32a2486
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions agenta-cli/agenta/sdk/decorators/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 32a2486

Please sign in to comment.