Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
18 changes: 17 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
Loading