Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ gem "rack-mini-profiler"
gem "memory_profiler"
gem "flamegraph"

# Rails Performance monitoring dashboard
gem "rails_performance"

gem "skylight"

# Ahoy analytics
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ GEM
msgpack (~> 1.2)
brakeman (7.0.2)
racc
browser (6.2.0)
builder (3.3.0)
bullet (8.0.8)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -385,6 +386,10 @@ GEM
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails_performance (1.4.2)
browser
railties
redis
railties (8.0.2)
actionpack (= 8.0.2)
activesupport (= 8.0.2)
Expand All @@ -403,6 +408,10 @@ GEM
erb
psych (>= 4.0.0)
redcarpet (3.6.1)
redis (5.4.0)
redis-client (>= 0.22.0)
redis-client (0.25.0)
connection_pool
regexp_parser (2.10.0)
reline (0.6.1)
io-console (~> 0.5)
Expand Down Expand Up @@ -587,6 +596,7 @@ DEPENDENCIES
rack-cors
rack-mini-profiler
rails (~> 8.0.2)
rails_performance
redcarpet
rubocop-rails-omakase
selenium-webdriver
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 @@
if defined?(RailsPerformance)
RailsPerformance.setup do |config|
# Redis is required for rails_performance
config.redis = Redis.new(url: ENV["REDIS_URL"].presence || "redis://127.0.0.1:6379/0")
config.duration = 4.hours

# Custom data to track
config.custom_data_proc = lambda do |env|
request = Rack::Request.new(env)
data = {}

# Track current user if available
if request.session && request.session["user_id"]
user = User.find_by(id: request.session["user_id"])
if user
data[:user_id] = user.id
data[:username] = user.username
data[:user_admin] = user.admin?
end
end

# Track HTTP User Agent
data[:user_agent] = request.user_agent

# Track IP address
data[:remote_ip] = request.ip

# Track referer
data[:referer] = request.referer

data
end

# Skip certain paths
config.ignored_paths = [ "/good_job", "/rails/health", "/assets", "/rails/performance" ]

# Enable monitoring for all environments (you might want to restrict this)
config.enabled = true
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def self.matches?(request)
mount GoodJob::Engine => "good_job"
mount AhoyCaptain::Engine => "/ahoy_captain"
mount Flipper::UI.app(Flipper) => "flipper", as: :flipper
mount RailsPerformance::Engine => "rails_performance", as: :rails_performance

get "/impersonate/:id", to: "sessions#impersonate", as: :impersonate_user
end
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ services:
environment:
- RAILS_ENV=development
- DATABASE_URL=postgres://postgres:secureorpheus123@db:5432/app_development
- REDIS_URL=redis://redis:6379/0
- POSTGRES_HOST=db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=secureorpheus123
depends_on:
- db
- redis

db:
image: postgres:16
Expand All @@ -28,6 +30,14 @@ services:
ports:
- "5432:5432"

redis:
image: redis:7.0
ports:
- "6379:6379"
volumes:
- harbor_redis_data:/data

volumes:
harbor_postgres_data:
harbor_redis_data:
bundle_cache: