Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,6 @@ class POTelSpan:
def __init__(
self,
*,
active=True, # type: bool
op=None, # type: Optional[str]
description=None, # type: Optional[str]
status=None, # type: Optional[str]
Expand All @@ -1221,7 +1220,6 @@ def __init__(
self._otel_span = tracer.start_span(
description or op or "", start_time=start_timestamp
) # XXX
self._active = active

self.origin = origin or DEFAULT_SPAN_ORIGIN
self.op = op
Expand Down Expand Up @@ -1250,19 +1248,17 @@ def __enter__(self):
# XXX use_span? https://github.com/open-telemetry/opentelemetry-python/blob/3836da8543ce9751051e38a110c0468724042e62/opentelemetry-api/src/opentelemetry/trace/__init__.py#L547
#
# create a Context object with parent set as current span
if self._active:
ctx = otel_trace.set_span_in_context(self._otel_span)
# set as the implicit current context
self._ctx_token = context.attach(ctx)
ctx = otel_trace.set_span_in_context(self._otel_span)
# set as the implicit current context
self._ctx_token = context.attach(ctx)

return self

def __exit__(self, ty, value, tb):
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
self._otel_span.end()
# XXX set status to error if unset and an exception occurred?
if self._active:
context.detach(self._ctx_token)
context.detach(self._ctx_token)

@property
def description(self):
Expand Down