Skip to content

Commit

Permalink
Add host label to request count
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoncadaisla committed Aug 1, 2017
1 parent 893fa48 commit 8674ec2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 8674ec2

Please sign in to comment.