From e2e221272823bc806be912f32133007cf5894f7d Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 19 Aug 2019 09:46:25 +0200 Subject: [PATCH 1/2] fix: Convert assertion into warning Fix #472 --- sentry_sdk/tracing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 57dd0d9f25..4fbe7ec36c 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -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( From 1ec3d8a538063c6217a647286f5599f3c66454c6 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 19 Aug 2019 10:59:13 +0200 Subject: [PATCH 2/2] fix: Add missing import --- sentry_sdk/tracing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 4fbe7ec36c..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