Skip to content

Commit ad6e7cc

Browse files
committed
move where finished is set
1 parent cb37a07 commit ad6e7cc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sentry_sdk/traces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,6 @@ def _end(self) -> None:
319319
del self._previous_span_on_scope
320320
self._scope.span = old_span
321321

322-
client = sentry_sdk.get_client()
323-
if not client.is_active():
324-
return
325-
326322
# Set attributes from the segment
327323
self.set_attribute("sentry.segment.id", self._segment.span_id)
328324
self.set_attribute("sentry.segment.name", self._segment.name)
@@ -339,6 +335,10 @@ def _end(self) -> None:
339335

340336
self._finished = True
341337

338+
client = sentry_sdk.get_client()
339+
if not client.is_active():
340+
return
341+
342342
# Finally, queue the span for sending to Sentry
343343
self._scope._capture_span(self)
344344

0 commit comments

Comments
 (0)