Skip to content

Commit b837541

Browse files
authored
fix: Convert assertion into warning (getsentry#474)
* fix: Convert assertion into warning Fix getsentry#472 * fix: Add missing import
1 parent 5c35389 commit b837541

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sentry_sdk/tracing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from datetime import datetime
66

77
import sentry_sdk
8-
from sentry_sdk.utils import capture_internal_exceptions
8+
from sentry_sdk.utils import capture_internal_exceptions, logger
99
from sentry_sdk._compat import PY2
1010
from sentry_sdk._types import MYPY
1111

@@ -272,9 +272,9 @@ def finish(self, hub=None):
272272
# resolved to a concrete decision. If `sampled` is `None`, it's
273273
# likely that somebody used `with sentry_sdk.Hub.start_span(..)` on a
274274
# non-transaction span and later decided to make it a transaction.
275-
assert (
276-
self.sampled is not None
277-
), "Need to set transaction when entering span!"
275+
if self.sampled is None:
276+
logger.warning("Discarding transaction Span without sampling decision")
277+
278278
return None
279279

280280
return hub.capture_event(

0 commit comments

Comments
 (0)