feat: expose expvars as profiling endpoint

This commit is contained in:
wpetit 2024-10-02 12:09:02 +02:00
parent 0ff9391a1b
commit f3b553cb10
2 changed files with 4 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package admin
import (
"context"
"expvar"
"fmt"
"log"
"net"
@ -176,6 +177,7 @@ func (s *Server) run(parentCtx context.Context, addrs chan net.Addr, errs chan e
r.HandleFunc("/profile", pprof.Profile)
r.HandleFunc("/symbol", pprof.Symbol)
r.HandleFunc("/trace", pprof.Trace)
r.Handle("/vars", expvar.Handler())
r.HandleFunc("/{name}", func(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
pprof.Handler(name).ServeHTTP(w, r)

View File

@ -3,6 +3,7 @@ package proxy
import (
"bytes"
"context"
"expvar"
"fmt"
"html/template"
"io"
@ -171,6 +172,7 @@ func (s *Server) run(parentCtx context.Context, addrs chan net.Addr, errs chan e
r.HandleFunc("/profile", pprof.Profile)
r.HandleFunc("/symbol", pprof.Symbol)
r.HandleFunc("/trace", pprof.Trace)
r.Handle("/vars", expvar.Handler())
r.HandleFunc("/{name}", func(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
pprof.Handler(name).ServeHTTP(w, r)