-
Notifications
You must be signed in to change notification settings - Fork 800
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
ASGI lifespan crash #855
Open
sheenobu opened this issue
Nov 15, 2022
· 1 comment
· Fixed by sheenobu/client_python#1 · May be fixed by #856
Open
ASGI lifespan crash #855
sheenobu opened this issue
Nov 15, 2022
· 1 comment
· Fixed by sheenobu/client_python#1 · May be fixed by #856
Comments
sheenobu
added a commit
to sheenobu/client_python
that referenced
this issue
Nov 16, 2022
Super simple hook that checks for lifespan and immediately responds type.complete, essentially making startup/shutdown lifespan events no-ops for the prometheus ASGI app. Fixes prometheus#855 ``` from hypercorn.middleware import DispatcherMiddleware from prometheus_client import make_asgi_app import asyncio async def main(): from hypercorn.asyncio import serve from hypercorn.config import Config app = DispatcherMiddleware({ "/metrics": make_asgi_app(), }) config = Config() config.bind = ["localhost:8080"] await serve(app, config) ``` Before: ``` assert scope.get("type") == "http" AssertionError ``` After: ``` [2022-11-15 16:05:20 -0800] [59048] [INFO] Running on http://127.0.0.1:8080 (CTRL + C to quit) INFO:hypercorn.error:Running on http://127.0.0.1:8080 (CTRL + C to quit) ``` Signed-off-by: Sheena Artrip <[email protected]>
middleware solution if you are eager for a fix: https://gist.github.com/sheenobu/064b501b76415c6f6dacb6afa1ac6305 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
client_python version: testing on 0.15.0 but the offending code exists in the master branch as well.
I'm trying to use the prometheus ASGI handler with Hypercorns DispatcherMiddleware. It sends lifecycle events which are not properly handled:
assert scope.get("type") == "http"
ensures any ASGI middleware sending lifecycle events will fail to start the prometheus asgi app.The text was updated successfully, but these errors were encountered: