I cannot figure out how to profile JRuby On Rails application within Tomcat. Actually, I don't know how to pass --profile
option to JRuby when ruby code ran not by jruby
command, but from java
.
To investigate the issue I created file:
$ cat bin/profile_puts.rb
require 'yaml'
puts ENV['JRUBY_OPTS']
require 'jruby/profiler'
def profile(&block)
JRuby::Profiler::GraphProfilePrinter.new(JRuby::Profiler.profile(&block)).printProfile(STDOUT)
end
profile do
puts "hi"
end
ran
$ jruby --profile.api bin/profile_puts.rb
And got a proper profiler output.
Then I packaged it with warbler and ran
$ gem install warbler
$ warble jar
$ JRUBY_OPTS=--profile.api java -jar profile.jar JarMain
And got an error:
--profile.api
RuntimeError: Profiling not enabled in runtime
As you can see the JRUBY_OPTS
environment variable got to the process, but had no effect for JRuby.
How can this be addressed?