MCPcopy
hub / github.com/tailscale/tailscale / Debugger

Function Debugger

tsweb/debug.go:46–73  ·  view source on GitHub ↗

Debugger returns the DebugHandler registered on mux at /debug/, creating it if necessary.

(mux *http.ServeMux)

Source from the content-addressed store, hash-verified

44// Debugger returns the DebugHandler registered on mux at /debug/,
45// creating it if necessary.
46func Debugger(mux *http.ServeMux) *DebugHandler {
47 h, pat := mux.Handler(&http.Request{URL: &url.URL{Path: "/debug/"}})
48 if d, ok := h.(*DebugHandler); ok && pat == "/debug/" {
49 return d
50 }
51 ret := &DebugHandler{
52 mux: mux,
53 title: fmt.Sprintf("%s debug", version.CmdName()),
54 }
55 mux.Handle("/debug/", ret)
56
57 ret.KVFunc("Uptime", func() any { return varz.Uptime() })
58 ret.KV("Version", version.Long())
59 ret.Handle("vars", "Metrics (Go)", expvar.Handler())
60 if PrometheusHandler.IsSet() {
61 PrometheusHandler.Get()(ret)
62 } else {
63 ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(varz.Handler))
64 }
65
66 addProfilingHandlers(ret)
67 ret.Handle("gc", "force GC", http.HandlerFunc(gcHandler))
68 hostname, err := os.Hostname()
69 if err == nil {
70 ret.KV("Machine", hostname)
71 }
72 return ret
73}
74
75// ServeHTTP implements http.Handler.
76func (d *DebugHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

Callers 15

mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
muxFunction · 0.92
mainFunction · 0.92
runFunction · 0.92
runServeFunction · 0.92
mainFunction · 0.92
TestDebuggerFunction · 0.70
TestDebuggerKVFunction · 0.70
TestDebuggerURLFunction · 0.70

Calls 12

KVFuncMethod · 0.95
KVMethod · 0.95
HandleMethod · 0.95
CmdNameFunction · 0.92
UptimeFunction · 0.92
LongFunction · 0.92
addProfilingHandlersFunction · 0.70
HandleMethod · 0.65
IsSetMethod · 0.65
GetMethod · 0.65
HandlerMethod · 0.45
HostnameMethod · 0.45

Tested by 10

TestDebuggerFunction · 0.56
TestDebuggerKVFunction · 0.56
TestDebuggerURLFunction · 0.56
TestDebuggerSectionFunction · 0.56
TestDebuggerHandleFunction · 0.56
ExampleDebugHandler_KVFunction · 0.56
ExampleDebugHandler_URLFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…