mirror of
https://github.com/astaxie/beego.git
synced 2024-11-23 17:30:53 +00:00
Merge pull request #3 from flycash/develop-1
Remove duration from prometheus label
This commit is contained in:
commit
19e6ba8e7c
@ -37,7 +37,7 @@ func PrometheusMiddleWare(next http.Handler) http.Handler {
|
|||||||
"appname": beego.BConfig.AppName,
|
"appname": beego.BConfig.AppName,
|
||||||
},
|
},
|
||||||
Help: "The statics info for http request",
|
Help: "The statics info for http request",
|
||||||
}, []string{"pattern", "method", "status", "duration"})
|
}, []string{"pattern", "method", "status"})
|
||||||
|
|
||||||
prometheus.MustRegister(summaryVec)
|
prometheus.MustRegister(summaryVec)
|
||||||
|
|
||||||
@ -95,5 +95,5 @@ func report(dur time.Duration, writer http.ResponseWriter, q *http.Request, vec
|
|||||||
logs.Warn("we can not find the router info for this request, so request will be recorded as UNKNOWN: " + q.URL.String())
|
logs.Warn("we can not find the router info for this request, so request will be recorded as UNKNOWN: " + q.URL.String())
|
||||||
}
|
}
|
||||||
ms := dur / time.Millisecond
|
ms := dur / time.Millisecond
|
||||||
vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status), strconv.Itoa(int(ms))).Observe(float64(ms))
|
vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status)).Observe(float64(ms))
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func TestPrometheusMiddleWare(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
}
|
}
|
||||||
vec := prometheus.NewSummaryVec(prometheus.SummaryOpts{}, []string{"pattern", "method", "status", "duration"})
|
vec := prometheus.NewSummaryVec(prometheus.SummaryOpts{}, []string{"pattern", "method", "status"})
|
||||||
|
|
||||||
report(time.Second, writer, request, vec)
|
report(time.Second, writer, request, vec)
|
||||||
middleware.ServeHTTP(writer, request)
|
middleware.ServeHTTP(writer, request)
|
||||||
|
Loading…
Reference in New Issue
Block a user