pprof.go 559 B

12345678910111213141516171819202122232425262728
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build !ios && !android && !js && !ts_omit_debug
  4. // We don't include it on mobile where we're more memory constrained and
  5. // there's no CLI to get at the results anyway.
  6. package localapi
  7. import (
  8. "net/http"
  9. "net/http/pprof"
  10. )
  11. func init() {
  12. servePprofFunc = servePprof
  13. }
  14. func servePprof(w http.ResponseWriter, r *http.Request) {
  15. name := r.FormValue("name")
  16. switch name {
  17. case "profile":
  18. pprof.Profile(w, r)
  19. default:
  20. pprof.Handler(name).ServeHTTP(w, r)
  21. }
  22. }