1

I am using net/http/pprof package to profile the golang app using a http.Server, which is configured with timeouts:

package main

import (
    "log"
    "net/http"
    _ "net/http/pprof"
    "time"
)

func main() {
    s := &http.Server{
        Addr:         ":8080",
        ReadTimeout:  time.Second * 5,
        WriteTimeout: time.Second * 10,
    }
    log.Fatal(s.ListenAndServe())
}

I want to keep timeouts, but I also want to perform long profiling for /debug/pprof/profile or /debug/pprof/trace. With current settings I get the error:

$ go tool pprof -http localhost:43242 http://localhost:8080/debug/pprof/profile\?seconds\=10

http://localhost:8080/debug/pprof/profile?seconds=10: server response: 400 Bad Request - profile duration exceeds server's WriteTimeout

I could run a separate http.Server on a different port, but I would like to use an existing server

slsy
  • 1,257
  • 8
  • 21

0 Answers0