Configuration Reference

Configuration options for rollbar-gem

Examples

# Set the access token, branch, code version, and project gems
Rollbar.configure do |config |
  config.access_token = '...'
  config.branch = 'master'
  config.code_version = '3da541559918a808c2402bba5012f6c60b27661c'
  config.project_gems = ['my_custom_gem', 'my_other_gem']
end

# Set an async_handler
config.use_async = true
config.async_handler = Proc.new { |payload|
  Thread.new { Rollbar.process_from_async_handler(payload) }
}

Hooks
You can configure the SDK to trigger your additional custom logic in selected situations through the Rollbar::Configuration.hook method.

Rollbar.configure do |config|
  config.hook :on_error_response do |response|
    ...
  end
end

:on_error_response
Triggered when Rollbar API responds with any status code different than 200. Parameters: response.

:on_report_internal_error
Triggered when the SDK throws an internal unexpected error. Parameters: exception.

Configuration Reference

access_token

Sets the access token used to send payloads to Rollbar.

Items sent through a given access token arrive in that access token's project and respect the rate limits set on that access token.

async_handler

If config.use_async = true explicitly sets the function used to send asynchronous payloads to Rollbar. Should be an object that responds to #call. Not needed if using one of the built in async reporters:

  • girl_friday
  • sucker_punch
  • Sidekiq
  • Resque
  • threading

branch

The name of the branch of the code that is running. Used for linking filenames in stacktraces to GitHub.

Default: "master"

code_version

A string up to 40 characters describing the version control number (i.e. git SHA) of the current revision. Used for linking filenames in stacktraces to GitHub.

Rollbar understands these formats:

  • semantic version (i.e. "2.1.12")
  • integer (i.e. "45")
  • git SHA (i.e. "3da5415...")

custom_data_method

The method to call to gather custom data to send with each rollbar request.

def custom_data
  return {
    :custom => {
      :key1 => get_key_one,
      :key2 => get_key_two
    },
    :server => {
      :root => '/home/username/www/'
    }
  }
end

default_logger

What logger to use for printing debugging and informational messages during operation.

Default: Logger.new(STDERR) or ::Rails.logger when using Rails

disable_core_monkey_patch

Disables Rollbar's monkey patches in the Ruby core. One mandatory monkey patch is left. Be careful using this option as it may cause unexpected behavior in some situations.

Default: false

disable_monkey_patch

Disables monkey patching all non-core monkey patches and automatic reporting.

If you set this to true you will be responsible for rescuing and reporting all errors manually.

Default: false

disable_rack_monkey_patch

Disables monkey patches on Rack classes, Rack::Builder.

Default: false

delayed_job_enabled

Set to false if you have delayed_job but do not wish to wrap jobs with a Rollbar notifier.

Default: true

dj_threshold

The number of job failures before reporting the failure to Rollbar.

Default: 0 (Report any errors)

enabled

If set to false, no data will be sent to Rollbar.

Default: true

environment

The environment that your code is running in.

Default: unspecified

failover_handlers

An array of backup handlers if the async handlers fails. Each should respond to #call and should receive a payload.

filepath

For use with write_to_file. Indicates location of the Rollbar log file being tracked by rollbar-agent.

framework

Indicates which framework you're using. Common options include 'Rails', 'Sinatra', and 'Rack' to name a few.

Default: 'Plain'

host

The hostname (reported to Rollbar as server.host). When nil, the value of Socket.gethostname will be used.

Default: nil

ignored_person_ids

Ids of people whose reports you wish to ignore. Only works in conjunction with a properly defined person_method or person_id_method.

Default: []

logger

The logger to use instead of the default logger. Especially useful when you wish to send log messages elsewhere.

net_retries

Sets the number of retries caused by timeouts on the POST request.

Default: 3

open_timeout

Default: 3

payload_options

Extra data to send with the payload.

person_method

If not using Rails:

Populate the rollbar.person_data key with a hash containing :id, and optionally :username and :email.

Rails only: A string or symbol giving the name of the method on the controller. Should return an object with an id method, and optionally username and email methods. The names of the id, username and email methods can be overridden. See person_id_method, person_username_method, and person_email_method.

person_email_method

A string or symbol giving the name of the method on the user instance that returns the person's email. Gets called on the result of person_method. Ignored if person_method not present.

person_id_method

A string or symbol giving the name of the method on the user instance that returns the person's id. Gets called on the result of person_method. Ignored if person_method not present.

person_username_method

A string or symbol giving the name of the method on the user instance that returns the person's username. Gets called on the result of person_method. Ignored if person_method not present.

populate_empty_backtraces

Raising an exception in Ruby is what populates the backtraces. If you report a manually initialized exception instead of a raised and rescued exception, the backtraces will be empty. Set populate_empty_backtraces to true to have Rollbar load the traces before sending them.

project_gems

In the Rollbar interface, stacktraces are shown with in-project code expanded and other code collapsed. Stack frames are counted as in-project if they occur in a file that is inside of the configuration.root (automatically set to Rails.root if you're using Rails). The collapsed sections can be expanded by clicking on them.

If you want code from some specific gems to start expanded as well, you can configure this in config/initializers/rollbar.rb:

Rollbar.configure do |config |
  config.access_token = '...'
  config.project_gems =  ['my_custom_gem', 'my_other_gem']
end

randomize_scrub_length

When true, randomizes the number of asterisks used to display scrubbed fields.

Default: true

report_dj_data

Set to false to skip automatic bundling of job metadata like queue, job class name, and job options.

Default: true

request_timeout

Set the request timeout for sending POST data to Rollbar.

Default: 3

root

Sets the server root. All stack frames outside that root are considered 'non-project' frames. Also used to setup GitHub linking.

safely

When true, evaluates custom_data_method and returns {} if an error, otherwise reports the error to Rollbar.

Default: false

scrub_fields

Fields to scrub out of the parsed request data. Will scrub from GET, POST, url, and several other locations. Does not recurse into the full payload. If a request contains one of these fields, the value will be replaced with a "*" before being sent.

Default: [:passwd, :password, :password_confirmation, :secret, :confirm_password, :secret_token]

scrub_headers

The headers to scrub. The value will be replaced with a "*" before being sent

Default: ["Authentication"]

scrub_password

Set to false to skip scrubbing the password out of the URL. The value will be replaced with a "*" before being sent.

Default: true

scrub_user

Set to false to skip scrubbing the user out of the URL. The value will be replaced with a "*" before being sent.

Default: true

scrub_whitelist

Set to true to switch scrubbing mode to whitelist. In whitelist mode, everything but the fields provided in scrub_fields gets scrubbed. The values will be replaced with a "*" before being sent.

sidekiq_threshold

The number of job re-tries before reporting an error to Rollbar via Sidekiq. Ignored unless you've called use_sidekiq.

Default: 0

use_async

When true, indicates you wish to send data to Rollbar asynchronously. If installed, uses girl_friday, otherwise defaults to Thread.

Default: false

use_eventmachine

When true, indicates you wish to send data to Rollbar with eventmachine. Won't work unless eventmachine is installed.

Default: false

use_exception_level_filters_default

When true, the gem will use the exception_level_filters when reporting. It can be overriden via the :use_exception_level_filters option. See Exception level filters

user_ip_obfuscator_secret

A string used to hash IP addresses when obfuscating them.

uncaught_exception_level

Use this field to select a different level for uncaught errors (like critical, or warning).

Default: error

verify_ssl_peer

By default, the gem uses OpenSSL::SSL::VERIFY_PEER for SSL. Although it isn't recommended to change it, you can disable peer verification in case you experience SSL connection problems.

Default: true

web_base

The root of the web app that serves your Rollbar data. Unless you're an Enterprise customer running Rollbar on-premise, this should never change.

Default: 'https://rollbar.com'

write_to_file

If true writes all errors to a log file which can be sent with rollbar-agent.

Default: false

For more information on rollbar-gem, please see the docs here.

Configuration Reference

Configuration options for rollbar-gem