Change the logic of success request metrics (#1059)
Co-authored-by: robotljw <790504160@qq.com>
diff --git a/server/metrics/http.go b/server/metrics/http.go
index db9c71e..8ffb0c0 100644
--- a/server/metrics/http.go
+++ b/server/metrics/http.go
@@ -77,7 +77,7 @@
reqDurations.WithLabelValues(r.Method, instance, route, domain).Observe(elapsed)
}
- success, code := codeOf(r.Context().Value(rest.CtxResponseStatus).(int))
+ success, code := parseStatus(r.Context().Value(rest.CtxResponseStatus).(int))
incomingRequests.WithLabelValues(r.Method, code, instance, route, domain).Inc()
@@ -86,9 +86,9 @@
}
}
-func codeOf(code int) (bool, string) {
+func parseStatus(code int) (bool, string) {
sz := strconv.Itoa(code)
- if code >= http.StatusOK && code <= http.StatusAccepted {
+ if code < http.StatusInternalServerError {
return true, sz
}
return false, sz