pprof_default.go 852 B

123456789101112131415161718192021222324
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build !js && !wasm
  4. package tsweb
  5. import (
  6. "net/http"
  7. "net/http/pprof"
  8. )
  9. func addProfilingHandlers(d *DebugHandler) {
  10. // pprof.Index serves everything that runtime/pprof.Lookup finds:
  11. // goroutine, threadcreate, heap, allocs, block, mutex
  12. d.Handle("pprof/", "pprof (index)", http.HandlerFunc(pprof.Index))
  13. // But register the other ones from net/http/pprof directly:
  14. d.HandleSilent("pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
  15. d.HandleSilent("pprof/profile", http.HandlerFunc(pprof.Profile))
  16. d.HandleSilent("pprof/symbol", http.HandlerFunc(pprof.Symbol))
  17. d.HandleSilent("pprof/trace", http.HandlerFunc(pprof.Trace))
  18. d.URL("/debug/pprof/goroutine?debug=1", "Goroutines (collapsed)")
  19. d.URL("/debug/pprof/goroutine?debug=2", "Goroutines (full)")
  20. }