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.
fastapi instrumentation #890
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
fastapi instrumentation #890
Changes from all commits
d26d8ea
24bb771
040690f
d27b35e
3a0b7ca
2d6b9cc
4f36ca4
07485d0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually this is still utilizing the starlette components of fastapi. So either is correct.
I wanted to link to the actual blocker ticket here, which is in the starlette repo, rather than FastAPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you briefly explain what this "hack" does to get the http.route? What is in app.routes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.routes is the list of routes added to starlette: https://www.starlette.io/routing/
This mimics logic in the starlette app router itself to match to one of the routes in the list, and find the appropriate one.
In the future the code in the linked pr in the docstring will add the appropriate objects in the scope, at which point we will be able to extract the 'http.route' object by querying the first object in the "routes" value added to the scope: encode/starlette#804.
By doing this, we can avoid two iterations of all match objects, which will lead to performance hits depending on the complexity and number of routes added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right that makes sense. What I'm confused about is, if
starlette_route
is one of the list of routes added, why match it with scope? Does scope contain the actual route that is being used, but we don't know the key? Also, ismatches
a method of theRoute
object in starlette? I can't seem to find documentation on it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the documentation around starlette is a bit rough. I found it via looking through the code (particularly the router part. the starlette PR above is still a good reference).
a starlette_route is just an object, and you iterate through all routes mounted on the app, regardless of whether it's appropriate for the http route or not. the scope contains the url and path, which is what the route is matching against (as well as other things like HTTP method).