Skip to content

Commit

Permalink
feat: add rails-performance gem
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed Jun 11, 2024
1 parent 3cb0d62 commit df86ea6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ gem "recaptcha", require: "recaptcha/rails"
gem "countries"
gem "money"
gem "phony_rails"
gem 'rails_performance'


group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
40 changes: 40 additions & 0 deletions config/initializers/rails_performance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
RailsPerformance.setup do |config|
config.debug = false # currently not used>
config.enabled = !ENV['REDIS_URL'].nil? && (Rails.env.kubernetes? || ENV['RAILS_PERFORMANCE_ENABLED'] == 'true')

redis = Redis.new(url: ENV['REDIS_URL'])

config.redis = Redis::Namespace.new("#{ENV['INSTANCE_NAME'] || "development"}-#{Rails.env}-rails-performance", redis: redis)
config.duration = 4.hours

# default path where to mount gem
config.mount_at = '/rails/performance'

# protect your Performance Dashboard with HTTP BASIC password
config.http_basic_authentication_enabled = false
config.http_basic_authentication_user_name = 'rails_performance'
config.http_basic_authentication_password = 'password12'

# if you need an additional rules to check user permissions
config.verify_access_proc = proc { |controller| true }
# for example when you have `current_user`
# config.verify_access_proc = proc { |controller| controller.current_user && controller.current_user.admin? }

# You can ignore endpoints with Rails standard notation controller#action
# config.ignored_endpoints = ['HomeController#contact']

# store custom data for the request
# config.custom_data_proc = proc do |env|
# request = Rack::Request.new(env)
# {
# email: request.env['warden'].user&.email, # if you are using Devise for example
# user_agent: request.env['HTTP_USER_AGENT']
# }
# end

# config home button link
config.home_link = '/'
config.skipable_rake_tasks = ['webpacker:compile']
config.include_rake_tasks = false
config.include_custom_events = true
end if defined?(RailsPerformance)

0 comments on commit df86ea6

Please sign in to comment.