Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions tests/profiler/test_continuous_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,28 @@ def test_continuous_profiler_setup_twice(mode, make_options, teardown_profiling)
assert not is_profile_session_sampled()


def assert_single_transaction_with_profile_chunks(
envelopes, thread, max_chunks=None, transactions=1
):
def _collect_envelope_items(envelopes):
items = defaultdict(list)
for envelope in envelopes:
for item in envelope.items:
items[item.type].append(item)
return items


def assert_single_transaction_with_profile_chunks(
envelopes, thread, max_chunks=None, transactions=1, timeout=2.0
):
# Poll for profile_chunk items to arrive, since the profiler thread
# may not have flushed yet when this assertion runs (especially under
# gevent on slow CI runners).
deadline = time.monotonic() + timeout
while True:
items = _collect_envelope_items(envelopes)
if len(items["profile_chunk"]) > 0:
break
if time.monotonic() >= deadline:
break
time.sleep(0.01)

assert len(items["transaction"]) == transactions
assert len(items["profile_chunk"]) > 0
Expand Down
Loading