Skip to content
Snippets Groups Projects
Commit efe1ce96 authored by ale's avatar ale
Browse files

Fix incomplete commit 9d388e

It left the Prometheus instrumentation in server/http.go, while
it is already provided by the ai3/go-common package.
parent ad6e4c82
Branches
No related tags found
No related merge requests found
......@@ -18,8 +18,6 @@ import (
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
"github.com/gorilla/sessions"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"git.autistici.org/id/auth"
authclient "git.autistici.org/id/auth/client"
......@@ -64,8 +62,6 @@ func newAuthSession(ttl time.Duration, username string, userinfo *auth.UserInfo)
func init() {
gob.Register(&authSession{})
prometheus.MustRegister(totalRequests, inFlightRequests)
}
// Returns the URL of the login handler on the target service.
......@@ -278,13 +274,11 @@ func (h *Server) Handler() http.Handler {
AssetInfo: AssetInfo,
Prefix: "static",
})))
m.Handle("/metrics", promhttp.Handler())
m.Handle("/exchange", withDynamicHeaders(http.HandlerFunc(h.handleExchange)))
m.Handle("/", withDynamicHeaders(h.withAuth(h.handleHomepage)))
return promhttp.InstrumentHandlerInFlight(inFlightRequests,
promhttp.InstrumentHandlerCounter(totalRequests, m))
return m
}
// A relatively strict CSP.
......@@ -303,23 +297,6 @@ func withDynamicHeaders(h http.Handler) http.Handler {
})
}
// Instrumentation.
var (
totalRequests = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "total_requests",
Help: "Total number of requests.",
},
[]string{"code"},
)
inFlightRequests = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "inflight_requests",
Help: "Number of in-flight requests.",
},
)
)
// Parse the templates that are embedded with the binary (in bindata.go).
func parseEmbeddedTemplates() *template.Template {
root := template.New("").Funcs(template.FuncMap{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment