kubernetes-sigs / kubernetes-sigs/controller-runtime
Remove metrics global registry
- Dominant language
- Go
- Stars
- 3k
- Forks
- 1.3k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 14
Description
I would like to suggest to remove the global registry as currently the controller-runtime global registry does not capture metrics registered onto `prometheus.DefaultRegisterer`. As a step forward and in line with the prosed [KEP](https://github.com/kubernetes/community/pull/2909), the controller-runtime should be able to have the registry injected. (for a start with `prometheus.DefaultRegisterer`, with the long term goal of removing the global registry in the first place, I am open for suggestions on that.)
As per the proposal https://github.com/kubernetes/community/pull/2909:
> Kubernetes also makes extensive use of a global metrics registry to register metrics to be exposed. Aside from general shortcomings of global variables, Kubernetes is seeing actual effects of this, causing a number of components to use sync.Once or other mechanisms to ensure to not panic, when registering metrics. Instead a metrics registry should be passed to each component in order to explicitly register metrics instead of through init methods or other global, non-obvious executions.
Lastly, this may be my own opinion, but introducing globals as a library hides its dependencies, therefore I think having the registry be injected makes the API more clear.
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by reviewing the controller-runtime metrics implementation and the linked Kubernetes KEP, then define the scope for injecting a Prometheus registry and what removal of the global registry would require.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, prometheus
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100