Skip to content

feat(flask): Add span streaming support and request body capture#6264

Draft
ericapisani wants to merge 2 commits into
masterfrom
py-2323-migrate-flask
Draft

feat(flask): Add span streaming support and request body capture#6264
ericapisani wants to merge 2 commits into
masterfrom
py-2323-migrate-flask

Conversation

@ericapisani
Copy link
Copy Markdown
Member

@ericapisani ericapisani commented May 13, 2026

Add span streaming support to the Flask integration. When span streaming is enabled via _experiments={"trace_lifecycle": "stream"}, the integration now captures request body data as an attribute on the segment span.

The request body handling respects existing size limits and content type rules — oversized bodies get the substitution marker, unparseable raw data gets annotated accordingly (different from what we do today where we remove the value entirely).

Fixes PY-2323
Fixes #6021

Add request body data to the streaming segment span when span streaming is enabled. Update existing tests to cover both streaming and non-streaming code paths, and add new tests for request body capture, size limits, and header scrubbing in streaming mode.

Fixes PY-2323
Fixes #6021
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 13, 2026

PY-2323

@ericapisani
Copy link
Copy Markdown
Member Author

bugbot run

@ericapisani
Copy link
Copy Markdown
Member Author

@sentry review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Codecov Results 📊

282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 41.72s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests 📈 +143
Failed Tests
Skipped Tests 📉 -143

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 13.89%. Project has 14795 uncovered lines.
✅ Project coverage is 33.58%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
starlette.py 5.68% ⚠️ 365 Missing
flask.py 11.69% ⚠️ 136 Missing
_wsgi_common.py 28.47% ⚠️ 98 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    28.45%    33.58%    +5.13%
==========================================
  Files          190       190         —
  Lines        22250     22275       +25
  Branches      7534      7544       +10
==========================================
+ Hits          6330      7480     +1150
- Misses       15920     14795     -1125
- Partials       606       747      +141

Generated by Codecov Action

Comment thread sentry_sdk/integrations/flask.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c74acb1. Configure here.

Comment thread sentry_sdk/integrations/flask.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate flask to span first

1 participant