Skip to content

Commit fb72ce0

Browse files
committed
feat(tracing): Add propagate_traces deprecation warning
Fixes GH-3106
1 parent bb85c26 commit fb72ce0

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

Diff for: sentry_sdk/integrations/celery/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
import warnings
3+
24
from collections.abc import Mapping
35
from functools import wraps
46

@@ -67,6 +69,11 @@ def __init__(
6769
monitor_beat_tasks=False,
6870
exclude_beat_tasks=None,
6971
):
72+
warnings.warn(
73+
"The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.",
74+
DeprecationWarning,
75+
stacklevel=2,
76+
)
7077
# type: (bool, bool, Optional[List[str]]) -> None
7178
self.propagate_traces = propagate_traces
7279
self.monitor_beat_tasks = monitor_beat_tasks

Diff for: sentry_sdk/scope.py

+5
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ def iter_trace_propagation_headers(self, *args, **kwargs):
621621
"""
622622
client = self.get_client()
623623
if not client.options.get("propagate_traces"):
624+
warnings.warn(
625+
"The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.",
626+
DeprecationWarning,
627+
stacklevel=2,
628+
)
624629
return
625630

626631
span = kwargs.pop("span", None)

Diff for: tests/integrations/celery/test_celery.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def dummy_task():
268268

269269

270270
def test_simple_no_propagation(capture_events, init_celery):
271-
celery = init_celery(propagate_traces=False)
271+
with pytest.warns(DeprecationWarning):
272+
celery = init_celery(propagate_traces=False)
273+
272274
events = capture_events()
273275

274276
@celery.task(name="dummy_task")
@@ -532,9 +534,10 @@ def test_sentry_propagate_traces_override(init_celery):
532534
Test if the `sentry-propagate-traces` header given to `apply_async`
533535
overrides the `propagate_traces` parameter in the integration constructor.
534536
"""
535-
celery = init_celery(
536-
propagate_traces=True, traces_sample_rate=1.0, release="abcdef"
537-
)
537+
with pytest.warns(DeprecationWarning):
538+
celery = init_celery(
539+
propagate_traces=True, traces_sample_rate=1.0, release="abcdef"
540+
)
538541

539542
@celery.task(name="dummy_task", bind=True)
540543
def dummy_task(self, message):

Diff for: tests/tracing/test_integration_tests.py

+14
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ def test_continue_from_headers(sentry_init, capture_envelopes, sampled, sample_r
138138
assert message_payload["message"] == "hello"
139139

140140

141+
@pytest.mark.parametrize("sample_rate", [0.0, 1.0])
142+
def test_propagate_traces_deprecation_warning(sentry_init, sample_rate):
143+
sentry_init(traces_sample_rate=sample_rate, propagate_traces=False)
144+
145+
with start_transaction(name="hi"):
146+
with start_span() as old_span:
147+
with pytest.warns(DeprecationWarning):
148+
dict(
149+
sentry_sdk.get_current_scope().iter_trace_propagation_headers(
150+
old_span
151+
)
152+
)
153+
154+
141155
@pytest.mark.parametrize("sample_rate", [0.5, 1.0])
142156
def test_dynamic_sampling_head_sdk_creates_dsc(
143157
sentry_init, capture_envelopes, sample_rate, monkeypatch

0 commit comments

Comments
 (0)