Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arp242/zprof
Display runtime profiling data for Go programs over HTTP
https://github.com/arp242/zprof
Last synced: about 1 month ago
JSON representation
Display runtime profiling data for Go programs over HTTP
- Host: GitHub
- URL: https://github.com/arp242/zprof
- Owner: arp242
- License: other
- Created: 2021-04-06T13:56:06.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-17T10:43:46.000Z (almost 3 years ago)
- Last Synced: 2024-06-19T16:34:49.199Z (5 months ago)
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
zprof displays runtime profiling data over HTTP.
This is based on [net/http/pprof][httppprof]; but has been rewritten quite a bit
and is much nicer. You can display the callgraphs directly without downloading
the file first, and a bunch of other changes. It doesn't give you the full power
of the CLI, but overall it's fairly useful.Import as `zgo.at/zprof`; you need Go 1.16.
Current status: fairly functional, still some things left to do. API may break.
[httppprof]: https://godocs.io/net/http/pprof
Usage
-----Unlike `net/http/pprof` endpoints are not registered automatically; use
`zprof.NewHandler()` to create a new handler to mount with your router, for
example using net/http's default mux:http.Handle("/profile*", zprof.NewHandler(zprof.Prefix("/profile")))
Or with chi:
r := chi.NewRouter()
r.Handle("/profile*", zprof.NewHandler(zprof.Prefix("/profile")))Because you may not want to expose this to everyone you can add HTTP Basic auth
with `Auth()`:http.Handle("/profile*", zprof.NewHandler(zprof.Prefix("/profile"),
zprof.Auth("user", "passwd")))Or handle auth in your regular app middleware.
You can use the `zprof.Profile()` shortcut if your application doesn't have a
HTTP server:zprof.Profile("")
This will set up a HTTP server on `localhost:6060`; use the first parameter to
configure the address.Like with net/http/pprof, you can still use the commandline tool if you prefer:
$ go tool pprof http://localhost:6060/debug/pprof/heap
$ wget -O trace.out http://localhost:6060/debug/pprof/trace?seconds=5
$ go tool trace trace.out