Merge pull request #77379 from tedyu/http-stat-map

Use map to check whether stack trace is needed
This commit is contained in:
Kubernetes Prow Robot
2019-05-09 14:13:34 -07:00
committed by GitHub
2 changed files with 17 additions and 17 deletions

View File

@@ -837,19 +837,19 @@ func isLongRunningRequest(path string) bool {
return ok
}
var statusesNoTracePred = httplog.StatusIsNot(
http.StatusOK,
http.StatusFound,
http.StatusMovedPermanently,
http.StatusTemporaryRedirect,
http.StatusBadRequest,
http.StatusNotFound,
http.StatusSwitchingProtocols,
)
// ServeHTTP responds to HTTP requests on the Kubelet.
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
defer httplog.NewLogged(req, &w).StacktraceWhen(
httplog.StatusIsNot(
http.StatusOK,
http.StatusFound,
http.StatusMovedPermanently,
http.StatusTemporaryRedirect,
http.StatusBadRequest,
http.StatusNotFound,
http.StatusSwitchingProtocols,
),
).Log()
defer httplog.NewLogged(req, &w).StacktraceWhen(statusesNoTracePred).Log()
// monitor http requests
var serverType string