Skip to content

Expose metrics registration function #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

brandond
Copy link
Member

@brandond brandond commented Jul 16, 2024

Allows exposing metrics via a custom registerer, instead of forcing the use of prometheus.DefaultRegisterer. Also allows initializing metrics outside of init() which is generally considered an anti-pattern.

The default behavior of calling prometheus.DefaultRegisterer.MustRegister() is retained, ref:
https://github.com/prometheus/client_golang/blob/fec6b222d9ac46f61b0194fd343d5a10bf1e1d09/prometheus/registry.go#L174-L178

I also had to add a function to avoid registering the kubernetes internal workqueue metrics, to prevent conflicts in k3s where kubernetes itself registers those in the same process:

// This file is copied and adapted from https://github.com/kubernetes/kubernetes/blame/master/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go
// which implement MetricsProvider and register metrics to customized Registry

@brandond brandond requested a review from a team as a code owner July 16, 2024 01:10
Allows exposing metrics via a custom registerer, instead of forcing the
use of prometheus.DefaultRegisterer. Also allows initializing metrics
outside of init() which is generally considered an anti-pattern.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
@MbolotSuse MbolotSuse removed the request for review from tomleb July 16, 2024 14:17
@MbolotSuse MbolotSuse merged commit 24ab3db into rancher:master Jul 24, 2024
1 check passed
moio added a commit to moio/rancher that referenced this pull request Oct 2, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
This includes various fixes to the UI Server-Side Pagination experimental
feature:

https://ranchermanager.docs.rancher.com/how-to-guides/advanced-user-guides/enable-experimental-features/ui-server-side-pagination

- rancher/lasso#86
- rancher/lasso#90
- rancher/lasso#85
- rancher/lasso#92
- rancher/lasso#79
- rancher/lasso#97
- rancher/lasso#94
- rancher/lasso#98
- rancher/lasso#108
- rancher/lasso#99

It also includes improvements to code collecting metrics:
- rancher/lasso#89
- rancher/lasso#95

And to test code:
- rancher/lasso#100
- rancher/lasso#101

Signed-off-by: Silvio Moioli <silvio@moioli.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants