When an app chokes on an unexpected condition or data, developers can spend hours going down rabbit holes trying to reproduce and diagnose the issue. It helps to have as much information as possible about the error and the environment at the time of the error, so that’s why I want to look at the error reporting and monitoring tool called Airbrake. This tool lets you get into the guts of your application’s errors to see what is going on.
I have personally used Airbrake to monitor some applications that I previously built at a startup, so you can imagine that I was really excited when Exceptional Cloud Services, the team behind Airbrake, recently became part of the Rackspace family. You can get started with Airbrake by going to www.airbrake.io to learn more information about its plans and pricing (note: there is a free developer plan). I have included a screencast below that walks you through a step-by-step guide on installing Airbrake to your Rails app.
Getting started with Rails? Find out how Bret taught himself the framework.
After you get Airbrake set up, there are several features that I have found helpful:
To setup Airbrake in your Rails application, open up your gem file and type:
Now go into terminal and type:
Once that’s done, go back into your Rails application, and go to your application controller file and make sure that it does not include “exceptionnotifiable” up in the top. It should look something like this:
class ApplicationController < ActionController::Base protect_from_forgery end
Go back into terminal and type:
rails generate airbrake --api-key [your_key_here]
Where [your_key_here] is your API key from Airbrake. This will install Airbrake and throw an example error in the Airbrake portal to verify you did the installation correctly. Logging back into the Airbrake application, you can see the error that was just generated here in your log that reads, “If you can see this, it works.” You now have Airbrake up and running, and can rest a little bit easier knowing that your application is being monitored.
Check out Bret’s previous post where he talks about monitoring the cloud infrastructure that your app is sitting on. In his next post and screencast, Bret discusses a tool that can help developers monitor the hosting costs of their application.
Head over to the Rackspace DevOps blog for a drill down into using Airbrake on the Rackspace Cloud.