feat(fastapi): Capture request body on segment span under streaming#6136
Open
ericapisani wants to merge 3 commits intoep/py-2362-2mwfrom
Open
feat(fastapi): Capture request body on segment span under streaming#6136ericapisani wants to merge 3 commits intoep/py-2362-2mwfrom
ericapisani wants to merge 3 commits intoep/py-2362-2mwfrom
Conversation
FastAPI runs its own request-body extraction and was missing the same logic as that which exists in the Starlette integration. Extract the logic that writes `http.request.body.data` on the streaming segment into a shared helper in the Starlette integration, and call it from FastAPI's request handler once the body has been read.
Contributor
Codecov Results 📊✅ 142 passed | Total: 142 | Pass Rate: 100% | Execution Time: 21.25s All tests are passing successfully. ❌ Patch coverage is 8.33%. Project has 13973 uncovered lines. Files with missing lines (2)
Generated by Codecov Action |
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 793e2f7. Configure here.
FastAPI 0.79.1 pulls in Starlette 0.19.1, whose `TestClient` is built on `requests` and does not accept the `content` kwarg. Match the skipif already in place for the analogous Starlette test so CI on older FastAPI versions passes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Capture the request body as
http.request.body.dataon the streaming segment span for FastAPI requests, matching the behavior already in place for Starlette.FastAPI runs its own request-body extraction path, so it was bypassing the data-capture logic that lives in the Starlette integration. This extracts that logic into a shared helper in the Starlette integration and invokes it from FastAPI's request handler once the body has been read.
Stacked on top of #6123.
Refs PY-2322
Fixes #6020