aioprometheus
aioprometheus copied to clipboard
Metrics exposure is blocking
Hello,
I'm using aioprometheus in my FastAPI like this:
@app.get("/metrics")
async def handle_metrics(
accept: List[str] = Header(None),
) -> Response:
content, http_headers = render(REGISTRY, accept)
return Response(content=content, media_type=http_headers["Content-Type"])
And I notice that when querying /metrics my application freeze for few seconds. Is this normal? I'm looking at the code of render() and it seems not async.
Do you plan to make it async? If not what solution do you suggest?
Thank you in advance
Looking at the official client, it seems that they added async ASGI metric exposure. But I don't know if their metrics update will then be blocking. https://github.com/prometheus/client_python/pull/512