This repository has been archived by the owner on Sep 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 594
router: enable pprof handler via build flag #909
Merged
Merged
Conversation
This file contains 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
@@ -72,6 +73,7 @@ func main() { | |||
certFile := flag.String("tlscert", "", "TLS (SSL) cert file in pem format") | |||
keyFile := flag.String("tlskey", "", "TLS (SSL) key file in pem format") | |||
apiAddr := flag.String("apiaddr", ":"+apiPort, "api listen address") | |||
pprofAddr := flag.String("pprofaddr", ":6060", "pprof handler listen address") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about mounting this on the API HTTP server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good. 👍
benburkert
force-pushed
the
router-pprof
branch
4 times, most recently
from
January 31, 2015 00:58
15337a2
to
62b8f17
Compare
ok, the pprof handler is now mounted on the API listener instead of staring it's own listener. |
|
||
var Handler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { | ||
rw.WriteHeader(404) | ||
rw.Write([]byte(`pprof disabled, go build with -tags=pprof to enable\n`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The \n
will be two literal bytes
Only pull in the real net/http/pprof package when the pprof build tag is set. Signed-off-by: Ben Burkert <ben@benburkert.com>
Adds the pprof handler to the api listener when built with the pprof build tag. Signed-off-by: Ben Burkert <ben@benburkert.com>
Set go build tags via the GO_BUILD_TAGS environment variable. Signed-off-by: Ben Burkert <ben@benburkert.com>
benburkert
force-pushed
the
router-pprof
branch
from
January 31, 2015 01:15
62b8f17
to
f53a75d
Compare
turns out pprof only prints the status code on a bad URL, so the message body wasn't useful anyways. |
LGTM |
titanous
added a commit
that referenced
this pull request
Jan 31, 2015
router: enable pprof handler via build flag
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Profiling the router with the
net/http/pprof
handler is useful for debugging the router, but it has a lot of baggage. Pulling in theruntime/pprof
dependency should not be done by default. This adds apkg/pprof
package that only pulls in theruntime/pprof
/net/http/pprof
packages when thepprof
build tag is set (go build -tags=pprof
).