-
Notifications
You must be signed in to change notification settings - Fork 1.2k
✨ Add webhook total and in-flight metrics #944
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 webhook total and in-flight metrics #944
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
Welcome @boekkooi-fresh! |
Hi @boekkooi-fresh. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
Add a gauge for requests currently being handled and a counter for the total amount of requests processed. Used [prometheus/promhttp](https://pkg.go.dev/github.com/prometheus/client_golang/prometheus/promhttp?tab=doc) package which provides nice decorators for `Http.Handler` to handle the metrics instead of the custom code.
aafa8b0
to
96e2b22
Compare
This created to much noise and broke BC.
5f17acc
to
374972f
Compare
/assign @vincepri |
Name: "controller_runtime_webhook_requests_total", | ||
Help: "Total number of admission requests by HTTP status code.", | ||
}, | ||
[]string{"webhook", "code"}, |
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.
I think path
would be the more sensible name than webhook
.
Also, please use const
for the label keys.
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.
I think
path
would be the more sensible name thanwebhook
.
This maybe a better name but I preferred to sick with the naming convention introduced by RequestLatency
.
In my opinion have the labels consistent across metrics and avoiding a BC break was more important.
Also, please use
const
for the label keys.
Using const
here could be done but would not fit within the current code based. See for example pkg/webhook/internal/metrics/metrics.go, pkg/metrics/client_go_adapter.go, pkg/metrics/workqueue.go etc.
From my point of view I prefer to sick with the current code style.
Would you like me to open a separate PR to ensure const's are used for all metrics within controller-runtime
?
gge := metrics.RequestInFlight.With(lbl) | ||
|
||
// Initialize the most likely HTTP status codes. | ||
cnt.WithLabelValues("200") |
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.
What value does initialization here add?
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.
It adds the metric to the /metrics
endpoint with the count set to 0
.
In my experience this allows the user of the metrics just this little more insight about which data they can work with, (used prometheus/client_golang/prometheus/promhttp/http.go as my example here)
RequestInFlight = func() *prometheus.GaugeVec { | ||
return prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "controller_runtime_webhook_requests_in_flight", |
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.
technically a conversion hook is also a webhook
, would it maybe make sense to add the admission
somewhere in the name to avoid name clashes?
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.
I'm honestly not sure what the best name here but the controller_runtime_webhook_
prefixed used I got from RequestLatency
since these metrics apply for the same piece of code.
It maybe better to change these names in a follow up PR to avoid a BC break within this PR?
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.
Yeah, makes sense
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.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: boekkooi-fresh, DirectXMan12 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 |
Add a gauge for requests currently being handled and a counter for the total amount of requests processed.
I used prometheus/promhttp package which provides nice decorators for
Http.Handler
to handle the metrics instead of the custom code.