Use Histogram instead of Summary

A histogram allows to aggregate by labels and calculate more
comprehensive quantiles.
This commit is contained in:
Fabian Reinartz 2016-11-14 12:45:13 +01:00
parent 49e2074f74
commit 2b66b49a2f

View File

@ -30,11 +30,11 @@ import (
var ( var (
// requestLatency is a Prometheus Summary metric type partitioned by // requestLatency is a Prometheus Summary metric type partitioned by
// "verb" and "url" labels. It is used for the rest client latency metrics. // "verb" and "url" labels. It is used for the rest client latency metrics.
requestLatency = prometheus.NewSummaryVec( requestLatency = prometheus.NewHistogramVec(
prometheus.SummaryOpts{ prometheus.HistogramOpts{
Name: "rest_client_request_latency_seconds", Name: "rest_client_request_latency_seconds",
Help: "Request latency in seconds. Broken down by verb and URL.", Help: "Request latency in seconds. Broken down by verb and URL.",
MaxAge: time.Hour, Buckets: prometheus.ExponentialBuckets(0.001, 2, 10),
}, },
[]string{"verb", "url"}, []string{"verb", "url"},
) )
@ -55,7 +55,7 @@ func init() {
} }
type latencyAdapter struct { type latencyAdapter struct {
m *prometheus.SummaryVec m *prometheus.HistogramVec
} }
func (l *latencyAdapter) Observe(verb string, u url.URL, latency time.Duration) { func (l *latencyAdapter) Observe(verb string, u url.URL, latency time.Duration) {