8000 fix(potel): Set POTelSpan on current scope · getsentry/sentry-python@04b3ce8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04b3ce8

Browse files
fix(potel): Set POTelSpan on current scope
1 parent 971642b commit 04b3ce8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sentry_sdk/tracing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,19 @@ def __enter__(self):
12771277
# set as the implicit current context
12781278
self._ctx_token = context.attach(ctx)
12791279

1280+
self._scope_manager = sentry_sdk.new_scope()
1281+
scope = self._scope_manager.__enter__()
1282+
scope.span = self
1283+
12801284
return self
12811285

12821286
def __exit__(self, ty, value, tb):
12831287
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
1288+
self._scope_manager.__exit__(ty, value, tb)
1289+
del (
1290+
self._scope_manager
1291+
) # Eliminate circular reference which could prevent garbage collection
1292+
12841293
self._otel_span.end()
12851294
# XXX set status to error if unset and an exception occurred?
12861295
if self._active:

0 commit comments

Comments
 (0)
0