mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 20:57:20 +00:00
Fix the broken calls to the monitor() by having it take arguments as pointers.
This is needed for the changes to various labels from later in the function to be picked up.
This commit is contained in:
@@ -68,9 +68,9 @@ func init() {
|
||||
|
||||
// monitor is a helper function for each HTTP request handler to use for
|
||||
// instrumenting basic request counter and latency metrics.
|
||||
func monitor(handler, verb, resource string, httpCode int, reqStart time.Time) {
|
||||
requestCounter.WithLabelValues(handler, verb, resource, strconv.Itoa(httpCode)).Inc()
|
||||
requestLatencies.WithLabelValues(handler, verb).Observe(float64((time.Since(reqStart)) / time.Microsecond))
|
||||
func monitor(handler string, verb, resource *string, httpCode *int, reqStart time.Time) {
|
||||
requestCounter.WithLabelValues(handler, *verb, *resource, strconv.Itoa(*httpCode)).Inc()
|
||||
requestLatencies.WithLabelValues(handler, *verb).Observe(float64((time.Since(reqStart)) / time.Microsecond))
|
||||
}
|
||||
|
||||
// monitorFilter creates a filter that reports the metrics for a given resource and action.
|
||||
@@ -78,7 +78,8 @@ func monitorFilter(action, resource string) restful.FilterFunction {
|
||||
return func(req *restful.Request, res *restful.Response, chain *restful.FilterChain) {
|
||||
reqStart := time.Now()
|
||||
chain.ProcessFilter(req, res)
|
||||
monitor("rest", action, resource, res.StatusCode(), reqStart)
|
||||
httpCode := res.StatusCode()
|
||||
monitor("rest", &action, &resource, &httpCode, reqStart)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user