rename metric for apiserver request terminations and reword corresponding documentation
Change-Id: I47a9c7b10614afe85bb652fa61984f91848d6d65 Kubernetes-commit: f8f1def5f1d92a588f48ebc01293e142f8dd63fd
This commit is contained in:
parent
a5356f425d
commit
00d376192a
|
@ -188,10 +188,10 @@ var (
|
||||||
[]string{"requestKind"},
|
[]string{"requestKind"},
|
||||||
)
|
)
|
||||||
|
|
||||||
requestErrorsTotal = compbasemetrics.NewCounterVec(
|
requestTerminationsTotal = compbasemetrics.NewCounterVec(
|
||||||
&compbasemetrics.CounterOpts{
|
&compbasemetrics.CounterOpts{
|
||||||
Name: "apiserver_request_errors_total",
|
Name: "apiserver_request_terminations_total",
|
||||||
Help: "Number of requests which have resulted in an apiserver response error.",
|
Help: "Number of requests which apiserver terminated in self-defense.",
|
||||||
StabilityLevel: compbasemetrics.ALPHA,
|
StabilityLevel: compbasemetrics.ALPHA,
|
||||||
},
|
},
|
||||||
[]string{"verb", "group", "version", "resource", "subresource", "scope", "component", "code"},
|
[]string{"verb", "group", "version", "resource", "subresource", "scope", "component", "code"},
|
||||||
|
@ -212,7 +212,7 @@ var (
|
||||||
WatchEvents,
|
WatchEvents,
|
||||||
WatchEventsSizes,
|
WatchEventsSizes,
|
||||||
currentInflightRequests,
|
currentInflightRequests,
|
||||||
requestErrorsTotal,
|
requestTerminationsTotal,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -246,9 +246,11 @@ func UpdateInflightRequestMetrics(nonmutating, mutating int) {
|
||||||
currentInflightRequests.WithLabelValues(MutatingKind).Set(float64(mutating))
|
currentInflightRequests.WithLabelValues(MutatingKind).Set(float64(mutating))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordRequestError records the occurrence of a request error during apiserver handling (e.g. timeouts,
|
// RecordRequestTermination records that the request was terminated early as part of a resource
|
||||||
// maxinflight throttling, proxyHandler errors).
|
// preservation or apiserver self-defense mechanism (e.g. timeouts, maxinflight throttling,
|
||||||
func RecordRequestError(req *http.Request, requestInfo *request.RequestInfo, component string, code int) {
|
// proxyHandler errors). RecordRequestTermination should only be called zero or one times
|
||||||
|
// per request.
|
||||||
|
func RecordRequestTermination(req *http.Request, requestInfo *request.RequestInfo, component string, code int) {
|
||||||
if requestInfo == nil {
|
if requestInfo == nil {
|
||||||
requestInfo = &request.RequestInfo{Verb: req.Method, Path: req.URL.Path}
|
requestInfo = &request.RequestInfo{Verb: req.Method, Path: req.URL.Path}
|
||||||
}
|
}
|
||||||
|
@ -260,9 +262,9 @@ func RecordRequestError(req *http.Request, requestInfo *request.RequestInfo, com
|
||||||
// However, we need to tweak it e.g. to differentiate GET from LIST.
|
// However, we need to tweak it e.g. to differentiate GET from LIST.
|
||||||
verb := canonicalVerb(strings.ToUpper(req.Method), scope)
|
verb := canonicalVerb(strings.ToUpper(req.Method), scope)
|
||||||
if requestInfo.IsResourceRequest {
|
if requestInfo.IsResourceRequest {
|
||||||
requestErrorsTotal.WithLabelValues(cleanVerb(verb, req), requestInfo.APIGroup, requestInfo.APIVersion, requestInfo.Resource, requestInfo.Subresource, scope, component, codeToString(code)).Inc()
|
requestTerminationsTotal.WithLabelValues(cleanVerb(verb, req), requestInfo.APIGroup, requestInfo.APIVersion, requestInfo.Resource, requestInfo.Subresource, scope, component, codeToString(code)).Inc()
|
||||||
} else {
|
} else {
|
||||||
requestErrorsTotal.WithLabelValues(cleanVerb(verb, req), "", "", "", requestInfo.Path, scope, component, codeToString(code)).Inc()
|
requestTerminationsTotal.WithLabelValues(cleanVerb(verb, req), "", "", "", requestInfo.Path, scope, component, codeToString(code)).Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ func WithMaxInFlightLimit(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metrics.RecordRequestError(r, requestInfo, metrics.APIServerComponent, http.StatusTooManyRequests)
|
metrics.RecordRequestTermination(r, requestInfo, metrics.APIServerComponent, http.StatusTooManyRequests)
|
||||||
tooManyRequests(r, w)
|
tooManyRequests(r, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func WithTimeoutForNonLongRunningRequests(handler http.Handler, longRunning apir
|
||||||
|
|
||||||
postTimeoutFn := func() {
|
postTimeoutFn := func() {
|
||||||
cancel()
|
cancel()
|
||||||
metrics.RecordRequestError(req, requestInfo, metrics.APIServerComponent, http.StatusGatewayTimeout)
|
metrics.RecordRequestTermination(req, requestInfo, metrics.APIServerComponent, http.StatusGatewayTimeout)
|
||||||
}
|
}
|
||||||
return req, time.After(timeout), postTimeoutFn, apierrors.NewTimeoutError(fmt.Sprintf("request did not complete within %s", timeout), 0)
|
return req, time.After(timeout), postTimeoutFn, apierrors.NewTimeoutError(fmt.Sprintf("request did not complete within %s", timeout), 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue