yahoo / kubectl-flame

Kubectl plugin for effortless profiling on kubernetes
Apache License 2.0
787 stars 94 forks source link

couldn't record ruby subprocess #54

Open Willis0826 opened 3 years ago

Willis0826 commented 3 years ago

Hi, I would like to record a flame graph with ruby application running with unicorn_rails. However, the flame graph seems only record the master process.

Currently, the running processes likes below:

$ ps aux

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   4288   768 ?        Ss   Apr22   0:00 sh -c ./start.sh
root         9  0.0  1.2 399664 192104 ?       Sl   Apr22   0:14 unicorn_rails master -c config/unicorn.rb
root      4741  0.1  1.3 551768 202820 ?       Sl   06:36   0:01 unicorn_rails worker[6] -c config/unicorn.rb
root      4939  0.1  1.2 752732 199644 ?       Sl   06:40   0:01 unicorn_rails worker[5] -c config/unicorn.rb
root      4978  0.1  1.3 552028 201684 ?       Sl   06:40   0:01 unicorn_rails worker[2] -c config/unicorn.rb
root      5005  0.1  1.2 551712 199332 ?       Sl   06:40   0:01 unicorn_rails worker[0] -c config/unicorn.rb
root      5152  0.2  1.3 822852 201480 ?       Sl   06:43   0:01 unicorn_rails worker[4] -c config/unicorn.rb
root      5171  0.1  1.2 551804 199864 ?       Sl   06:43   0:01 unicorn_rails worker[7] -c config/unicorn.rb
root      5193  0.1  1.2 552108 195444 ?       Sl   06:43   0:01 unicorn_rails worker[1] -c config/unicorn.rb
root      5397  0.0  1.1 399664 182352 ?       Sl   06:55   0:00 unicorn_rails worker[3] -c config/unicorn.rb

I run the following command to record the flame graph but the flame graph only record the master process.

$ kubectl flame my-app -t 1m --lang ruby -f flamegraph.svg

Also, I tried the rbspy with --subprocesses flag and the flame graph can record all the worker process correctly.

$ ./rbspy record --duration 60 --pid 9 --subprocesses

Therefore, I'm thinking if we need to set the --subprocesses flag in agent/profiler/ruby.go line 31 to make it able to record all the subprocess. Thanks!