Skip to content

Commit

Permalink
proxy/httpproxy: document histogram
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed May 23, 2018
1 parent 0427018 commit d950623
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions proxy/httpproxy/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ var (
Help: "Counter of requests dropped on the proxy.",
}, []string{"method", "proxying_error"})

requestsHandlingTime = prometheus.NewHistogramVec(
requestsHandlingSec = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "etcd",
Subsystem: "proxy",
Name: "handling_duration_seconds",
Help: "Bucketed histogram of handling time of successful events (non-watches), by method " +
"(GET/PUT etc.).",
Help: "Bucketed histogram of handling time of successful events (non-watches), by method (GET/PUT etc.).",

// lowest bucket start of upper bound 0.0005 sec (0.5 ms) with factor 2
// highest bucket start of 0.0005 sec * 2^12 == 2.048 sec
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
}, []string{"method"})
)
Expand All @@ -70,7 +72,7 @@ func init() {
prometheus.MustRegister(requestsIncoming)
prometheus.MustRegister(requestsHandled)
prometheus.MustRegister(requestsDropped)
prometheus.MustRegister(requestsHandlingTime)
prometheus.MustRegister(requestsHandlingSec)
}

func reportIncomingRequest(request *http.Request) {
Expand All @@ -80,7 +82,7 @@ func reportIncomingRequest(request *http.Request) {
func reportRequestHandled(request *http.Request, response *http.Response, startTime time.Time) {
method := request.Method
requestsHandled.WithLabelValues(method, strconv.Itoa(response.StatusCode)).Inc()
requestsHandlingTime.WithLabelValues(method).Observe(time.Since(startTime).Seconds())
requestsHandlingSec.WithLabelValues(method).Observe(time.Since(startTime).Seconds())
}

func reportRequestDropped(request *http.Request, err forwardingError) {
Expand Down

0 comments on commit d950623

Please sign in to comment.