From c350dcfff44efc27a752552090f49a86477790ee Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 1 Sep 2015 18:41:28 +0200 Subject: [PATCH 1/2] configures rollbar gem --- Gemfile | 1 + Gemfile.lock | 2 ++ config/initializers/rollbar.rb | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 config/initializers/rollbar.rb diff --git a/Gemfile b/Gemfile index ce51295bc..3f7d3da35 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ gem 'unicorn' gem 'paranoia' gem 'savon' gem 'dalli' +gem 'rollbar', '~> 2.2.1' gem 'ahoy_matey', '~> 1.2.1' gem 'groupdate' # group temporary data diff --git a/Gemfile.lock b/Gemfile.lock index 922a30d37..206e1173e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -285,6 +285,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) + rollbar (2.2.1) rspec (3.3.0) rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) @@ -428,6 +429,7 @@ DEPENDENCIES quiet_assets rails (= 4.2.4) responders + rollbar (~> 2.2.1) rspec-rails (~> 3.0) sass-rails (~> 5.0) savon diff --git a/config/initializers/rollbar.rb b/config/initializers/rollbar.rb new file mode 100644 index 000000000..5eb57a2b8 --- /dev/null +++ b/config/initializers/rollbar.rb @@ -0,0 +1,51 @@ +require 'rollbar/rails' +Rollbar.configure do |config| + # Without configuration, Rollbar is enabled in all environments. + # To disable in specific environments, set config.enabled=false. + + config.access_token = Rails.application.secrets.rollbar_server_token + + # Here we'll disable in 'test': + if Rails.env.test? + config.enabled = false + end + + # By default, Rollbar will try to call the `current_user` controller method + # to fetch the logged-in user object, and then call that object's `id`, + # `username`, and `email` methods to fetch those properties. To customize: + # config.person_method = "my_current_user" + # config.person_id_method = "my_id" + # config.person_username_method = "my_username" + # config.person_email_method = "my_email" + + # If you want to attach custom data to all exception and message reports, + # provide a lambda like the following. It should return a hash. + # config.custom_data_method = lambda { {:some_key => "some_value" } } + + # Add exception class names to the exception_level_filters hash to + # change the level that exception is reported at. Note that if an exception + # has already been reported and logged the level will need to be changed + # via the rollbar interface. + # Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore' + # 'ignore' will cause the exception to not be reported at all. + # config.exception_level_filters.merge!('MyCriticalException' => 'critical') + # + # You can also specify a callable, which will be called with the exception instance. + # config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' }) + + # Enable asynchronous reporting (uses girl_friday or Threading if girl_friday + # is not installed) + # config.use_async = true + # Supply your own async handler: + # config.async_handler = Proc.new { |payload| + # Thread.new { Rollbar.process_from_async_handler(payload) } + # } + + # Enable asynchronous reporting (using sucker_punch) + # config.use_sucker_punch + + # Enable delayed reporting (using Sidekiq) + # config.use_sidekiq + # You can supply custom Sidekiq options: + # config.use_sidekiq 'queue' => 'my_queue' +end From e1d6319953982f4ef8ea3109146434be855ee3ea Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 1 Sep 2015 19:15:56 +0200 Subject: [PATCH 2/2] enable rollbar only in pre and pro envs --- config/initializers/rollbar.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/rollbar.rb b/config/initializers/rollbar.rb index 5eb57a2b8..d8a4e30a1 100644 --- a/config/initializers/rollbar.rb +++ b/config/initializers/rollbar.rb @@ -5,8 +5,10 @@ Rollbar.configure do |config| config.access_token = Rails.application.secrets.rollbar_server_token - # Here we'll disable in 'test': - if Rails.env.test? + # Here we'll disable all environments except 'production': + if Rails.env.preproduction? || Rails.env.production? + config.enabled = true + else config.enabled = false end