Skip to content

Commit

Permalink
Issue #88 Adding Host Label to all metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ankittiwari-harness committed Mar 1, 2023
1 parent 3020071 commit bdd4529
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ var reqDur = &Metric{
ID: "reqDur",
Name: "request_duration_seconds",
Description: "The HTTP request latencies in seconds.",
Args: []string{"code", "method", "url"},
Args: []string{"code", "method", "host", "url"},
Type: "histogram_vec",
Buckets: reqDurBuckets}

var resSz = &Metric{
ID: "resSz",
Name: "response_size_bytes",
Description: "The HTTP response sizes in bytes.",
Args: []string{"code", "method", "url"},
Args: []string{"code", "method", "host", "url"},
Type: "histogram_vec",
Buckets: resSzBuckets}

var reqSz = &Metric{
ID: "reqSz",
Name: "request_size_bytes",
Description: "The HTTP request sizes in bytes.",
Args: []string{"code", "method", "url"},
Args: []string{"code", "method", "host", "url"},
Type: "histogram_vec",
Buckets: reqSzBuckets}

Expand Down Expand Up @@ -439,12 +439,12 @@ func (p *Prometheus) HandlerFunc(next echo.HandlerFunc) echo.HandlerFunc {
}

statusStr := strconv.Itoa(status)
p.reqDur.WithLabelValues(statusStr, c.Request().Method, url).Observe(elapsed)
p.reqDur.WithLabelValues(statusStr, c.Request().Method, p.RequestCounterHostLabelMappingFunc(c), url).Observe(elapsed)
p.reqCnt.WithLabelValues(statusStr, c.Request().Method, p.RequestCounterHostLabelMappingFunc(c), url).Inc()
p.reqSz.WithLabelValues(statusStr, c.Request().Method, url).Observe(float64(reqSz))
p.reqSz.WithLabelValues(statusStr, c.Request().Method, p.RequestCounterHostLabelMappingFunc(c), url).Observe(float64(reqSz))

resSz := float64(c.Response().Size)
p.resSz.WithLabelValues(statusStr, c.Request().Method, url).Observe(resSz)
p.resSz.WithLabelValues(statusStr, c.Request().Method, p.RequestCounterHostLabelMappingFunc(c), url).Observe(resSz)

return err
}
Expand Down

0 comments on commit bdd4529

Please sign in to comment.