Skip to content

Commit 9583029

Browse files
committed
Improvements from code review
1 parent 7090227 commit 9583029

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

sentry_sdk/integrations/wsgi.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,9 @@ def _finish_long_running_transaction(current_scope, isolation_scope):
356356
Triggered after MAX_TRANSACTION_DURATION_SECONDS have passed.
357357
"""
358358
try:
359-
transaction_duration = (
360-
datetime.now(timezone.utc) - current_scope.transaction.start_timestamp
361-
).total_seconds()
362-
if transaction_duration > MAX_TRANSACTION_DURATION_SECONDS:
363-
with use_isolation_scope(isolation_scope):
364-
with use_scope(current_scope):
365-
finish_running_transaction()
359+
with use_isolation_scope(isolation_scope):
360+
with use_scope(current_scope):
361+
finish_running_transaction()
366362
except AttributeError:
367363
# transaction is not there anymore
368364
pass

sentry_sdk/tracing_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,13 @@ def get_current_span(scope=None):
746746

747747
def finish_running_transaction(scope=None, exc_info=None, timer=None):
748748
# type: (Optional[sentry_sdk.Scope], Optional[ExcInfo], Optional[Timer]) -> None
749+
if timer is not None:
750+
timer.cancel()
751+
749752
current_scope = scope or sentry_sdk.get_current_scope()
750753
if current_scope.transaction is not None and hasattr(
751754
current_scope.transaction, "_context_manager_state"
752755
):
753-
if timer is not None:
754-
timer.cancel()
755-
756756
if exc_info is not None:
757757
current_scope.transaction.__exit__(*exc_info)
758758
else:

0 commit comments

Comments
 (0)