Merge pull request #46593 from shyamjvs/fix-perfdata-subresource

Automatic merge from submit-queue

Fix minor bugs in setting API call metrics with subresource

Based on changes from https://github.com/kubernetes/kubernetes/pull/46354

/cc @wojtek-t @smarterclayton
This commit is contained in:
Kubernetes Submit Queue 2017-05-29 08:45:02 -07:00 committed by GitHub
commit d9f3ea5191
2 changed files with 6 additions and 5 deletions

View File

@ -224,7 +224,7 @@ func (a *APIResponsiveness) Less(i, j int) bool {
// Only 0.5, 0.9 and 0.99 quantiles are supported. // Only 0.5, 0.9 and 0.99 quantiles are supported.
func (a *APIResponsiveness) addMetricRequestLatency(resource, subresource, verb string, quantile float64, latency time.Duration) { func (a *APIResponsiveness) addMetricRequestLatency(resource, subresource, verb string, quantile float64, latency time.Duration) {
for i, apicall := range a.APICalls { for i, apicall := range a.APICalls {
if apicall.Resource == resource && apicall.Verb == verb { if apicall.Resource == resource && apicall.Subresource == subresource && apicall.Verb == verb {
a.APICalls[i] = setQuantileAPICall(apicall, quantile, latency) a.APICalls[i] = setQuantileAPICall(apicall, quantile, latency)
return return
} }
@ -255,7 +255,7 @@ func setQuantile(metric *LatencyMetric, quantile float64, latency time.Duration)
// Add request count to the APICall metric entry (creating one if necessary). // Add request count to the APICall metric entry (creating one if necessary).
func (a *APIResponsiveness) addMetricRequestCount(resource, subresource, verb string, count int) { func (a *APIResponsiveness) addMetricRequestCount(resource, subresource, verb string, count int) {
for i, apicall := range a.APICalls { for i, apicall := range a.APICalls {
if apicall.Resource == resource && apicall.Verb == verb { if apicall.Resource == resource && apicall.Subresource == subresource && apicall.Verb == verb {
a.APICalls[i].Count += count a.APICalls[i].Count += count
return return
} }

View File

@ -41,9 +41,10 @@ func ApiCallToPerfData(apicalls *APIResponsiveness) *perftype.PerfData {
}, },
Unit: "ms", Unit: "ms",
Labels: map[string]string{ Labels: map[string]string{
"Verb": apicall.Verb, "Verb": apicall.Verb,
"Resource": apicall.Resource, "Resource": apicall.Resource,
"Count": fmt.Sprintf("%v", apicall.Count), "Subresource": apicall.Subresource,
"Count": fmt.Sprintf("%v", apicall.Count),
}, },
} }
perfData.DataItems = append(perfData.DataItems, item) perfData.DataItems = append(perfData.DataItems, item)