在检查pprof
的输出时,我可以看到goroutine的堆栈跟踪。但是,我想知道是谁开始(产生?)这个goroutine,这可能吗?
答案 0 :(得分:1)
如果查看端点/debug/pprof/goroutine?debug=2
,堆栈跟踪的输出会略有不同:
goroutine 859579 [running]:
runtime/pprof.writeGoroutineStacks(0x176a0e0, 0xc43403a340, 0x178d740, 0x30)
/usr/local/go/src/runtime/pprof/pprof.go:585 +0x79
runtime/pprof.writeGoroutine(0x176a0e0, 0xc43403a340, 0x2, 0x0, 0xd)
/usr/local/go/src/runtime/pprof/pprof.go:574 +0x44
runtime/pprof.(*Profile).WriteTo(0x178f9e0, 0x176a0e0, 0xc43403a340, 0x2, 0xc43403a340, 0xc4587b5834)
/usr/local/go/src/runtime/pprof/pprof.go:298 +0x341
net/http/pprof.handler.ServeHTTP(0xc4587b5841, 0x9, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:209 +0x1a6
net/http/pprof.Index(0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:221 +0x205
net/http.HandlerFunc.ServeHTTP(0x12664a8, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.(*ServeMux).ServeHTTP(0x179dde0, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc46d06ed80, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc45dc83180, 0x17734a0, 0xc4942f0600)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2293 +0x44d
最后包括created by
行。