prometheus / prometheus/client_python
Avoid duplicated metric types using multiprocess
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
I'm using the library (v 0.9.0) with multiprocess and I'm getting duplicated metric types. Getting the prometheus metrics I got this:
HELP custom_metric_1 Multiprocess metric
TYPE custom_metric_1 gauge
custom_metric_1 {pid="203"} 1.0
custom_metric_1 {pid="203"} 6.0
...
HELP custom_metric_1 Multiprocess metric
TYPE custom_metric_1 gauge
custom_metric_1 0.0
My code:
path = os.environ.get("prometheus_multiproc_dir", "/tmp/prometheus")
registry = prometheus_client.CollectorRegistry()
prometheus_client.multiprocess.MultiProcessCollector(registry, path)
metric_1 = prometheus_client.Gauge("custom_metric_1", "", registry=registry)
Any idea for avoiding this duplication.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the duplicate HELP, TYPE, and gauge samples with the provided prometheus_client.CollectorRegistry, MultiProcessCollector, and Gauge setup, then inspect the multiprocess collection and metric registration paths. Done means the reported setup no longer emits duplicated metric types while preserving the expected multiprocess samples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- prometheus, python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100