Skip to content

Commit

Permalink
agent: avoid truncating stacktrace if it's bigger than 64kb (#29)
Browse files Browse the repository at this point in the history
Using pprof.Lookup("goroutine") instead of runtime.Stack directly
because the former already takes care of expanding the buffer used with
runtime.Stack until it's big enough for the stack.
  • Loading branch information
cezarsa authored and Jaana Burcu Dogan committed Jan 13, 2017
1 parent 0e47ba9 commit ad978d7
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ func Close() {
func handle(conn net.Conn, msg []byte) error {
switch msg[0] {
case signal.StackTrace:
buf := make([]byte, 1<<16)
n := runtime.Stack(buf, true)
_, err := conn.Write(buf[:n])
return err
return pprof.Lookup("goroutine").WriteTo(conn, 2)
case signal.GC:
runtime.GC()
_, err := conn.Write([]byte("ok"))
Expand Down

0 comments on commit ad978d7

Please sign in to comment.