From f041fe36196940c36a7854807a0ac8ca9a225135 Mon Sep 17 00:00:00 2001 From: Colton Allen Date: Thu, 13 Feb 2025 11:34:09 -0600 Subject: [PATCH 1/2] Revert "feat(tracing): Add `propagate_traces` deprecation warning (#3899)" This reverts commit 8a70b76f69789585efbd39fcef087005b765a346. --- sentry_sdk/integrations/celery/__init__.py | 7 ------- sentry_sdk/scope.py | 5 ----- tests/integrations/celery/test_celery.py | 11 ++++------- tests/tracing/test_integration_tests.py | 14 -------------- 4 files changed, 4 insertions(+), 33 deletions(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index 80decb6064..dc48aac0e6 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -1,6 +1,4 @@ import sys -import warnings - from collections.abc import Mapping from functools import wraps @@ -70,11 +68,6 @@ def __init__( exclude_beat_tasks=None, ): # type: (bool, bool, Optional[List[str]]) -> None - warnings.warn( - "The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.", - DeprecationWarning, - stacklevel=2, - ) self.propagate_traces = propagate_traces self.monitor_beat_tasks = monitor_beat_tasks self.exclude_beat_tasks = exclude_beat_tasks diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 4e3bb87489..04cc3ea67b 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -625,11 +625,6 @@ def iter_trace_propagation_headers(self, *args, **kwargs): """ client = self.get_client() if not client.options.get("propagate_traces"): - warnings.warn( - "The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.", - DeprecationWarning, - stacklevel=2, - ) return span = kwargs.pop("span", None) diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index f8d118e7e9..e51341599f 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -268,9 +268,7 @@ def dummy_task(): def test_simple_no_propagation(capture_events, init_celery): - with pytest.warns(DeprecationWarning): - celery = init_celery(propagate_traces=False) - + celery = init_celery(propagate_traces=False) events = capture_events() @celery.task(name="dummy_task") @@ -534,10 +532,9 @@ def test_sentry_propagate_traces_override(init_celery): Test if the `sentry-propagate-traces` header given to `apply_async` overrides the `propagate_traces` parameter in the integration constructor. """ - with pytest.warns(DeprecationWarning): - celery = init_celery( - propagate_traces=True, traces_sample_rate=1.0, release="abcdef" - ) + celery = init_celery( + propagate_traces=True, traces_sample_rate=1.0, release="abcdef" + ) @celery.task(name="dummy_task", bind=True) def dummy_task(self, message): diff --git a/tests/tracing/test_integration_tests.py b/tests/tracing/test_integration_tests.py index 13d1a7a77b..49806e6604 100644 --- a/tests/tracing/test_integration_tests.py +++ b/tests/tracing/test_integration_tests.py @@ -147,20 +147,6 @@ def test_continue_from_headers( assert message_payload["message"] == "hello" -@pytest.mark.parametrize("sample_rate", [0.0, 1.0]) -def test_propagate_traces_deprecation_warning(sentry_init, sample_rate): - sentry_init(traces_sample_rate=sample_rate, propagate_traces=False) - - with start_transaction(name="hi"): - with start_span() as old_span: - with pytest.warns(DeprecationWarning): - dict( - sentry_sdk.get_current_scope().iter_trace_propagation_headers( - old_span - ) - ) - - @pytest.mark.parametrize("sample_rate", [0.5, 1.0]) def test_dynamic_sampling_head_sdk_creates_dsc( sentry_init, capture_envelopes, sample_rate, monkeypatch From a74cded0a1e70dcc55c742c2a15b43b404c000a3 Mon Sep 17 00:00:00 2001 From: Colton Allen Date: Fri, 14 Feb 2025 08:24:24 -0600 Subject: [PATCH 2/2] Partially unrevert --- sentry_sdk/scope.py | 5 +++++ tests/tracing/test_integration_tests.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 04cc3ea67b..4e3bb87489 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -625,6 +625,11 @@ def iter_trace_propagation_headers(self, *args, **kwargs): """ client = self.get_client() if not client.options.get("propagate_traces"): + warnings.warn( + "The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.", + DeprecationWarning, + stacklevel=2, + ) return span = kwargs.pop("span", None) diff --git a/tests/tracing/test_integration_tests.py b/tests/tracing/test_integration_tests.py index 49806e6604..13d1a7a77b 100644 --- a/tests/tracing/test_integration_tests.py +++ b/tests/tracing/test_integration_tests.py @@ -147,6 +147,20 @@ def test_continue_from_headers( assert message_payload["message"] == "hello" +@pytest.mark.parametrize("sample_rate", [0.0, 1.0]) +def test_propagate_traces_deprecation_warning(sentry_init, sample_rate): + sentry_init(traces_sample_rate=sample_rate, propagate_traces=False) + + with start_transaction(name="hi"): + with start_span() as old_span: + with pytest.warns(DeprecationWarning): + dict( + sentry_sdk.get_current_scope().iter_trace_propagation_headers( + old_span + ) + ) + + @pytest.mark.parametrize("sample_rate", [0.5, 1.0]) def test_dynamic_sampling_head_sdk_creates_dsc( sentry_init, capture_envelopes, sample_rate, monkeypatch