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

Embed metrics into structs and optional initialization #1512

Closed
jtlisi opened this issue Jul 14, 2019 · 8 comments
Closed

Embed metrics into structs and optional initialization #1512

jtlisi opened this issue Jul 14, 2019 · 8 comments
Labels

Comments

@jtlisi
Copy link
Contributor

jtlisi commented Jul 14, 2019

The single binary version of cortex ends up reporting metrics for each component in cortex regardless of whether the module is enabled or not. At this point it would make sense to start embedding metrics into structs so that the initialization of those metrics is actually dependent on whether that module is deployed or not.

This can be done piecemeal one module or package at a time.

@bboreham
Copy link
Contributor

I support this idea; came here to add that we have some other metrics that come in via promauto from vendor'd code that never gets called. Example prometheus_remote_storage_highest_timestamp_in_seconds

@jtlisi
Copy link
Contributor Author

jtlisi commented Aug 5, 2019

@stale
Copy link

stale bot commented Feb 3, 2020

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 3, 2020
@pracucci pracucci added keepalive Skipped by stale bot and removed stale labels Feb 4, 2020
@pracucci
Copy link
Contributor

I think the solution we've already started adopting is to pass prometheus.Registerer to services and register metrics on that, avoiding promauto.

@stale
Copy link

stale bot commented Dec 4, 2020

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.

@stale stale bot added the stale label Dec 4, 2020
@stale stale bot closed this as completed Dec 19, 2020
@bboreham
Copy link
Contributor

This issue says not to use promauto, while #2204 says to use promauto.

This one got closed as stale; does that mean promauto won?

@pracucci
Copy link
Contributor

This one got closed as stale; does that mean promauto won?

I think we can close this issue. The pattern we're currently using (and looks working fine with downstream projects) is to take the prometheus.Registerer in input (eg. NewSomething(reg prometheus.Registerer) and then registering metrics via promauto.With(reg).

@bboreham
Copy link
Contributor

Agreed: if we create the metrics in NewSomething() that achieves the aim of this issue.

Nitpick: the key is we are creating metrics via promauto.With(), hence not needing to think about whether they need registering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants