Auto capture profiles.
package main
import "github.com/gochore/pprofs"
func main() {
if err := pprofs.EnableCapture(); err != nil {
panic(err)
}
// ...
}
It will auto capture profiles and store files in temp dir.
You can specify the dir and the ttl of files by environment variables:
export PPROF_DIR="~/somewhere"
export PPROF_TTL="1h"
Or use options:
func main() {
if err := pprofs.EnableCapture(
pprofs.WithStorage(pprofs.NewFileStorage("prefix", "~/somewhere", time.Hour)),
); err != nil {
panic(err)
}
// ...
}
See more examples.
- Inspired by autopprof.
- Learned a lot from Continuous Profiling of Go programs.