@@ -127,7 +127,7 @@ def test_continuous_profiler_setup_twice(mode, make_options, teardown_profiling)
127
127
128
128
129
129
def assert_single_transaction_with_profile_chunks (
130
- envelopes , thread , max_chunks , transactions = 1
130
+ envelopes , thread , max_chunks = None , transactions = 1
131
131
):
132
132
items = defaultdict (list )
133
133
for envelope in envelopes :
@@ -136,7 +136,8 @@ def assert_single_transaction_with_profile_chunks(
136
136
137
137
assert len (items ["transaction" ]) == transactions
138
138
assert len (items ["profile_chunk" ]) > 0
139
- assert len (items ["profile_chunk" ]) <= max_chunks
139
+ if max_chunks is not None :
140
+ assert len (items ["profile_chunk" ]) <= max_chunks
140
141
141
142
transaction = items ["transaction" ][0 ].payload .json
142
143
@@ -235,7 +236,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
235
236
with sentry_sdk .start_span (op = "op" ):
236
237
time .sleep (0.05 )
237
238
238
- assert_single_transaction_with_profile_chunks (envelopes , thread , max_chunks = 10 )
239
+ assert_single_transaction_with_profile_chunks (envelopes , thread )
239
240
240
241
for _ in range (3 ):
241
242
stop_profiler ()
@@ -256,7 +257,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
256
257
with sentry_sdk .start_span (op = "op" ):
257
258
time .sleep (0.05 )
258
259
259
- assert_single_transaction_with_profile_chunks (envelopes , thread , max_chunks = 10 )
260
+ assert_single_transaction_with_profile_chunks (envelopes , thread )
260
261
261
262
262
263
@pytest .mark .parametrize (
@@ -299,18 +300,27 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
299
300
envelopes .clear ()
300
301
301
302
with sentry_sdk .start_transaction (name = "profiling" ):
303
+ assert get_profiler_id () is not None , "profiler should be running"
302
304
with sentry_sdk .start_span (op = "op" ):
303
- time .sleep (0.05 )
305
+ time .sleep (0.1 )
306
+ assert get_profiler_id () is not None , "profiler should be running"
304
307
305
- assert_single_transaction_with_profile_chunks (envelopes , thread , max_chunks = 10 )
308
+ assert_single_transaction_with_profile_chunks (envelopes , thread )
309
+
310
+ assert get_profiler_id () is not None , "profiler should be running"
306
311
307
312
stop_profiler ()
308
313
314
+ # the profiler stops immediately in manual mode
315
+ assert get_profiler_id () is None , "profiler should not be running"
316
+
309
317
envelopes .clear ()
310
318
311
319
with sentry_sdk .start_transaction (name = "profiling" ):
320
+ assert get_profiler_id () is None , "profiler should not be running"
312
321
with sentry_sdk .start_span (op = "op" ):
313
- time .sleep (0.05 )
322
+ time .sleep (0.1 )
323
+ assert get_profiler_id () is None , "profiler should not be running"
314
324
315
325
assert_single_transaction_without_profile_chunks (envelopes )
316
326
@@ -397,17 +407,17 @@ def test_continuous_profiler_auto_start_and_stop_sampled(
397
407
with sentry_sdk .start_transaction (name = "profiling 1" ):
398
408
assert get_profiler_id () is not None , "profiler should be running"
399
409
with sentry_sdk .start_span (op = "op" ):
400
- time .sleep (0.03 )
410
+ time .sleep (0.1 )
401
411
assert get_profiler_id () is not None , "profiler should be running"
402
412
403
- # the profiler takes a while to stop so if we start a transaction
404
- # immediately, it'll be part of the same chunk
413
+ # the profiler takes a while to stop in auto mode so if we start
414
+ # a transaction immediately, it'll be part of the same chunk
405
415
assert get_profiler_id () is not None , "profiler should be running"
406
416
407
417
with sentry_sdk .start_transaction (name = "profiling 2" ):
408
418
assert get_profiler_id () is not None , "profiler should be running"
409
419
with sentry_sdk .start_span (op = "op" ):
410
- time .sleep (0.03 )
420
+ time .sleep (0.1 )
411
421
assert get_profiler_id () is not None , "profiler should be running"
412
422
413
423
# wait at least 1 cycle for the profiler to stop
0 commit comments