diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 06aad5857f..4e90b636ff 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -849,6 +849,10 @@ def transaction(self, value: "Any") -> None: def set_transaction_name(self, name: str, source: "Optional[str]" = None) -> None: """Set the transaction name and optionally the transaction source.""" self._transaction = name + + if source: + self._transaction_info["source"] = source + if self._span: if isinstance(self._span, NoOpStreamedSpan): return @@ -865,9 +869,6 @@ def set_transaction_name(self, name: str, source: "Optional[str]" = None) -> Non if source: self._span.containing_transaction.source = source - if source: - self._transaction_info["source"] = source - @_attr_setter def user(self, value: "Optional[Dict[str, Any]]") -> None: """When set a specific user is bound to the scope. Deprecated in favor of set_user."""