-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add process and go runtime metrics for controller #6966
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @mindw. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Gabi Davar <grizzly.nyo@gmail.com>
9080f16
to
c19108f
Compare
/ok-to-test |
@mindw: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mindw
I deployed this and used https://grafana.com/grafana/dashboards/6671-go-processes/ to visualize the resulting metrics:
I can see that these metrics will be useful to the cert-manager team for optimizing cert-manager.
I'd be interested to learn how you might use these metrics in your platform.
Maybe you could write a short paragraph describing the user-story.
Do you think there's any risk to adding ~200 new metrics?
Might it cause any extra cost for people who are already monitoring cert-manager using a commercial monitoring service?
@@ -186,10 +188,19 @@ func New(log logr.Logger, c clock.Clock) *Metrics { | |||
) | |||
) | |||
|
|||
// Create Registry and register the recommended collectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest rewording this comment to explain why rather than what the following code does.
Perhaps:
We want to avoid using and mutating global state so we avoid
prometheus.DefaultRegisterer
. Instead we create a local Registry and manually register
the same two collectors that are used by DefaultRegisterer.Process collector
Exports the current state of process metrics including CPU, memory and file
descriptor usage as well as the process start time. The detailed behavior is
defined by the provided ProcessCollectorOpts. The zero value of
ProcessCollectorOpts creates a collector for the current process with an empty
namespace string and no error reporting.The collector only works on operating systems with a Linux-style proc
filesystem and on Microsoft Windows. On other operating systems, it will not
collect any metrics.Go collector
Exports metrics about the current Go process using debug.GCStats (base
metrics) and runtime/metrics.
registry.MustRegister( | ||
collectors.NewGoCollector( | ||
collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll), | ||
collectors.WithoutGoCollectorRuntimeMetrics(regexp.MustCompile("^/godebug/.*")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment to the code explaining why we omit the godebug
metrics.
And give an example of the metrics that will not be available.
OR
Remove that line and include all the Go metrics.
The DefaultRegisterer doesn't omit them.
Nor could I find any examples of other Go processes that omit these.
- https://github.com/prometheus/client_golang/blob/main/prometheus/registry.go#L60-L62
- https://github.com/letsencrypt/boulder/blob/5be3650e564e9fbc3492f2ff17678fdf9476efd7/cmd/shell.go#L262-L265
- https://github.com/istio/istio/blob/3b01bc01992b64c5d7710fbe0e32c74aca925170/pilot/cmd/pilot-agent/status/server.go#L163-L166
- https://github.com/search?q=repo%3Acilium%2Fcilium%20NewGoCollector&type=code
- https://github.com/cloudflare/pint/blob/af68e2a13dc46e87688752c4a96d9f81ec78b870/cmd/pint/watch.go#L170-L173
I tried removing that line and observed ~75 extra lines in the metrics.
$ kubectl get --raw /api/v1/namespaces/cert-manager/services/cert-manager:9402/proxy/metrics | wc -l
395
# Vs
$ kubectl get --raw /api/v1/namespaces/cert-manager/services/cert-manager:9402/proxy/metrics | wc -l
470
And 25 extra metrics:
$ kubectl get --raw /api/v1/namespaces/cert-manager/services/cert-manager:9402/proxy/metrics | grep '^go_godebug_'
go_godebug_non_default_behavior_execerrdot_events_total 0
go_godebug_non_default_behavior_gocachehash_events_total 0
go_godebug_non_default_behavior_gocachetest_events_total 0
go_godebug_non_default_behavior_gocacheverify_events_total 0
go_godebug_non_default_behavior_gotypesalias_events_total 0
go_godebug_non_default_behavior_http2client_events_total 0
go_godebug_non_default_behavior_http2server_events_total 0
go_godebug_non_default_behavior_httplaxcontentlength_events_total 0
go_godebug_non_default_behavior_httpmuxgo121_events_total 1
go_godebug_non_default_behavior_installgoroot_events_total 0
go_godebug_non_default_behavior_jstmpllitinterp_events_total 0
go_godebug_non_default_behavior_multipartmaxheaders_events_total 0
go_godebug_non_default_behavior_multipartmaxparts_events_total 0
go_godebug_non_default_behavior_multipathtcp_events_total 0
go_godebug_non_default_behavior_panicnil_events_total 0
go_godebug_non_default_behavior_randautoseed_events_total 0
go_godebug_non_default_behavior_tarinsecurepath_events_total 0
go_godebug_non_default_behavior_tls10server_events_total 0
go_godebug_non_default_behavior_tlsmaxrsasize_events_total 0
go_godebug_non_default_behavior_tlsrsakex_events_total 0
go_godebug_non_default_behavior_tlsunsafeekm_events_total 0
go_godebug_non_default_behavior_x509sha1_events_total 0
go_godebug_non_default_behavior_x509usefallbackroots_events_total 0
go_godebug_non_default_behavior_x509usepolicies_events_total 0
go_godebug_non_default_behavior_zipinsecurepath_events_total 0
$ kubectl get --raw /api/v1/namespaces/cert-manager/services/cert-manager:9402/proxy/metrics | grep '^go_godebug_' | wc -l
25
/kind feature |
@wallrj Thank you for the detailed review and questions! |
Pull Request Motivation
These metrics are default when using Prometheus go client's pre-defined registry, but were missing as the controller creates it's own registry.
Useful many debug scenarios
Kind
feature
Release Note