Add opt-in pprof HTTP server for profiling - #1244
Merged
Merged
Conversation
baizhenyu
self-requested a review
August 24, 2026 21:09
baizhenyu
approved these changes
Aug 24, 2026
baizhenyu
left a comment
Contributor
There was a problem hiding this comment.
/lgtm Only one minor thing, this is the first instance that using env var for a config (i.e other configs are passed by CLI flags). Consider making them consistent if feasible.
Contributor
Author
|
I verified that the newly added env is not reconciled. |
Expose Go's net/http/pprof handlers on a dedicated HTTP server, enabled only when the PPROF_SERVER_PORT environment variable is set (disabled by default). The server runs on its own ServeMux and port, is started in a goroutine, and is gracefully shut down when the process stop channel is closed. Move the Prometheus /metrics handler off http.DefaultServeMux onto a private ServeMux so that importing net/http/pprof (which registers its handlers on the default mux in its init) cannot inadvertently expose the profiling endpoints on the metrics port. Add a unit test for startPprofServer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose Go's net/http/pprof handlers on a dedicated HTTP server, enabled only when the PPROF_SERVER_PORT environment variable is set (disabled by default). The server runs on its own ServeMux and port, is started in a goroutine, and is gracefully shut down when the process stop channel is closed.
Move the Prometheus /metrics handler off http.DefaultServeMux onto a private ServeMux so that importing net/http/pprof (which registers its handlers on the default mux in its init) cannot inadvertently expose the profiling endpoints on the metrics port.
Add a unit test for startPprofServer.