@@ -127,7 +127,7 @@ def test_continuous_profiler_setup_twice(mode, make_options, teardown_profiling)
127127
128128
129129def assert_single_transaction_with_profile_chunks (
130- envelopes , thread , max_chunks , transactions = 1
130+ envelopes , thread , max_chunks = None , transactions = 1
131131):
132132 items = defaultdict (list )
133133 for envelope in envelopes :
@@ -136,7 +136,8 @@ def assert_single_transaction_with_profile_chunks(
136136
137137 assert len (items ["transaction" ]) == transactions
138138 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
140141
141142 transaction = items ["transaction" ][0 ].payload .json
142143
@@ -235,7 +236,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
235236 with sentry_sdk .start_span (op = "op" ):
236237 time .sleep (0.05 )
237238
238- assert_single_transaction_with_profile_chunks (envelopes , thread , max_chunks = 10 )
239+ assert_single_transaction_with_profile_chunks (envelopes , thread )
239240
240241 for _ in range (3 ):
241242 stop_profiler ()
@@ -256,7 +257,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
256257 with sentry_sdk .start_span (op = "op" ):
257258 time .sleep (0.05 )
258259
259- assert_single_transaction_with_profile_chunks (envelopes , thread , max_chunks = 10 )
260+ assert_single_transaction_with_profile_chunks (envelopes , thread )
260261
261262
262263@pytest .mark .parametrize (
@@ -299,18 +300,27 @@ def test_continuous_profiler_manual_start_and_stop_sampled(
299300 envelopes .clear ()
300301
301302 with sentry_sdk .start_transaction (name = "profiling" ):
303+ assert get_profiler_id () is not None , "profiler should be running"
302304 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"
304307
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"
306311
307312 stop_profiler ()
308313
314+ # the profiler stops immediately in manual mode
315+ assert get_profiler_id () is None , "profiler should not be running"
316+
309317 envelopes .clear ()
310318
311319 with sentry_sdk .start_transaction (name = "profiling" ):
320+ assert get_profiler_id () is None , "profiler should not be running"
312321 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"
314324
315325 assert_single_transaction_without_profile_chunks (envelopes )
316326
@@ -397,17 +407,17 @@ def test_continuous_profiler_auto_start_and_stop_sampled(
397407 with sentry_sdk .start_transaction (name = "profiling 1" ):
398408 assert get_profiler_id () is not None , "profiler should be running"
399409 with sentry_sdk .start_span (op = "op" ):
400- time .sleep (0.03 )
410+ time .sleep (0.1 )
401411 assert get_profiler_id () is not None , "profiler should be running"
402412
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
405415 assert get_profiler_id () is not None , "profiler should be running"
406416
407417 with sentry_sdk .start_transaction (name = "profiling 2" ):
408418 assert get_profiler_id () is not None , "profiler should be running"
409419 with sentry_sdk .start_span (op = "op" ):
410- time .sleep (0.03 )
420+ time .sleep (0.1 )
411421 assert get_profiler_id () is not None , "profiler should be running"
412422
413423 # wait at least 1 cycle for the profiler to stop
0 commit comments