Skip to content

Commit b8c7c1b

Browse files
committed
Adding exception info when closing transaction
1 parent 26ec3d7 commit b8c7c1b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

sentry_sdk/integrations/wsgi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def __call__(self, environ, start_response):
135135
)
136136
except BaseException:
137137
reraise(*_capture_exception())
138+
finally:
139+
finish_running_transaction(current_scope, sys.exc_info())
138140
finally:
139141
_wsgi_middleware_applied.set(False)
140142

sentry_sdk/tracing_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,13 @@ def get_current_span(scope=None):
726726
from sentry_sdk.tracing import Span
727727

728728

729-
def finish_running_transaction(scope=None):
730-
# type: (Optional[sentry_sdk.Scope]) -> None
729+
def finish_running_transaction(scope=None, exc_info=None):
730+
# type: (Optional[sentry_sdk.Scope], Optional[ExcInfo]) -> None
731731
current_scope = scope or sentry_sdk.get_current_scope()
732732
if current_scope.transaction is not None and hasattr(
733733
current_scope.transaction, "_context_manager_state"
734734
):
735-
current_scope.transaction.__exit__(None, None, None)
735+
if exc_info is not None:
736+
current_scope.transaction.__exit__(*exc_info)
737+
else:
738+
current_scope.transaction.__exit__(None, None, None)

0 commit comments

Comments
 (0)