Closed
Description
Problem
Before POTel, you could do:
span = start_span(...)
sentry_sdk.get_current_scope().span = span # forgot this initially, in case you're confused by the comments
# do stuff
span.finish()
i.e., start and finish a span without using a context manager.
With the current POTel design, this would create an inactive span (not attached to the current span as a child span) because the context attach/detach happens in __enter__
and __exit__
, respectively.
This might break a lot of setups -> we should find a way to still support this, while also giving people the possibility to create inactive spans.
(Same for start_transaction
.)
Solution
- make the code snippet above work in POTel to not break users (i.e., implement the
scope.span
setter) and deprecate it - add a
span.activate()
method that is a user-friendly equivalent of setting the span on the scope