diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 2e560ff3d7..112ad2bdc4 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -1273,8 +1273,10 @@ def __enter__(self): def __exit__(self, ty, value, tb): # type: (Optional[Any], Optional[Any], Optional[Any]) -> None + if value is not None: + self.set_status(SPANSTATUS.INTERNAL_ERROR) + self.finish() - # XXX set status to error if unset and an exception occurred? context.detach(self._ctx_token) def _get_attribute(self, name):