Skip to content

Commit 2064e0c

Browse files
fix(potel): Set POTelSpan on current scope
1 parent 4668c3e commit 2064e0c

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
@@ -1283,10 +1283,19 @@ def __enter__(self):
12831283
# set as the implicit current context
12841284
self._ctx_token = context.attach(ctx)
12851285

1286+
self._scope_manager = sentry_sdk.new_scope()
1287+
scope = self._scope_manager.__enter__()
1288+
scope.span = self
1289+
12861290
return self
12871291

12881292
def __exit__(self, ty, value, tb):
12891293
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
1294+
self._scope_manager.__exit__(ty, value, tb)
1295+
del (
1296+
self._scope_manager
1297+
) # Eliminate circular reference which could prevent garbage collection
1298+
12901299
self._otel_span.end()
12911300
# XXX set status to error if unset and an exception occurred?
12921301
if self._active:

0 commit comments

Comments
 (0)