Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable rails-performance memory and CPU stats #3212

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ gem "omniauth_openid_connect", "~> 0.8.0"
gem "sidekiq-cron", "~> 2.0"

group :development, :production do
gem "rails_performance", "~> 1.4"
gem "redis-namespace"
gem "sys-cpu", "~> 1.1"
gem "get_process_mem", "~> 1.0"
# gem "rails_performance", "~> 1.4"
# gem "redis-namespace"
end

gem "pghero", "~> 3.6"
gem "pg_query", "~> 5.1"

gem "get_process_mem", "~> 1.0"
12 changes: 3 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ GEM
msgpack (~> 1.2)
brakeman (6.2.2)
racc
browser (6.1.0)
builder (3.3.0)
bullet (8.0.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -535,10 +534,6 @@ GEM
rails-settings-cached (2.9.5)
activerecord (>= 5.0.0)
railties (>= 5.0.0)
rails_performance (1.4.0)
browser
railties
redis
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
Expand Down Expand Up @@ -566,8 +561,6 @@ GEM
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.2)
reline (0.5.11)
io-console (~> 0.5)
Expand Down Expand Up @@ -687,6 +680,8 @@ GEM
attr_required (>= 0.0.5)
faraday (~> 2.0)
faraday-follow_redirects
sys-cpu (1.1.0)
ffi (~> 1.1)
sys-filesystem (1.5.3)
ffi (~> 1.1)
terminal-table (3.0.2)
Expand Down Expand Up @@ -801,10 +796,8 @@ DEPENDENCIES
rails-controller-testing (~> 1.0)
rails-i18n (~> 7.0)
rails-settings-cached (~> 2.9)
rails_performance (~> 1.4)
ransack (~> 4.2)
redis (~> 5.3)
redis-namespace
rolify (~> 6.0)
rspec-rails
rubocop-factory_bot
Expand All @@ -826,6 +819,7 @@ DEPENDENCIES
standard (~> 1.42.1)
stopwords-filter2
string-similarity (~> 2.1)
sys-cpu (~> 1.1)
sys-filesystem (~> 1.5)
translation (~> 1.41)
tzinfo-data
Expand Down
10 changes: 3 additions & 7 deletions config/initializers/rails_performance.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if defined?(RailsPerformance) && !Rails.env.test?
if defined?(RailsPerformance) && !Rails.env.test? && ENV["RAILS_ASSETS_PRECOMPILE"].blank?
RailsPerformance.setup do |config|
config.redis = Redis::Namespace.new("#{Rails.env}-rails-performance", redis: Redis.new)
config.duration = 4.hours
Expand All @@ -17,12 +17,8 @@
# config.slow_requests_threshold = 500 # number of ms

# store custom data for the request
config.custom_data_proc = proc do |env|
{
pid: Process.pid,
memory_usage: GetProcessMem.new.bytes
}
end
# config.custom_data_proc = proc do |env|
# end

# config home button link
config.home_link = "/"
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
resources :libraries, only: [:index]
end
mount Sidekiq::Web => "/admin/sidekiq"
mount RailsPerformance::Engine => "/admin/performance" unless Rails.env.test?
mount RailsPerformance::Engine => "/admin/performance" unless Rails.env.test? || ENV["RAILS_ASSETS_PRECOMPILE"].present?
mount PgHero::Engine => "/admin/pghero"
get "/activity" => "activity#index", :as => :activity
end
Expand Down
1 change: 1 addition & 0 deletions docker/build.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ RUN \
DATABASE_URL="nulldb://user:pass@localhost/db" \
SECRET_KEY_BASE="placeholder" \
RACK_ENV="production" \
RAILS_ASSETS_PRECOMPILE=1 \
bundle exec rake assets:precompile
Loading