Serverside stuff. Mostly shuffling things around
This commit is contained in:
parent
90667d96c7
commit
be70109c43
20 changed files with 513 additions and 71 deletions
|
@ -12,8 +12,10 @@ import (
|
|||
"gitlab.com/mstarongitlab/goutils/other"
|
||||
)
|
||||
|
||||
// Mounted at /profiling
|
||||
func setupProfilingHandler() http.Handler {
|
||||
router := http.NewServeMux()
|
||||
router.HandleFunc("/", profilingRootHandler)
|
||||
router.HandleFunc("GET /current-goroutines", metricActiveGoroutinesHandler)
|
||||
router.HandleFunc("GET /memory", metricMemoryStatsHandler)
|
||||
router.HandleFunc("GET /pprof/cpu", pprof.Profile)
|
||||
|
@ -28,6 +30,13 @@ func isAliveHandler(w http.ResponseWriter, r *http.Request) {
|
|||
fmt.Fprint(w, "yup")
|
||||
}
|
||||
|
||||
func profilingRootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(
|
||||
w,
|
||||
"Endpoints: /, /{memory,current-goroutines}, /pprof/{cpu,memory,goroutines,blockers}",
|
||||
)
|
||||
}
|
||||
|
||||
func metricActiveGoroutinesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "{\"goroutines\": %d}", runtime.NumGoroutine())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue