For debugging purposes, how can I get more information on exactly where my http.TimeoutHandler
wrapped handler canceled an active http.Request::Context()
?
Ideally, a stacktrace should be logged.
Background: The server is set up like this:
mux := http.NewServeMux()
mux.Handle("/", http.HandlerFunc(handle_root))
srv := &http.Server {
Addr : fmt.Sprintf("%s:%d", args.address, args.port),
ReadTimeout : 2 * time.Second,
WriteTimeout : 2 * time.Second,
IdleTimeout : 2 * time.Second,
Handler : http.TimeoutHandler(mux, 1500 * time.Millisecond,
"Backend timeout exceeded"),
}
log.Fatal(srv.ListenAndServe())
Where handle_root()
calls some helper functions and passes the http.Request
s Context() to some database.sql
prepared statements QueryContext()
calls.
When the timeout is exceeded it would be helpful for debugging/profiling to get some hint on exactly how far the execution proceeded into the handler, e.g. whether it was waiting on the result set of a certain SQL statement or not - and if it was on which one exactly.
Hence, a stacktrace at the point of cancellation should provide this information.
By default, nothing is logged, while my test client receives the expected '503 Service Unavailable/Backend timeout exceeded' reply.