/
metrics.go
27 lines (21 loc) · 863 Bytes
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package cli
import (
"net/http"
"github.com/Korpenter/tusd/v2/pkg/handler"
"github.com/Korpenter/tusd/v2/pkg/hooks"
"github.com/Korpenter/tusd/v2/pkg/prometheuscollector"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var MetricsOpenConnections = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "tusd_connections_open",
Help: "Current number of open connections.",
})
func SetupMetrics(mux *http.ServeMux, handler *handler.Handler) {
prometheus.MustRegister(MetricsOpenConnections)
prometheus.MustRegister(hooks.MetricsHookErrorsTotal)
prometheus.MustRegister(hooks.MetricsHookInvocationsTotal)
prometheus.MustRegister(prometheuscollector.New(handler.Metrics))
stdout.Printf("Using %s as the metrics path.\n", Flags.MetricsPath)
mux.Handle(Flags.MetricsPath, promhttp.Handler())
}