claws / aioprometheus

A Prometheus Python client library for asyncio-based applications
174 stars 21 forks source link

hypercorn with several workers #89

Open l1f opened 1 year ago

l1f commented 1 year ago

I would like to start my quart application with several workers, but this is not so easy in connection with aioprometheus, because each worker has its own state.

In the official prometheus client library this can be solved like this: https://github.com/prometheus/client_python#multiprocess-mode-eg-gunicorn

How can I solve this?

claws commented 1 year ago

I think I understand the problem you are trying to solve. The aioprometheus package does not support using it like how you point out the official prometheus client library (which I think looks pretty complicated) accommodates this problem. I've simply exposed the metrics from each worker when I've run a FastAPI server with uvicorn (similar to what you are doing with Quart and Hypercorn). Like you noticed, they each have their own state.

l1f commented 1 year ago

But doesn't it make the metrics unstable because so another worker keeps responding?

rroque6428 commented 6 months ago

Any news on this? I agree with @l1f. State should be unique across all workers, since the scraping will hit once to collect all metrics in a consolidate way.

gonzaloetjo commented 3 months ago

Also waiting for an update on this. Not sure if you found a way @l1f