Skip to content

Commit bd17c62

Browse files
authored
Remove start/stop_profile_session in favor of start/stop_profiler (#4170)
Closes #4163
1 parent 1ba5c66 commit bd17c62

File tree

3 files changed

+8
-96
lines changed

3 files changed

+8
-96
lines changed

sentry_sdk/profiler/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from sentry_sdk.profiler.continuous_profiler import (
2-
start_profile_session,
32
start_profiler,
4-
stop_profile_session,
53
stop_profiler,
64
)
75
from sentry_sdk.profiler.transaction_profiler import (
@@ -25,9 +23,7 @@
2523
)
2624

2725
__all__ = [
28-
"start_profile_session", # TODO: Deprecate this in favor of `start_profiler`
2926
"start_profiler",
30-
"stop_profile_session", # TODO: Deprecate this in favor of `stop_profiler`
3127
"stop_profiler",
3228
# DEPRECATED: The following was re-exported for backwards compatibility. It
3329
# will be removed from sentry_sdk.profiler in a future release.

sentry_sdk/profiler/continuous_profiler.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,6 @@ def start_profiler():
151151
_scheduler.manual_start()
152152

153153

154-
def start_profile_session():
155-
# type: () -> None
156-
157-
# TODO: deprecate this as it'll be replaced by `start_profiler`
158-
start_profiler()
159-
160-
161154
def stop_profiler():
162155
# type: () -> None
163156
if _scheduler is None:
@@ -166,13 +159,6 @@ def stop_profiler():
166159
_scheduler.manual_stop()
167160

168161

169-
def stop_profile_session():
170-
# type: () -> None
171-
172-
# TODO: deprecate this as it'll be replaced by `stop_profiler`
173-
stop_profiler()
174-
175-
176162
def teardown_continuous_profiler():
177163
# type: () -> None
178164
stop_profiler()

tests/profiler/test_continuous_profiler.py

Lines changed: 8 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
get_profiler_id,
1212
setup_continuous_profiler,
1313
start_profiler,
14-
start_profile_session,
1514
stop_profiler,
16-
stop_profile_session,
1715
)
1816
from tests.conftest import ApproxDict
1917

@@ -209,21 +207,6 @@ def assert_single_transaction_without_profile_chunks(envelopes):
209207
pytest.param("gevent", marks=requires_gevent),
210208
],
211209
)
212-
@pytest.mark.parametrize(
213-
["start_profiler_func", "stop_profiler_func"],
214-
[
215-
pytest.param(
216-
start_profile_session,
217-
stop_profile_session,
218-
id="start_profile_session/stop_profile_session",
219-
),
220-
pytest.param(
221-
start_profiler,
222-
stop_profiler,
223-
id="start_profiler/stop_profiler (deprecated)",
224-
),
225-
],
226-
)
227210
@pytest.mark.parametrize(
228211
"make_options",
229212
[
@@ -236,8 +219,6 @@ def test_continuous_profiler_auto_start_and_manual_stop(
236219
sentry_init,
237220
capture_envelopes,
238221
mode,
239-
start_profiler_func,
240-
stop_profiler_func,
241222
make_options,
242223
teardown_profiling,
243224
):
@@ -258,7 +239,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
258239
assert_single_transaction_with_profile_chunks(envelopes, thread)
259240

260241
for _ in range(3):
261-
stop_profiler_func()
242+
stop_profiler()
262243

263244
envelopes.clear()
264245

@@ -268,7 +249,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
268249

269250
assert_single_transaction_without_profile_chunks(envelopes)
270251

271-
start_profiler_func()
252+
start_profiler()
272253

273254
envelopes.clear()
274255

@@ -286,21 +267,6 @@ def test_continuous_profiler_auto_start_and_manual_stop(
286267
pytest.param("gevent", marks=requires_gevent),
287268
],
288269
)
289-
@pytest.mark.parametrize(
290-
["start_profiler_func", "stop_profiler_func"],
291-
[
292-
pytest.param(
293-
start_profile_session,
294-
stop_profile_session,
295-
id="start_profile_session/stop_profile_session",
296-
),
297-
pytest.param(
298-
start_profiler,
299-
stop_profiler,
300-
id="start_profiler/stop_profiler (deprecated)",
301-
),
302-
],
303-
)
304270
@pytest.mark.parametrize(
305271
"make_options",
306272
[
@@ -313,8 +279,6 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
313279
sentry_init,
314280
capture_envelopes,
315281
mode,
316-
start_profiler_func,
317-
stop_profiler_func,
318282
make_options,
319283
teardown_profiling,
320284
):
@@ -331,7 +295,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
331295
thread = threading.current_thread()
332296

333297
for _ in range(3):
334-
start_profiler_func()
298+
start_profiler()
335299

336300
envelopes.clear()
337301

@@ -345,7 +309,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
345309

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

348-
stop_profiler_func()
312+
stop_profiler()
349313

350314
# the profiler stops immediately in manual mode
351315
assert get_profiler_id() is None, "profiler should not be running"
@@ -368,21 +332,6 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
368332
pytest.param("gevent", marks=requires_gevent),
369333
],
370334
)
371-
@pytest.mark.parametrize(
372-
["start_profiler_func", "stop_profiler_func"],
373-
[
374-
pytest.param(
375-
start_profile_session,
376-
stop_profile_session,
377-
id="start_profile_session/stop_profile_session",
378-
),
379-
pytest.param(
380-
start_profiler,
381-
stop_profiler,
382-
id="start_profiler/stop_profiler (deprecated)",
383-
),
384-
],
385-
)
386335
@pytest.mark.parametrize(
387336
"make_options",
388337
[
@@ -394,8 +343,6 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(
394343
sentry_init,
395344
capture_envelopes,
396345
mode,
397-
start_profiler_func,
398-
stop_profiler_func,
399346
make_options,
400347
teardown_profiling,
401348
):
@@ -409,15 +356,15 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(
409356

410357
envelopes = capture_envelopes()
411358

412-
start_profiler_func()
359+
start_profiler()
413360

414361
with sentry_sdk.start_span(name="profiling"):
415362
with sentry_sdk.start_span(op="op"):
416363
time.sleep(0.05)
417364

418365
assert_single_transaction_without_profile_chunks(envelopes)
419366

420-
stop_profiler_func()
367+
stop_profiler()
421368

422369

423370
@pytest.mark.parametrize(
@@ -538,21 +485,6 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
538485
),
539486
],
540487
)
541-
@pytest.mark.parametrize(
542-
["start_profiler_func", "stop_profiler_func"],
543-
[
544-
pytest.param(
545-
start_profile_session,
546-
stop_profile_session,
547-
id="start_profile_session/stop_profile_session",
548-
),
549-
pytest.param(
550-
start_profiler,
551-
stop_profiler,
552-
id="start_profiler/stop_profiler (deprecated)",
553-
),
554-
],
555-
)
556488
@pytest.mark.parametrize(
557489
"make_options",
558490
[
@@ -563,8 +495,6 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
563495
def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyle(
564496
sentry_init,
565497
mode,
566-
start_profiler_func,
567-
stop_profiler_func,
568498
class_name,
569499
make_options,
570500
teardown_profiling,
@@ -580,11 +510,11 @@ def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyl
580510
with mock.patch(
581511
f"sentry_sdk.profiler.continuous_profiler.{class_name}.ensure_running"
582512
) as mock_ensure_running:
583-
start_profiler_func()
513+
start_profiler()
584514
mock_ensure_running.assert_not_called()
585515

586516
with mock.patch(
587517
f"sentry_sdk.profiler.continuous_profiler.{class_name}.teardown"
588518
) as mock_teardown:
589-
stop_profiler_func()
519+
stop_profiler()
590520
mock_teardown.assert_not_called()

0 commit comments

Comments
 (0)