I am profiling a go server using "go tool pprof" command. I want to generate a machine-readable call graph using the dynamic profile of my program. When I run "go tool pprof" with the -tree option, I see
this. I want precisely this information in a machine readable form. Specifically, I want to take a profile and generate a graph such that:
- Nodes are functions
- Directed edges between nodes represent that one function called another
- The weight of edges represent the percent of calls from one function to another (exactly like the last column in the image above)
I have thought of a few potential options:
- Parse the string output of "go tool pprof --tree"
- Copy the code in the cmd/pprof library which generates a graph from a dynamic profile
However, I don't love either of these options because they can break in future versions of go if the pprof reporting format changes. Are there any alternatives I should consider? For example, could I use the -proto option to get a protobuf file including the graph?