mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-12 00:39:29 -06:00
- split metrics by service (API, portal, cdn, "common") - fix domain name appended to path in metrics - fix built-in http dashboard in Grafana
28 lines
773 B
Go
28 lines
773 B
Go
//go:build profile
|
|
|
|
package monitoring
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"net/http"
|
|
"net/http/pprof"
|
|
)
|
|
|
|
// NOTE: (default) alternative would be to _ import the pprof package and start http server on :6060
|
|
func (s *Service) setupProfiling(ctx context.Context, mux *http.ServeMux) {
|
|
slog.DebugContext(ctx, "Enabling profiling endpoints")
|
|
|
|
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
|
|
|
profiles := []string{"goroutine", "heap", "allocs", "threadcreate", "block", "mutex"}
|
|
for _, p := range profiles {
|
|
mux.Handle("/debug/pprof/"+p, pprof.Handler(p))
|
|
}
|
|
|
|
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
|
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
|
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
|
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
|
}
|