aboutsummaryrefslogtreecommitdiff
path: root/internal/httputil
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-04-08 12:24:40 +0200
committerGitHub <noreply@github.com>2022-04-08 12:24:40 +0200
commite8dd37d533275233b7bebeeb70b996e166cf2d3b (patch)
tree5316a53ae7dc2931b4e74e9cc64d9702cd9d4a79 /internal/httputil
parent25d99c44733036a638eb2e5061e42e90dd089f0e (diff)
Add metrics for internal API requests (#2310)
* Add response size and requests total to internal handler * Move MustRegister calls to New* funcs * Move MustRegister back to init * Init at some place, minimize changes
Diffstat (limited to 'internal/httputil')
-rw-r--r--internal/httputil/httpapi.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/internal/httputil/httpapi.go b/internal/httputil/httpapi.go
index 1a37a1ee..5fcacd2a 100644
--- a/internal/httputil/httpapi.go
+++ b/internal/httputil/httpapi.go
@@ -169,8 +169,9 @@ func MakeHTMLAPI(metricsName string, f func(http.ResponseWriter, *http.Request)
return promhttp.InstrumentHandlerCounter(
promauto.NewCounterVec(
prometheus.CounterOpts{
- Name: metricsName,
- Help: "Total number of http requests for HTML resources",
+ Name: metricsName,
+ Help: "Total number of http requests for HTML resources",
+ Namespace: "dendrite",
},
[]string{"code"},
),
@@ -201,7 +202,28 @@ func MakeInternalAPI(metricsName string, f func(*http.Request) util.JSONResponse
h.ServeHTTP(w, req)
}
- return http.HandlerFunc(withSpan)
+ return promhttp.InstrumentHandlerCounter(
+ promauto.NewCounterVec(
+ prometheus.CounterOpts{
+ Name: metricsName + "_requests_total",
+ Help: "Total number of internal API calls",
+ Namespace: "dendrite",
+ },
+ []string{"code"},
+ ),
+ promhttp.InstrumentHandlerResponseSize(
+ promauto.NewHistogramVec(
+ prometheus.HistogramOpts{
+ Namespace: "dendrite",
+ Name: metricsName + "_response_size_bytes",
+ Help: "A histogram of response sizes for requests.",
+ Buckets: []float64{200, 500, 900, 1500, 5000, 15000, 50000, 100000},
+ },
+ []string{},
+ ),
+ http.HandlerFunc(withSpan),
+ ),
+ )
}
// MakeFedAPI makes an http.Handler that checks matrix federation authentication.