Skip to content

Commit 7acdb58

Browse files
committed
ref: remove deprecated propagate_traces option
`propagate_traces` is not documented and superseded by `trace_propagation_targets`. Refs getsentry#3106
1 parent 5e2d2cf commit 7acdb58

File tree

5 files changed

+3
-44
lines changed

5 files changed

+3
-44
lines changed

sentry_sdk/consts.py

-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ def __init__(
517517
debug=None, # type: Optional[bool]
518518
attach_stacktrace=False, # type: bool
519519
ca_certs=None, # type: Optional[str]
520-
propagate_traces=True, # type: bool
521520
traces_sample_rate=None, # type: Optional[float]
522521
traces_sampler=None, # type: Optional[TracesSampler]
523522
profiles_sample_rate=None, # type: Optional[float]

sentry_sdk/integrations/celery/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ class CeleryIntegration(Integration):
6363

6464
def __init__(
6565
self,
66-
propagate_traces=True,
6766
monitor_beat_tasks=False,
6867
exclude_beat_tasks=None,
6968
):
70-
# type: (bool, bool, Optional[List[str]]) -> None
71-
self.propagate_traces = propagate_traces
69+
# type: (bool, Optional[List[str]]) -> None
7270
self.monitor_beat_tasks = monitor_beat_tasks
7371
self.exclude_beat_tasks = exclude_beat_tasks
7472

@@ -257,12 +255,6 @@ def apply_async(*args, **kwargs):
257255
return f(*args, **kwargs)
258256

259257
kwarg_headers = kwargs.get("headers") or {}
260-
propagate_traces = kwarg_headers.pop(
261-
"sentry-propagate-traces", integration.propagate_traces
262-
)
263-
264-
if not propagate_traces:
265-
return f(*args, **kwargs)
266258

267259
if isinstance(args[0], Task):
268260
task_name = args[0].name # type: str

sentry_sdk/scope.py

-2
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,6 @@ def iter_trace_propagation_headers(self, *args, **kwargs):
615615
If no span is given, the trace data is taken from the scope.
616616
"""
617617
client = self.get_client()
618-
if not client.options.get("propagate_traces"):
619-
return
620618

621619
span = kwargs.pop("span", None)
622620
span = span or self.span

tests/integrations/celery/integration_tests/test_celery_beat_cron_monitoring.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ def celery_init(sentry_init, celery_config):
3434

3535
from sentry_sdk.integrations.celery import CeleryIntegration
3636

37-
def inner(propagate_traces=True, monitor_beat_tasks=False, **kwargs):
37+
def inner(monitor_beat_tasks=False, **kwargs):
3838
sentry_init(
3939
integrations=[
4040
CeleryIntegration(
41-
propagate_traces=propagate_traces,
4241
monitor_beat_tasks=monitor_beat_tasks,
4342
)
4443
],

tests/integrations/celery/test_celery.py

+1-30
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ def inner(signal, f):
2828
@pytest.fixture
2929
def init_celery(sentry_init, request):
3030
def inner(
31-
propagate_traces=True,
3231
backend="always_eager",
3332
monitor_beat_tasks=False,
3433
**kwargs,
3534
):
3635
sentry_init(
3736
integrations=[
3837
CeleryIntegration(
39-
propagate_traces=propagate_traces,
4038
monitor_beat_tasks=monitor_beat_tasks,
4139
)
4240
],
@@ -267,24 +265,6 @@ def dummy_task():
267265
assert not sentry_sdk.get_isolation_scope()._tags
268266

269267

270-
def test_simple_no_propagation(capture_events, init_celery):
271-
celery = init_celery(propagate_traces=False)
272-
events = capture_events()
273-
274-
@celery.task(name="dummy_task")
275-
def dummy_task():
276-
1 / 0
277-
278-
with start_transaction() as transaction:
279-
dummy_task.delay()
280-
281-
(event,) = events
282-
assert event["contexts"]["trace"]["trace_id"] != transaction.trace_id
283-
assert event["transaction"] == "dummy_task"
284-
(exception,) = event["exception"]["values"]
285-
assert exception["type"] == "ZeroDivisionError"
286-
287-
288268
def test_ignore_expected(capture_events, celery):
289269
events = capture_events()
290270

@@ -532,9 +512,7 @@ def test_sentry_propagate_traces_override(init_celery):
532512
Test if the `sentry-propagate-traces` header given to `apply_async`
533513
overrides the `propagate_traces` parameter in the integration constructor.
534514
"""
535-
celery = init_celery(
536-
propagate_traces=True, traces_sample_rate=1.0, release="abcdef"
537-
)
515+
celery = init_celery(traces_sample_rate=1.0, release="abcdef")
538516

539517
@celery.task(name="dummy_task", bind=True)
540518
def dummy_task(self, message):
@@ -550,13 +528,6 @@ def dummy_task(self, message):
550528
).get()
551529
assert transaction_trace_id == task_transaction_id
552530

553-
# should NOT propagate trace (overrides `propagate_traces` parameter in integration constructor)
554-
task_transaction_id = dummy_task.apply_async(
555-
args=("another message",),
556-
headers={"sentry-propagate-traces": False},
557-
).get()
558-
assert transaction_trace_id != task_transaction_id
559-
560531

561532
def test_apply_async_manually_span(sentry_init):
562533
sentry_init(

0 commit comments

Comments
 (0)