MCPcopy
hub / github.com/kubernetes/client-go / updateURLMetrics

Function updateURLMetrics

rest/request.go:608–622  ·  view source on GitHub ↗

updateURLMetrics is a convenience function for pushing metrics. It also handles corner cases for incomplete/invalid request data.

(req *Request, resp *http.Response, err error)

Source from the content-addressed store, hash-verified

606// updateURLMetrics is a convenience function for pushing metrics.
607// It also handles corner cases for incomplete/invalid request data.
608func updateURLMetrics(req *Request, resp *http.Response, err error) {
609 url := "none"
610 if req.baseURL != nil {
611 url = req.baseURL.Host
612 }
613
614 // Errors can be arbitrary strings. Unbound label cardinality is not suitable for a metric
615 // system so we just report them as `<error>`.
616 if err != nil {
617 metrics.RequestResult.Increment("<error>", req.verb, url)
618 } else {
619 //Metrics for failure codes
620 metrics.RequestResult.Increment(strconv.Itoa(resp.StatusCode), req.verb, url)
621 }
622}
623
624// Stream formats and executes the request, and offers streaming of the response.
625// Returns io.ReadCloser which could be used for streaming of the response, or an error

Callers 3

StreamMethod · 0.85
requestMethod · 0.85

Calls 1

IncrementMethod · 0.65

Tested by

no test coverage detected