Skip to content

Remove start/stop_profile_session in favor of start/stop_profiler #4170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2025
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
4 changes: 0 additions & 4 deletions sentry_sdk/profiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from sentry_sdk.profiler.continuous_profiler import (
start_profile_session,
start_profiler,
stop_profile_session,
stop_profiler,
)
from sentry_sdk.profiler.transaction_profiler import (
Expand All @@ -25,9 +23,7 @@
)

__all__ = [
"start_profile_session", # TODO: Deprecate this in favor of `start_profiler`
"start_profiler",
"stop_profile_session", # TODO: Deprecate this in favor of `stop_profiler`
"stop_profiler",
# DEPRECATED: The following was re-exported for backwards compatibility. It
# will be removed from sentry_sdk.profiler in a future release.
Expand Down
14 changes: 0 additions & 14 deletions sentry_sdk/profiler/continuous_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ def start_profiler():
_scheduler.manual_start()


def start_profile_session():
# type: () -> None

# TODO: deprecate this as it'll be replaced by `start_profiler`
start_profiler()


def stop_profiler():
# type: () -> None
if _scheduler is None:
Expand All @@ -166,13 +159,6 @@ def stop_profiler():
_scheduler.manual_stop()


def stop_profile_session():
# type: () -> None

# TODO: deprecate this as it'll be replaced by `stop_profiler`
stop_profiler()


def teardown_continuous_profiler():
# type: () -> None
stop_profiler()
Expand Down
86 changes: 8 additions & 78 deletions tests/profiler/test_continuous_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
get_profiler_id,
setup_continuous_profiler,
start_profiler,
start_profile_session,
stop_profiler,
stop_profile_session,
)
from tests.conftest import ApproxDict

Expand Down Expand Up @@ -209,21 +207,6 @@ def assert_single_transaction_without_profile_chunks(envelopes):
pytest.param("gevent", marks=requires_gevent),
],
)
@pytest.mark.parametrize(
["start_profiler_func", "stop_profiler_func"],
[
pytest.param(
start_profile_session,
stop_profile_session,
id="start_profile_session/stop_profile_session",
),
pytest.param(
start_profiler,
stop_profiler,
id="start_profiler/stop_profiler (deprecated)",
),
],
)
@pytest.mark.parametrize(
"make_options",
[
Expand All @@ -236,8 +219,6 @@ def test_continuous_profiler_auto_start_and_manual_stop(
sentry_init,
capture_envelopes,
mode,
start_profiler_func,
stop_profiler_func,
make_options,
teardown_profiling,
):
Expand All @@ -258,7 +239,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
assert_single_transaction_with_profile_chunks(envelopes, thread)

for _ in range(3):
stop_profiler_func()
stop_profiler()

envelopes.clear()

Expand All @@ -268,7 +249,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(

assert_single_transaction_without_profile_chunks(envelopes)

start_profiler_func()
start_profiler()

envelopes.clear()

Expand All @@ -286,21 +267,6 @@ def test_continuous_profiler_auto_start_and_manual_stop(
pytest.param("gevent", marks=requires_gevent),
],
)
@pytest.mark.parametrize(
["start_profiler_func", "stop_profiler_func"],
[
pytest.param(
start_profile_session,
stop_profile_session,
id="start_profile_session/stop_profile_session",
),
pytest.param(
start_profiler,
stop_profiler,
id="start_profiler/stop_profiler (deprecated)",
),
],
)
@pytest.mark.parametrize(
"make_options",
[
Expand All @@ -313,8 +279,6 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
sentry_init,
capture_envelopes,
mode,
start_profiler_func,
stop_profiler_func,
make_options,
teardown_profiling,
):
Expand All @@ -331,7 +295,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
thread = threading.current_thread()

for _ in range(3):
start_profiler_func()
start_profiler()

envelopes.clear()

Expand All @@ -345,7 +309,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(

assert get_profiler_id() is not None, "profiler should be running"

stop_profiler_func()
stop_profiler()

# the profiler stops immediately in manual mode
assert get_profiler_id() is None, "profiler should not be running"
Expand All @@ -368,21 +332,6 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
pytest.param("gevent", marks=requires_gevent),
],
)
@pytest.mark.parametrize(
["start_profiler_func", "stop_profiler_func"],
[
pytest.param(
start_profile_session,
stop_profile_session,
id="start_profile_session/stop_profile_session",
),
pytest.param(
start_profiler,
stop_profiler,
id="start_profiler/stop_profiler (deprecated)",
),
],
)
@pytest.mark.parametrize(
"make_options",
[
Expand All @@ -394,8 +343,6 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(
sentry_init,
capture_envelopes,
mode,
start_profiler_func,
stop_profiler_func,
make_options,
teardown_profiling,
):
Expand All @@ -409,15 +356,15 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(

envelopes = capture_envelopes()

start_profiler_func()
start_profiler()

with sentry_sdk.start_span(name="profiling"):
with sentry_sdk.start_span(op="op"):
time.sleep(0.05)

assert_single_transaction_without_profile_chunks(envelopes)

stop_profiler_func()
stop_profiler()


@pytest.mark.parametrize(
Expand Down Expand Up @@ -538,21 +485,6 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
),
],
)
@pytest.mark.parametrize(
["start_profiler_func", "stop_profiler_func"],
[
pytest.param(
start_profile_session,
stop_profile_session,
id="start_profile_session/stop_profile_session",
),
pytest.param(
start_profiler,
stop_profiler,
id="start_profiler/stop_profiler (deprecated)",
),
],
)
@pytest.mark.parametrize(
"make_options",
[
Expand All @@ -563,8 +495,6 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyle(
sentry_init,
mode,
start_profiler_func,
stop_profiler_func,
class_name,
make_options,
teardown_profiling,
Expand All @@ -580,11 +510,11 @@ def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyl
with mock.patch(
f"sentry_sdk.profiler.continuous_profiler.{class_name}.ensure_running"
) as mock_ensure_running:
start_profiler_func()
start_profiler()
mock_ensure_running.assert_not_called()

with mock.patch(
f"sentry_sdk.profiler.continuous_profiler.{class_name}.teardown"
) as mock_teardown:
stop_profiler_func()
stop_profiler()
mock_teardown.assert_not_called()
Loading