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 Ingester metrics into struct #1527

Merged

Conversation

jtlisi
Copy link
Contributor

@jtlisi jtlisi commented Jul 23, 2019

Relates To: #1512

This PR embeds the metrics from the ingester into the ingester struct. This means they will only be initialized if an ingester struct is initialized.

I avoided embedding a prometheus Registerer into the config and passing it because we do not currently use non-default registerers anywhere in cortex. Down the line we may want to consider this approach.

Signed-off-by: Jacob Lisi jacob.t.lisi@gmail.com

Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
@beorn7
Copy link

beorn7 commented Jul 23, 2019

I think this change only addresses a small part of the problems. It's essentially only moving the registration into the constructor, but still registers everything with the global registry. That's certainly an improvement, but you could have it much simpler (by not using promauto metrics but the normal metrics from the prometheus package, and then explicitly register them with prometheus.Register in the constructor). The problem now is that you will get a panic if you call ingester.New twice (e.g. in a test), with no way of intercepting it.

There are many ways to do it, but I see a certain convergence onto something like in prometheus/tsdb. Check out https://github.com/prometheus/tsdb/blob/master/db.go#L426 and take it from there. They are also using a metrics struct there. Note how you can pass in nil as the prometheus.Registerer, which will just not register anything.

Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
@jtlisi
Copy link
Contributor Author

jtlisi commented Jul 23, 2019

@beorn7 Thanks for the feedback, I updated this PR to reflect your suggestions.

@beorn7
Copy link

beorn7 commented Jul 23, 2019

I'll have a detailed look ASAP (but perhaps not tonight… 😴 ).

@csmarchbanks
Copy link
Contributor

I like the pattern, but what is the scope you want to remove metrics for? It looks like you only removed the metrics from ingester.go, but there are lots of other metrics being registered by promauto or init in the ingester package.

@beorn7
Copy link

beorn7 commented Jul 25, 2019

I think this is just meant as an incremental step to try things out, with the goal of converting all metrics in the package to the same pattern eventually.

Copy link
Contributor

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This incremental step looks good. If you want to add more metrics from the ingester package to the struct I am happy to review again though!

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems legit

@csmarchbanks csmarchbanks merged commit abc2c21 into cortexproject:master Jul 29, 2019
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

4 participants