aboutsummaryrefslogtreecommitdiff
path: root/cmd/site/internal/middleware/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/site/internal/middleware/metrics.go')
-rw-r--r--cmd/site/internal/middleware/metrics.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/cmd/site/internal/middleware/metrics.go b/cmd/site/internal/middleware/metrics.go
deleted file mode 100644
index f9d7e0f..0000000
--- a/cmd/site/internal/middleware/metrics.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package middleware
-
-import (
- "net/http"
-
- "github.com/prometheus/client_golang/prometheus"
- "github.com/prometheus/client_golang/prometheus/promhttp"
-)
-
-var (
- requestCounter = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Name: "handler_requests_total",
- Help: "Total number of request/responses by HTTP status code.",
- }, []string{"handler", "code"})
-
- requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
- Name: "handler_request_duration",
- Help: "Handler request duration.",
- }, []string{"handler", "method"})
-
- requestInFlight = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Name: "handler_requests_in_flight",
- Help: "Current number of requests being served.",
- }, []string{"handler"})
-)
-
-func init() {
- _ = prometheus.Register(requestCounter)
- _ = prometheus.Register(requestDuration)
- _ = prometheus.Register(requestInFlight)
-}
-
-// Metrics captures request duration, request count and in-flight request count
-// metrics for HTTP handlers. The family field is used to discriminate handlers.
-func Metrics(family string, next http.Handler) http.Handler {
- return promhttp.InstrumentHandlerDuration(
- requestDuration.MustCurryWith(prometheus.Labels{"handler": family}),
- promhttp.InstrumentHandlerCounter(requestCounter.MustCurryWith(prometheus.Labels{"handler": family}),
- promhttp.InstrumentHandlerInFlight(requestInFlight.With(prometheus.Labels{"handler": family}), next),
- ),
- )
-}