Skip to content

Commit 5d26c2f

Browse files
sentrivanaclaude
andauthored
ref(tests): Replace deprecated enable_tracingwith traces_sample_rate (#6077)
- Replaced deprecated `enable_tracing=True` with `traces_sample_rate=1.0` across 9 test files - Preserved tests that specifically test the `enable_tracing` option itself (`test_enable_tracing_deprecated`, `test_option_enable_tracing`, `test_celery_trace_propagation_enable_tracing`) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e23a8f1 commit 5d26c2f

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

tests/integrations/asyncpg/test_asyncpg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ async def test_connection_pool(sentry_init, capture_events) -> None:
485485
async def test_query_source_disabled(sentry_init, capture_events):
486486
sentry_options = {
487487
"integrations": [AsyncPGIntegration()],
488-
"enable_tracing": True,
488+
"traces_sample_rate": 1.0,
489489
"enable_db_query_source": False,
490490
"db_query_source_threshold_ms": 0,
491491
}
@@ -523,7 +523,7 @@ async def test_query_source_enabled(
523523
):
524524
sentry_options = {
525525
"integrations": [AsyncPGIntegration()],
526-
"enable_tracing": True,
526+
"traces_sample_rate": 1.0,
527527
"db_query_source_threshold_ms": 0,
528528
}
529529
if enable_db_query_source is not None:
@@ -559,7 +559,7 @@ async def test_query_source_enabled(
559559
async def test_query_source(sentry_init, capture_events):
560560
sentry_init(
561561
integrations=[AsyncPGIntegration()],
562-
enable_tracing=True,
562+
traces_sample_rate=1.0,
563563
enable_db_query_source=True,
564564
db_query_source_threshold_ms=0,
565565
)
@@ -609,7 +609,7 @@ async def test_query_source_with_module_in_search_path(sentry_init, capture_even
609609
"""
610610
sentry_init(
611611
integrations=[AsyncPGIntegration()],
612-
enable_tracing=True,
612+
traces_sample_rate=1.0,
613613
enable_db_query_source=True,
614614
db_query_source_threshold_ms=0,
615615
)
@@ -655,7 +655,7 @@ async def test_query_source_with_module_in_search_path(sentry_init, capture_even
655655
async def test_no_query_source_if_duration_too_short(sentry_init, capture_events):
656656
sentry_init(
657657
integrations=[AsyncPGIntegration()],
658-
enable_tracing=True,
658+
traces_sample_rate=1.0,
659659
enable_db_query_source=True,
660660
db_query_source_threshold_ms=100,
661661
)
@@ -700,7 +700,7 @@ def fake_record_sql_queries(*args, **kwargs):
700700
async def test_query_source_if_duration_over_threshold(sentry_init, capture_events):
701701
sentry_init(
702702
integrations=[AsyncPGIntegration()],
703-
enable_tracing=True,
703+
traces_sample_rate=1.0,
704704
enable_db_query_source=True,
705705
db_query_source_threshold_ms=100,
706706
)

tests/integrations/celery/test_celery.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def example_task():
606606
def test_messaging_destination_name_default_exchange(
607607
mock_request, routing_key, init_celery, capture_events
608608
):
609-
celery_app = init_celery(enable_tracing=True)
609+
celery_app = init_celery(traces_sample_rate=1.0)
610610
events = capture_events()
611611
mock_request.delivery_info = {"routing_key": routing_key, "exchange": ""}
612612

@@ -630,7 +630,7 @@ def test_messaging_destination_name_nondefault_exchange(
630630
that the routing key is the queue name. Other exchanges may not guarantee this
631631
behavior.
632632
"""
633-
celery_app = init_celery(enable_tracing=True)
633+
celery_app = init_celery(traces_sample_rate=1.0)
634634
events = capture_events()
635635
mock_request.delivery_info = {"routing_key": "celery", "exchange": "custom"}
636636

@@ -645,7 +645,7 @@ def task(): ...
645645

646646

647647
def test_messaging_id(init_celery, capture_events):
648-
celery = init_celery(enable_tracing=True)
648+
celery = init_celery(traces_sample_rate=1.0)
649649
events = capture_events()
650650

651651
@celery.task
@@ -659,7 +659,7 @@ def example_task(): ...
659659

660660

661661
def test_retry_count_zero(init_celery, capture_events):
662-
celery = init_celery(enable_tracing=True)
662+
celery = init_celery(traces_sample_rate=1.0)
663663
events = capture_events()
664664

665665
@celery.task()
@@ -676,7 +676,7 @@ def task(): ...
676676
def test_retry_count_nonzero(mock_request, init_celery, capture_events):
677677
mock_request.retries = 3
678678

679-
celery = init_celery(enable_tracing=True)
679+
celery = init_celery(traces_sample_rate=1.0)
680680
events = capture_events()
681681

682682
@celery.task()
@@ -691,7 +691,7 @@ def task(): ...
691691

692692
@pytest.mark.parametrize("system", ("redis", "amqp"))
693693
def test_messaging_system(system, init_celery, capture_events):
694-
celery = init_celery(enable_tracing=True)
694+
celery = init_celery(traces_sample_rate=1.0)
695695
events = capture_events()
696696

697697
# Does not need to be a real URL, since we use always eager
@@ -716,7 +716,7 @@ def publish(*args, **kwargs):
716716

717717
monkeypatch.setattr(kombu.messaging.Producer, "_publish", publish)
718718

719-
sentry_init(integrations=[CeleryIntegration()], enable_tracing=True)
719+
sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0)
720720
celery = Celery(__name__, broker=f"{system}://example.com") # noqa: E231
721721
events = capture_events()
722722

@@ -754,7 +754,7 @@ def task(): ...
754754

755755

756756
def tests_span_origin_consumer(init_celery, capture_events):
757-
celery = init_celery(enable_tracing=True)
757+
celery = init_celery(traces_sample_rate=1.0)
758758
celery.conf.broker_url = "redis://example.com" # noqa: E231
759759

760760
events = capture_events()
@@ -778,7 +778,7 @@ def publish(*args, **kwargs):
778778

779779
monkeypatch.setattr(kombu.messaging.Producer, "_publish", publish)
780780

781-
sentry_init(integrations=[CeleryIntegration()], enable_tracing=True)
781+
sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0)
782782
celery = Celery(__name__, broker="redis://example.com") # noqa: E231
783783

784784
events = capture_events()
@@ -807,7 +807,7 @@ def test_send_task_wrapped(
807807
capture_events,
808808
reset_integrations,
809809
):
810-
sentry_init(integrations=[CeleryIntegration()], enable_tracing=True)
810+
sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0)
811811
celery = Celery(__name__, broker="redis://example.com") # noqa: E231
812812

813813
events = capture_events()

tests/integrations/celery/test_update_celery_task_headers.py

Lines changed: 2 additions & 2 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,

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def test_engine_name_not_string(sentry_init):
301301
def test_query_source_disabled(sentry_init, capture_events):
302302
sentry_options = {
303303
"integrations": [SqlalchemyIntegration()],
304-
"enable_tracing": True,
304+
"traces_sample_rate": 1.0,
305305
"enable_db_query_source": False,
306306
"db_query_source_threshold_ms": 0,
307307
}
@@ -352,7 +352,7 @@ class Person(Base):
352352
def test_query_source_enabled(sentry_init, capture_events, enable_db_query_source):
353353
sentry_options = {
354354
"integrations": [SqlalchemyIntegration()],
355-
"enable_tracing": True,
355+
"traces_sample_rate": 1.0,
356356
"db_query_source_threshold_ms": 0,
357357
}
358358
if enable_db_query_source is not None:
@@ -403,7 +403,7 @@ class Person(Base):
403403
def test_query_source(sentry_init, capture_events):
404404
sentry_init(
405405
integrations=[SqlalchemyIntegration()],
406-
enable_tracing=True,
406+
traces_sample_rate=1.0,
407407
enable_db_query_source=True,
408408
db_query_source_threshold_ms=0,
409409
)
@@ -468,7 +468,7 @@ def test_query_source_with_module_in_search_path(sentry_init, capture_events):
468468
"""
469469
sentry_init(
470470
integrations=[SqlalchemyIntegration()],
471-
enable_tracing=True,
471+
traces_sample_rate=1.0,
472472
enable_db_query_source=True,
473473
db_query_source_threshold_ms=0,
474474
)
@@ -531,7 +531,7 @@ class Person(Base):
531531
def test_no_query_source_if_duration_too_short(sentry_init, capture_events):
532532
sentry_init(
533533
integrations=[SqlalchemyIntegration()],
534-
enable_tracing=True,
534+
traces_sample_rate=1.0,
535535
enable_db_query_source=True,
536536
db_query_source_threshold_ms=100,
537537
)
@@ -597,7 +597,7 @@ def __exit__(self, type, value, traceback):
597597
def test_query_source_if_duration_over_threshold(sentry_init, capture_events):
598598
sentry_init(
599599
integrations=[SqlalchemyIntegration()],
600-
enable_tracing=True,
600+
traces_sample_rate=1.0,
601601
enable_db_query_source=True,
602602
db_query_source_threshold_ms=100,
603603
)

tests/test_basics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ def test_classmethod_instance_tracing(sentry_init, capture_events):
10921092

10931093

10941094
def test_last_event_id(sentry_init):
1095-
sentry_init(enable_tracing=True)
1095+
sentry_init(traces_sample_rate=1.0)
10961096

10971097
assert last_event_id() is None
10981098

@@ -1102,7 +1102,7 @@ def test_last_event_id(sentry_init):
11021102

11031103

11041104
def test_last_event_id_transaction(sentry_init):
1105-
sentry_init(enable_tracing=True)
1105+
sentry_init(traces_sample_rate=1.0)
11061106

11071107
assert last_event_id() is None
11081108

@@ -1113,7 +1113,7 @@ def test_last_event_id_transaction(sentry_init):
11131113

11141114

11151115
def test_last_event_id_scope(sentry_init):
1116-
sentry_init(enable_tracing=True)
1116+
sentry_init(traces_sample_rate=1.0)
11171117

11181118
# Should not crash
11191119
with isolation_scope() as scope:

tests/test_scope.py

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

877877

878878
def test_last_event_id(sentry_init):
879-
sentry_init(enable_tracing=True)
879+
sentry_init(traces_sample_rate=1.0)
880880

881881
assert Scope.last_event_id() is None
882882

@@ -886,7 +886,7 @@ def test_last_event_id(sentry_init):
886886

887887

888888
def test_last_event_id_transaction(sentry_init):
889-
sentry_init(enable_tracing=True)
889+
sentry_init(traces_sample_rate=1.0)
890890

891891
assert Scope.last_event_id() is None
892892

@@ -897,7 +897,7 @@ def test_last_event_id_transaction(sentry_init):
897897

898898

899899
def test_last_event_id_cleared(sentry_init):
900-
sentry_init(enable_tracing=True)
900+
sentry_init(traces_sample_rate=1.0)
901901

902902
# Make sure last_event_id is set
903903
sentry_sdk.capture_exception(Exception("test"))

tests/tracing/test_misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def test_start_transaction_updates_scope_name_source(sentry_init):
478478

479479
@pytest.mark.parametrize("sampled", (True, None))
480480
def test_transaction_dropped_debug_not_started(sentry_init, sampled):
481-
sentry_init(enable_tracing=True)
481+
sentry_init(traces_sample_rate=1.0)
482482

483483
tx = Transaction(sampled=sampled)
484484

@@ -498,7 +498,7 @@ def test_transaction_dropped_debug_not_started(sentry_init, sampled):
498498

499499

500500
def test_transaction_dropeed_sampled_false(sentry_init):
501-
sentry_init(enable_tracing=True)
501+
sentry_init(traces_sample_rate=1.0)
502502

503503
tx = Transaction(sampled=False)
504504

@@ -516,7 +516,7 @@ def test_transaction_dropeed_sampled_false(sentry_init):
516516

517517

518518
def test_transaction_not_started_warning(sentry_init):
519-
sentry_init(enable_tracing=True)
519+
sentry_init(traces_sample_rate=1.0)
520520

521521
tx = Transaction()
522522

tests/tracing/test_propagation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def test_standalone_span_iter_headers(sentry_init):
6-
sentry_init(enable_tracing=True)
6+
sentry_init(traces_sample_rate=1.0)
77

88
with sentry_sdk.start_span(op="test") as span:
99
with pytest.raises(StopIteration):
@@ -12,7 +12,7 @@ def test_standalone_span_iter_headers(sentry_init):
1212

1313

1414
def test_span_in_span_iter_headers(sentry_init):
15-
sentry_init(enable_tracing=True)
15+
sentry_init(traces_sample_rate=1.0)
1616

1717
with sentry_sdk.start_span(op="test"):
1818
with sentry_sdk.start_span(op="test2") as span_inner:
@@ -22,7 +22,7 @@ def test_span_in_span_iter_headers(sentry_init):
2222

2323

2424
def test_span_in_transaction(sentry_init):
25-
sentry_init(enable_tracing=True)
25+
sentry_init(traces_sample_rate=1.0)
2626

2727
with sentry_sdk.start_transaction(op="test"):
2828
with sentry_sdk.start_span(op="test2") as span:
@@ -31,7 +31,7 @@ def test_span_in_transaction(sentry_init):
3131

3232

3333
def test_span_in_span_in_transaction(sentry_init):
34-
sentry_init(enable_tracing=True)
34+
sentry_init(traces_sample_rate=1.0)
3535

3636
with sentry_sdk.start_transaction(op="test"):
3737
with sentry_sdk.start_span(op="test2"):

0 commit comments

Comments
 (0)