11
11
get_profiler_id ,
12
12
setup_continuous_profiler ,
13
13
start_profiler ,
14
+ start_profile_session ,
14
15
stop_profiler ,
16
+ stop_profile_session ,
15
17
)
16
18
from tests .conftest import ApproxDict
17
19
@@ -207,6 +209,21 @@ def assert_single_transaction_without_profile_chunks(envelopes):
207
209
pytest .param ("gevent" , marks = requires_gevent ),
208
210
],
209
211
)
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
+ )
210
227
@pytest .mark .parametrize (
211
228
"make_options" ,
212
229
[
@@ -219,6 +236,8 @@ def test_continuous_profiler_auto_start_and_manual_stop(
219
236
sentry_init ,
220
237
capture_envelopes ,
221
238
mode ,
239
+ start_profiler_func ,
240
+ stop_profiler_func ,
222
241
make_options ,
223
242
teardown_profiling ,
224
243
):
@@ -239,7 +258,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
239
258
assert_single_transaction_with_profile_chunks (envelopes , thread )
240
259
241
260
for _ in range (3 ):
242
- stop_profiler ()
261
+ stop_profiler_func ()
243
262
244
263
envelopes .clear ()
245
264
@@ -249,7 +268,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
249
268
250
269
assert_single_transaction_without_profile_chunks (envelopes )
251
270
252
- start_profiler ()
271
+ start_profiler_func ()
253
272
254
273
envelopes .clear ()
255
274
@@ -267,6 +286,21 @@ def test_continuous_profiler_auto_start_and_manual_stop(
267
286
pytest .param ("gevent" , marks = requires_gevent ),
268
287
],
269
288
)
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
+ )
270
304
@pytest .mark .parametrize (
271
305
"make_options" ,
272
306
[
@@ -279,6 +313,8 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
279
313
sentry_init ,
280
314
capture_envelopes ,
281
315
mode ,
316
+ start_profiler_func ,
317
+ stop_profiler_func ,
282
318
make_options ,
283
319
teardown_profiling ,
284
320
):
@@ -295,7 +331,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
295
331
thread = threading .current_thread ()
296
332
297
333
for _ in range (3 ):
298
- start_profiler ()
334
+ start_profiler_func ()
299
335
300
336
envelopes .clear ()
301
337
@@ -309,7 +345,7 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
309
345
310
346
assert get_profiler_id () is not None , "profiler should be running"
311
347
312
- stop_profiler ()
348
+ stop_profiler_func ()
313
349
314
350
# the profiler stops immediately in manual mode
315
351
assert get_profiler_id () is None , "profiler should not be running"
@@ -332,6 +368,21 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
332
368
pytest .param ("gevent" , marks = requires_gevent ),
333
369
],
334
370
)
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
+ )
335
386
@pytest .mark .parametrize (
336
387
"make_options" ,
337
388
[
@@ -343,6 +394,8 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(
343
394
sentry_init ,
344
395
capture_envelopes ,
345
396
mode ,
397
+ start_profiler_func ,
398
+ stop_profiler_func ,
346
399
make_options ,
347
400
teardown_profiling ,
348
401
):
@@ -356,15 +409,15 @@ def test_continuous_profiler_manual_start_and_stop_unsampled(
356
409
357
410
envelopes = capture_envelopes ()
358
411
359
- start_profiler ()
412
+ start_profiler_func ()
360
413
361
414
with sentry_sdk .start_transaction (name = "profiling" ):
362
415
with sentry_sdk .start_span (op = "op" ):
363
416
time .sleep (0.05 )
364
417
365
418
assert_single_transaction_without_profile_chunks (envelopes )
366
419
367
- stop_profiler ()
420
+ stop_profiler_func ()
368
421
369
422
370
423
@pytest .mark .parametrize (
@@ -485,6 +538,21 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
485
538
),
486
539
],
487
540
)
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
+ )
488
556
@pytest .mark .parametrize (
489
557
"make_options" ,
490
558
[
@@ -495,6 +563,8 @@ def test_continuous_profiler_auto_start_and_stop_unsampled(
495
563
def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyle (
496
564
sentry_init ,
497
565
mode ,
566
+ start_profiler_func ,
567
+ stop_profiler_func ,
498
568
class_name ,
499
569
make_options ,
500
570
teardown_profiling ,
@@ -510,11 +580,11 @@ def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyl
510
580
with mock .patch (
511
581
f"sentry_sdk.profiler.continuous_profiler.{ class_name } .ensure_running"
512
582
) as mock_ensure_running :
513
- start_profiler ()
583
+ start_profiler_func ()
514
584
mock_ensure_running .assert_not_called ()
515
585
516
586
with mock .patch (
517
587
f"sentry_sdk.profiler.continuous_profiler.{ class_name } .teardown"
518
588
) as mock_teardown :
519
- stop_profiler ()
589
+ stop_profiler_func ()
520
590
mock_teardown .assert_not_called ()
0 commit comments