Skip to content

Commit

Permalink
Transactions and spans live on the current span.
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Feb 20, 2024
1 parent 8987340 commit 4d7d4c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def start_span(
**kwargs # type: Any
):
# type: (...) -> Span
return Scope.get_isolation_scope().start_span(span=span, **kwargs)
return Scope.get_current_scope().start_span(span=span, **kwargs)

Check warning on line 290 in sentry_sdk/api.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/api.py#L290

Added line #L290 was not covered by tests


@scopemethod
Expand All @@ -296,12 +296,12 @@ def start_transaction(
**kwargs # type: Any
):
# type: (...) -> Union[Transaction, NoOpSpan]
return Scope.get_isolation_scope().start_transaction(transaction, **kwargs)
return Scope.get_current_scope().start_transaction(transaction, **kwargs)

Check warning on line 299 in sentry_sdk/api.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/api.py#L299

Added line #L299 was not covered by tests


def set_measurement(name, value, unit=""):
# type: (str, float, MeasurementUnit) -> None
transaction = Scope.get_isolation_scope().transaction
transaction = Scope.get_current_scope().transaction

Check warning on line 304 in sentry_sdk/api.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/api.py#L304

Added line #L304 was not covered by tests
if transaction is not None:
transaction.set_measurement(name, value, unit)

Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __repr__(self):

def __enter__(self):
# type: () -> Span
scope = self.scope or sentry_sdk.Scope.get_isolation_scope()
scope = self.scope or sentry_sdk.Scope.get_current_scope()
old_span = scope.span
scope.span = self
self._context_manager_state = (scope, old_span)
Expand Down Expand Up @@ -455,7 +455,7 @@ def finish(self, scope=None, end_timestamp=None):
if the span represents a database or HTTP request.
:param scope: The scope to use for this transaction.
If not provided, the active isolation scope will be used.
If not provided, the current scope will be used.
:param end_timestamp: Optional timestamp that should
be used as timestamp instead of the current time.
Expand All @@ -466,7 +466,7 @@ def finish(self, scope=None, end_timestamp=None):
# This span is already finished, ignore.
return None

scope = scope or sentry_sdk.Scope.get_isolation_scope()
scope = scope or sentry_sdk.Scope.get_current_scope()

try:
if end_timestamp:
Expand Down

0 comments on commit 4d7d4c3

Please sign in to comment.