Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Airbrake for your Ruby application #80

Open
trosborn opened this issue Mar 1, 2017 · 0 comments
Open

Setup Airbrake for your Ruby application #80

trosborn opened this issue Mar 1, 2017 · 0 comments
Labels

Comments

@trosborn
Copy link
Owner

trosborn commented Mar 1, 2017

Installation

Using bundler

Add the Airbrake Ruby gem to your Gemfile:

gem 'airbrake-ruby', '~> 1.7'

Manual

Invoke the following command from your terminal:

gem install airbrake-ruby

Example

This is the minimal example that you can use to test Airbrake Ruby with your project (You can find your project ID and API KEY with your project's settings):

require 'airbrake-ruby'

# Every Airbrake notifier must configure
# two options: `project_id` and `project_key`.
Airbrake.configure do |c|
  c.project_id = <Your project ID>
  c.project_key = '<Your project API KEY>'
end

# Asynchronous error delivery.
begin
  1/0
rescue ZeroDivisionError => ex
  # Return value is always `nil`.
  Airbrake.notify(ex)
end

puts 'A ZeroDivisionError was sent to Airbrake asynchronously!',
     "Find it at your project's dashboard on https://airbrake.io"

# Synchronous error delivery.
begin
  1/0
rescue ZeroDivisionError => ex
  # Return value is a Hash.
  response = Airbrake.notify_sync(ex)
end

puts "\nAnother ZeroDivisionError was sent to Airbrake, but this time synchronously.",
     "See it at #{response['url']}"

Configuration

For advanced configuration options like error filtering or custom parameters, please visit our official GitHub repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant