Files
nairobi/config/initializers/errbit.rb
Javi Martín a1bb9bd5d6 Fix Airbrake crash with no project key
We were checking tho project_id but not the project_key. However, in our
example secrets file we actually include a project_id but not a
project_key, and so new CONSUL installations would crash in production
environments.

Although technically the application doesn't crash if no host is
defined, we're also ignoring the current environment if no host is
defined, since errbit/airbrake is unlikely to work in this scenario.
2020-09-23 13:00:25 +02:00

35 lines
1.1 KiB
Ruby

Airbrake.configure do |config|
config.host = Rails.application.secrets.errbit_host
config.project_id = Rails.application.secrets.errbit_project_id
config.project_key = Rails.application.secrets.errbit_project_key
config.environment = Rails.env
config.ignore_environments = %w[development test]
if config.host.blank? || config.project_id.blank? || config.project_key.blank?
config.ignore_environments += [Rails.env]
end
end
Airbrake.add_filter do |notice|
ignorables = %w[ActiveRecord::RecordNotFound]
notice.ignore! if ignorables.include? notice[:errors].first[:type]
end
if Rails.application.secrets.errbit_self_hosted_ssl.present?
# Patch from: https://mensfeld.pl/2016/05/setting-up-errbit-reporter-airbrake-v5-gem-to-work-with-self-signed-https-certificate/
module Patches
module Airbrake
module SyncSender
def build_https(uri)
super.tap do |req|
req.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
end
end
end
end
Airbrake::SyncSender.prepend(::Patches::Airbrake::SyncSender)
end