Skip to content

Instantly share code, notes, and snippets.

@gebv
Created February 16, 2023 20:01
Show Gist options
  • Save gebv/7ec7819f48a408b4c2d83753e9b1b7bf to your computer and use it in GitHub Desktop.
Save gebv/7ec7819f48a408b4c2d83753e9b1b7bf to your computer and use it in GitHub Desktop.
Golang debug handlers
mux.HandleFunc("/debug/pprof/", pprof.Index)
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)
mux.Handle("/debug/pprof/block", pprof.Handler("block"))
mux.Handle("/debug/pprof/heap", pprof.Handler("heap"))
mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
mux.Handle("/debug/vars", expvar.Handler())
mux.HandleFunc("/debug/requests", trace.Traces)
mux.HandleFunc("/debug/events", trace.Events)
mux.Handle("/debug/gc", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
runtime.GC()
l.Warn("triggered GC from debug endpoint")
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment