Rollbar

This add-on is operated by Rollbar Inc

Track exceptions, reproduce and fix them faster.

Rollbar

Last Updated: 19 March 2014

Table of Contents

Rollbar is an add-on for tracking and reproducing exceptions and errors. We collect, de-duplicate, and alert on error conditions, and provide a dashboard and analysis tools so you can understand, reproduce, and fix errors quickly.

Adding Rollbar to your app means you’ll always know what errors your users are seeing, and you’ll often be able to fix them before users complain.

Rollbar is accessible via an API and has supported client libraries for Ruby, Python, Node.js, PHP, Javascript, and Flash.

Provisioning the add-on

Rollbar can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:add rollbar
-----> Adding rollbar to sharp-mountain-4005... done, v18 (free)

Once Rollbar has been added a ROLLBAR_ACCESS_TOKEN setting will be available in the app configuration and will contain your server-side access token. This can be confirmed using the heroku config:get command.

$ heroku config:get ROLLBAR_ACCESS_TOKEN
a1a1b2b2c3c3d4d4e5e5f6f6e7e7d8d8

After installing Rollbar the application should be configured to fully integrate with the add-on.

Local setup

Environment setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Though less portable it’s also possible to set local environment variables using export ROLLBAR_ACCESS_TOKEN=value.

Use Foreman to configure, run and manage process types specified in your app’s Procfile. Foreman reads configuration variables from an .env file. Use the following command to add the ROLLBAR_ACCESS_TOKEN values retrieved from heroku config to .env.

$ heroku config -s | grep ROLLBAR_ACCESS_TOKEN >> .env
$ more .env

Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

Using with Ruby / Rails

Add the following to your Gemfile:

gem 'rollbar'

Then from your project’s RAILS_ROOT, run:

$ bundle install
$ bundle exec rails generate rollbar

To make sure things are working, run:

$ bundle exec rake rollbar:test

That’s all you need for the basics: uncaught exceptions (anything that would display an error page) will now be reported to Rollbar. Access the Rollbar interface via the link on the Addons page in heroku.

Additional configuration options are available and can be set in config/initializers/rollbar.rb (which was generated by rails generate rollbar).

Manually reporting exceptions and messages

To report a caught exception to Rollbar, simply call Rollbar.report_exception:

begin
  foo = bar
rescue Exception => e
  Rollbar.report_exception(e)
end

If you’re reporting an exception in the context of a request and are in a controller, you can pass along the same request and person context as the global exception handler, like so:

begin
  foo = bar
rescue Exception => e
  Rollbar.report_exception(e, rollbar_request_data, rollbar_person_data)
end

You can also log individual messages:

# logs at the 'warning' level. all levels: debug, info, warning, error, critical
Rollbar.report_message("Unexpected input", "warning")

# default level is "info"
Rollbar.report_message("Login successful")

# can also include additional data as a hash in the final param. :body is reserved.
Rollbar.report_message("Login successful", "info", :user => @user)

Asynchronous reporting

By default, all messages are reported synchronously. You can enable asynchronous reporting by adding the following in config/initializers/rollbar.rb:

config.use_async = true

Rollbar uses girl_friday to handle asynchronous reporting when installed, and falls back to Threading if girl_friday is not installed.

You can supply your own handler using config.async_handler. The handler should schedule the payload for later processing (i.e. with a delayed_job, in a resque queue, etc.) and should itself return immediately. For example:

config.async_handler = Proc.new { |payload|
  Thread.new { Rollbar.process_payload(payload) }
}

Make sure to call Rollbar.process_payload(payload).

Dashboard

For more information on the features available within the Rollbar dashboard please see the docs at rollbar.com/features.

The dashboard can be accessed via the CLI:

$ heroku addons:open rollbar
Opening rollbar for sharp-mountain-4005

or by visiting the Heroku apps web interface and selecting the application in question. Select Rollbar from the Add-ons menu.

Migrating between plans

Use the heroku addons:upgrade command to choose a new plan. This is a downtime-free operation.

$ heroku addons:upgrade rollbar:newplan
-----> Upgrading rollbar:newplan to sharp-mountain-4005... done, v18 ($49/mo)
       Your plan has been updated to: rollbar:newplan

Removing the add-on

Rollbar can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:remove rollbar
-----> Removing rollbar from sharp-mountain-4005... done, v20 (free)

Before removing Rollbar a data export can be performed by contacting support@rollbar.com.

Support

All Rollbar support and runtime issues should be submitted via on of the Heroku Support channels. Any non-support related issues or product feedback is welcome at team@rollbar.com.