-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fix:Update starlette.asciidoc, incorrect middleware order #1956
Conversation
Fix typo
I don't think this is correct:
So, BaseHTTPMiddleware needs to be above (i.e. before) our middleware in the list so that we have an unbroken contextvar chain from the endpoint to our middleware. Does this not match your experience? Edit: see also the original issue: #1701 |
Yesterday, we integrated the APM agent across all our microservices, placing the agent's middleware as the last element. No data was reaching the APM server in this configuration. However, when we placed it as the first element, everything worked correctly. Could it be that one of our custom middlewares(BaseHTTPMiddleware) was invalidating the context variable? Thanks for your time Colton 🥇 |
Are you passing in the middleware as a list or using the I think we need to expand this warning with examples of both. |
run docs-build |
@mariocandela Can you answer my question above? |
Hi @basepi, sorry for the delay, we use middleware as a list. I haven't had the chance to delve deeper into the issue yet. It's possible that our custom middleware, which utilizes dependency injection, could be causing the problem. I'll make sure to allocate some time to debug the APM and figure out what's going on with the contextvar. Thanks for your time |
Alright, you've confirmed my suspicion. Our middleware must be first in the list if you're passing in a list of middleware, but last if you're adding each one manually with add_middleware. I'll add a commit to your PR clarifying that point. Edit: Ah, I can't push a commit because you used your |
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.
One change. Thanks again for talking through this with me!
thank you for your time! |
run docs-build |
run docs-build |
* Update starlette.asciidoc Fix typo * Update starlette.asciidoc --------- Co-authored-by: Colton Myers <[email protected]>
What does this pull request do?
The documentation contains an error, you need to put the APM middleware before BaseHTTPMiddleware.