From 14ae5164bc0bcbace8f198d19eca434d9ef9278c Mon Sep 17 00:00:00 2001 From: David Cheung Date: Tue, 20 Jun 2023 22:03:50 +0000 Subject: [PATCH 1/2] update k8s/gce server request metrics to count server error --- pkg/neg/metrics/metrics.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/neg/metrics/metrics.go b/pkg/neg/metrics/metrics.go index 647d7cc5f2..7c1f6be23d 100644 --- a/pkg/neg/metrics/metrics.go +++ b/pkg/neg/metrics/metrics.go @@ -345,14 +345,32 @@ func PublishAnnotationMetrics(annotationSize int, labelNumber int) { // PublishGCERequestCountMetrics publishes collected metrics for GCE Request Counts func PublishGCERequestCountMetrics(start time.Time, requestType string, err error) { - result := getResult(err) + var result string + if err == nil { + result = resultSuccess + } else { + if utils.IsGCEServerError(err) { + result = gceServerError + } else { + result = otherError + } + } GCERequestLatency.WithLabelValues(requestType, result).Observe(time.Since(start).Seconds()) GCERequestCount.WithLabelValues(requestType, result).Inc() } // PublishK8sRequestCountMetrics publishes collected metrics for K8s Request Counts func PublishK8sRequestCountMetrics(start time.Time, requestType string, err error) { - result := getResult(err) + var result string + if err == nil { + result = resultSuccess + } else { + if utils.IsK8sServerError(err) { + result = k8sServerError + } else { + result = otherError + } + } K8sRequestLatency.WithLabelValues(requestType, result).Observe(time.Since(start).Seconds()) K8sRequestCount.WithLabelValues(requestType, result).Inc() } From fa5d2b75f2ceffcdfb0e94a5887981e5360c7b66 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Wed, 21 Jun 2023 23:36:48 +0000 Subject: [PATCH 2/2] count server errors first for neg controller error metrics --- pkg/neg/metrics/metrics.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/neg/metrics/metrics.go b/pkg/neg/metrics/metrics.go index 7c1f6be23d..122d3d0a2e 100644 --- a/pkg/neg/metrics/metrics.go +++ b/pkg/neg/metrics/metrics.go @@ -383,14 +383,14 @@ func getResult(err error) string { } func getErrorLabel(err error, isIgnored bool) string { - if isIgnored { - return ignoredError - } if utils.IsGCEServerError(err) { return gceServerError } if utils.IsK8sServerError(err) { return k8sServerError } + if isIgnored { + return ignoredError + } return otherError }