diff --git a/pkg/net/http/blademaster/client.go b/pkg/net/http/blademaster/client.go index 4ab8aca6e..a5ad62443 100644 --- a/pkg/net/http/blademaster/client.go +++ b/pkg/net/http/blademaster/client.go @@ -213,16 +213,16 @@ func (client *Client) Raw(c context.Context, req *xhttp.Request, v ...string) (b brk := client.breaker.Get(uri) if err = brk.Allow(); err != nil { code = "breaker" - _metricClientReqCodeTotal.Inc(uri, code) + _metricClientReqCodeTotal.Inc(uri, req.Method, code) return } defer client.onBreaker(brk, &err) // stat now := time.Now() defer func() { - _metricClientReqDur.Observe(int64(time.Since(now)/time.Millisecond), uri) + _metricClientReqDur.Observe(int64(time.Since(now)/time.Millisecond), uri, req.Method) if code != "" { - _metricClientReqCodeTotal.Inc(uri, code) + _metricClientReqCodeTotal.Inc(uri, req.Method, code) } }() // get config diff --git a/pkg/net/http/blademaster/logger.go b/pkg/net/http/blademaster/logger.go index b4c353fe0..6a440cdd4 100644 --- a/pkg/net/http/blademaster/logger.go +++ b/pkg/net/http/blademaster/logger.go @@ -35,8 +35,8 @@ func Logger() HandlerFunc { } if len(c.RoutePath) > 0 { - _metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, strconv.FormatInt(int64(cerr.Code()), 10)) - _metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller) + _metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, req.Method, strconv.FormatInt(int64(cerr.Code()), 10)) + _metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller, req.Method) } lf := log.Infov diff --git a/pkg/net/http/blademaster/metrics.go b/pkg/net/http/blademaster/metrics.go index e92eabe5e..1625090fc 100644 --- a/pkg/net/http/blademaster/metrics.go +++ b/pkg/net/http/blademaster/metrics.go @@ -13,7 +13,7 @@ var ( Subsystem: "requests", Name: "duration_ms", Help: "http server requests duration(ms).", - Labels: []string{"path", "caller"}, + Labels: []string{"path", "caller", "method"}, Buckets: []float64{5, 10, 25, 50, 100, 250, 500, 1000}, }) _metricServerReqCodeTotal = metric.NewCounterVec(&metric.CounterVecOpts{ @@ -21,21 +21,21 @@ var ( Subsystem: "requests", Name: "code_total", Help: "http server requests error count.", - Labels: []string{"path", "caller", "code"}, + Labels: []string{"path", "caller", "method", "code"}, }) _metricServerBBR = metric.NewCounterVec(&metric.CounterVecOpts{ Namespace: serverNamespace, Subsystem: "", Name: "bbr_total", Help: "http server bbr total.", - Labels: []string{"url"}, + Labels: []string{"url", "method"}, }) _metricClientReqDur = metric.NewHistogramVec(&metric.HistogramVecOpts{ Namespace: clientNamespace, Subsystem: "requests", Name: "duration_ms", Help: "http client requests duration(ms).", - Labels: []string{"path"}, + Labels: []string{"path", "method"}, Buckets: []float64{5, 10, 25, 50, 100, 250, 500, 1000}, }) _metricClientReqCodeTotal = metric.NewCounterVec(&metric.CounterVecOpts{ @@ -43,6 +43,6 @@ var ( Subsystem: "requests", Name: "code_total", Help: "http client requests code count.", - Labels: []string{"path", "code"}, + Labels: []string{"path", "method", "code"}, }) ) diff --git a/pkg/net/http/blademaster/ratelimit.go b/pkg/net/http/blademaster/ratelimit.go index 352ec3bae..cacc47b85 100644 --- a/pkg/net/http/blademaster/ratelimit.go +++ b/pkg/net/http/blademaster/ratelimit.go @@ -39,7 +39,7 @@ func (b *RateLimiter) Limit() HandlerFunc { limiter := b.group.Get(uri) done, err := limiter.Allow(c) if err != nil { - _metricServerBBR.Inc(uri) + _metricServerBBR.Inc(uri, c.Request.Method) c.JSON(nil, err) c.Abort() return