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_tokenSets 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_handlerIf 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_payloadIf 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_handlerHandler 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_cleanerSet 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_processHandlers 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
branchThe name of the branch of the code that is running. Used for linking filenames in stacktraces to GitHub.

Default: "master"
capture_uncaughtReport uncaught exceptions to Rollbar. Set to false to ignore uncaught exceptions.

Default: true
code_versionA 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_methodThe method to call to gather custom data to send with each rollbar request.

ruby def custom_data return { :custom => { :key1 => get_key_one, :key2 => get_key_two }, :server => { :root => '/home/username/www/' } } end
default_loggerWhat logger to use for printing debugging and informational messages during operation.

Default: Logger.new(STDERR) or ::Rails.logger when using Rails
disable_core_monkey_patchDisables 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_patchDisables 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_patchDisables monkey patches on Rack classes, Rack::Builder.

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

Default: true
dj_thresholdThe number of job failures before reporting the failure to Rollbar.

Default: 0 (Report any errors)
enabledIf set to false, no data will be sent to Rollbar.

Default: true
environmentThe environment that your code is running in.

Default: unspecified
failover_handlersAn array of backup handlers if the async handlers fails. Each should respond to #call and should receive a payload.
filepathFor use with write_to_file. Indicates location of the Rollbar log file being tracked by rollbar-agent.
frameworkIndicates which framework you're using. Common options include 'Rails', 'Sinatra', and 'Rack' to name a few.

Default: 'Plain'
hostThe hostname (reported to Rollbar as server.host). When nil, the value of Socket.gethostname will be used.

Default: nil
ignore_internal_errorsSpecify 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_idsIds of people whose reports you wish to ignore. Only works in conjunction with a properly defined person_method or person_id_method.

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

Default: disabled
log_payloadWhen true, payloads will be logged to the configured local logger.

Default: false
loggerThe logger to use instead of the default logger. Especially useful when you wish to send log messages elsewhere.
logger_levelMinimum level of logger messages to write to the log. Accepts 'debug', 'info', 'warn' or 'error'.

Default: 'info'
net_retriesSets the number of retries caused by timeouts on the POST request.

Default: 3
open_timeoutDefault: 3
payload_optionsExtra data to send with the payload.
person_methodIf 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_methodA 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_methodA 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_methodA 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_backtracesRaising 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_gemsIn 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:

ruby Rollbar.configure do |config | config.access_token = '...' config.project_gems = ['my_custom_gem', 'my_other_gem'] end
raise_on_errorWhen true, exceptions logged via the Rollbar logging methods will raise after reporting to Rollbar.

Default: false
randomize_scrub_lengthWhen true, randomizes the number of asterisks used to display scrubbed fields.

Default: true
report_dj_dataSet to false to skip automatic bundling of job metadata like queue, job class name, and job options.

Default: true
request_timeoutSet the request timeout for sending POST data to Rollbar.

Default: 3
rootSets the server root. All stack frames outside that root are considered 'non-project' frames. Also used to setup GitHub linking.
safelyWhen true, evaluates custom_data_method and returns {} if an error, otherwise reports the error to Rollbar.

Default: false
scrub_fieldsFields 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_headersThe headers to scrub. The value will be replaced with a "*" before being sent

Default: ["Authentication"]
scrub_passwordSet to false to skip scrubbing the password out of the URL. The value will be replaced with a "*" before being sent.

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

Default: true
scrub_whitelistAn array of fields to not scrub, even if they also appear in scrub_fields.

Default: []
sidekiq_thresholdThe number of job re-tries before reporting an error to Rollbar via Sidekiq. Ignored unless you've called use_sidekiq.

Default: 0
transmitWhen false items will be fully processed but not sent to Rollbar.

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

Default: false
use_active_jobInvoking 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_eventmachineWhen true, indicates you wish to send data to Rollbar with eventmachine. Won't work unless eventmachine is installed.

Default: false
use_threadWhen 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_defaultWhen 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_secretA string used to hash IP addresses when obfuscating them.
user_ip_rack_env_keySpecifies 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_levelUse this field to select a different level for uncaught errors (like critical, or warning).

Default: error
verify_ssl_peerBy 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_baseThe 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_fileIf 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.