Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pprof fails to locate source files when running over http

Tags:

go

pprof

I am running remote profiling of my golang application on a remote server using "net/http/pprof".
I have set PPROF_BINARY_PATH env variable for go tool to be able to find my the local binary on my machine.
When I use the "list" keyword in the go tool pprof cli - I get a "no such file or directory" when the go tool is looking for the .go source files.

Error: open /go/src/github.com/foo/bar/baz.go: no such file or directory

it looks like it is looking for the source files in the remote machine's GOPATH which is "/go/" while on my personal machine it is in my home directory so that file is in .

/Users/myuser/go/src/github.com/foo/bar/baz.go

When I copied the desired source code file outside my GOPATH and to the directory the go tool is searching for - the "list" keyword works as expected but this is of course not optimal.

like image 375
OhadBasan Avatar asked Jan 17 '18 17:01

OhadBasan


1 Answers

menghan@gram:/opt$ go tool pprof --help 2>&1 | grep source_path
    -source_path     Search path for source files

Option --source_path may help.

like image 57
menghan Avatar answered Oct 23 '22 18:10

menghan