Skip to content

Commit

Permalink
WIP - add mini profiler gem
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel committed May 24, 2023
1 parent 5c6d0d1 commit 6e60d5c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ services:
orangelight_database:
type: postgres:13
portforward: true
orangelight_redis:
type: redis:4.0.9
portforward: true
proxy:
orangelight_test_solr:
- orangelight.test.solr.lndo.site:8983
Expand Down
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ gem 'lograge'
gem 'logstash-event'
gem 'mail_form'
gem 'matrix'
# For memory profiling
# See https://github.com/MiniProfiler/rack-mini-profiler#memory-profiling for usage
gem 'memory_profiler'
# Modernizr.js library
gem 'modernizr-rails'
gem 'net-imap', require: false
Expand All @@ -65,7 +68,11 @@ gem 'openurl', '~> 1.0'
# Use postgresql as the database for Active Record
gem 'pg'
gem 'puma', '~> 6.0'
# For profiling
gem 'rack-mini-profiler'
gem 'rake'
# Needed for
gem 'redis'
# Interact with Solr
gem 'rsolr'
# Should this be in the test, development group?
Expand All @@ -76,6 +83,8 @@ gem 'sass-rails', '~> 6.0'
gem 'simple_form'
gem 'sneakers'
gem 'sprockets-es6'
# For call-stack profiling flamegraphs
gem 'stackprof'
gem 'stringex', git: 'https://github.com/pulibrary/stringex.git', tag: 'vpton.2.5.2.2'
gem 'string_rtl'
gem 'terser', '~> 1.1'
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
coveralls_reborn (0.25.0)
simplecov (>= 0.18.1, < 0.22.0)
term-ansicolor (~> 1.6)
Expand Down Expand Up @@ -339,6 +340,7 @@ GEM
marc (~> 1.0)
marcel (1.0.2)
matrix (0.4.2)
memory_profiler (1.0.1)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
Expand Down Expand Up @@ -400,6 +402,8 @@ GEM
nio4r (~> 2.0)
racc (1.6.2)
rack (2.2.6.4)
rack-mini-profiler (3.1.0)
rack (>= 1.2.0)
rack-proxy (0.7.4)
rack
rack-test (2.1.0)
Expand Down Expand Up @@ -437,6 +441,10 @@ GEM
rainbow (3.1.1)
rake (13.0.6)
rbtree (0.4.6)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.14.1)
connection_pool
regexp_parser (2.6.1)
request_store (1.5.1)
rack (>= 1.4)
Expand Down Expand Up @@ -557,6 +565,7 @@ GEM
sshkit (1.21.3)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
stackprof (0.2.25)
string_rtl (0.1.0)
sync (0.5.0)
term-ansicolor (1.7.1)
Expand Down Expand Up @@ -686,6 +695,7 @@ DEPENDENCIES
logstash-event
mail_form
matrix
memory_profiler
modernizr-rails
net-imap
net-ldap
Expand All @@ -697,9 +707,11 @@ DEPENDENCIES
pg
pry-byebug
puma (~> 6.0)
rack-mini-profiler
rails (~> 6.1, >= 6.1.7.1)
rails-controller-testing
rake
redis
rsolr
rspec-rails
rspec_junit_formatter
Expand All @@ -709,6 +721,7 @@ DEPENDENCIES
sneakers
solargraph
sprockets-es6
stackprof
string_rtl
stringex!
terser (~> 1.1)
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ def verify_admin!
authenticate_user!
head :forbidden unless current_user.admin?
end

before_action do
if (current_user && current_user.admin?)
Rack::MiniProfiler.authorize_request
end
end
end
4 changes: 4 additions & 0 deletions config/initializers/mini_profiler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

Rack::MiniProfiler.config.storage_options = { host: '127.0.0.1', port: '55212' }
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore

0 comments on commit 6e60d5c

Please sign in to comment.