Go pprof Operations: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
where profile name can be one of <code[[Go_pprof_Concepts#goroutine|goroutine]]</code>, <code>[[Go_pprof_Concepts#heap|heap]]</code>, <code>[[Go_pprof_Concepts#threadcreate|threadcreate]]</code>, <code>[[Go_pprof_Concepts#block|block]]</code>, <code>[[Go_pprof_Concepts#mutex|mutex]]</code>. | where profile name can be one of <code>[[Go_pprof_Concepts#goroutine|goroutine]]</code>, <code>[[Go_pprof_Concepts#heap|heap]]</code>, <code>[[Go_pprof_Concepts#threadcreate|threadcreate]]</code>, <code>[[Go_pprof_Concepts#block|block]]</code>, <code>[[Go_pprof_Concepts#mutex|mutex]]</code>. | ||
For example, to dump goroutines: | For example, to dump goroutines: |
Revision as of 04:04, 16 November 2024
Internal
Make Sure an Executable Starts with the Profiling Subsystem Enabled
TODO
Connect with a Browser to an Executable that Has the Profiling Subsystem Enabled
Go to https://127.0.0.1:8443/debug/pprof/
If the process has TLS enabled, see TLS and Certificates for suggestions on how to address the issue.
Dump Profiles
Once a Go executable is started with the profiling subsystem enabled, you can use curl
to connect to the embedded web server and dump various profiles.
The general syntax of the command is:
curl -k https://localhost:<http-port>/debug/pprof/<profile-name>?[debug=1|2]
where profile name can be one of goroutine
, heap
, threadcreate
, block
, mutex
.
For example, to dump goroutines:
curl -k https://localhost:<http-port>/debug/pprof/goroutine?debug=2 > ~/tmp/goroutine-profile.txt
TLS and Certificates
Profile a Running Process
Assuming that your local 127.0.0.1 address is aliased to "localhost.somedomain.com" in /etc/hosts
and the certificates are issued for "localhost.somedomain.com", set CERT_PATH
to the directory that contains and
and:
export CERT_PATH=/Users/ovidiu/some-project/config
go tool pprof -http 127.0.0.1:8080 -tls_cert ${CERT_PATH}/localhost.somedomain.com.chain.pem -tls_key ${CERT_PATH}/localhost.somedomain.com.key.pem https://localhost.somedomain.com:8443