diff --git a/bundler.d/profiling.rb b/bundler.d/profiling.rb new file mode 100644 index 00000000000..3059107cf36 --- /dev/null +++ b/bundler.d/profiling.rb @@ -0,0 +1,9 @@ +group :profiling, optional: true do + gem 'rack-mini-profiler' + + # For memory profiling + gem 'memory_profiler' + + # For call-stack profiling flamegraphs + gem 'stackprof' +end diff --git a/config/application.rb b/config/application.rb index 621ea50ff8e..80a442a5480 100644 --- a/config/application.rb +++ b/config/application.rb @@ -41,7 +41,7 @@ Bundler.ui = Bundler::UI::Silent.new if Rails.env.production? Bundler.require(*Rails.groups) - optional_bundler_groups = %w[assets ec2 fog libvirt openstack vmware redis] + optional_bundler_groups = %w[assets ec2 fog libvirt openstack profiling vmware redis] optional_bundler_groups.each do |group| Bundler.require(group) rescue LoadError diff --git a/config/initializers/rack_mini_profiler.rb b/config/initializers/rack_mini_profiler.rb new file mode 100644 index 00000000000..f85e0cc0446 --- /dev/null +++ b/config/initializers/rack_mini_profiler.rb @@ -0,0 +1,7 @@ +if defined? Rack::MiniProfiler + # enable profiling for all pages; per-default it is disabled on production-env + Rack::MiniProfiler.config.authorization_mode = SETTINGS.fetch(:profiler_authorization_mode, :allow_all) + + # enable additional profiling-features + Rack::MiniProfiler.config.enable_advanced_debugging_tools = true +end diff --git a/config/settings.yaml.example b/config/settings.yaml.example index a41aaabea00..91dda0e1b36 100644 --- a/config/settings.yaml.example +++ b/config/settings.yaml.example @@ -144,3 +144,7 @@ # :options: # :compress: true # :namespace: foreman + +# set to :allow_authorized to not run rack-mini-profiler on all pages +# see https://github.com/MiniProfiler/rack-mini-profiler#access-control-in-non-development-environments +# :profiler_authorization_mode: :allow_all