-
Notifications
You must be signed in to change notification settings - Fork 469
fix(fastapi): apply tracing to user middlewares in fastapi #4478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
32222ee
chore(fastapi): add reproduction for fastapi bug
mabdinur a781b61
add fix and releasenote
mabdinur ef20716
Update releasenotes/notes/fastapi-fix-middlewares-705975a535daaea8.yaml
mabdinur e584ba9
make trace middleware test a snapshot test
mabdinur 68cd3fa
Update releasenotes/notes/fastapi-fix-middlewares-705975a535daaea8.yaml
mabdinur 0034720
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur 08b8efa
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur 019aebb
Update releasenotes/notes/fastapi-fix-middlewares-705975a535daaea8.yaml
mabdinur 0a2f67c
add error and span type tags to snapshot file
mabdinur 413520c
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur 0a6a7a2
ensure all fastapi middlewares are traced
mabdinur 50982f1
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur b277e81
fix failing snapshot test
mabdinur 1d4159f
fix 1.x conflict, add component tag to new snapshot
mabdinur e16a491
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur cf1ea66
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur 29f68f4
Merge branch '1.x' into fastapi/fix-tracing-in-middlewares
mabdinur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/fastapi-fix-middlewares-705975a535daaea8.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| fixes: | ||
| - | | ||
| fastapi: Previously, custom fastapi middlewares configured after application startup were not traced. This fix ensures that all fastapi middlewares are captured in the `fastapi.request` span. |
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
53 changes: 53 additions & 0 deletions
53
tests/snapshots/tests.contrib.fastapi.test_fastapi.test_tracing_in_middleware.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| [[ | ||
| { | ||
| "name": "fastapi.request", | ||
| "service": "fastapi", | ||
| "resource": "GET /", | ||
| "trace_id": 0, | ||
| "span_id": 1, | ||
| "parent_id": 0, | ||
| "type": "web", | ||
| "error": 0, | ||
| "meta": { | ||
| "_dd.p.dm": "-0", | ||
| "http.method": "GET", | ||
| "http.status_code": "200", | ||
| "http.url": "http://testserver/", | ||
| "http.useragent": "testclient", | ||
| "http.version": "1.1", | ||
| "runtime-id": "7433b22c2562484081ca485a65d19945" | ||
| }, | ||
| "metrics": { | ||
| "_dd.agent_psr": 1.0, | ||
| "_dd.top_level": 1, | ||
| "_dd.tracer_kr": 1.0, | ||
| "_sampling_priority_v1": 1, | ||
| "process_id": 4144 | ||
| }, | ||
| "duration": 1034000, | ||
| "start": 1669131973327481000 | ||
| }, | ||
| { | ||
| "name": "traced_middlware", | ||
| "service": "fastapi", | ||
| "resource": "traced_middlware", | ||
| "trace_id": 0, | ||
| "span_id": 2, | ||
| "parent_id": 1, | ||
| "type": "", | ||
| "error": 0, | ||
| "duration": 459000, | ||
| "start": 1669131973327931000 | ||
| }, | ||
| { | ||
| "name": "fastapi.serialize_response", | ||
| "service": "fastapi", | ||
| "resource": "fastapi.serialize_response", | ||
| "trace_id": 0, | ||
| "span_id": 3, | ||
| "parent_id": 2, | ||
| "type": "", | ||
| "error": 0, | ||
| "duration": 24000, | ||
| "start": 1669131973328198000 | ||
| }]] |
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.
Uh oh!
There was an error while loading. Please reload this page.