From 865ae1a7f320a1ddd635ed3d0a843e88be37370f Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 29 Sep 2026 13:34:14 +0200 Subject: [PATCH 1/3] chore: Deprecate transaction profiling --- sentry_sdk/client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 16c17813c2..9f54088438 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -403,6 +403,21 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]": stacklevel=2, ) + if has_profiling_enabled(rv): + warnings.warn( + "Transaction-based profiling is deprecated and will be removed in the next major version of the SDK. " + "Please use continuous profiling instead: https://docs.sentry.io/platforms/python/profiling/", + DeprecationWarning, + stacklevel=2, + ) + if has_span_streaming_enabled(rv): + warnings.warn( + "Transaction-based profiling has no effect when `trace_lifecycle` is set to `stream`. " + "Please use continuous profiling instead: https://docs.sentry.io/platforms/python/profiling/", + UserWarning, + stacklevel=2, + ) + return rv From e962488c67bc5e7450be85c2eb47e66ba18c5841 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 29 Sep 2026 13:45:19 +0200 Subject: [PATCH 2/3] fix test --- tests/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client.py b/tests/test_client.py index ad08932690..f90d0361b1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1311,7 +1311,7 @@ def test_uwsgi_warnings(sentry_init, recwarn, opt, missing_flags): uwsgi = mock.MagicMock() uwsgi.opt = opt with mock.patch.dict("sys.modules", uwsgi=uwsgi): - sentry_init(profiles_sample_rate=1.0) + sentry_init() if missing_flags: assert len(recwarn) == 1 record = recwarn.pop() From 0c8647d8233d162734554c81ec677aab3fd47d78 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 30 Sep 2026 13:51:32 +0200 Subject: [PATCH 3/3] add tests --- tests/test_client.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index f90d0361b1..7d42fc4446 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1485,6 +1485,22 @@ def test_enable_tracing_deprecated(sentry_init, enable_tracing): sentry_init(enable_tracing=enable_tracing) +def test_transaction_profiling_warns(sentry_init): + with pytest.warns(DeprecationWarning, match="Transaction-based profiling"): + sentry_init(profiles_sample_rate=1.0) + + +def test_continuous_profiling_does_not_warn(sentry_init): + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always") + sentry_init(profile_session_sample_rate=1.0) + + profiling_warnings = [ + w for w in caught if "Transaction-based profiling" in str(w.message) + ] + assert profiling_warnings == [] + + def test_ignore_spans_warns_without_streaming(sentry_init): with pytest.warns(UserWarning, match=r"`ignore_spans` parameter only works"): sentry_init(ignore_spans=["/health"], trace_lifecycle="static")