go/minotarproxy: clean up Prometheus metrics

This commit is contained in:
Luke Hanley (LukeHandle) 2022-01-22 15:28:31 +00:00
parent bf8e6b62ed
commit 516ee3e20a

View file

@ -60,7 +60,7 @@ func (rt *roundRobinRoundtripper) RoundTrip(req *http.Request) (*http.Response,
rt.mu.Unlock()
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.Inc()
defer gi.Dec()
@ -76,7 +76,8 @@ func (rt *roundRobinRoundtripper) RoundTrip(req *http.Request) (*http.Response,
latency := time.Now().Sub(startTime)
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
}
@ -216,21 +217,21 @@ func main() {
Name: "proxy_inflight",
Help: "Count of current inflight HTTP requests, per source-IP",
},
[]string{"handler", "sourceIP"},
[]string{"handler"},
),
mLatency: prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "proxy_latency",
Help: "Histogram of request latency distributions",
},
[]string{"handler", "sourceIP"},
[]string{"handler"},
),
mRequests: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "proxy_requests",
Help: "Count of requests that have passed through this proxy",
},
[]string{"handler", "sourceIP"},
[]string{"handler"},
),
mResponses: prometheus.NewCounterVec(
prometheus.CounterOpts{