feat: add prometheus metrics

This commit is contained in:
Sam 2023-04-17 23:44:21 +02:00
parent b4c331daa0
commit 5c8c6eed63
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
7 changed files with 110 additions and 9 deletions

View file

@ -6,6 +6,7 @@ import (
"codeberg.org/u1f320/pronouns.cc/backend/server"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
type Server struct {
@ -23,6 +24,8 @@ func Mount(srv *server.Server, r chi.Router) {
r.Patch("/reports/{id}", server.WrapHandler(s.resolveReport))
})
r.With(MustAdmin).Handle("/metrics", promhttp.Handler())
r.With(server.MustAuth).Post("/users/{id}/reports", server.WrapHandler(s.createUserReport))
r.With(server.MustAuth).Post("/members/{id}/reports", server.WrapHandler(s.createMemberReport))