Merge pull request #114774 from kkkkun/update-normal-request-metric-verb
Fix normal request metric verb correctly Kubernetes-commit: 0b2e54123f233d87c3a132c94d62d0e551bf60ba
This commit is contained in:
commit
362fcbc123
8
go.mod
8
go.mod
|
|
@ -43,9 +43,9 @@ require (
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||||
gopkg.in/square/go-jose.v2 v2.2.2
|
gopkg.in/square/go-jose.v2 v2.2.2
|
||||||
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4
|
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4
|
||||||
k8s.io/apimachinery v0.0.0-20221223015414-47a8bb64c845
|
k8s.io/apimachinery v0.0.0-20230104022610-6c409361e35e
|
||||||
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357
|
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357
|
||||||
k8s.io/component-base v0.0.0-20221223033131-522c0db97a9d
|
k8s.io/component-base v0.0.0-20230103213415-cd0561133b79
|
||||||
k8s.io/klog/v2 v2.80.1
|
k8s.io/klog/v2 v2.80.1
|
||||||
k8s.io/kms v0.0.0-20221223035546-6bcec3321a14
|
k8s.io/kms v0.0.0-20221223035546-6bcec3321a14
|
||||||
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
|
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
|
||||||
|
|
@ -123,8 +123,8 @@ require (
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
k8s.io/api => k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4
|
k8s.io/api => k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4
|
||||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20221223015414-47a8bb64c845
|
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230104022610-6c409361e35e
|
||||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230102172837-3e0d99053357
|
k8s.io/client-go => k8s.io/client-go v0.0.0-20230102172837-3e0d99053357
|
||||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20221223033131-522c0db97a9d
|
k8s.io/component-base => k8s.io/component-base v0.0.0-20230103213415-cd0561133b79
|
||||||
k8s.io/kms => k8s.io/kms v0.0.0-20221223035546-6bcec3321a14
|
k8s.io/kms => k8s.io/kms v0.0.0-20221223035546-6bcec3321a14
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
go.sum
8
go.sum
|
|
@ -990,12 +990,12 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
|
||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4 h1:xXF6vJObhLxxs90hdEZENpbta24zuE/s8CGGRcIn384=
|
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4 h1:xXF6vJObhLxxs90hdEZENpbta24zuE/s8CGGRcIn384=
|
||||||
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4/go.mod h1:7VeiiNXwWDDV/gC/WTZA9plPSLqAQnOrZaAyXJsAudE=
|
k8s.io/api v0.0.0-20221223233726-92fe7a3ca2f4/go.mod h1:7VeiiNXwWDDV/gC/WTZA9plPSLqAQnOrZaAyXJsAudE=
|
||||||
k8s.io/apimachinery v0.0.0-20221223015414-47a8bb64c845 h1:vqU5mNvTR9zJZf7TEu4XhpgRInUeLe6ARyN9kD2RVck=
|
k8s.io/apimachinery v0.0.0-20230104022610-6c409361e35e h1:eJYyIfU4uOvJsSbI8fQkqQa+udeFbJDBUjw0I2F30k0=
|
||||||
k8s.io/apimachinery v0.0.0-20221223015414-47a8bb64c845/go.mod h1:E7c0pLSvNLZyzn9NBKnVO5+N8E8J25dNmB4m9TyuirA=
|
k8s.io/apimachinery v0.0.0-20230104022610-6c409361e35e/go.mod h1:E7c0pLSvNLZyzn9NBKnVO5+N8E8J25dNmB4m9TyuirA=
|
||||||
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357 h1:byPV8fJpLa21Z1uyJGe17H5O3wIuXaLz9n+XVEx1Ai0=
|
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357 h1:byPV8fJpLa21Z1uyJGe17H5O3wIuXaLz9n+XVEx1Ai0=
|
||||||
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357/go.mod h1:JYb/VVqQBLq2no4OmdLAj0HmkVMEdilejF0TWZDvpZQ=
|
k8s.io/client-go v0.0.0-20230102172837-3e0d99053357/go.mod h1:JYb/VVqQBLq2no4OmdLAj0HmkVMEdilejF0TWZDvpZQ=
|
||||||
k8s.io/component-base v0.0.0-20221223033131-522c0db97a9d h1:qEr7nhvQVZ8HcE6Am5aHFXAz+2TdCSqHHVC6no/AhK0=
|
k8s.io/component-base v0.0.0-20230103213415-cd0561133b79 h1:pWkWAgTCTFU/YcBNwBGW1oaGD8bkKTU2kkbaKqpMFHk=
|
||||||
k8s.io/component-base v0.0.0-20221223033131-522c0db97a9d/go.mod h1:TMuaLx8PNaRXbniuPjDEClqiwnmhH93MltUpk9G4S2Q=
|
k8s.io/component-base v0.0.0-20230103213415-cd0561133b79/go.mod h1:rBPtTKjMeZAQEcVDJBABh8tf4t2YgDVnI08QSLF1j/A=
|
||||||
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
|
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
|
||||||
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||||
k8s.io/kms v0.0.0-20221223035546-6bcec3321a14 h1:BLaDgiUPi2P78tmi0RHv7buWRPokavOk5jBcuUWC3s4=
|
k8s.io/kms v0.0.0-20221223035546-6bcec3321a14 h1:BLaDgiUPi2P78tmi0RHv7buWRPokavOk5jBcuUWC3s4=
|
||||||
|
|
|
||||||
|
|
@ -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