Skip to content

Commit 168be8c

Browse files
committed
remove enable_tracing
1 parent ca46ffc commit 168be8c

File tree

9 files changed

+23
-112
lines changed

9 files changed

+23
-112
lines changed

sentry_sdk/client.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from datetime import datetime, timezone
1010
from importlib import import_module
1111
from typing import TYPE_CHECKING, List, Dict, cast, overload
12-
import warnings
1312

1413
from sentry_sdk._compat import check_uwsgi_thread_support
1514
from sentry_sdk.utils import (
@@ -121,9 +120,6 @@ def _get_options(*args, **kwargs):
121120

122121
rv["project_root"] = project_root
123122

124-
if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None:
125-
rv["traces_sample_rate"] = 1.0
126-
127123
if rv["event_scrubber"] is None:
128124
rv["event_scrubber"] = EventScrubber(
129125
send_default_pii=(
@@ -137,13 +133,6 @@ def _get_options(*args, **kwargs):
137133
)
138134
rv["socket_options"] = None
139135

140-
if rv["enable_tracing"] is not None:
141-
warnings.warn(
142-
"The `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.",
143-
DeprecationWarning,
144-
stacklevel=2,
145-
)
146-
147136
return rv
148137

149138

sentry_sdk/consts.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ def __init__(
526526
proxy_headers=None, # type: Optional[Dict[str, str]]
527527
before_send_transaction=None, # type: Optional[TransactionProcessor]
528528
project_root=None, # type: Optional[str]
529-
enable_tracing=None, # type: Optional[bool]
530529
include_local_variables=True, # type: Optional[bool]
531530
include_source_context=True, # type: Optional[bool]
532531
trace_propagation_targets=[ # noqa: B006
@@ -915,9 +914,6 @@ def __init__(
915914
916915
:param profile_session_sample_rate:
917916
918-
919-
:param enable_tracing:
920-
921917
:param propagate_traces:
922918
923919
:param auto_session_tracking:

sentry_sdk/tracing_utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,14 @@ def has_tracing_enabled(options):
9393
# type: (Optional[Dict[str, Any]]) -> bool
9494
"""
9595
Returns True if either traces_sample_rate or traces_sampler is
96-
defined and enable_tracing is set and not false.
96+
defined.
9797
"""
9898
if options is None:
9999
return False
100100

101101
return bool(
102-
options.get("enable_tracing") is not False
103-
and (
104-
options.get("traces_sample_rate") is not None
105-
or options.get("traces_sampler") is not None
106-
)
102+
options.get("traces_sample_rate") is not None
103+
or options.get("traces_sampler") is not None
107104
)
108105

109106

tests/integrations/celery/test_update_celery_task_headers.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_monitor_beat_tasks_with_headers(monitor_beat_tasks):
7171

7272

7373
def test_span_with_transaction(sentry_init):
74-
sentry_init(enable_tracing=True)
74+
sentry_init(traces_sample_rate=1.0)
7575
headers = {}
7676
monitor_beat_tasks = False
7777

@@ -91,7 +91,7 @@ def test_span_with_transaction(sentry_init):
9191

9292

9393
def test_span_with_transaction_custom_headers(sentry_init):
94-
sentry_init(enable_tracing=True)
94+
sentry_init(traces_sample_rate=1.0)
9595
headers = {
9696
"baggage": BAGGAGE_VALUE,
9797
"sentry-trace": SENTRY_TRACE_VALUE,
@@ -190,39 +190,3 @@ def test_celery_trace_propagation_traces_sample_rate(
190190
else:
191191
assert "sentry-monitor-start-timestamp-s" not in outgoing_headers
192192
assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"]
193-
194-
195-
@pytest.mark.parametrize(
196-
"enable_tracing,monitor_beat_tasks",
197-
list(itertools.product([None, True, False], [True, False])),
198-
)
199-
def test_celery_trace_propagation_enable_tracing(
200-
sentry_init, enable_tracing, monitor_beat_tasks
201-
):
202-
"""
203-
The celery integration does not check the traces_sample_rate.
204-
By default traces_sample_rate is None which means "do not propagate traces".
205-
But the celery integration does not check this value.
206-
The Celery integration has its own mechanism to propagate traces:
207-
https://docs.sentry.io/platforms/python/integrations/celery/#distributed-traces
208-
"""
209-
sentry_init(enable_tracing=enable_tracing)
210-
211-
headers = {}
212-
span = None
213-
214-
scope = sentry_sdk.get_isolation_scope()
215-
216-
outgoing_headers = _update_celery_task_headers(headers, span, monitor_beat_tasks)
217-
218-
assert outgoing_headers["sentry-trace"] == scope.get_traceparent()
219-
assert outgoing_headers["headers"]["sentry-trace"] == scope.get_traceparent()
220-
assert outgoing_headers["baggage"] == scope.get_baggage().serialize()
221-
assert outgoing_headers["headers"]["baggage"] == scope.get_baggage().serialize()
222-
223-
if monitor_beat_tasks:
224-
assert "sentry-monitor-start-timestamp-s" in outgoing_headers
225-
assert "sentry-monitor-start-timestamp-s" in outgoing_headers["headers"]
226-
else:
227-
assert "sentry-monitor-start-timestamp-s" not in outgoing_headers
228-
assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"]

tests/integrations/graphene/test_graphene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def graphql_server_sync():
207207
def test_graphql_span_holds_query_information(sentry_init, capture_events):
208208
sentry_init(
209209
integrations=[GrapheneIntegration(), FlaskIntegration()],
210-
enable_tracing=True,
210+
traces_sample_rate=1.0,
211211
default_integrations=False,
212212
)
213213
events = capture_events()

tests/integrations/sqlalchemy/test_sqlalchemy.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,12 @@ def test_engine_name_not_string(sentry_init):
295295

296296

297297
def test_query_source_disabled(sentry_init, capture_events):
298-
sentry_options = {
299-
"integrations": [SqlalchemyIntegration()],
300-
"enable_tracing": True,
301-
"enable_db_query_source": False,
302-
"db_query_source_threshold_ms": 0,
303-
}
304-
305-
sentry_init(**sentry_options)
298+
sentry_init(
299+
integrations=[SqlalchemyIntegration()],
300+
traces_sample_rate=1.0,
301+
enable_db_query_source=False,
302+
db_query_source_threshold_ms=0,
303+
)
306304

307305
events = capture_events()
308306

@@ -348,7 +346,7 @@ class Person(Base):
348346
def test_query_source_enabled(sentry_init, capture_events, enable_db_query_source):
349347
sentry_options = {
350348
"integrations": [SqlalchemyIntegration()],
351-
"enable_tracing": True,
349+
"traces_sample_rate": 1.0,
352350
"db_query_source_threshold_ms": 0,
353351
}
354352
if enable_db_query_source is not None:
@@ -399,7 +397,7 @@ class Person(Base):
399397
def test_query_source(sentry_init, capture_events):
400398
sentry_init(
401399
integrations=[SqlalchemyIntegration()],
402-
enable_tracing=True,
400+
traces_sample_rate=1.0,
403401
enable_db_query_source=True,
404402
db_query_source_threshold_ms=0,
405403
)
@@ -464,7 +462,7 @@ def test_query_source_with_module_in_search_path(sentry_init, capture_events):
464462
"""
465463
sentry_init(
466464
integrations=[SqlalchemyIntegration()],
467-
enable_tracing=True,
465+
traces_sample_rate=1.0,
468466
enable_db_query_source=True,
469467
db_query_source_threshold_ms=0,
470468
)
@@ -527,7 +525,7 @@ class Person(Base):
527525
def test_no_query_source_if_duration_too_short(sentry_init, capture_events):
528526
sentry_init(
529527
integrations=[SqlalchemyIntegration()],
530-
enable_tracing=True,
528+
traces_sample_rate=1.0,
531529
enable_db_query_source=True,
532530
db_query_source_threshold_ms=100,
533531
)
@@ -595,7 +593,7 @@ def __exit__(self, type, value, traceback):
595593
def test_query_source_if_duration_over_threshold(sentry_init, capture_events):
596594
sentry_init(
597595
integrations=[SqlalchemyIntegration()],
598-
enable_tracing=True,
596+
traces_sample_rate=1.0,
599597
enable_db_query_source=True,
600598
db_query_source_threshold_ms=100,
601599
)

tests/test_basics.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from sentry_sdk.integrations.stdlib import StdlibIntegration
3434
from sentry_sdk.scope import add_global_event_processor
3535
from sentry_sdk.utils import datetime_from_isoformat, get_sdk_name, reraise
36-
from sentry_sdk.tracing_utils import has_tracing_enabled
3736

3837

3938
class NoOpIntegration(Integration):
@@ -249,32 +248,6 @@ def do_this():
249248
assert crumb["type"] == "default"
250249

251250

252-
@pytest.mark.parametrize(
253-
"enable_tracing, traces_sample_rate, tracing_enabled, updated_traces_sample_rate",
254-
[
255-
(None, None, False, None),
256-
(False, 0.0, False, 0.0),
257-
(False, 1.0, False, 1.0),
258-
(None, 1.0, True, 1.0),
259-
(True, 1.0, True, 1.0),
260-
(None, 0.0, True, 0.0), # We use this as - it's configured but turned off
261-
(True, 0.0, True, 0.0), # We use this as - it's configured but turned off
262-
(True, None, True, 1.0),
263-
],
264-
)
265-
def test_option_enable_tracing(
266-
sentry_init,
267-
enable_tracing,
268-
traces_sample_rate,
269-
tracing_enabled,
270-
updated_traces_sample_rate,
271-
):
272-
sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate)
273-
options = sentry_sdk.get_client().options
274-
assert has_tracing_enabled(options) is tracing_enabled
275-
assert options["traces_sample_rate"] == updated_traces_sample_rate
276-
277-
278251
def test_breadcrumb_arguments(sentry_init, capture_events):
279252
assert_hint = {"bar": 42}
280253

@@ -839,7 +812,7 @@ def test_classmethod_tracing(sentry_init):
839812

840813

841814
def test_last_event_id(sentry_init):
842-
sentry_init(enable_tracing=True)
815+
sentry_init(traces_sample_rate=1.0)
843816

844817
assert last_event_id() is None
845818

@@ -849,7 +822,7 @@ def test_last_event_id(sentry_init):
849822

850823

851824
def test_last_event_id_transaction(sentry_init):
852-
sentry_init(enable_tracing=True)
825+
sentry_init(traces_sample_rate=1.0)
853826

854827
assert last_event_id() is None
855828

@@ -860,7 +833,7 @@ def test_last_event_id_transaction(sentry_init):
860833

861834

862835
def test_last_event_id_scope(sentry_init):
863-
sentry_init(enable_tracing=True)
836+
sentry_init(traces_sample_rate=1.0)
864837

865838
# Should not crash
866839
with isolation_scope() as scope:

tests/test_client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,9 +1440,3 @@ def run(self, sentry_init, capture_record_lost_event_calls):
14401440
)
14411441
def test_dropped_transaction(sentry_init, capture_record_lost_event_calls, test_config):
14421442
test_config.run(sentry_init, capture_record_lost_event_calls)
1443-
1444-
1445-
@pytest.mark.parametrize("enable_tracing", [True, False])
1446-
def test_enable_tracing_deprecated(sentry_init, enable_tracing):
1447-
with pytest.warns(DeprecationWarning):
1448-
sentry_init(enable_tracing=enable_tracing)

tests/test_scope.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def test_set_tags():
884884

885885

886886
def test_last_event_id(sentry_init):
887-
sentry_init(enable_tracing=True)
887+
sentry_init(traces_sample_rate=1.0)
888888

889889
assert Scope.last_event_id() is None
890890

@@ -894,7 +894,7 @@ def test_last_event_id(sentry_init):
894894

895895

896896
def test_last_event_id_transaction(sentry_init):
897-
sentry_init(enable_tracing=True)
897+
sentry_init(traces_sample_rate=1.0)
898898

899899
assert Scope.last_event_id() is None
900900

@@ -905,7 +905,7 @@ def test_last_event_id_transaction(sentry_init):
905905

906906

907907
def test_last_event_id_cleared(sentry_init):
908-
sentry_init(enable_tracing=True)
908+
sentry_init(traces_sample_rate=1.0)
909909

910910
# Make sure last_event_id is set
911911
sentry_sdk.capture_exception(Exception("test"))

0 commit comments

Comments
 (0)