From ca714a51a3afcb50b0b5e37c786a38b5abe51494 Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Wed, 19 Mar 2025 08:23:06 +0100 Subject: [PATCH 1/2] reverse profile_session start/stop methods deprecation --- sentry_sdk/profiler/__init__.py | 8 ++++---- sentry_sdk/profiler/continuous_profiler.py | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sentry_sdk/profiler/__init__.py b/sentry_sdk/profiler/__init__.py index d8d4e076d5..b1ef43abe6 100644 --- a/sentry_sdk/profiler/__init__.py +++ b/sentry_sdk/profiler/__init__.py @@ -25,10 +25,10 @@ ) __all__ = [ - "start_profile_session", - "start_profiler", # TODO: Deprecate this in favor of `start_profile_session` - "stop_profile_session", - "stop_profiler", # TODO: Deprecate this in favor of `stop_profile_session` + "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. "MAX_PROFILE_DURATION_NS", diff --git a/sentry_sdk/profiler/continuous_profiler.py b/sentry_sdk/profiler/continuous_profiler.py index 9e2aa35fc1..58ecbb43e9 100644 --- a/sentry_sdk/profiler/continuous_profiler.py +++ b/sentry_sdk/profiler/continuous_profiler.py @@ -145,32 +145,34 @@ def try_profile_lifecycle_trace_start(): def start_profiler(): # type: () -> None + if _scheduler is None: + return + + _scheduler.manual_start() - # TODO: deprecate this as it'll be replaced by `start_profile_session` - start_profile_session() def start_profile_session(): # type: () -> None - if _scheduler is None: - return - _scheduler.manual_start() + # TODO: deprecate this as it'll be replaced by `start_profiler` + start_profiler() def stop_profiler(): # type: () -> None + if _scheduler is None: + return - # TODO: deprecate this as it'll be replaced by `stop_profile_session` - stop_profile_session() + _scheduler.manual_stop() def stop_profile_session(): # type: () -> None - if _scheduler is None: - return - _scheduler.manual_stop() + # TODO: deprecate this as it'll be replaced by `stop_profiler` + stop_profiler() + def teardown_continuous_profiler(): From 5807ca669c6d842bf2df505eebb8d3c4cef72acc Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Wed, 19 Mar 2025 08:43:22 +0100 Subject: [PATCH 2/2] fix linter errors --- sentry_sdk/profiler/__init__.py | 8 ++++---- sentry_sdk/profiler/continuous_profiler.py | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sentry_sdk/profiler/__init__.py b/sentry_sdk/profiler/__init__.py index b1ef43abe6..0bc63e3a6d 100644 --- a/sentry_sdk/profiler/__init__.py +++ b/sentry_sdk/profiler/__init__.py @@ -25,10 +25,10 @@ ) __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", + "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. "MAX_PROFILE_DURATION_NS", diff --git a/sentry_sdk/profiler/continuous_profiler.py b/sentry_sdk/profiler/continuous_profiler.py index 58ecbb43e9..47f63d8f59 100644 --- a/sentry_sdk/profiler/continuous_profiler.py +++ b/sentry_sdk/profiler/continuous_profiler.py @@ -151,7 +151,6 @@ def start_profiler(): _scheduler.manual_start() - def start_profile_session(): # type: () -> None @@ -174,7 +173,6 @@ def stop_profile_session(): stop_profiler() - def teardown_continuous_profiler(): # type: () -> None stop_profiler()