Table of Contents generated with DocToc
Add the following line to your Go code:
// create and start the profiler handler
profiler.New().Start()
// ... or with custom values
profiler.New(
profiler.WithSignal(syscall.SIGUSR1),
profiler.WithAddress(":8080"),
profiler.WithTimeout(15 * time.Minute),
)
Defaults:
- Signal HUP
- Listen :6666
- Timeout 10m
pkill -HUP <your Go program>
After timeout the endpoint will shutdown.
go tool pprof -http $(hostname):8080 http://localhost:6666/debug/pprof/profile
$ k get pods
NAME READY STATUS RESTARTS AGE
...
$ k exec -ti <your pod> sh
/ # pkill -HUP <your Go program>
/ #
After timeout the endpoint will shutdown.
$ k logs <your pod> -f
...
2020/02/10 16:37:09 start pprof endpoint on ":6666"
...
$ k port-forward <your pod> 8080:6666
Forwarding from 127.0.0.1:8080 -> 6666
Forwarding from [::1]:8080 -> 6666
Handling connection for 8080
$ go tool pprof -http $(hostname):8888 http://localhost:8080/debug/pprof/profile