feat(backend): add request latency tracking

This commit is contained in:
Sam 2023-06-23 03:27:09 +02:00
parent 0a012d75af
commit c61186b22a
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
3 changed files with 14 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/go-chi/cors"
"github.com/go-chi/httprate"
"github.com/go-chi/render"
chiprometheus "github.com/toshi0607/chi-prometheus"
)
// Revision is the git commit, filled at build time
@ -59,6 +60,12 @@ func New() (*Server, error) {
MaxAge: 300,
}))
// enable request latency tracking
os.Setenv(chiprometheus.EnvChiPrometheusLatencyBuckets, "10,25,50,100,300,500,1000,5000")
prom := chiprometheus.New("pronouns.cc")
s.Router.Use(prom.Handler)
prom.MustRegisterDefault()
// enable authentication for all routes (but don't require it)
s.Router.Use(s.maybeAuth)