mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix normal request metric verb correctly
Signed-off-by: kkkkun <scuzk373x@gmail.com>
This commit is contained in:
parent
1edbb8cf1a
commit
0b6e641810
@ -516,11 +516,15 @@ func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, comp
|
|||||||
// MonitorRequest handles standard transformations for client and the reported verb and then invokes Monitor to record
|
// MonitorRequest handles standard transformations for client and the reported verb and then invokes Monitor to record
|
||||||
// a request. verb must be uppercase to be backwards compatible with existing monitoring tooling.
|
// a request. verb must be uppercase to be backwards compatible with existing monitoring tooling.
|
||||||
func MonitorRequest(req *http.Request, verb, group, version, resource, subresource, scope, component string, deprecated bool, removedRelease string, httpCode, respSize int, elapsed time.Duration) {
|
func MonitorRequest(req *http.Request, verb, group, version, resource, subresource, scope, component string, deprecated bool, removedRelease string, httpCode, respSize int, elapsed time.Duration) {
|
||||||
|
requestInfo, ok := request.RequestInfoFrom(req.Context())
|
||||||
|
if !ok || requestInfo == nil {
|
||||||
|
requestInfo = &request.RequestInfo{Verb: req.Method, Path: req.URL.Path}
|
||||||
|
}
|
||||||
// We don't use verb from <requestInfo>, as this may be propagated from
|
// We don't use verb from <requestInfo>, as this may be propagated from
|
||||||
// InstrumentRouteFunc which is registered in installer.go with predefined
|
// InstrumentRouteFunc which is registered in installer.go with predefined
|
||||||
// list of verbs (different than those translated to RequestInfo).
|
// list of verbs (different than those translated to RequestInfo).
|
||||||
// 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.
|
||||||
reportedVerb := cleanVerb(CanonicalVerb(strings.ToUpper(req.Method), scope), verb, req, nil)
|
reportedVerb := cleanVerb(CanonicalVerb(strings.ToUpper(req.Method), scope), verb, req, requestInfo)
|
||||||
|
|
||||||
dryRun := cleanDryRun(req.URL)
|
dryRun := cleanDryRun(req.URL)
|
||||||
elapsedSeconds := elapsed.Seconds()
|
elapsedSeconds := elapsed.Seconds()
|
||||||
|
Loading…
Reference in New Issue
Block a user