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

added process metrics and Go runtime metrics #198

Merged

Conversation

droot
Copy link
Contributor

@droot droot commented Nov 5, 2018

Enabled Prometheus collector for process metrics and Go runtime

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 5, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: droot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 5, 2018
@droot
Copy link
Contributor Author

droot commented Nov 5, 2018

@JoelSpeed Can you pl. take a quick look at this one ?

@DirectXMan12
Copy link
Contributor

For the record, I seem to recall some people hesitant about including process and runtime stats. I think it's probably fine for now, and if people file issues, we can always add a flag to turn it off.

// expose process metrics like CPU, Memory, file descriptor usage etc.
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
// expose Go runtime metrics like GC stats, memory stats etc.
metrics.Registry.MustRegister(prometheus.NewGoCollector()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you don't need to wrap prometheus.NewGoCollector() in this MustRegister

Suggested change
metrics.Registry.MustRegister(prometheus.NewGoCollector()),
prometheus.NewGoCollector(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, last minute refactor introduced it. I had two separate MustRegister calls earlier.

@@ -48,4 +48,10 @@ func init() {
metrics.Registry.MustRegister(QueueLength)
metrics.Registry.MustRegister(ReconcileErrors)
metrics.Registry.MustRegister(ReconcileTime)
metrics.Registry.MustRegister(
// expose process metrics like CPU, Memory, file descriptor usage etc.
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be worth adding the a namespace to the ProcessCollerctorOpts{}, if we add the namespace controller_runtime then all metrics here will be prefixed with controller_runtime_ and will fit in with the other metrics we are emitting from the library, WDYT?

Suggested change
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{Namespace: "controller_runtime"}),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it and was a bit hesitant because these are not really controller-runtime specific metrics. If users are running other Go services (and k8s metrics for other components), they might already have configuration for processing these default prometheus metrics in their dashboards/pipelines. So keeping the same name might help them. WDYT ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah good point, I've double checked with what the Kubernetes API server does and it doesn't prefix so let's keep it as is

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

@droot I've added a couple of comments here

I'm not sure this would build as it is currently with the Collector being wrapped by MustRegister?

I'm wondering whether it is worth changing this to register all of the Collectors in one call to MustRegister or whether we should keep them all separate, would be good to be consistent

@droot
Copy link
Contributor Author

droot commented Nov 6, 2018

Thanks for the review @JoelSpeed

I have moved all the registration in single call (fits our use case).

Enabled Prometheus collector for process metrics and Go runtime
@droot droot force-pushed the feature/add-runtime-metrics branch from cb07718 to 40e1154 Compare November 6, 2018 18:24
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 6, 2018
@droot
Copy link
Contributor Author

droot commented Nov 6, 2018

@JoelSpeed addressed the comments. PTAL.

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

LGTM

@droot droot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2018
@k8s-ci-robot k8s-ci-robot merged commit 86b3a15 into kubernetes-sigs:master Nov 6, 2018
justinsb pushed a commit to justinsb/controller-runtime that referenced this pull request Dec 7, 2018
…-metrics

added process metrics and Go runtime metrics
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants