prometheus / prometheus/prometheus
Remove instances of `prometheus.DefaultRegisterer`
Open
@Vandit1604 is already working on this.
Since Jan 14, 2025.
kind/enhancement
priority/P3
- Dominant language
- Go
- Stars
- 66.1k
- Forks
- 10.8k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 131
Description
Proposal
Following #12549, the scrape and discovery packages no longer require use of the default registerer. However, prometheus.DefaultRegisterer is still used in the codebase, particularly in main.go. It would be good to replace this with a single prometheus.NewRegistry().
This would have a few advantages:
- We are closing a loophole where a new feature could still use
prometheus.DefaultRegistereroutside ofmain.go. - It's a signal that
prometheus.DefaultRegistereris no longer required.
While I think that scrape and discovery packages would work well with a non-default registry, there could be other packages which still rely on the default resiterer. We would need to take extra care when doing this change:
- Browse the codebase for code which registers metrics in the default registry
- Run a Prometheus instance which uses these bits of code.
- Reload the config of that Prometheus instance to make sure there are no errors due to double registration.
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.
Assessment
This issue has not been assessed yet.