Installing with the CLI
The Airbrake CLI installs the Airbrake Ruby notifier automatically in your Ruby project. To install the gem directly without using the CLI, please scroll down to the Installing manually section.
Install the CLI via Homebrew
brew install airbrake/airbrake-cli/airbrake
Authenticate via config
command
Authenticate by setting your user-key
with the config
command:
airbrake config set user-key YOUR_USER_KEY_HERE
You can find your user key in your profile settings page.
Install command
Invoke the following to have the Airbrake CLI install the Airbrake notifier for your project:
airbrake install --project-id YOUR_PROJECT_ID_HERE
You can find your project ID in your project's settings.
After this, you are set! Check out the Testing your installation section to send a test error to Airbrake.
Installing manually
Option 1: Bundler
Add the Airbrake Ruby gem to your Gemfile:
Option 2: Manual
Invoke the following command from your terminal:
gem install airbrake-ruby
Configuration
Just require
the library and copy this configuration snippet into your Ruby project:
(You can find your project ID and API key in your project's settings)
require 'airbrake-ruby'
Airbrake.configure do |c|
c.project_id = <Your project ID>
c.project_key = '<Your project API KEY>'
end
Testing your installation
To test your installation, send a test error to Airbrake as shown in one of the examples below. Uncaught errors are automatically sent to Airbrake. Caught errors can be sent to Airbrake using the notify
or notify_sync
methods:
Report errors synchronously
# Synchronous error delivery for short lived processes/scripts.
begin
1/0
rescue ZeroDivisionError => ex
Airbrake.notify_sync(ex)
end
Report errors asynchronously
# Asynchronous error delivery for longer living processes/apps.
begin
1/0
rescue ZeroDivisionError => ex
Airbrake.notify(ex)
end
Full documentation
For in depth examples and advanced configuration options like error filtering or custom parameters, please visit our official GitHub repo.