Async CustomCollector
So I need to obtain some metrics from a database and I'm planning to create a custom collector as described here: http://prometheus.github.io/client_python/collector/custom/
I use asyncpg to connect to PostgreSQL. My problem though is that asyncpg query needs to be called from an async function and collect() is synchronous.
Is there an async equivalent? It looks like the client supports being used from ASGI.
Not today, but adding async support for custom collectors would be a reasonable feature to add. I doubt I will have time to add it soon but would be happy to take a contribution.
How can we help get asyncio features out? Are you open to accept PRs that maybe don't affect existing codebase but give options to users to use an async solution? Or do you prefer this happens in a separate module entirely?
@chamini2 I think you can make PR. Probably there would be another method like collect that calls async code. I'm not exactly sure how it could be done, as normally all the calls that leading to the collect() would have to be converted to async as well...
I also found this thread in async add-on to this library: https://github.com/hynek/prometheus-async/issues/13
But I guess it might be implemented here.
I managed to run async code in the regular collect() but it feels extremely hacky and I hate that code. I wish the library would natively support it.