GitXplorerGitXplorer
k

goflamegraph

public
17 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
8bcf6106fa26518a1f59c02d061a59b0e1e9a537

Disable showing source paths by default. Fix stack order.

kkisielk committed 10 years ago
Unverified
302d958b7a51dc0a5c47f1d006d2ae77e96766b9

Export those things which should be exported.

kkisielk committed 11 years ago
Unverified
064bffee52ee3b283058677571e82cbb2fcf2e58

Add sort function for a list of stacks.

kkisielk committed 11 years ago
Unverified
0372131f57118f277e9377095c82eaf992d346a8

Initial commit.

kkisielk committed 11 years ago

README

The README file for this repository.

goflamegraph

goflamegraph helps generate flamegraphs from Go stack traces.

Usage

First install this tool:

go get github.com/kisielk/goflamegraph

You will also need flamegraph.pl from https://github.com/brendangregg/FlameGraph

Then generate a bunch of stack traces. There are several facilities to do this in Go.

You can periodically run something like:

prof := pprof.Lookup("goroutine")
prof.WriteTo(os.Stderr, 2)

inside your program.

Another option is to install the HTTP handler from net/http/pprof and periodically sample the /debug/pprof/goroutine?debug=2 URL.

Note that in both cases you must ensure that each dump is separated by an extra newline or else the output will apear to be incorrect.

Once you have your stack traces, you can filter them through goflamegraph and flamgraph.pl:

goflamegraph < stacks.txt | flamegraph.pl > out.svg

Then view the SVG file in a web browser to get the interactive output.

TODO

Some future developments:

  • Rewrite SVG rendering in Go.
  • Automate stack collection.
  • Provide an HTTP handler to view a flamegraph of a running program.