go/{mirko,statusz}: enable profiling

Change-Id: I5f1a51f349196f2a187e484f44fdbff5d0acde3f
This commit is contained in:
q3k 2020-01-23 14:17:30 +01:00
parent a2ee865a0c
commit 400ac7a88d
2 changed files with 13 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import (
"fmt"
"net"
"net/http"
"net/http/pprof"
"os"
"os/signal"
"sort"
@ -103,6 +104,13 @@ func (m *Mirko) Listen() error {
})
m.httpMux.HandleFunc("/debug/requests", trace.Traces)
// pprof endpoints
m.httpMux.HandleFunc("/debug/pprof/", pprof.Index)
m.httpMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
m.httpMux.HandleFunc("/debug/pprof/profile", pprof.Profile)
m.httpMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
m.httpMux.HandleFunc("/debug/pprof/trace", pprof.Trace)
// -z legacy URLs
m.httpMux.HandleFunc("/statusz", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/debug/status", http.StatusSeeOther)
@ -113,6 +121,9 @@ func (m *Mirko) Listen() error {
m.httpMux.HandleFunc("/requestz", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/debug/requests", http.StatusSeeOther)
})
m.httpMux.HandleFunc("/profilez", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/debug/pprof", http.StatusSeeOther)
})
// root redirect
m.httpMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

View file

@ -118,7 +118,8 @@ SHA256 {{.BinaryHash}}<br>
Running as {{.Username}} on <a href="{{.PublicAddress}}">{{.Hostname}}</a><br>
Load {{.LoadAvg}}<br>
View <a href=/debug/status>status</a>,
<a href=/debug/requests>requests</a>
<a href=/debug/requests>requests</a>,
<a href=/debug/pprof>profile</a>
</div>
<div style="clear: both;"> </div>
</div>`