Skip to content

Commit

Permalink
pkg/receive: add requests counter metric
Browse files Browse the repository at this point in the history
As per the discussion in
thanos-io#1261 (comment),
let's add a metric to track the total number of requests handled by the
receive component.
  • Loading branch information
squat committed Jun 19, 2019
1 parent b3256e0 commit 04da970
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ var (
},
[]string{"handler"},
)
requestsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "thanos_http_requests_total",
Help: "Tracks the number of HTTP requests.",
}, []string{"code", "handler", "method"},
)
responseSize = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "thanos_http_response_size_bytes",
Expand Down Expand Up @@ -67,7 +73,10 @@ func instrumentHandler(handlerName string, handler http.HandlerFunc) http.Handle
requestDuration.MustCurryWith(prometheus.Labels{"handler": handlerName}),
promhttp.InstrumentHandlerResponseSize(
responseSize.MustCurryWith(prometheus.Labels{"handler": handlerName}),
handler,
promhttp.InstrumentHandlerCounter(
requestsTotal.MustCurryWith(prometheus.Labels{"handler": handlerName}),
handler,
),
),
)
}
Expand All @@ -92,6 +101,7 @@ func NewHandler(logger log.Logger, o *Options) *Handler {
if o.Registry != nil {
o.Registry.MustRegister(
requestDuration,
requestsTotal,
responseSize,
)
}
Expand Down

0 comments on commit 04da970

Please sign in to comment.