-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/pprof: respect timeouts set using http.ResponseController #62358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Another option would be to re-implement https://github.com/golang/go/blob/master/src/net/http/pprof/pprof.go on my own without |
Since // ServeDeltaProfile reports the difference between two measurements collected between the given seconds
// It can be used by people who want to register their own pprof handlers.
func ServeDeltaProfile(name string, w http.ResponseWriter, r *http.Request, p *pprof.Profile, secStr string) |
I found a workaround, set |
I guess it could also be an exported function: // SetWriteTimeout configures write timeout for HTTP handlers
func SetWriteTimeout(timeout time.Duration) |
I have just stumbled on to this issue myself. I believe there is still merit in making the |
Configure write deadline according to requested profiling duration. Fixes golang#62358
Change https://go.dev/cl/544756 mentions this issue: |
I think we can adjust write timeout based on the requested profiling duration, see https://go-review.googlesource.com/c/go/+/544756 |
Is there any good reason for |
Looked at the CL. I don't believe this needs a proposal but thanks for checking with us. |
I think the fix will benefit PGO. |
Configure write deadline according to requested profiling duration. Fixes golang#62358 Change-Id: I2350110ff20a637c7e90bdda57026b0b0d9c87ba GitHub-Last-Rev: b79ae38 GitHub-Pull-Request: golang#64360 Reviewed-on: https://go-review.googlesource.com/c/go/+/544756 Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Example program with issue: https://go.dev/play/p/DoZD1wMDPhw
Most time I find myself wanting to run my http requests with tight deadlines using
http.Server.WriteTimeout
.While at the same time, I would like requests to the pprof endpoints to operate under more lenient timeouts.
For example I would set
http.Server.WriteTimeout
to 3 seconds and at the same time want to be able to take a pprof sample that would take a long timecurl -vkL "http://localhost:9192/debug/pprof/profile?seconds=30"
I thought I would use
http.NewResponseController
to do that, see https://go.dev/play/p/DoZD1wMDPhwHowever, that fails with
profile duration exceeds server's WriteTimeout
.This is because the pprof handlers only consider the server timeout;
go/src/net/http/pprof/pprof.go
Lines 117 to 120 in a9d4b2d
My proposal is that they should also consider any timeout that has been set by
http.ResponseController
.I don't know how such a functionality might be implemented since
durationExceedsWriteTimeout
takes ahttp.Request
and its context does not contain information on whether http.ResponseController has been used.The current workaround is to use two servers, one for application handler and one for pprof handlers each with its own
http.Server.WriteTimeout
. But I like having one server.The text was updated successfully, but these errors were encountered: