diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 57dd0d9f25..0743c8ef43 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -5,7 +5,7 @@ from datetime import datetime import sentry_sdk -from sentry_sdk.utils import capture_internal_exceptions +from sentry_sdk.utils import capture_internal_exceptions, logger from sentry_sdk._compat import PY2 from sentry_sdk._types import MYPY @@ -272,9 +272,9 @@ def finish(self, hub=None): # resolved to a concrete decision. If `sampled` is `None`, it's # likely that somebody used `with sentry_sdk.Hub.start_span(..)` on a # non-transaction span and later decided to make it a transaction. - assert ( - self.sampled is not None - ), "Need to set transaction when entering span!" + if self.sampled is None: + logger.warning("Discarding transaction Span without sampling decision") + return None return hub.capture_event(