Llandy3d/pytheus

Is it fully async for metrics update and metrics exposure

Closed this issue · 2 comments

Hello,

I'm currently using aioprometheus but facing an issue the metrics exposure is blocking my entire FastAPI app claws/aioprometheus#98
Do you think I won't face this issue with Pytheus?

Thank you in advance

Hi there,

For a FastAPI application with this lib you should try the rust based backend, it's documented here: https://pythe.us/rust_backend/

With that you just create a normal sync view to expose the metrics and it won't block your application

@app.get('/metrics')
def pytheus_metrics():
    return generate_metrics()

note: there is an issue in multiprocess applications where a scrape will only get data for the instance it hits, this means it might get a couple of scrapes to update some values, depending on your use case it might be a problem or not

Closing this issue as there doesn't seem to be an actionable problem 😄

The issue with multiprocessing above has been fixed with Llandy3d/pytheus-backend-rs#6