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

async_json_payload

If async_json_payload = true it allows truncation to happen before the payload is added to queues, ensuring the payload is always under 500K bytes. This flag applies to any/all of the async handlers (Sidekiq, Resque, ActiveJob, AsyncJob, etc.)

Default: false

async_skip_report_handler

Handler to be called before sending via an async handler. The handler should be a Proc object or object responding to #call method.

The received argument is the current job being processed.

The handler should return true to skip the report, or a falsey value to send.

Default: nil

backtrace_cleaner

Set with any instance of ActiveSupport::BacktraceCleaner or with any object that supports its interface. When set, it will be applied to all error stacks before sending to Rollbar.

Default: nil

before_process

Handlers to be called before processing data sent. The handlers should be Proc objects or objects responding to #call method.

The received argument is a Hash object with these keys:

  • level: the level used for the report.
  • exception: the exception that caused the report, if any.
  • message: the message to use for the report, if any.
  • extra: extra data passed to the report methods.
  • scope: the current Scope; see Scope

It supports ignoring items

branch

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

Default: "master"

capture_uncaught

Report uncaught exceptions to Rollbar. Set to false to ignore uncaught exceptions.

Default: true

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

ignore_internal_errors

Specify error class names to ignore for internal errors from rollbar-gem. This shouldn't need to be updated unless there is an excess of unwanted internal error reports. Set true to ignore all internal errors.

Default: ['Net::ReadTimeout', 'Net::OpenTimeout', 'SocketError']

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: []

locals

Enable capture of local variables in error stack traces. Enable by setting config.locals = { :enabled => true }. More information

Default: disabled

log_payload

When true, payloads will be logged to the configured local logger.

Default: false

logger

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

logger_level

Minimum level of logger messages to write to the log. Accepts 'debug', 'info', 'warn' or 'error'.

Default: 'info'

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

raise_on_error

When true, exceptions logged via the Rollbar logging methods will raise after reporting to Rollbar.

Default: false

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

An array of fields to not scrub, even if they also appear in scrub_fields.

Default: []

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

transmit

When false items will be fully processed but not sent to Rollbar.

Default: true

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_active_job

Invoking this method will instruct the SDK to use your Rails' configured ActiveJob implementation to deliver items to Rollbar. This will automatically set use_async to true and async_handler to Rollbar::Delay::ActiveJob. Only available on Rails 4.2+.

use_eventmachine

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

Default: false

use_thread

When enabled, sends Rollbar data on a separate Ruby thread. use_thread can either take no arguments, or can take a thread priority:
config.use_thread({ :priority => 2 })

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.

user_ip_rack_env_key

Specifies the rack env key that provides the user IP address. For example, this may be set to the key used by Cloudflare ('HTTP_CF_CONNECTING_IP') or any other custom key that contains the IP address.

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.


Did this page help you?