diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 7a1275b852..ef3aa427a2 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -17,6 +17,8 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - `Span.finish()` no longer returns the `event_id` if the event is sent to sentry. - The `Profile()` constructor does not accept a `hub` parameter anymore. - A `Profile` object does not have a `.hub` property anymore. +- `MAX_PROFILE_DURATION_NS`, `PROFILE_MINIMUM_SAMPLES`, `Profile`, `Scheduler`, `ThreadScheduler`, `GeventScheduler`, `has_profiling_enabled`, `setup_profiler`, `teardown_profiler` are no longer accessible from `sentry_sdk.profiler`. They're still accessible from `sentry_sdk.profiler.transaction_profiler`. +- `DEFAULT_SAMPLING_FREQUENCY`, `MAX_STACK_DEPTH`, `get_frame_name`, `extract_frame`, `extract_stack`, `frame_id` are no longer accessible from `sentry_sdk.profiler`. They're still accessible from `sentry_sdk.profiler.utils`. - `sentry_sdk.continue_trace` no longer returns a `Transaction` and is now a context manager. - Redis integration: In Redis pipeline spans there is no `span["data"]["redis.commands"]` that contains a dict `{"count": 3, "first_ten": ["cmd1", "cmd2", ...]}` but instead `span["data"]["redis.commands.count"]` (containing `3`) and `span["data"]["redis.commands.first_ten"]` (containing `["cmd1", "cmd2", ...]`). - clickhouse-driver integration: The query is now available under the `db.query.text` span attribute (only if `send_default_pii` is `True`). @@ -130,6 +132,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - Spans no longer have a `description`. Use `name` instead. - Dropped support for Python 3.6. +- The `enable_tracing` `init` option has been removed. Configure `traces_sample_rate` directly. - The `custom_sampling_context` parameter of `start_transaction` has been removed. Use `attributes` instead to set key-value pairs of data that should be accessible in the traces sampler. Note that span attributes need to conform to the [OpenTelemetry specification](https://opentelemetry.io/docs/concepts/signals/traces/#attributes), meaning only certain types can be set as values. - The PyMongo integration no longer sets tags. The data is still accessible via span attributes. - The PyMongo integration doesn't set `operation_ids` anymore. The individual IDs (`operation_id`, `request_id`, `session_id`) are now accessible as separate span attributes. @@ -141,13 +144,17 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - The context manager `auto_session_tracking()` has been removed. Use `track_session()` instead. - The context manager `auto_session_tracking_scope()` has been removed. Use `track_session()` instead. - Utility function `is_auto_session_tracking_enabled()` has been removed. There is no public replacement. There is a private `_is_auto_session_tracking_enabled()` (if you absolutely need this function) It accepts a `scope` parameter instead of the previously used `hub` parameter. -- Utility function `is_auto_session_tracking_enabled_scope()` has been removed. There is no public replacement. There is a private `_is_auto_session_tracking_enabled()` (if you absolutely need this function) +- Utility function `is_auto_session_tracking_enabled_scope()` has been removed. There is no public replacement. There is a private `_is_auto_session_tracking_enabled()` (if you absolutely need this function). - Setting `scope.level` has been removed. Use `scope.set_level` instead. - `span.containing_transaction` has been removed. Use `span.root_span` instead. - `continue_from_headers`, `continue_from_environ` and `from_traceparent` have been removed, please use top-level API `sentry_sdk.continue_trace` instead. - `PropagationContext` constructor no longer takes a `dynamic_sampling_context` but takes a `baggage` object instead. - `ThreadingIntegration` no longer takes the `propagate_hub` argument. - `Baggage.populate_from_transaction` has been removed. +- `debug.configure_debug_hub` was removed. +- `profiles_sample_rate` and `profiler_mode` were removed from options available via `_experiments`. Use the top-level `profiles_sample_rate` and `profiler_mode` options instead. +- `Transport.capture_event` has been removed. Use `Transport.capture_envelope` instead. +- Function transports are no longer supported. Subclass the `Transport` instead. ### Deprecated diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index bce5361572..059a752451 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -9,7 +9,6 @@ from datetime import datetime, timezone from importlib import import_module from typing import TYPE_CHECKING, List, Dict, cast, overload -import warnings from sentry_sdk._compat import check_uwsgi_thread_support from sentry_sdk.utils import ( @@ -121,9 +120,6 @@ def _get_options(*args, **kwargs): rv["project_root"] = project_root - if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None: - rv["traces_sample_rate"] = 1.0 - if rv["event_scrubber"] is None: rv["event_scrubber"] = EventScrubber( send_default_pii=( @@ -137,13 +133,6 @@ def _get_options(*args, **kwargs): ) rv["socket_options"] = None - if rv["enable_tracing"] is not None: - warnings.warn( - "The `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.", - DeprecationWarning, - stacklevel=2, - ) - return rv diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index eee70006fe..7841c4d9b4 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -526,7 +526,6 @@ def __init__( proxy_headers=None, # type: Optional[Dict[str, str]] before_send_transaction=None, # type: Optional[TransactionProcessor] project_root=None, # type: Optional[str] - enable_tracing=None, # type: Optional[bool] include_local_variables=True, # type: Optional[bool] include_source_context=True, # type: Optional[bool] trace_propagation_targets=[ # noqa: B006 @@ -915,9 +914,6 @@ def __init__( :param profile_session_sample_rate: - - :param enable_tracing: - :param propagate_traces: :param auto_session_tracking: diff --git a/sentry_sdk/debug.py b/sentry_sdk/debug.py index f740d92dec..32b36a4048 100644 --- a/sentry_sdk/debug.py +++ b/sentry_sdk/debug.py @@ -1,6 +1,5 @@ import sys import logging -import warnings from sentry_sdk import get_client from sentry_sdk.client import _client_init_debug @@ -30,12 +29,3 @@ def configure_logger(): logger.addHandler(_handler) logger.setLevel(logging.DEBUG) logger.addFilter(_DebugFilter()) - - -def configure_debug_hub(): - # type: () -> None - warnings.warn( - "configure_debug_hub is deprecated. Please remove calls to it, as it is a no-op.", - DeprecationWarning, - stacklevel=2, - ) diff --git a/sentry_sdk/profiler/__init__.py b/sentry_sdk/profiler/__init__.py index c146dd3a97..762bd4d9cf 100644 --- a/sentry_sdk/profiler/__init__.py +++ b/sentry_sdk/profiler/__init__.py @@ -2,44 +2,8 @@ start_profiler, stop_profiler, ) -from sentry_sdk.profiler.transaction_profiler import ( - MAX_PROFILE_DURATION_NS, - PROFILE_MINIMUM_SAMPLES, - Profile, - Scheduler, - ThreadScheduler, - GeventScheduler, - has_profiling_enabled, - setup_profiler, - teardown_profiler, -) -from sentry_sdk.profiler.utils import ( - DEFAULT_SAMPLING_FREQUENCY, - MAX_STACK_DEPTH, - get_frame_name, - extract_frame, - extract_stack, - frame_id, -) __all__ = [ "start_profiler", "stop_profiler", - # DEPRECATED: The following was re-exported for backwards compatibility. It - # will be removed from sentry_sdk.profiler in a future release. - "MAX_PROFILE_DURATION_NS", - "PROFILE_MINIMUM_SAMPLES", - "Profile", - "Scheduler", - "ThreadScheduler", - "GeventScheduler", - "has_profiling_enabled", - "setup_profiler", - "teardown_profiler", - "DEFAULT_SAMPLING_FREQUENCY", - "MAX_STACK_DEPTH", - "get_frame_name", - "extract_frame", - "extract_stack", - "frame_id", ] diff --git a/sentry_sdk/profiler/continuous_profiler.py b/sentry_sdk/profiler/continuous_profiler.py index 1619925bd2..371f61c632 100644 --- a/sentry_sdk/profiler/continuous_profiler.py +++ b/sentry_sdk/profiler/continuous_profiler.py @@ -87,15 +87,9 @@ def setup_continuous_profiler(options, sdk_info, capture_func): else: default_profiler_mode = ThreadContinuousScheduler.mode + profiler_mode = default_profiler_mode if options.get("profiler_mode") is not None: profiler_mode = options["profiler_mode"] - else: - # TODO: deprecate this and just use the existing `profiler_mode` - experiments = options.get("_experiments", {}) - - profiler_mode = ( - experiments.get("continuous_profiling_mode") or default_profiler_mode - ) frequency = DEFAULT_SAMPLING_FREQUENCY diff --git a/sentry_sdk/profiler/transaction_profiler.py b/sentry_sdk/profiler/transaction_profiler.py index 626bcabb52..095ce2f2f9 100644 --- a/sentry_sdk/profiler/transaction_profiler.py +++ b/sentry_sdk/profiler/transaction_profiler.py @@ -125,16 +125,6 @@ def has_profiling_enabled(options): if profiles_sample_rate is not None and profiles_sample_rate > 0: return True - profiles_sample_rate = options["_experiments"].get("profiles_sample_rate") - if profiles_sample_rate is not None: - logger.warning( - "_experiments['profiles_sample_rate'] is deprecated. " - "Please use the non-experimental profiles_sample_rate option " - "directly." - ) - if profiles_sample_rate > 0: - return True - return False @@ -157,16 +147,9 @@ def setup_profiler(options): else: default_profiler_mode = ThreadScheduler.mode + profiler_mode = default_profiler_mode if options.get("profiler_mode") is not None: profiler_mode = options["profiler_mode"] - else: - profiler_mode = options.get("_experiments", {}).get("profiler_mode") - if profiler_mode is not None: - logger.warning( - "_experiments['profiler_mode'] is deprecated. Please use the " - "non-experimental profiler_mode option directly." - ) - profiler_mode = profiler_mode or default_profiler_mode if ( profiler_mode == ThreadScheduler.mode @@ -283,12 +266,11 @@ def _set_initial_sampling_decision(self, sampling_context): options = client.options + sample_rate = None if callable(options.get("profiles_sampler")): sample_rate = options["profiles_sampler"](sampling_context) elif options["profiles_sample_rate"] is not None: sample_rate = options["profiles_sample_rate"] - else: - sample_rate = options["_experiments"].get("profiles_sample_rate") # The profiles_sample_rate option was not set, so profiling # was never enabled. diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 11b5361de9..4f88ef26fc 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -93,17 +93,14 @@ def has_tracing_enabled(options): # type: (Optional[Dict[str, Any]]) -> bool """ Returns True if either traces_sample_rate or traces_sampler is - defined and enable_tracing is set and not false. + defined. """ if options is None: return False return bool( - options.get("enable_tracing") is not False - and ( - options.get("traces_sample_rate") is not None - or options.get("traces_sampler") is not None - ) + options.get("traces_sample_rate") is not None + or options.get("traces_sampler") is not None ) diff --git a/sentry_sdk/transport.py b/sentry_sdk/transport.py index 16957af743..ec0b6b2349 100644 --- a/sentry_sdk/transport.py +++ b/sentry_sdk/transport.py @@ -5,7 +5,6 @@ import socket import ssl import time -import warnings from datetime import datetime, timedelta, timezone from collections import defaultdict from urllib.request import getproxies @@ -40,7 +39,7 @@ from urllib3.poolmanager import PoolManager from urllib3.poolmanager import ProxyManager - from sentry_sdk._types import Event, EventDataCategory + from sentry_sdk._types import EventDataCategory KEEP_ALIVE_SOCKET_OPTIONS = [] for option in [ @@ -73,25 +72,6 @@ def __init__(self, options=None): else: self.parsed_dsn = None - def capture_event(self, event): - # type: (Self, Event) -> None - """ - DEPRECATED: Please use capture_envelope instead. - - This gets invoked with the event dictionary when an event should - be sent to sentry. - """ - - warnings.warn( - "capture_event is deprecated, please use capture_envelope instead!", - DeprecationWarning, - stacklevel=2, - ) - - envelope = Envelope() - envelope.add_event(event) - self.capture_envelope(envelope) - @abstractmethod def capture_envelope(self, envelope): # type: (Self, Envelope) -> None @@ -806,35 +786,6 @@ def _make_pool(self): return httpcore.ConnectionPool(**opts) -class _FunctionTransport(Transport): - """ - DEPRECATED: Users wishing to provide a custom transport should subclass - the Transport class, rather than providing a function. - """ - - def __init__( - self, func # type: Callable[[Event], None] - ): - # type: (...) -> None - Transport.__init__(self) - self._func = func - - def capture_event( - self, event # type: Event - ): - # type: (...) -> None - self._func(event) - return None - - def capture_envelope(self, envelope: Envelope) -> None: - # Since function transports expect to be called with an event, we need - # to iterate over the envelope and call the function for each event, via - # the deprecated capture_event method. - event = envelope.get_event() - if event is not None: - self.capture_event(event) - - def make_transport(options): # type: (Dict[str, Any]) -> Optional[Transport] ref_transport = options["transport"] @@ -850,14 +801,6 @@ def make_transport(options): return ref_transport elif isinstance(ref_transport, type) and issubclass(ref_transport, Transport): transport_cls = ref_transport - elif callable(ref_transport): - warnings.warn( - "Function transports are deprecated and will be removed in a future release." - "Please provide a Transport instance or subclass, instead.", - DeprecationWarning, - stacklevel=2, - ) - return _FunctionTransport(ref_transport) # if a transport class is given only instantiate it if the dsn is not # empty or None diff --git a/tests/conftest.py b/tests/conftest.py index b1badd18ad..3fdbab5e54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,7 +28,7 @@ _installed_integrations, _processed_integrations, ) -from sentry_sdk.profiler import teardown_profiler +from sentry_sdk.profiler.transaction_profiler import teardown_profiler from sentry_sdk.profiler.continuous_profiler import teardown_continuous_profiler from sentry_sdk.transport import Transport from sentry_sdk.utils import reraise diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 2f25e13a60..241c79dc9d 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -611,7 +611,7 @@ def example_task(): def test_messaging_destination_name_default_exchange( mock_request, routing_key, init_celery, capture_events ): - celery_app = init_celery(enable_tracing=True) + celery_app = init_celery(traces_sample_rate=1.0) events = capture_events() mock_request.delivery_info = {"routing_key": routing_key, "exchange": ""} @@ -635,7 +635,7 @@ def test_messaging_destination_name_nondefault_exchange( that the routing key is the queue name. Other exchanges may not guarantee this behavior. """ - celery_app = init_celery(enable_tracing=True) + celery_app = init_celery(traces_sample_rate=1.0) events = capture_events() mock_request.delivery_info = {"routing_key": "celery", "exchange": "custom"} @@ -650,7 +650,7 @@ def task(): ... def test_messaging_id(init_celery, capture_events): - celery = init_celery(enable_tracing=True) + celery = init_celery(traces_sample_rate=1.0) events = capture_events() @celery.task @@ -664,7 +664,7 @@ def example_task(): ... def test_retry_count_zero(init_celery, capture_events): - celery = init_celery(enable_tracing=True) + celery = init_celery(traces_sample_rate=1.0) events = capture_events() @celery.task() @@ -681,7 +681,7 @@ def task(): ... def test_retry_count_nonzero(mock_request, init_celery, capture_events): mock_request.retries = 3 - celery = init_celery(enable_tracing=True) + celery = init_celery(traces_sample_rate=1.0) events = capture_events() @celery.task() @@ -696,7 +696,7 @@ def task(): ... @pytest.mark.parametrize("system", ("redis", "amqp")) def test_messaging_system(system, init_celery, capture_events): - celery = init_celery(enable_tracing=True) + celery = init_celery(traces_sample_rate=1.0) events = capture_events() # Does not need to be a real URL, since we use always eager @@ -721,7 +721,7 @@ def publish(*args, **kwargs): monkeypatch.setattr(kombu.messaging.Producer, "_publish", publish) - sentry_init(integrations=[CeleryIntegration()], enable_tracing=True) + sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0) celery = Celery(__name__, broker=f"{system}://example.com") # noqa: E231 events = capture_events() @@ -759,7 +759,7 @@ def task(): ... def tests_span_origin_consumer(init_celery, capture_events): - celery = init_celery(enable_tracing=True) + celery = init_celery(traces_sample_rate=1.0) celery.conf.broker_url = "redis://example.com" # noqa: E231 events = capture_events() @@ -783,7 +783,7 @@ def publish(*args, **kwargs): monkeypatch.setattr(kombu.messaging.Producer, "_publish", publish) - sentry_init(integrations=[CeleryIntegration()], enable_tracing=True) + sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0) celery = Celery(__name__, broker="redis://example.com") # noqa: E231 events = capture_events() @@ -812,7 +812,7 @@ def test_send_task_wrapped( capture_events, reset_integrations, ): - sentry_init(integrations=[CeleryIntegration()], enable_tracing=True) + sentry_init(integrations=[CeleryIntegration()], traces_sample_rate=1.0) celery = Celery(__name__, broker="redis://example.com") # noqa: E231 events = capture_events() diff --git a/tests/integrations/celery/test_update_celery_task_headers.py b/tests/integrations/celery/test_update_celery_task_headers.py index 709e49b54a..3eb9bd7e88 100644 --- a/tests/integrations/celery/test_update_celery_task_headers.py +++ b/tests/integrations/celery/test_update_celery_task_headers.py @@ -71,7 +71,7 @@ def test_monitor_beat_tasks_with_headers(monitor_beat_tasks): def test_span_with_transaction(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) headers = {} monitor_beat_tasks = False @@ -91,7 +91,7 @@ def test_span_with_transaction(sentry_init): def test_span_with_transaction_custom_headers(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) headers = { "baggage": BAGGAGE_VALUE, "sentry-trace": SENTRY_TRACE_VALUE, @@ -190,39 +190,3 @@ def test_celery_trace_propagation_traces_sample_rate( else: assert "sentry-monitor-start-timestamp-s" not in outgoing_headers assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"] - - -@pytest.mark.parametrize( - "enable_tracing,monitor_beat_tasks", - list(itertools.product([None, True, False], [True, False])), -) -def test_celery_trace_propagation_enable_tracing( - sentry_init, enable_tracing, monitor_beat_tasks -): - """ - The celery integration does not check the traces_sample_rate. - By default traces_sample_rate is None which means "do not propagate traces". - But the celery integration does not check this value. - The Celery integration has its own mechanism to propagate traces: - https://docs.sentry.io/platforms/python/integrations/celery/#distributed-traces - """ - sentry_init(enable_tracing=enable_tracing) - - headers = {} - span = None - - scope = sentry_sdk.get_isolation_scope() - - outgoing_headers = _update_celery_task_headers(headers, span, monitor_beat_tasks) - - assert outgoing_headers["sentry-trace"] == scope.get_traceparent() - assert outgoing_headers["headers"]["sentry-trace"] == scope.get_traceparent() - assert outgoing_headers["baggage"] == scope.get_baggage().serialize() - assert outgoing_headers["headers"]["baggage"] == scope.get_baggage().serialize() - - if monitor_beat_tasks: - assert "sentry-monitor-start-timestamp-s" in outgoing_headers - assert "sentry-monitor-start-timestamp-s" in outgoing_headers["headers"] - else: - assert "sentry-monitor-start-timestamp-s" not in outgoing_headers - assert "sentry-monitor-start-timestamp-s" not in outgoing_headers["headers"] diff --git a/tests/integrations/graphene/test_graphene.py b/tests/integrations/graphene/test_graphene.py index 5d54bb49cb..63bc5de5d2 100644 --- a/tests/integrations/graphene/test_graphene.py +++ b/tests/integrations/graphene/test_graphene.py @@ -207,7 +207,7 @@ def graphql_server_sync(): def test_graphql_span_holds_query_information(sentry_init, capture_events): sentry_init( integrations=[GrapheneIntegration(), FlaskIntegration()], - enable_tracing=True, + traces_sample_rate=1.0, default_integrations=False, ) events = capture_events() diff --git a/tests/integrations/sqlalchemy/test_sqlalchemy.py b/tests/integrations/sqlalchemy/test_sqlalchemy.py index 48390b352e..999b17a19f 100644 --- a/tests/integrations/sqlalchemy/test_sqlalchemy.py +++ b/tests/integrations/sqlalchemy/test_sqlalchemy.py @@ -295,14 +295,12 @@ def test_engine_name_not_string(sentry_init): def test_query_source_disabled(sentry_init, capture_events): - sentry_options = { - "integrations": [SqlalchemyIntegration()], - "enable_tracing": True, - "enable_db_query_source": False, - "db_query_source_threshold_ms": 0, - } - - sentry_init(**sentry_options) + sentry_init( + integrations=[SqlalchemyIntegration()], + traces_sample_rate=1.0, + enable_db_query_source=False, + db_query_source_threshold_ms=0, + ) events = capture_events() @@ -348,7 +346,7 @@ class Person(Base): def test_query_source_enabled(sentry_init, capture_events, enable_db_query_source): sentry_options = { "integrations": [SqlalchemyIntegration()], - "enable_tracing": True, + "traces_sample_rate": 1.0, "db_query_source_threshold_ms": 0, } if enable_db_query_source is not None: @@ -399,7 +397,7 @@ class Person(Base): def test_query_source(sentry_init, capture_events): sentry_init( integrations=[SqlalchemyIntegration()], - enable_tracing=True, + traces_sample_rate=1.0, enable_db_query_source=True, db_query_source_threshold_ms=0, ) @@ -464,7 +462,7 @@ def test_query_source_with_module_in_search_path(sentry_init, capture_events): """ sentry_init( integrations=[SqlalchemyIntegration()], - enable_tracing=True, + traces_sample_rate=1.0, enable_db_query_source=True, db_query_source_threshold_ms=0, ) @@ -527,7 +525,7 @@ class Person(Base): def test_no_query_source_if_duration_too_short(sentry_init, capture_events): sentry_init( integrations=[SqlalchemyIntegration()], - enable_tracing=True, + traces_sample_rate=1.0, enable_db_query_source=True, db_query_source_threshold_ms=100, ) @@ -595,7 +593,7 @@ def __exit__(self, type, value, traceback): def test_query_source_if_duration_over_threshold(sentry_init, capture_events): sentry_init( integrations=[SqlalchemyIntegration()], - enable_tracing=True, + traces_sample_rate=1.0, enable_db_query_source=True, db_query_source_threshold_ms=100, ) diff --git a/tests/profiler/test_transaction_profiler.py b/tests/profiler/test_transaction_profiler.py index 7679831be3..97836d59d9 100644 --- a/tests/profiler/test_transaction_profiler.py +++ b/tests/profiler/test_transaction_profiler.py @@ -39,30 +39,13 @@ def process_test_sample(sample): return [(tid, (stack, stack)) for tid, stack in sample] -def non_experimental_options(mode=None, sample_rate=None): - return {"profiler_mode": mode, "profiles_sample_rate": sample_rate} - - -def experimental_options(mode=None, sample_rate=None): - return { - "_experiments": {"profiler_mode": mode, "profiles_sample_rate": sample_rate} - } - - @pytest.mark.parametrize( "mode", [pytest.param("foo")], ) -@pytest.mark.parametrize( - "make_options", - [ - pytest.param(experimental_options, id="experiment"), - pytest.param(non_experimental_options, id="non experimental"), - ], -) -def test_profiler_invalid_mode(mode, make_options, teardown_profiling): +def test_profiler_invalid_mode(mode, teardown_profiling): with pytest.raises(ValueError): - setup_profiler(make_options(mode)) + setup_profiler({"profiler_mode": mode}) @pytest.mark.parametrize( @@ -73,30 +56,16 @@ def test_profiler_invalid_mode(mode, make_options, teardown_profiling): pytest.param("gevent", marks=requires_gevent), ], ) -@pytest.mark.parametrize( - "make_options", - [ - pytest.param(experimental_options, id="experiment"), - pytest.param(non_experimental_options, id="non experimental"), - ], -) -def test_profiler_valid_mode(mode, make_options, teardown_profiling): +def test_profiler_valid_mode(mode, teardown_profiling): # should not raise any exceptions - setup_profiler(make_options(mode)) + setup_profiler({"profiler_mode": mode}) -@pytest.mark.parametrize( - "make_options", - [ - pytest.param(experimental_options, id="experiment"), - pytest.param(non_experimental_options, id="non experimental"), - ], -) -def test_profiler_setup_twice(make_options, teardown_profiling): +def test_profiler_setup_twice(teardown_profiling): # setting up the first time should return True to indicate success - assert setup_profiler(make_options()) + assert setup_profiler({}) # setting up the second time should return False to indicate no-op - assert not setup_profiler(make_options()) + assert not setup_profiler({}) @pytest.mark.parametrize( @@ -116,13 +85,6 @@ def test_profiler_setup_twice(make_options, teardown_profiling): pytest.param(None, 0, id="profiler not enabled"), ], ) -@pytest.mark.parametrize( - "make_options", - [ - pytest.param(experimental_options, id="experiment"), - pytest.param(non_experimental_options, id="non experimental"), - ], -) @mock.patch("sentry_sdk.profiler.transaction_profiler.PROFILE_MINIMUM_SAMPLES", 0) def test_profiles_sample_rate( sentry_init, @@ -131,15 +93,12 @@ def test_profiles_sample_rate( teardown_profiling, profiles_sample_rate, profile_count, - make_options, mode, ): - options = make_options(mode=mode, sample_rate=profiles_sample_rate) sentry_init( traces_sample_rate=1.0, - profiler_mode=options.get("profiler_mode"), - profiles_sample_rate=options.get("profiles_sample_rate"), - _experiments=options.get("_experiments", {}), + profiler_mode=mode, + profiles_sample_rate=profiles_sample_rate, ) envelopes = capture_envelopes() @@ -211,6 +170,7 @@ def test_profiles_sampler( sentry_init( traces_sample_rate=1.0, profiles_sampler=profiles_sampler, + profiler_mode=mode, ) envelopes = capture_envelopes() @@ -243,7 +203,7 @@ def test_minimum_unique_samples_required( ): sentry_init( traces_sample_rate=1.0, - _experiments={"profiles_sample_rate": 1.0}, + profiles_sample_rate=1.0, ) envelopes = capture_envelopes() @@ -272,7 +232,7 @@ def test_profile_captured( ): sentry_init( traces_sample_rate=1.0, - _experiments={"profiles_sample_rate": 1.0}, + profiles_sample_rate=1.0, ) envelopes = capture_envelopes() diff --git a/tests/test_basics.py b/tests/test_basics.py index 75d9fcd0bc..272f8e9fd9 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -33,7 +33,6 @@ from sentry_sdk.integrations.stdlib import StdlibIntegration from sentry_sdk.scope import add_global_event_processor from sentry_sdk.utils import datetime_from_isoformat, get_sdk_name, reraise -from sentry_sdk.tracing_utils import has_tracing_enabled class NoOpIntegration(Integration): @@ -249,32 +248,6 @@ def do_this(): assert crumb["type"] == "default" -@pytest.mark.parametrize( - "enable_tracing, traces_sample_rate, tracing_enabled, updated_traces_sample_rate", - [ - (None, None, False, None), - (False, 0.0, False, 0.0), - (False, 1.0, False, 1.0), - (None, 1.0, True, 1.0), - (True, 1.0, True, 1.0), - (None, 0.0, True, 0.0), # We use this as - it's configured but turned off - (True, 0.0, True, 0.0), # We use this as - it's configured but turned off - (True, None, True, 1.0), - ], -) -def test_option_enable_tracing( - sentry_init, - enable_tracing, - traces_sample_rate, - tracing_enabled, - updated_traces_sample_rate, -): - sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate) - options = sentry_sdk.get_client().options - assert has_tracing_enabled(options) is tracing_enabled - assert options["traces_sample_rate"] == updated_traces_sample_rate - - def test_breadcrumb_arguments(sentry_init, capture_events): assert_hint = {"bar": 42} @@ -839,7 +812,7 @@ def test_classmethod_tracing(sentry_init): def test_last_event_id(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) assert last_event_id() is None @@ -849,7 +822,7 @@ def test_last_event_id(sentry_init): def test_last_event_id_transaction(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) assert last_event_id() is None @@ -860,7 +833,7 @@ def test_last_event_id_transaction(sentry_init): def test_last_event_id_scope(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) # Should not crash with isolation_scope() as scope: diff --git a/tests/test_client.py b/tests/test_client.py index 3c370f79af..fb547e495a 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1440,9 +1440,3 @@ def run(self, sentry_init, capture_record_lost_event_calls): ) def test_dropped_transaction(sentry_init, capture_record_lost_event_calls, test_config): test_config.run(sentry_init, capture_record_lost_event_calls) - - -@pytest.mark.parametrize("enable_tracing", [True, False]) -def test_enable_tracing_deprecated(sentry_init, enable_tracing): - with pytest.warns(DeprecationWarning): - sentry_init(enable_tracing=enable_tracing) diff --git a/tests/test_scope.py b/tests/test_scope.py index 1ae1a2fd35..98b9320944 100644 --- a/tests/test_scope.py +++ b/tests/test_scope.py @@ -884,7 +884,7 @@ def test_set_tags(): def test_last_event_id(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) assert Scope.last_event_id() is None @@ -894,7 +894,7 @@ def test_last_event_id(sentry_init): def test_last_event_id_transaction(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) assert Scope.last_event_id() is None @@ -905,7 +905,7 @@ def test_last_event_id_transaction(sentry_init): def test_last_event_id_cleared(sentry_init): - sentry_init(enable_tracing=True) + sentry_init(traces_sample_rate=1.0) # Make sure last_event_id is set sentry_sdk.capture_exception(Exception("test"))