diff --git a/sentry_sdk/api.py b/sentry_sdk/api.py index 55bb8166d1..166dddd199 100644 --- a/sentry_sdk/api.py +++ b/sentry_sdk/api.py @@ -176,7 +176,7 @@ def configure_scope( # noqa: F811 :returns: If no callback is provided, returns a context manager that returns the scope. """ - scope = Scope.get_isolation_scope() + scope = Scope.get_current_scope() scope.generate_propagation_context() if callback is not None: @@ -228,7 +228,7 @@ def __init__(self): def __enter__(self): # type: () -> Scope - return Scope.get_isolation_scope() + return Scope.get_current_scope() def __exit__(self, exc_type, exc_value, tb): # type: (Any, Any, Any) -> None @@ -318,7 +318,7 @@ def get_traceparent(): """ Returns the traceparent either from the active span or from the scope. """ - return Scope.get_isolation_scope().get_traceparent() + return Scope.get_current_scope().get_traceparent() def get_baggage(): @@ -326,7 +326,7 @@ def get_baggage(): """ Returns Baggage either from the active span or from the scope. """ - baggage = Scope.get_isolation_scope().get_baggage() + baggage = Scope.get_current_scope().get_baggage() if baggage is not None: return baggage.serialize() @@ -339,6 +339,6 @@ def continue_trace(environ_or_headers, op=None, name=None, source=None): """ Sets the propagation context from environment or headers and returns a transaction. """ - return Scope.get_isolation_scope().continue_trace( + return Scope.get_current_scope().continue_trace( environ_or_headers, op, name, source ) diff --git a/sentry_sdk/hub.py b/sentry_sdk/hub.py index 23d139c4f4..1d38bce5f8 100644 --- a/sentry_sdk/hub.py +++ b/sentry_sdk/hub.py @@ -280,7 +280,7 @@ def scope(self): This property is deprecated and will be removed in a future release. Returns the current scope on the hub. """ - return Scope.get_isolation_scope() + return Scope.get_current_scope() def last_event_id(self): # type: () -> Optional[str] diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 7445c3614a..2121dcfe8d 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -454,7 +454,8 @@ def set_new_propagation_context(self): def generate_propagation_context(self, incoming_data=None): # type: (Optional[Dict[str, str]]) -> None """ - Makes sure `_propagation_context` is set. + Makes sure the propagation context (`_propagation_context`) is set. + The propagation context only lives on the current scope. If there is `incoming_data` overwrite existing `_propagation_context`. if there is no `incoming_data` create new `_propagation_context`, but do NOT overwrite if already existing. """ @@ -468,7 +469,7 @@ def generate_propagation_context(self, incoming_data=None): self._propagation_context, ) - if self._propagation_context is None and self._type != ScopeType.CURRENT: + if self._propagation_context is None and self._type == ScopeType.CURRENT: self.set_new_propagation_context() def get_dynamic_sampling_context(self): diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 1602742a0c..a177fe0ed6 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -566,7 +566,7 @@ def get_current_span(scope=None): """ Returns the currently active span if there is one running, otherwise `None` """ - scope = scope or sentry_sdk.Scope.get_isolation_scope() + scope = scope or sentry_sdk.Scope.get_current_scope() current_span = scope.span return current_span