Skip to content

Commit

Permalink
fix(potel): Set POTelSpan on current scope
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Jul 31, 2024
1 parent 4668c3e commit 2064e0c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,10 +1283,19 @@ def __enter__(self):
# set as the implicit current context
self._ctx_token = context.attach(ctx)

self._scope_manager = sentry_sdk.new_scope()
scope = self._scope_manager.__enter__()
scope.span = self

return self

def __exit__(self, ty, value, tb):
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
self._scope_manager.__exit__(ty, value, tb)
del (
self._scope_manager
) # Eliminate circular reference which could prevent garbage collection

self._otel_span.end()
# XXX set status to error if unset and an exception occurred?
if self._active:
Expand Down

0 comments on commit 2064e0c

Please sign in to comment.