(profileName string, w http.ResponseWriter, r *http.Request)
| 511 | } |
| 512 | |
| 513 | func pprofHandler(profileName string, w http.ResponseWriter, r *http.Request) { |
| 514 | // This switch has been stolen from init func at https://golang.org/src/net/http/pprof/pprof.go |
| 515 | switch profileName { |
| 516 | case "cmdline": |
| 517 | pprofCmdlineRequests.Inc() |
| 518 | pprof.Cmdline(w, r) |
| 519 | case "profile": |
| 520 | pprofProfileRequests.Inc() |
| 521 | pprof.Profile(w, r) |
| 522 | case "symbol": |
| 523 | pprofSymbolRequests.Inc() |
| 524 | pprof.Symbol(w, r) |
| 525 | case "trace": |
| 526 | pprofTraceRequests.Inc() |
| 527 | pprof.Trace(w, r) |
| 528 | case "mutex": |
| 529 | pprofMutexRequests.Inc() |
| 530 | seconds, _ := strconv.Atoi(r.FormValue("seconds")) |
| 531 | if seconds <= 0 { |
| 532 | seconds = 10 |
| 533 | } |
| 534 | prev := runtime.SetMutexProfileFraction(10) |
| 535 | time.Sleep(time.Duration(seconds) * time.Second) |
| 536 | pprof.Index(w, r) |
| 537 | runtime.SetMutexProfileFraction(prev) |
| 538 | default: |
| 539 | pprofDefaultRequests.Inc() |
| 540 | pprof.Index(w, r) |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | var ( |
| 545 | metricsRequests = metrics.NewCounter(`vm_http_requests_total{path="/metrics"}`) |
no test coverage detected
searching dependent graphs…