We are excited to announce the new major release of our Ruby notifier library for Airbrake Bug Tracker!
It was as clear as day that the gem needed a major update. The code was hard to maintain, the issue tracker had too many unresolved issues, and some important pull requests couldn’t be easily merged because they diverged from the master branch. While these problems could be fixed in a minor release, we also wanted to improve our library API, simplify the configuration process, and add missing integrations.
Meet the new notifier
This was not an easy decision, but we’re happy with the outcome. The airbrake gem reports exceptions for Rails and other third-party Ruby libraries and frameworks, while the airbrake-ruby gem performs all the heavy-lifting like sending, filtering and truncating exceptions. This allowed us to design a clearer API and simplify testing. If you are using any frameworks or libraries like Rails or Sidekiq, it’s better to use airbrake (which depends on airbrake-ruby). For pure Ruby projects all you need is airbrake-ruby.
We have created airbrake-ruby to have zero dependencies, so gem install airbrake and require ‘airbrake’ are faster than ever. As for sending exceptions asynchronously, we’ve implemented our own solution independent of any third-party libraries, which even supports multiple workers. We also started benchmarking the gem’s code (Figure 3). This helped us write faster code, so the overhead of including the library in your application is as minimal as possible.
Fig. 3 — Benchmarking async notify with multiple workers (source code)
% ruby -Ilib benchmarks/notify_async_workers.rb
user system total real
1 worker Airbrake.notify 14.100000 0.650000 14.750000 ( 74.852615)
4 workers Airbrake.notify 10.450000 0.520000 10.970000 ( 18.919285)
8 workers Airbrake.notify 8.330000 0.460000 8.790000 ( 10.226176)
One of the hottest new features is the support for multiple notifiers in the same application/process. This is beneficial for users who want to send exceptions from different subsystems of the same application to multiple Airbrake projects (Figure 4). You are no longer limited to only one Airbrake.configure per application. Instead, you can configure as many notifiers as you want.
Fig. 4 — Configuring multiple notifiers
# Configure a notifier whose name is 'project_a'.
Airbrake.configure(:project_a) do |c|
# Configure notifier A
# Configure a notifier whose name is 'project_b'.
Airbrake.configure(:project_b) do |c|
# Configure notifier B
# Send exception to Project A.
Airbrake.notify('error1', param1: 'val1', :project_a)
# Send exception to Project B.
Airbrake.notify('error2', param2: 'val2', :project_b)
Other prominent changes include:
- Improved JRuby support (we can send Java exceptions now)
- Support for nested exceptions (a new dashboard is coming soon, which will show these nested exceptions hierarchically. For now they’ll display separately)
- The Airbrake.add_filter API allows you to filter or attach data to your exceptions
- Simplified configuration process (no more complex or obscure options)
- Better Rails support (we now capture even more exceptions)
- New integrations with ActiveJob and DelayedJob
Migrating to Airbrake V5
First of all, don’t worry, you don’t have to migrate immediately. The good news is that we still support Airbrake v4! We still accept pull requests with bug fixes, but it is feature-frozen.
Please use our migration guide to help you with the upgrade to v5. Also, bear in mind that we dropped support for ancient versions of Rubies and Rails so we can focus on ensuring a great user experience for the most common versions. Figure 3 shows officially supported Rubies and Rails.
Our YARD API documentation and README extensively describes the new library, so migration should be like a snap. The wiki is deprecated and should be used only if you still work with Airbrake v4. Email email@example.com if you have any trouble upgrading.
While we’re happy about the progress made on the airbrake gem, it’s by no means the final version. We plan to update the error dashboard to properly display nested exceptions. There’s also a great demand for exceptions with attached snippets of code at each backtrace frame. This is a top priority on our airbrake gem roadmap.
Try it out
We encourage you to try out the new library. Sign up to start capturing exceptions in your Ruby apps now! Get in touch if you have any questions, problems, feature ideas, or bug reports, we look forward to hearing from you!
- file an issue (airbrake repo for integration problems; airbrake-ruby for anything else)
- send us an email
- tweet at us
- chat with us (visit airbrake.io and click on the round orange button in the bottom right corner)
New to Airbrake? Start your 30-day free trial today and you’ll be organizing and tracking all your application’s errors in just a few minutes.