ruby-on-railsherokuairbrake

airbrake config for heroku+rails


I'm trying to configure airbrake, but can't figure it out. What I wanna achieve is not getting errors from development and test envs only from production.

With the following setup though, I'm getting all the 3 types of error messages as they were occurred in production. So production error sends production error notification but development/test error also sends production error notification.

How can I configure it properly?

# Configures the environment the application is running in. Helps the Airbrake
# dashboard to distinguish between exceptions occurring in different
# environments. By default, it's not set.
# NOTE: This option must be set in order to make the 'ignore_environments'
# option work.
# https://github.com/airbrake/airbrake-ruby#environment
c.environment = :production 

# Setting this option allows Airbrake to filter exceptions occurring in
# unwanted environments such as :test. By default, it is equal to an empty
# Array, which means Airbrake Ruby sends exceptions occurring in all
# environments.
# NOTE: This option *does not* work if you don't set the 'environment' option.
# https://github.com/airbrake/airbrake-ruby#ignore_environments
c.ignore_environments = %w(test, development)

Solution

  • You configure your ignored environments like this:

    c.ignore_environments = %w(test, development)
    # Which is equivalent to:
    c.ignore_environments = ['test,', 'development']
    

    The correct way to configure this option is this:

    c.ignore_environments = %w(test development)
    # Which is equivalent to:
    c.ignore_environments = ['test', 'development']
    

    If you use Ruby's %w syntax for arrays, you don't want to use commas.

    Another potential issue is that you specify:

    c.environment = :production 
    

    It will be more robust to use a String (instead of a Symbol) or Rails.env here.

    c.environment = Rails.env