Raven for Ruby is a client and integration layer for the GlitchTip error reporting API. It supports Ruby 1.9.3 and 2.x. JRuby support is provided but experimental.
Raven Ruby comes as a gem and is straightforward to install. If you are using Bundler, add this to your Gemfile
:
gem "sentry-raven"
To use Raven Ruby all you need is your DSN. Like most Sentry-compatible libraries, it will honor the SENTRY_DSN
environment variable. You can find it on the project settings page under API Keys. You can either export it as environment variable or manually configure it with Raven.configure
:
Raven.configure do |config|
config.dsn = 'YOUR-GLITCHTIP-DSN-HERE'
end
If you use Rails, Rake, Sidekiq, etc, you’re already done - no more configuration required!
Raven supports two methods of capturing exceptions:
Raven.capture do
# capture any exceptions which happen during execution of this block
1 / 0
end
begin
1 / 0
rescue ZeroDivisionError => exception
Raven.capture_exception(exception)
end
You can add either of the snippets above into your application to verify that GlitchTip is set up correctly.