├── .github └── workflows │ └── build.yml ├── .gitignore ├── CHANGELOG.md ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── errbase.gemspec ├── lib ├── errbase.rb └── errbase │ └── version.rb └── test ├── errbase_test.rb └── test_helper.rb /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: [push, pull_request] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v3 8 | - uses: ruby/setup-ruby@v1 9 | with: 10 | ruby-version: 3.1 11 | bundler-cache: true 12 | - run: bundle exec rake test 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | *.bundle 19 | *.so 20 | *.o 21 | *.a 22 | mkmf.log 23 | /log/ 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.2 (2022-02-03) 2 | 3 | - Added support for Scout APM 4 | - Fixed warning with Appsignal 5 | 6 | ## 0.2.1 (2021-01-03) 7 | 8 | - Added support for `sentry-ruby` gem 9 | 10 | ## 0.2.0 (2019-10-28) 11 | 12 | - Added context to New Relic 13 | - Removed support for Exceptional and Opbeat 14 | 15 | ## 0.1.1 (2018-09-19) 16 | 17 | - Added support for passing extra context 18 | - Added support for New Relic 19 | 20 | ## 0.1.0 (2018-02-27) 21 | 22 | - Rescue exceptions during reporting 23 | - Added support for Exception Notification and Stackdriver 24 | 25 | ## 0.0.3 (2015-03-15) 26 | 27 | - Added support for Opbeat 28 | 29 | ## 0.0.2 (2014-11-02) 30 | 31 | - Added support for Appsignal 32 | 33 | ## 0.0.1 (2014-08-12) 34 | 35 | - First release 36 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | 5 | gem "rake" 6 | gem "minitest", ">= 5" 7 | 8 | gem "airbrake" 9 | gem "appsignal" 10 | gem "bugsnag" 11 | gem "exception_notification" 12 | gem "google-cloud-error_reporting" 13 | gem "honeybadger" 14 | gem "newrelic_rpm" 15 | gem "raygun4ruby" 16 | gem "rollbar" 17 | gem "scout_apm" 18 | gem "sentry-raven" 19 | gem "sentry-ruby" 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2022 Andrew Kane 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Errbase 2 | 3 | Errbase has been merged into [Safely](https://github.com/ankane/safely) - use that instead. 4 | 5 | --- 6 | 7 | Common exception reporting for a variety of services 8 | 9 | Libraries are automatically detected. Supports: 10 | 11 | - [Airbrake](https://airbrake.io/) 12 | - [Appsignal](https://appsignal.com/) 13 | - [Bugsnag](https://bugsnag.com/) 14 | - [Exception Notification](https://github.com/smartinez87/exception_notification) 15 | - [Google Stackdriver](https://cloud.google.com/stackdriver/) 16 | - [Honeybadger](https://www.honeybadger.io/) 17 | - [New Relic](https://newrelic.com/) 18 | - [Raygun](https://raygun.io/) 19 | - [Rollbar](https://rollbar.com/) 20 | - [Scout APM](https://scoutapm.com/) 21 | - [Sentry](https://getsentry.com/) 22 | 23 | ```ruby 24 | begin 25 | # code 26 | rescue => e 27 | Errbase.report(e) 28 | end 29 | ``` 30 | 31 | You can add extra context with: 32 | 33 | ```ruby 34 | Errbase.report(e, {username: "hello"}) 35 | ``` 36 | 37 | > Context is not supported for Google Stackdriver 38 | 39 | [![Build Status](https://github.com/ankane/errbase/workflows/build/badge.svg?branch=master)](https://github.com/ankane/errbase/actions) 40 | 41 | ## Installation 42 | 43 | Errbase is designed to be used as a dependency. 44 | 45 | Add this line to your gemspec: 46 | 47 | ```ruby 48 | spec.add_dependency "errbase" 49 | ``` 50 | 51 | ## Contributing 52 | 53 | Everyone is encouraged to help improve this project. Here are a few ways you can help: 54 | 55 | - [Report bugs](https://github.com/ankane/errbase/issues) 56 | - Fix bugs and [submit pull requests](https://github.com/ankane/errbase/pulls) 57 | - Write, clarify, or fix documentation 58 | - Suggest or add new features 59 | 60 | To get started with development: 61 | 62 | ```sh 63 | git clone https://github.com/ankane/errbase.git 64 | cd errbase 65 | bundle install 66 | bundle exec rake test 67 | ``` 68 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/testtask" 3 | 4 | task default: :test 5 | Rake::TestTask.new do |t| 6 | t.libs << "test" 7 | t.pattern = "test/**/*_test.rb" 8 | t.warning = false 9 | end 10 | -------------------------------------------------------------------------------- /errbase.gemspec: -------------------------------------------------------------------------------- 1 | require_relative "lib/errbase/version" 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = "errbase" 5 | spec.version = Errbase::VERSION 6 | spec.summary = "Common exception reporting for a variety of services" 7 | spec.homepage = "https://github.com/ankane/errbase" 8 | spec.license = "MIT" 9 | 10 | spec.author = "Andrew Kane" 11 | spec.email = "andrew@ankane.org" 12 | 13 | spec.files = Dir["*.{md,txt}", "{lib}/**/*"] 14 | spec.require_path = "lib" 15 | 16 | spec.required_ruby_version = ">= 2.4" 17 | end 18 | -------------------------------------------------------------------------------- /lib/errbase.rb: -------------------------------------------------------------------------------- 1 | require "errbase/version" 2 | 3 | module Errbase 4 | class << self 5 | def report(e, info = {}) 6 | Airbrake.notify(e, info) if defined?(Airbrake) 7 | 8 | if defined?(Appsignal) 9 | if Appsignal::VERSION.to_i >= 3 10 | Appsignal.send_error(e) do |transaction| 11 | transaction.set_tags(info) 12 | end 13 | else 14 | Appsignal.send_error(e, info) 15 | end 16 | end 17 | 18 | if defined?(Bugsnag) 19 | Bugsnag.notify(e) do |report| 20 | report.add_tab(:info, info) if info.any? 21 | end 22 | end 23 | 24 | ExceptionNotifier.notify_exception(e, data: info) if defined?(ExceptionNotifier) 25 | 26 | # TODO add info 27 | Google::Cloud::ErrorReporting.report(e) if defined?(Google::Cloud::ErrorReporting) 28 | 29 | Honeybadger.notify(e, context: info) if defined?(Honeybadger) 30 | 31 | NewRelic::Agent.notice_error(e, custom_params: info) if defined?(NewRelic::Agent) 32 | 33 | Raven.capture_exception(e, extra: info) if defined?(Raven) 34 | 35 | Raygun.track_exception(e, custom_data: info) if defined?(Raygun) 36 | 37 | Rollbar.error(e, info) if defined?(Rollbar) 38 | 39 | if defined?(ScoutApm::Error) 40 | ScoutApm::Context.add(info) 41 | ScoutApm::Error.capture(e) 42 | end 43 | 44 | Sentry.capture_exception(e, extra: info) if defined?(Sentry) 45 | rescue => e 46 | $stderr.puts "[errbase] Error reporting exception: #{e.class.name}: #{e.message}" 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /lib/errbase/version.rb: -------------------------------------------------------------------------------- 1 | module Errbase 2 | VERSION = "0.2.2" 3 | end 4 | -------------------------------------------------------------------------------- /test/errbase_test.rb: -------------------------------------------------------------------------------- 1 | require_relative "test_helper" 2 | 3 | class TestErrbase < Minitest::Test 4 | def test_errbase 5 | Errbase.report(RuntimeError.new("Boom")) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require(:default) 3 | require "minitest/autorun" 4 | require "minitest/pride" 5 | 6 | # exception reporting libraries 7 | require "airbrake" 8 | require "appsignal" 9 | require "bugsnag" 10 | require "exception_notification" 11 | # require "google/cloud/error_reporting" # raises exception when not configured 12 | require "honeybadger" 13 | require "newrelic_rpm" 14 | # require "raygun4ruby" # raises exception when not configured 15 | require "rollbar" 16 | require "scout_apm" 17 | require "sentry-raven" 18 | require "sentry-ruby" 19 | --------------------------------------------------------------------------------