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 #2204
Comments
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
It's a very low priority on-going work I continue every while and then. |
Help wanted! |
I will take this one. |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
Still valid, even if over the time we've significantly improved it |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
Still valid |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
While doing code reviews I've realized a common mistake is to create metrics but not register them to the registry. Functions like
promauto.NewXXX()
are now discouraged due to #1512 and this makes even easier to forget.In order to overcome this problem, Prometheus client
1.5.0
has introduced a new factorypromauto.With(registerer).NewXXX()
(713) which allows to usepromauto
with a custom registerer (thus honoring the design we picked in #1512).The proposal to enforce all metrics to be registered is:
1.5.0
promauto.With().NewXXX()
taking the opportunity to pass theregisterer
everywhere so we will also solve Embed metrics into structs and optional initialization #1512github.com/prometheus/client_golang/prometheus
(except few cases where it's OK, like the metrics mapping we do for the blocks storage and alertmanager)For the records, this is the same path Thanos is following to avoid the same problem (actually the idea came from @bwplotka).
The text was updated successfully, but these errors were encountered: