Sentry

This add-on is operated by GetSentry

Capture and aggregate exceptions in real-time

Sentry

Last Updated: 19 March 2014

Table of Contents

Sentry is a realtime event logging and aggregation platform. It specializes in monitoring errors and extracting all the information needed to do a proper post-mortum without any of the hassle of the standard user feedback loop.

Provisioning the add-on

Start by adding the Sentry addon:

$ heroku addons:add sentry

Integrating with Ruby (or Rails 3.x)

Add the Raven gem to your Gemfile:

gem 'sentry-raven'

In Rails we will automatically pick up unhandled exceptions and send them to Sentry. For other platforms you can wrap your code to manually log the exceptions:

begin
  1 / 0
rescue ZeroDivisionError => exception
  Raven.capture_exception(exception)
end

If you’re not running with the “production” environment, you’ll need to manually specify that by calling out to Raven:

Raven.configure do |config|
    config.current_environment = 'production'
end

Integrating with Python (or Django)

Add the Raven library to your setup.py or requirements.txt:

raven>=3

If you’re using Django, drop the app into your INSTALLED_APPS:

INSTALLED_APPS = INSTALLED_APPS + (
    'raven.contrib.django.raven_compat',
)

You’ll also find your client available automatically:

from raven.contrib.django.models import client

If you’re not using Django, you’ll need to create a client instance in your app:

from raven.base import Client
client = Client()

In any platform, you can explicitally capture an error using the captureException method:

try:
    1 / 0
except Exception:
    client.captureException()

If you are just looking to generate a test exception, you can do that via the raven CLI:

raven test `heroku config:get SENTRY_DSN`

Viewing Sentry

Heroku provides an easy interface for logging into the Sentry web UI:

$ heroku addons:open sentry

Removing the add-on

Just as provisioning, this is done through the addons interface:

$ heroku addons:remove sentry