From deaf17e178ffbb2a009a6f869d727a623a01a975 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Sat, 25 Sep 2021 22:58:40 +0800 Subject: [PATCH] http metric redefine fail/ok --- dtmsvr/metrics.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dtmsvr/metrics.go b/dtmsvr/metrics.go index d24f310..2c50e20 100644 --- a/dtmsvr/metrics.go +++ b/dtmsvr/metrics.go @@ -53,12 +53,10 @@ func httpMetrics(app *gin.Engine) *gin.Engine { defer timer.ObserveDuration() c.Next() status := c.Writer.Status() - if status >= 500 { + if status >= 400 { processTotal.WithLabelValues("http", api, "fail").Inc() - } else if status == 200 { - processTotal.WithLabelValues("http", api, "ok").Inc() } else { - panic("undefined status") + processTotal.WithLabelValues("http", api, "ok").Inc() } }) return app