Last active
December 17, 2015 06:19
-
-
Save tdl/5564590 to your computer and use it in GitHub Desktop.
Using MiniProfiler in production on Heroku
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
before_filter :miniprofiler | |
# just authorize all requests | |
private | |
def miniprofiler | |
Rack::MiniProfiler.authorize_request | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it's best to depend on trunk of MiniProfiler, e.g. due to the issue I had with | |
# graphs not showing up over HTTPS which is fixed in | |
# https://github.com/SamSaffron/MiniProfiler/commit/831b917e70d57bc3c03858c46b3c5828f73e3f35 | |
gem 'rack-mini-profiler', git: 'git://github.com/SamSaffron/MiniProfiler.git' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/mini_profiler.rb | |
# Heroku + Unicorn will not work with either: | |
# FileStore (no persistent disk access allowed) | |
# MemoryStore (data kept in one process, but Unicorn forks multiple processes) | |
# Easiest to use is therefore MemcacheStore. RedisStore requires more setup. | |
if Rails.env.production? | |
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemcacheStore | |
# optional: set a user_provider which defaults to always the same user | |
# by default MiniProfiler separates requests by IP address | |
# Rack::MiniProfiler.config.user_provider = Proc.new { |env| "tom" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment