Configuration options

Customize the content of error reports and how reports are delivered to Bugsnag.

Bugsnag can be configured using the configure block:

Bugsnag.configure do |config|
  config.api_key = 'your-api-key-here'
end

The configuration for Bugsnag can also be changed by accessing the configuration directly:

Bugsnag.configuration.api_key = 'your-api-key-here'

Configuration options

api_key

Your Integration API Key (required).

config.api_key = 'your-api-key-here'

app_type

You can set the type of application executing the current code by using app_type:

config.app_type = 'resque'

This is usually used to represent if you are running in a Rails server, Sidekiq job or Rake task for example. Bugsnag will automatically detect most application types for you.

app_version

If you want to track in which versions of your application each exception happens, you can set app_version. This is set to nil by default.

config.app_version = '2.5.1'

auto_notify

By default, we will automatically notify Bugsnag of any fatal exceptions in your application. If you want to stop this from happening, you can set auto_notify:

config.auto_notify = false

auto_capture_sessions

By default, Bugsnag will automatically capture and report session information from your application.

If the notify endpoint is changed and the sessions endpoint is not, this option will be set to false and session tracking will be disabled.

To disable automatic session capturing:

config.auto_capture_sessions = false

before_breadcrumb_callbacks

An array of callbacks to be run when a breadcrumb is left. Each callback will be passed a breadcrumb.

config.before_breadcrumb_callbacks << Proc.new do |breadcrumb|
  breadcrumb.meta_data[:user] = get_current_user
end

enabled_automatic_breadcrumb_types

An array of types that can be automatically captured. Defaults to all breadcrumb types.

Setting this to an empty array will prevent automatic breadcrumb capture.

config.enabled_automatic_breadcrumb_types = [] # No breadcrumbs will automatically be captured

Valid breadcrumb types are:

ERROR_BREADCRUMB_TYPE
REQUEST_BREADCRUMB_TYPE
PROCESS_BREADCRUMB_TYPE

endpoints

By default we will send error reports to notify.bugsnag.com and sessions to sessions.bugsnag.com.

If you are using Bugsnag On-premise you’ll need to set these to your Event Server and Session Server endpoints. If the notify endpoint is set but the sessions endpoint is not, session tracking will be disabled automatically to avoid leaking session information outside of your server configuration, and a warning will be logged.

To set the endpoints:

config.set_endpoints(
  "https://bugsnag-notify.example.com", # Your notify, "Event Server", endpoint
  "https://bugsnag-session.example.com", # Your session, "Session Server", endpoint
)

hostname

The name or descriptor of the Ruby server host. Defaults to the server’s hostname.

config.hostname = "NameOfServer-1B"

ignore_classes

Sets for which exception classes we should not send exceptions to Bugsnag.

config.ignore_classes << ActiveRecord::StatementInvalid

You can also provide a lambda function here to ignore by other exception attributes or by a regex:

config.ignore_classes << lambda {|ex| ex.message =~ /timeout/}

By default, ignore_classes contains the following:

[
  SystemExit,
  SignalException
]

logger

Sets which logger to use for Bugsnag log messages. In rails apps, this is automatically set to use Rails.logger, otherwise it will be set to Logger.new(STDOUT).

max_breadcrumbs

The number of breadcrumbs that can be captured before the oldest start to be dropped. Defaults to 25.

config.max_breadcrumbs = 10 # A maximum of 10 breadcrumbs will be kept at any one time

meta_data_filters

Sets which keys should be filtered out from the report and breadcrumb metadata before sending them to Bugsnag. Use this if you want to ensure you don’t send sensitive data such as passwords, and credit card numbers to our servers. You can add both strings and regular expressions to this array. When adding strings, keys which contain the string will be filtered. When adding regular expressions, any keys which match the regular expression will be filtered.

config.meta_data_filters += ['credit_card_number', /^password$/]

By default, meta_data_filters is set to

[
  /authorization/i,
  /cookie/i,
  /password/i,
  /secret/i,
  /warden\.user\.([^.]+)\.key/,
  "rack.request.form_vars"
]

and for Rails apps, all values from Rails.configuration.filter_parameters are added as well. String values within Rails.configuration.filter_parameters are matched as case-sensitive substrings and regular expression values are imported as-is.

Note: Assigning (=) instead of appending (+=) to the default value will remove the default protections.

notify_release_stages

By default, we will notify Bugsnag of exceptions that happen in any release_stage. If you would like to change which release stages notify Bugsnag of exceptions you can set notify_release_stages:

config.notify_release_stages = ['production', 'development']

project_root

We mark stacktrace lines as inProject if they come from files inside your project_root. In rails apps this value is automatically set to RAILS_ROOT, otherwise you should set it manually:

config.project_root = '/var/www/myproject'

proxy_host

Sets the address of the HTTP proxy that should be used for requests to Bugsnag.

config.proxy_host = '10.10.10.10'

All proxy options can also be configured using the http_proxy or https_proxy environment variables as described in the Net::HTTP documentation:

http_proxy='http://username:password@hostname:port'

Alternatively the proxy options can be parsed from a url by calling the parse_proxy method:

config.parse_proxy('http://username:password@hostname:port')

proxy_password

Sets the password for the user that should be used to send requests to the HTTP proxy for requests to bugsnag.

config.proxy_password = 'proxy_secret_password_here'

proxy_port

Sets the port of the HTTP proxy that should be used for requests to Bugsnag.

config.proxy_port = 1089

proxy_user

Sets the user that should be used to send requests to the HTTP proxy for requests to bugsnag.

config.proxy_user = 'proxy_user'

release_stage

If you would like to distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the release_stage that is reported to Bugsnag.

config.release_stage = 'development'

In rails apps this value is automatically set from RAILS_ENV, and in rack apps it is automatically set to RACK_ENV. Otherwise the default is ‘production’.

send_environment

Bugsnag can transmit your rack environment to help diagnose issues. This environment can sometimes contain private information so Bugsnag does not transmit by default. To send your rack environment, set the send_environment option to true.

config.send_environment = true

send_code

Bugsnag automatically sends a small snippet of the code that crashed to help you diagnose even faster from within your dashboard. If you don’t want to send this snippet you can set the send_code option to false.

config.send_code = false

timeout

By default the timeout for posting errors to Bugsnag is 15 seconds, to change this you can set the timeout:

config.timeout = 10

Custom middleware loading

By default all Ruby framework integrations Bugsnag provides will be initialized when the notifier is loaded. This behaviour can be disabled by setting the environment variable BUGSNAG_DISABLE_AUTOCONFIGURE to true inside of your application. Integrations can then be required as necessary using:

Bugsnag.load_integration(:sidekiq)