prometheus-fastapi-instrumentator
prometheus-fastapi-instrumentator copied to clipboard
BaseHTTPMiddleware vs BackgroundTasks
@trallnag I've just noticed that we use @app.middleware('http') here, I should have been able to catch this earlier... Anyway, that decorator is implemented on top of BaseHTTPMiddleware, which has a problem: https://github.com/encode/starlette/issues/919
Solution: change the implementation to a pure ASGI app/middleware.
PS.: I can open a PR with it, jfyk.
Async Python is a complete black box for me I have zero experience with so far (except the little bit I interact with it in FastAPI). So if you know a way to refactor the code, please go on. Would be awesome
I've found a very insightful article yesterday: https://florimond.dev/blog/articles/2019/08/introduction-to-asgi-async-python-web/
But anyway, thank you. I'll be working on it then (it should not be many changes, only focused on the middleware interface).
Took me a few hours today to get to this issue 😄 Glad to see it has already been worked on, thanks @Kludex and @trallnag 🙂 Any way I can help moving this forward?
Oh, I see @Kludex is also working on resolving the original issue in Starlette.
Any way I can help moving this forward?
Yes, you can take my PR: https://github.com/trallnag/prometheus-fastapi-instrumentator/pull/23 .
Oh, I see @Kludex is also working on resolving the original issue in Starlette.
🏃 💨
Should I understand the Starlette PR is doomed 😅 ? I'll see if I can continue your work once @trallnag has given us updates (on this PR or on the CI one) 🙂
Should I understand the Starlette PR is doomed 😅 ?
I'm bothering ppl to review it... 😅
Hi all, would it be possible to get a status update here? Does the close on this PR means this will never be implemented? https://github.com/encode/starlette/issues/919 or it's fixed via: https://github.com/encode/starlette/pull/1715?
Does anybody have/tested a workaround, like: https://github.com/encode/starlette/issues/919#issuecomment-644596659 ?
thanks
This was already fixed here.