test: Join thread in continuous profiler test by alexander-alderman-webb · Pull Request #6125 · getsentry/sentry-python
Description
Flush the profiler's buffer after the first profile is collected, and suspend execution of main thread to wait for the profiler's buffer to flush before evaluating assertions.
According to the logs in the following failed run
https://github.com/getsentry/sentry-python/actions/runs/24769385099/job/72476526451
the test fails with the following stack trace:
FAILED tests/profiler/test_continuous_profiler.py::test_continuous_profiler_auto_start_and_manual_stop[non-experiment-start_profile_session/stop_profile_session (deprecated)-thread] - tests/profiler/test_continuous_profiler.py:270: in test_continuous_profiler_auto_start_and_manual_stop
assert_single_transaction_with_profile_chunks(envelopes, thread)
tests/profiler/test_continuous_profiler.py:147: in assert_single_transaction_with_profile_chunks
assert len(items["profile_chunk"]) > 0
E assert 0 > 0
E + where 0 = len([])
The stack trace shows that profiles were not collected in the test transport by the time the assertion is executed.
The assertion runs before any manual calls to start and stop the profiler. The profiler is auto-activated and creates a profile for the transaction context manager.
Issues
Reminders
- Please add tests to validate your changes, and lint your code using
tox -e linters. - Add GH Issue ID & Linear ID (if applicable)
- PR title should use conventional commit style (
feat:,fix:,ref:,meta:) - For external contributors: CONTRIBUTING.md, Sentry SDK development docs, Discord community