go/minotarproxy: clean up Prometheus metrics
This commit is contained in:
parent
bf8e6b62ed
commit
516ee3e20a
1 changed files with 6 additions and 5 deletions
|
@ -60,7 +60,7 @@ func (rt *roundRobinRoundtripper) RoundTrip(req *http.Request) (*http.Response,
|
||||||
rt.mu.Unlock()
|
rt.mu.Unlock()
|
||||||
|
|
||||||
handler := handlerName(req.Context())
|
handler := handlerName(req.Context())
|
||||||
labels := prometheus.Labels{"handler": handler, "sourceIP": rt.sip[rt.last]}
|
labels := prometheus.Labels{"handler": handler}
|
||||||
gi := rt.m.mInflight.With(labels)
|
gi := rt.m.mInflight.With(labels)
|
||||||
gi.Inc()
|
gi.Inc()
|
||||||
defer gi.Dec()
|
defer gi.Dec()
|
||||||
|
@ -76,7 +76,8 @@ func (rt *roundRobinRoundtripper) RoundTrip(req *http.Request) (*http.Response,
|
||||||
latency := time.Now().Sub(startTime)
|
latency := time.Now().Sub(startTime)
|
||||||
|
|
||||||
hl.Observe(latency.Seconds())
|
hl.Observe(latency.Seconds())
|
||||||
cvr.With(prometheus.Labels{"responseCode": fmt.Sprintf("%d", resp.StatusCode)}).Inc()
|
respLabels := prometheus.Labels{"responseCode": fmt.Sprintf("%d", resp.StatusCode), "sourceIP": rt.sip[rt.last]}
|
||||||
|
cvr.With(respLabels).Inc()
|
||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
@ -216,21 +217,21 @@ func main() {
|
||||||
Name: "proxy_inflight",
|
Name: "proxy_inflight",
|
||||||
Help: "Count of current inflight HTTP requests, per source-IP",
|
Help: "Count of current inflight HTTP requests, per source-IP",
|
||||||
},
|
},
|
||||||
[]string{"handler", "sourceIP"},
|
[]string{"handler"},
|
||||||
),
|
),
|
||||||
mLatency: prometheus.NewHistogramVec(
|
mLatency: prometheus.NewHistogramVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.HistogramOpts{
|
||||||
Name: "proxy_latency",
|
Name: "proxy_latency",
|
||||||
Help: "Histogram of request latency distributions",
|
Help: "Histogram of request latency distributions",
|
||||||
},
|
},
|
||||||
[]string{"handler", "sourceIP"},
|
[]string{"handler"},
|
||||||
),
|
),
|
||||||
mRequests: prometheus.NewCounterVec(
|
mRequests: prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "proxy_requests",
|
Name: "proxy_requests",
|
||||||
Help: "Count of requests that have passed through this proxy",
|
Help: "Count of requests that have passed through this proxy",
|
||||||
},
|
},
|
||||||
[]string{"handler", "sourceIP"},
|
[]string{"handler"},
|
||||||
),
|
),
|
||||||
mResponses: prometheus.NewCounterVec(
|
mResponses: prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
|
|
Loading…
Reference in a new issue