-
Notifications
You must be signed in to change notification settings - Fork 801
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
Multiprocessing with Gunicorn + FastAPI #810
Comments
Thanks for the report! Would you be interested in adding some documentation to the README similar to how we have an example for flask, but under the multiprocess section? |
@csmarchbanks If you think this is a correct way of doing things, I will add the instructions to the README |
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: prometheus#810
(me from my alt acc) |
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: prometheus#810 Signed-off-by: Matas Minelga <minematas@gmail.com.com>
Looking at the README I see this
Doesn't this mean that we could add that setup in a route? (see below) @app.get("/metrics")
def metrics(request: Request):
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
data = generate_latest(registry)
res = Response(content=data)
res.headers["Content-Type"] = CONTENT_TYPE_LATEST
return res |
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: prometheus#810 Signed-off-by: Matas Minelga minematas@gmail.com
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: prometheus#810 Signed-off-by: Matas Minelga <minematas@gmail.com>
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: #810 Signed-off-by: Matas Minelga <minematas@gmail.com>
Closing this as the information is now in the readme! |
I've been trying to make multiprocessing work with FastAPI, but it just doesn't seem to happen.
This part is what I've been struggling the most:
Had no idea where to put this, but after some experimentation it turns out, the simplest solution of creating a metrics app looks like this (including other parts from the documentation):
Just posting this to help others save hours of researching and debugging.
The text was updated successfully, but these errors were encountered: