From dafda320f05002f19c87d04d8e7de4284ab5bfc7 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 17 Jul 2024 09:33:44 +0200 Subject: [PATCH] ref(scope): Remove apparently unnecessary `if` The removed `if` statement is identical to the `if` statement immediately before. It does not seem that the code before the second `if` can modify `transaction.sampled`, so it should be safe to combine the two `if` blocks into a single block under the first `if` statement. --- sentry_sdk/scope.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index b4274a4e7c..e6ad86254f 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -1031,9 +1031,8 @@ def start_transaction( transaction._profile = profile - # we don't bother to keep spans if we already know we're not going to - # send the transaction - if transaction.sampled: + # we don't bother to keep spans if we already know we're not going to + # send the transaction max_spans = (client.options["_experiments"].get("max_spans")) or 1000 transaction.init_span_recorder(maxlen=max_spans)