diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index a068711fbb..9eacd0c7e5 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -26,6 +26,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh ## Removed +- The `enable_tracing` option was removed. Use `traces_sample_rate=1.0` instead. - The deprecated `push_scope` and `configure_scope` APIs have been removed. Use `with new_scope():` to push a new scope and `scope = get_current_scope()` to retrieve the current scope instead. - Transaction profiling and related code was removed. - Removed the deprecated Hub class and all uses of hub throughout the SDK in arguments, options, etc. Use a scope instead. diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index fb315cd674..f865cbac97 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -338,9 +338,6 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]": rv["project_root"] = project_root - if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None: - rv["traces_sample_rate"] = 1.0 - rv["data_collection"] = _resolve_data_collection(rv) # Do not add the event scrubber if data collection is enabled as it can remove data that's @@ -369,13 +366,6 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]": env_to_bool(os.environ.get("SENTRY_KEEP_ALIVE"), strict=True) or False ) - if rv["enable_tracing"] is not None: - warnings.warn( - "The `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.", - DeprecationWarning, - stacklevel=2, - ) - if rv["trace_ignore_status_codes"] and has_span_streaming_enabled(rv): warnings.warn( "The `trace_ignore_status_codes` parameter is ignored in span streaming mode.", diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index c2500ca913..a288c54f72 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -1306,7 +1306,6 @@ def __init__( proxy_headers: "Optional[Dict[str, str]]" = None, before_send_transaction: "Optional[TransactionProcessor]" = None, project_root: "Optional[str]" = None, - enable_tracing: "Optional[bool]" = None, include_local_variables: "Optional[bool]" = True, include_source_context: "Optional[bool]" = True, trace_propagation_targets: "Optional[Sequence[str]]" = [ # noqa: B006 @@ -1702,8 +1701,6 @@ def __init__( :param profile_session_sample_rate: - :param enable_tracing: - :param propagate_traces: :param auto_session_tracking: diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index d75d94efd6..105edb0ec7 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -95,17 +95,14 @@ def __iter__(self) -> "Generator[str, None, None]": def has_tracing_enabled(options: "Optional[Dict[str, Any]]") -> bool: """ Returns True if either traces_sample_rate or traces_sampler is - defined and enable_tracing is set and not false. + defined. """ if options is None: return False return bool( - options.get("enable_tracing") is not False - and ( - options.get("traces_sample_rate") is not None - or options.get("traces_sampler") is not None - ) + options.get("traces_sample_rate") is not None + or options.get("traces_sampler") is not None ) diff --git a/tests/integrations/celery/test_update_celery_task_headers.py b/tests/integrations/celery/test_update_celery_task_headers.py index 18f2f96bbf..4418653885 100644 --- a/tests/integrations/celery/test_update_celery_task_headers.py +++ b/tests/integrations/celery/test_update_celery_task_headers.py @@ -189,39 +189,3 @@ def test_celery_trace_propagation_traces_sample_rate( else: assert "sentry-monitor-start-timestamp-s" not in outgoing_headers assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"] - - -@pytest.mark.parametrize( - "enable_tracing,monitor_beat_tasks", - list(itertools.product([None, True, False], [True, False])), -) -def test_celery_trace_propagation_enable_tracing( - sentry_init, enable_tracing, monitor_beat_tasks -): - """ - The celery integration does not check the traces_sample_rate. - By default traces_sample_rate is None which means "do not propagate traces". - But the celery integration does not check this value. - The Celery integration has its own mechanism to propagate traces: - https://docs.sentry.io/platforms/python/integrations/celery/#distributed-traces - """ - sentry_init(enable_tracing=enable_tracing) - - headers = {} - span = None - - scope = sentry_sdk.get_isolation_scope() - - outgoing_headers = _update_celery_task_headers(headers, span, monitor_beat_tasks) - - assert outgoing_headers["sentry-trace"] == scope.get_traceparent() - assert outgoing_headers["headers"]["sentry-trace"] == scope.get_traceparent() - assert outgoing_headers["baggage"] == scope.get_baggage().serialize() - assert outgoing_headers["headers"]["baggage"] == scope.get_baggage().serialize() - - if monitor_beat_tasks: - assert "sentry-monitor-start-timestamp-s" in outgoing_headers - assert "sentry-monitor-start-timestamp-s" in outgoing_headers["headers"] - else: - assert "sentry-monitor-start-timestamp-s" not in outgoing_headers - assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"] diff --git a/tests/test_basics.py b/tests/test_basics.py index ada3f569dc..06b51d9867 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -31,7 +31,6 @@ from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.stdlib import StdlibIntegration from sentry_sdk.scope import add_global_event_processor -from sentry_sdk.tracing_utils import has_tracing_enabled from sentry_sdk.utils import datetime_from_isoformat, get_sdk_name, reraise @@ -248,32 +247,6 @@ def do_this(): assert crumb["type"] == "default" -@pytest.mark.parametrize( - "enable_tracing, traces_sample_rate, tracing_enabled, updated_traces_sample_rate", - [ - (None, None, False, None), - (False, 0.0, False, 0.0), - (False, 1.0, False, 1.0), - (None, 1.0, True, 1.0), - (True, 1.0, True, 1.0), - (None, 0.0, True, 0.0), # We use this as - it's configured but turned off - (True, 0.0, True, 0.0), # We use this as - it's configured but turned off - (True, None, True, 1.0), - ], -) -def test_option_enable_tracing( - sentry_init, - enable_tracing, - traces_sample_rate, - tracing_enabled, - updated_traces_sample_rate, -): - sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate) - options = sentry_sdk.get_client().options - assert has_tracing_enabled(options) is tracing_enabled - assert options["traces_sample_rate"] == updated_traces_sample_rate - - def test_breadcrumb_arguments(sentry_init, capture_events): assert_hint = {"bar": 42} diff --git a/tests/test_client.py b/tests/test_client.py index e654a1ede1..82ea2fcf73 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1471,12 +1471,6 @@ def test_dropped_transaction(sentry_init, capture_record_lost_event_calls, test_ test_config.run(sentry_init, capture_record_lost_event_calls) -@pytest.mark.parametrize("enable_tracing", [True, False]) -def test_enable_tracing_deprecated(sentry_init, enable_tracing): - with pytest.warns(DeprecationWarning): - sentry_init(enable_tracing=enable_tracing) - - def test_ignore_spans_warns_without_streaming(sentry_init): with pytest.warns(UserWarning, match=r"`ignore_spans` parameter only works"): sentry_init(ignore_spans=["/health"], trace_lifecycle="static")