feat: Allow integrations to define control flow exceptions#6425
Conversation
Codecov Results 📊✅ 282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 45.40s 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 14769 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 34.91% 34.91% —%
==========================================
Files 190 190 —
Lines 22689 22689 —
Branches 7742 7742 —
==========================================
+ Hits 7920 7920 —
- Misses 14769 14769 —
- Partials 832 832 —Generated by Codecov Action |
There was a problem hiding this comment.
No tests cover the new control-flow exception mechanism
There are no tests validating that register_control_flow_exception / should_be_treated_as_error suppress span-error status for registered exceptions, nor that AioHttpIntegration correctly exempts HTTPException — please add coverage for this new behavior.
Evidence
grepacrosstests/finds zero matches forcontrol_flow,register_control_flow_exception, orshould_be_treated_as_error.tests/integrations/aiohttp/test_aiohttp.pycontains no references toHTTPExceptionspan-status behaviour.should_be_treated_as_erroris called in bothsentry_sdk/traces.py:335andsentry_sdk/tracing.py:398to set span status, making the untested path critical.
Identified by Warden code-review
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
Nice not increasing API surface!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b81e07a. Configure here.

Description
Some frameworks we're integrating with use specific exception types for control flow. If we encounter them, we should not set the status of the current span to error.
Implement a global ignore list that each integration can populate with control flow exceptions known to it, so that whenever a span finishes, it has access to the list and can decide whether the exception that occurred constitutes an error or not.
Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)