-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update kubevirt_rest_client_request_latency_seconds to count list cal… #12716
Update kubevirt_rest_client_request_latency_seconds to count list cal… #12716
Conversation
Hi @Sreeja1725. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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-sigs/prow repository. |
3b6d13c
to
7616b52
Compare
cc @alaypatel07 |
7616b52
to
7213150
Compare
/cc @machadovilaca |
thanks for the PR @Sreeja1725, we would need to validate this change (removing the usage of the latency adapter for requestLatency) does not have unexpected consequences. I wonder if you couldn't adapt
|
7213150
to
7fe8be0
Compare
7fe8be0
to
c5049b8
Compare
Thanks for your response @machadovilaca , I have updated as per your comment. PTAL |
c5049b8
to
d10276e
Compare
resource := findResource(u) | ||
if resource == "" { | ||
resource = "none" | ||
} |
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 see that you improved a bit, was going to comment on this, but what would you think about:
func getVerbLabelValue(u url.URL, verb string) string {
if verb != "GET" {
return verb
}
if strings.Contains(u.Path, "/watch/") || u.Query().Get("watch") == "true" {
return "WATCH"
}
resource := findResource(u)
if resource == "" {
resource = "none"
}
if strings.HasSuffix(u.Path, resource) {
// If the resource is the last element in the url, then
// we're asking to list all resources of that type instead
// of getting an individual resource
return "LIST"
}
return verb
}
yet a bit better, no?
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.
and then just
l.m.WithLabelValues(getVerbLabelValue(u, verb), u.String()).Observe(latency.Seconds())
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.
Yes, it's better! The refactoring made the code cleaner and modular. Thanks @machadovilaca for simplifying the logic and separating concerns.
/ok-to-test |
/retest |
@machadovilaca can you please do a second round of reviews on this PR? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: machadovilaca 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 |
@xpivarc Can you PTAL |
/cc @0xFelix |
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.
Added some comments can you please put something in the commit message?
resource := findResource(u) | ||
if resource == "" { | ||
return "none" | ||
} |
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.
Could be inlined
match := r.FindStringSubmatch(u.Path) | ||
if len(match) > 1 { |
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.
Could be inlined
} | ||
match := r.FindStringSubmatch(u.Path) | ||
if len(match) > 1 { | ||
resource = match[1] |
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.
resource = match[1] | |
return match[1] |
if resource != "" { | ||
break | ||
} |
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.
Drop this
resource = match[1] | ||
} | ||
} | ||
return resource |
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.
return resource | |
return "" |
return resource, verb | ||
} | ||
|
||
func determineVerb(u url.URL, methodOrVerb string) (verb string) { |
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.
Can you make the funcs name more descriptive? Something like getVerbFromHTTPVerb
?
return resource | ||
} | ||
|
||
func getHost(request *http.Request) string { |
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.
Is it used only in a single place? If so it's okay to keep it inline.
resource string | ||
verb string | ||
host string |
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.
Define these vars on the go with :=
87e5ec4
to
9ce9c06
Compare
9ce9c06
to
35fe879
Compare
@0xFelix Addressed all your comments, PTAL |
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
Two nits, feel free to address
} | ||
|
||
switch method { | ||
verb = getVerbFromHTTPVerb(*request.URL, method) |
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.
nit: Could be inlined
var resource string | ||
var verb string | ||
var host string | ||
var status, host string |
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.
var status, host string | |
var status string | |
var host string |
nit: Not sure we got a rule for that though
Required labels detected, running phase 2 presubmits: |
…econds Signed-off-by: svarnam <[email protected]>
35fe879
to
b4cb1b4
Compare
@0xFelix Updated as per your comments, PTAL |
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
Thanks!
Required labels detected, running phase 2 presubmits: |
What this PR does
Currently, when a list call is made using field-selector or label-selector those calls are inaccurately counted as get calls. This MR will solve this issue.
Why we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note