update
parent
1eb10eb1af
commit
4ced8ae869
|
@ -4,6 +4,7 @@ import (
|
|||
"git.makemake.in/kzkzzzz/mycommon/mymetric"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/spf13/cast"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -11,7 +12,7 @@ const CtxCollectRequestFrom = "ctx_collect_request_from"
|
|||
|
||||
func QPSCollect(svcName string) gin.HandlerFunc {
|
||||
hs := mymetric.NewQPSHistogram(svcName, []string{
|
||||
"svc", "method", "route", "from",
|
||||
"svc", "method", "route", "status", "from",
|
||||
}...)
|
||||
|
||||
return func(ctx *gin.Context) {
|
||||
|
@ -23,6 +24,7 @@ func QPSCollect(svcName string) gin.HandlerFunc {
|
|||
"svc": svcName,
|
||||
"method": ctx.Request.Method,
|
||||
"route": ctx.Request.URL.Path,
|
||||
"status": cast.ToString(ctx.Writer.Status()),
|
||||
"from": ctx.GetString(CtxCollectRequestFrom),
|
||||
}).Observe(float64(time.Since(st).Milliseconds()))
|
||||
|
||||
|
|
Loading…
Reference in New Issue