Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tracing): Add propagate_traces deprecation warning #3899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
import warnings

from collections.abc import Mapping
from functools import wraps

Expand Down Expand Up @@ -68,6 +70,11 @@ 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
Expand Down
5 changes: 5 additions & 0 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,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)
Expand Down
11 changes: 7 additions & 4 deletions tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ def dummy_task():


def test_simple_no_propagation(capture_events, init_celery):
celery = init_celery(propagate_traces=False)
with pytest.warns(DeprecationWarning):
celery = init_celery(propagate_traces=False)

events = capture_events()

@celery.task(name="dummy_task")
Expand Down Expand Up @@ -532,9 +534,10 @@ 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.
"""
celery = init_celery(
propagate_traces=True, traces_sample_rate=1.0, release="abcdef"
)
with pytest.warns(DeprecationWarning):
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):
Expand Down
14 changes: 14 additions & 0 deletions tests/tracing/test_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ def test_continue_from_headers(sentry_init, capture_envelopes, sampled, sample_r
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
Expand Down
Loading