From 8674ec2a53b711a28b2635190a288836e064b525 Mon Sep 17 00:00:00 2001 From: Pablo Moncada Date: Tue, 1 Aug 2017 13:32:33 +0200 Subject: [PATCH] Add host label to request count --- middleware.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware.go b/middleware.go index 03ddd6f..7209afb 100644 --- a/middleware.go +++ b/middleware.go @@ -76,7 +76,7 @@ func (p *Prometheus) registerMetrics(subsystem string) { Name: "requests_total", Help: "How many HTTP requests processed, partitioned by status code and HTTP method.", }, - []string{"code", "method", "handler"}, + []string{"code", "method", "handler", "host"}, ) if err := prometheus.Register(p.reqCnt); err != nil { @@ -160,7 +160,7 @@ func (p *Prometheus) handlerFunc() gin.HandlerFunc { resSz := float64(c.Writer.Size()) p.reqDur.Observe(elapsed) - p.reqCnt.WithLabelValues(status, c.Request.Method, c.HandlerName()).Inc() + p.reqCnt.WithLabelValues(status, c.Request.Method, c.HandlerName(), c.Request.Host).Inc() p.reqSz.Observe(float64(<-reqSz)) p.resSz.Observe(resSz) }