Skip to content
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

Reduce the risk of having unregistered metrics #2751

Closed
pracucci opened this issue Aug 17, 2022 · 0 comments · Fixed by #2756
Closed

Reduce the risk of having unregistered metrics #2751

pracucci opened this issue Aug 17, 2022 · 0 comments · Fixed by #2756
Assignees

Comments

@pracucci
Copy link
Collaborator

pracucci commented Aug 17, 2022

A mistake, hard to spot during code reviews, is to create Prometheus metrics but not register them to the registry.

In order to overcome this problem, I've drafted a plan in Cortex cortexproject/cortex#2204 long time ago. I did a check and I think we're finally ready to enforce it in Mimir.

My proposed plan is to enforce the usage of promauto.With(reg).XXX() everywhere, doing the following:

  • Forbid the usage of prometheus.{MustRegister,Register,DefaultRegisterer} (see Reduce usage of global Prometheus registerer #2750)
  • Forbid the usage of promauto.{NewCounter,NewCounterVec,NewCounterFunc,NewGauge,NewGaugeVec,NewGaugeFunc,NewSummary,NewSummaryVec,NewHistogram,NewHistogramVec} and prometheus.{NewCounter,NewCounterVec,NewCounterFunc,NewGauge,NewGaugeVec,NewGaugeFunc,NewSummary,NewSummaryVec,NewHistogram,NewHistogramVec}, except few places where it's very difficult to get rid of it (with a //lint:ignore directive)
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 a pull request may close this issue.

1 participant