prometheus / prometheus/client_python

Async CustomCollector

Open
#1,069 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
876
Avg merge
8d 4h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom collector documentation linked in the issue and the client’s ASGI support. Trace how collect() is invoked and compare that path with asyncpg’s requirements. Done means establishing and documenting whether asynchronous collection is supported, or defining the required client behavior if it is not.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.