Skip to content

[Breaking] Remove deprecated propagate_traces option. #3725

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

Closed
Closed
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
1 change: 0 additions & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ def __init__(
debug=None, # type: Optional[bool]
attach_stacktrace=False, # type: bool
ca_certs=None, # type: Optional[str]
propagate_traces=True, # type: bool
traces_sample_rate=None, # type: Optional[float]
traces_sampler=None, # type: Optional[TracesSampler]
profiles_sample_rate=None, # type: Optional[float]
Expand Down
8 changes: 2 additions & 6 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ class CeleryIntegration(Integration):

def __init__(
self,
propagate_traces=True,
monitor_beat_tasks=False,
exclude_beat_tasks=None,
):
# type: (bool, bool, Optional[List[str]]) -> None
self.propagate_traces = propagate_traces
# type: (bool, Optional[List[str]]) -> None
self.monitor_beat_tasks = monitor_beat_tasks
self.exclude_beat_tasks = exclude_beat_tasks

Expand Down Expand Up @@ -256,9 +254,7 @@ def apply_async(*args, **kwargs):
return f(*args, **kwargs)

kwarg_headers = kwargs.get("headers") or {}
propagate_traces = kwarg_headers.pop(
"sentry-propagate-traces", integration.propagate_traces
)
propagate_traces = kwarg_headers.pop("sentry-propagate-traces", True)

if not propagate_traces:
return f(*args, **kwargs)
Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,6 @@ def iter_trace_propagation_headers(self, *args, **kwargs):
If no span is given, the trace data is taken from the scope.
"""
client = self.get_client()
if not client.options.get("propagate_traces"):
return

span = kwargs.pop("span", None)
span = span or self.span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ def celery_init(sentry_init, celery_config):

from sentry_sdk.integrations.celery import CeleryIntegration

def inner(propagate_traces=True, monitor_beat_tasks=False, **kwargs):
def inner(monitor_beat_tasks=False, **kwargs):
sentry_init(
integrations=[
CeleryIntegration(
propagate_traces=propagate_traces,
monitor_beat_tasks=monitor_beat_tasks,
)
],
Expand Down
28 changes: 3 additions & 25 deletions tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ def inner(signal, f):
@pytest.fixture
def init_celery(sentry_init, request):
def inner(
propagate_traces=True,
backend="always_eager",
monitor_beat_tasks=False,
**kwargs,
):
sentry_init(
integrations=[
CeleryIntegration(
propagate_traces=propagate_traces,
monitor_beat_tasks=monitor_beat_tasks,
)
],
Expand Down Expand Up @@ -267,24 +265,6 @@ def dummy_task():
assert not sentry_sdk.get_isolation_scope()._tags


def test_simple_no_propagation(capture_events, init_celery):
celery = init_celery(propagate_traces=False)
events = capture_events()

@celery.task(name="dummy_task")
def dummy_task():
1 / 0

with start_transaction() as transaction:
dummy_task.delay()

(event,) = events
assert event["contexts"]["trace"]["trace_id"] != transaction.trace_id
assert event["transaction"] == "dummy_task"
(exception,) = event["exception"]["values"]
assert exception["type"] == "ZeroDivisionError"


def test_ignore_expected(capture_events, celery):
events = capture_events()

Expand Down Expand Up @@ -530,11 +510,9 @@ def dummy_task(self, x, y):
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.
overrides the default trace propagation behavior.
"""
celery = init_celery(
propagate_traces=True, traces_sample_rate=1.0, release="abcdef"
)
celery = init_celery(traces_sample_rate=1.0, release="abcdef")

@celery.task(name="dummy_task", bind=True)
def dummy_task(self, message):
Expand All @@ -550,7 +528,7 @@ def dummy_task(self, message):
).get()
assert transaction_trace_id == task_transaction_id

# should NOT propagate trace (overrides `propagate_traces` parameter in integration constructor)
# should NOT propagate trace
task_transaction_id = dummy_task.apply_async(
args=("another message",),
headers={"sentry-propagate-traces": False},
Expand Down
Loading