Merge pull request #77759 from haiyanmeng/host

Remove the `host` label from the kubelet http traffic metrics
This commit is contained in:
Kubernetes Prow Robot 2019-05-13 13:15:36 -07:00 committed by GitHub
commit 2525ab8572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -38,7 +38,7 @@ var (
// server_type aims to differentiate the readonly server and the readwrite server. // server_type aims to differentiate the readonly server and the readwrite server.
// long_running marks whether the request is long-running or not. // long_running marks whether the request is long-running or not.
// Currently, long-running requests include exec/attach/portforward/debug. // Currently, long-running requests include exec/attach/portforward/debug.
[]string{"method", "path", "host", "server_type", "long_running"}, []string{"method", "path", "server_type", "long_running"},
) )
// HTTPRequestsDuration tracks the duration in seconds to serve http requests. // HTTPRequestsDuration tracks the duration in seconds to serve http requests.
HTTPRequestsDuration = prometheus.NewHistogramVec( HTTPRequestsDuration = prometheus.NewHistogramVec(
@ -49,7 +49,7 @@ var (
// Use DefBuckets for now, will customize the buckets if necessary. // Use DefBuckets for now, will customize the buckets if necessary.
Buckets: prometheus.DefBuckets, Buckets: prometheus.DefBuckets,
}, },
[]string{"method", "path", "host", "server_type", "long_running"}, []string{"method", "path", "server_type", "long_running"},
) )
// HTTPInflightRequests tracks the number of the inflight http requests. // HTTPInflightRequests tracks the number of the inflight http requests.
HTTPInflightRequests = prometheus.NewGaugeVec( HTTPInflightRequests = prometheus.NewGaugeVec(
@ -58,7 +58,7 @@ var (
Name: "http_inflight_requests", Name: "http_inflight_requests",
Help: "Number of the inflight http requests", Help: "Number of the inflight http requests",
}, },
[]string{"method", "path", "host", "server_type", "long_running"}, []string{"method", "path", "server_type", "long_running"},
) )
) )

View File

@ -859,17 +859,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
serverType = "readwrite" serverType = "readwrite"
} }
method, path, host := req.Method, trimURLPath(req.URL.Path), req.URL.Host method, path := req.Method, trimURLPath(req.URL.Path)
longRunning := strconv.FormatBool(isLongRunningRequest(path)) longRunning := strconv.FormatBool(isLongRunningRequest(path))
servermetrics.HTTPRequests.WithLabelValues(method, path, host, serverType, longRunning).Inc() servermetrics.HTTPRequests.WithLabelValues(method, path, serverType, longRunning).Inc()
servermetrics.HTTPInflightRequests.WithLabelValues(method, path, host, serverType, longRunning).Inc() servermetrics.HTTPInflightRequests.WithLabelValues(method, path, serverType, longRunning).Inc()
defer servermetrics.HTTPInflightRequests.WithLabelValues(method, path, host, serverType, longRunning).Dec() defer servermetrics.HTTPInflightRequests.WithLabelValues(method, path, serverType, longRunning).Dec()
startTime := time.Now() startTime := time.Now()
defer servermetrics.HTTPRequestsDuration.WithLabelValues(method, path, host, serverType, longRunning).Observe(servermetrics.SinceInSeconds(startTime)) defer servermetrics.HTTPRequestsDuration.WithLabelValues(method, path, serverType, longRunning).Observe(servermetrics.SinceInSeconds(startTime))
s.restfulCont.ServeHTTP(w, req) s.restfulCont.ServeHTTP(w, req)
} }