Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Customizing your airbrake.rb

Kyrylo Silin edited this page Aug 24, 2016 · 15 revisions

END OF SUPPORT WARNING: On November 24, 2016 Airbrake v4 won't be supported anymore and this wiki will be deleted. Read more & discuss: https://github.com/airbrake/airbrake/issues/596

DEPRECATION WARNING: The information presented on this page is related to Airbrake v4 only. If you seek for information for Airbrake v5, please refer to our README!

A Basic airbrake.rb file should look at least like the following:

Airbrake.configure do |config|
  config.api_key = '********************************'
end

Note: Extra options are configured by adding extra lines to the above block

Collect Errors from your Development Environment

config.development_environments = []

Set a custom environment name

the default will be taken from Rails.env
you can overwrite this if it will be useful for your deployment.

config.environment_name = "test"

Ignoring Errors certain types of errors

Airbrake ignores the following exceptions by default

# Ignore Defaults 
AbstractController::ActionNotFound
ActiveRecord::RecordNotFound
ActionController::RoutingError
ActionController::InvalidAuthenticityToken
ActionController::UnknownAction
ActionController::UnknownHttpMethod
CGI::Session::CookieStore::TamperedWithCookie
Mongoid::Errors::DocumentNotFound
ActionController::UnknownFormat

Add an error to the Ignore Defaults

config.ignore << "ActiveRecord::IgnoreThisError"

Ignore only this error & forget the ignore defaults

config.ignore_only  = ["ActiveRecord::IgnoreThisError"]

Send Every Error / don't ignore anything

config.ignore_only  = []

Ignore user agents

# string version
config.ignore_user_agent << 'IgnoredUserAgent'

# regex version
config.ignore_user_agent  << /IgnoredUserAgent/

Ignore exceptions based on conditions

config.ignore_by_filter do |exception_data|
  true if exception_data[:error_class] == "RuntimeError"
end

Filter Parameters

sensitive values will be replaced with [FILTERED]

config.params_filters << "credit_card_number"

This will show up in the airbrake ui as:

credit_card_number: [FILTERED]

Here are the defaults:

# this example taken from the rails console of a test project
airbrake_test >>  Airbrake.configuration.params_filters
=> [
  [0] "password",
  [1] "password_confirmation"
]

Note: when rescuing exceptions within an ActionController method airbrake will reuse filters specified by #filter_parameter_logging.**