@@ -299,20 +299,17 @@ func RecordRequestTermination(req *http.Request, requestInfo *request.RequestInf
299
299
requestInfo = & request.RequestInfo {Verb : req .Method , Path : req .URL .Path }
300
300
}
301
301
scope := CleanScope (requestInfo )
302
- // We don't use verb from <requestInfo>, as for the healthy path
303
- // MonitorRequest is called from InstrumentRouteFunc which is registered
304
- // in installer.go with predefined list of verbs (different than those
305
- // translated to RequestInfo).
302
+
303
+ // We don't use verb from <requestInfo>, as this may be propagated from
304
+ // InstrumentRouteFunc which is registered in installer.go with predefined
305
+ // list of verbs (different than those translated to RequestInfo).
306
306
// However, we need to tweak it e.g. to differentiate GET from LIST.
307
- verb := canonicalVerb (strings .ToUpper (req .Method ), scope )
308
- // set verbs to a bounded set of known and expected verbs
309
- if ! validRequestMethods .Has (verb ) {
310
- verb = OtherRequestMethod
311
- }
307
+ reportedVerb := cleanVerb (canonicalVerb (strings .ToUpper (req .Method ), scope ), req )
308
+
312
309
if requestInfo .IsResourceRequest {
313
- requestTerminationsTotal .WithLabelValues (cleanVerb ( verb , req ) , requestInfo .APIGroup , requestInfo .APIVersion , requestInfo .Resource , requestInfo .Subresource , scope , component , codeToString (code )).Inc ()
310
+ requestTerminationsTotal .WithLabelValues (reportedVerb , requestInfo .APIGroup , requestInfo .APIVersion , requestInfo .Resource , requestInfo .Subresource , scope , component , codeToString (code )).Inc ()
314
311
} else {
315
- requestTerminationsTotal .WithLabelValues (cleanVerb ( verb , req ) , "" , "" , "" , requestInfo .Path , scope , component , codeToString (code )).Inc ()
312
+ requestTerminationsTotal .WithLabelValues (reportedVerb , "" , "" , "" , requestInfo .Path , scope , component , codeToString (code )).Inc ()
316
313
}
317
314
}
318
315
@@ -324,12 +321,13 @@ func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, comp
324
321
}
325
322
var g compbasemetrics.GaugeMetric
326
323
scope := CleanScope (requestInfo )
327
- // We don't use verb from <requestInfo>, as for the healthy path
328
- // MonitorRequest is called from InstrumentRouteFunc which is registered
329
- // in installer.go with predefined list of verbs (different than those
330
- // translated to RequestInfo).
324
+
325
+ // We don't use verb from <requestInfo>, as this may be propagated from
326
+ // InstrumentRouteFunc which is registered in installer.go with predefined
327
+ // list of verbs (different than those translated to RequestInfo).
331
328
// However, we need to tweak it e.g. to differentiate GET from LIST.
332
329
reportedVerb := cleanVerb (canonicalVerb (strings .ToUpper (req .Method ), scope ), req )
330
+
333
331
if requestInfo .IsResourceRequest {
334
332
g = longRunningRequestGauge .WithLabelValues (reportedVerb , requestInfo .APIGroup , requestInfo .APIVersion , requestInfo .Resource , requestInfo .Subresource , scope , component )
335
333
} else {
@@ -343,7 +341,12 @@ func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, comp
343
341
// MonitorRequest handles standard transformations for client and the reported verb and then invokes Monitor to record
344
342
// a request. verb must be uppercase to be backwards compatible with existing monitoring tooling.
345
343
func MonitorRequest (req * http.Request , verb , group , version , resource , subresource , scope , component string , deprecated bool , removedRelease string , contentType string , httpCode , respSize int , elapsed time.Duration ) {
346
- reportedVerb := cleanVerb (verb , req )
344
+ // We don't use verb from <requestInfo>, as this may be propagated from
345
+ // InstrumentRouteFunc which is registered in installer.go with predefined
346
+ // list of verbs (different than those translated to RequestInfo).
347
+ // However, we need to tweak it e.g. to differentiate GET from LIST.
348
+ reportedVerb := cleanVerb (canonicalVerb (strings .ToUpper (req .Method ), scope ), req )
349
+
347
350
dryRun := cleanDryRun (req .URL )
348
351
elapsedSeconds := elapsed .Seconds ()
349
352
cleanContentType := cleanContentType (contentType )
@@ -440,7 +443,7 @@ func CleanScope(requestInfo *request.RequestInfo) string {
440
443
func canonicalVerb (verb string , scope string ) string {
441
444
switch verb {
442
445
case "GET" , "HEAD" :
443
- if scope != "resource" {
446
+ if scope != "resource" && scope != "" {
444
447
return "LIST"
445
448
}
446
449
return "GET"
0 commit comments