github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/metrics/prometheus.go (about) 1 package metrics 2 3 import ( 4 "net/http" 5 6 "github.com/prometheus/client_golang/prometheus" 7 "github.com/prometheus/client_golang/prometheus/promhttp" 8 "github.com/quickfeed/quickfeed/ci" 9 "github.com/quickfeed/quickfeed/web/interceptor" 10 ) 11 12 var reg = prometheus.NewRegistry() 13 14 func init() { 15 metricsCollectorsSets := [][]prometheus.Collector{ 16 interceptor.RPCMetricsCollectors(), 17 ci.TestExecutionMetricsCollectors(), 18 } 19 for _, collectors := range metricsCollectorsSets { 20 reg.MustRegister(collectors...) 21 } 22 } 23 24 func Handler() http.Handler { 25 return promhttp.HandlerFor(reg, promhttp.HandlerOpts{}) 26 }