Sinatra

Installing Airbrake in a Sinatra application

Features

  • Simple to install and configure
  • Automatic reporting of unhandled exceptions
  • Ignore specific errors and filter out sensitive information
  • Append extra information from requests before sending to Airbrake
  • Set error severity and control notification thresholds

View the full list of features on GitHub.

Install with bundler

Add the Airbrake Ruby gem to your Gemfile and run bundle install:

gem 'airbrake'

Manual installation

Invoke the following command from your terminal:

gem install airbrake

Configuration

To send exceptions to Airbrake from a Sinatra application, simply use our Rack middleware, and configure with your PROJECT ID and PROJECT API KEY available from your project’s settings page.

# sinatra-airbrake-example.rb
require 'sinatra/base'
require 'airbrake'

Airbrake.configure do |c|
  c.project_id = '<Your project ID>'
  c.project_key = '<Your project API KEY>'

  # Display debug output.
  c.logger.level = Logger::DEBUG
end

class MyApp < Sinatra::Base
  use Airbrake::Rack::Middleware

  get('/') { 1/0 }
end

run MyApp.run!

Going further

For advanced configuration options like ignoring errors, adding extra context, appending info from requests, filtering sensitive information, and more please visit the airbrake-ruby and airbrake GitHub repos.