From ab928fa5ce42661fa7d90a6faf2a3f60fa603817 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Thu, 13 Apr 2017 01:22:26 +0100 Subject: [PATCH] added airbrake --- Gemfile | 1 + Gemfile.lock | 4 +++ config.ru | 14 ++++----- config/initializers/airbrake.rb | 56 +++++++++++++++++++++++++++++++++ no_light_sinatra.rb | 2 ++ 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 config/initializers/airbrake.rb diff --git a/Gemfile b/Gemfile index 40e647d..2d36090 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ ruby '2.4.0' source 'https://rubygems.org' gem 'activemodel-serializers-xml' +gem 'airbrake' gem 'bson_ext' gem 'mongo_mapper' gem 'skylight' diff --git a/Gemfile.lock b/Gemfile.lock index c22d478..9aed756 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,6 +19,9 @@ GEM tzinfo (~> 1.1) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) + airbrake (6.0.0) + airbrake-ruby (~> 2.0) + airbrake-ruby (2.0.0) arel (7.1.4) backports (3.7.0) bson (1.12.5) @@ -114,6 +117,7 @@ PLATFORMS DEPENDENCIES activemodel-serializers-xml + airbrake bson_ext capybara capybara-webkit diff --git a/config.ru b/config.ru index dbc04a5..e660bd6 100644 --- a/config.ru +++ b/config.ru @@ -4,14 +4,12 @@ $LOAD_PATH << File.expand_path(File.dirname(__FILE__)) require "bundler" Bundler.require -# Local config -# require "find" - -# %w{config/initializers lib models}.each do |load_path| -# Find.find(load_path) { |f| -# require f unless f.match(/\/\..+$/) || File.directory?(f) -# } -# end +require "find" +%w{config/initializers lib models}.each do |load_path| + Find.find(load_path) { |f| + require f unless f.match(/\/\..+$/) || File.directory?(f) + } +end require "sinatra/reloader" if development? require "securerandom" diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb new file mode 100644 index 0000000..bd84cf1 --- /dev/null +++ b/config/initializers/airbrake.rb @@ -0,0 +1,56 @@ +# Airbrake is an online tool that provides robust exception tracking in your Rails +# applications. In doing so, it allows you to easily review errors, tie an error +# to an individual piece of code, and trace the cause back to recent +# changes. Airbrake enables for easy categorization, searching, and prioritization +# of exceptions so that when errors occur, your team can quickly determine the +# root cause. +# +# Configuration details: +# https://github.com/airbrake/airbrake-ruby#configuration +Airbrake.configure do |c| + # You must set both project_id & project_key. To find your project_id and + # project_key navigate to your project's General Settings and copy the values + # from the right sidebar. + # https://github.com/airbrake/airbrake-ruby#project_id--project_key + c.project_id = 141503 + c.project_key = '94823b6fc825a7bd16f6fc359d0ac501' + + # Configures the root directory of your project. Expects a String or a + # Pathname, which represents the path to your project. Providing this option + # helps us to filter out repetitive data from backtrace frames and link to + # GitHub files from our dashboard. + # https://github.com/airbrake/airbrake-ruby#root_directory + # c.root_directory = Rails.root + + # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to + # use the Rails' logger. + # https://github.com/airbrake/airbrake-ruby#logger + c.logger = NoLightSinatra.logger + + # Configures the environment the application is running in. Helps the Airbrake + # dashboard to distinguish between exceptions occurring in different + # environments. By default, it's not set. + # NOTE: This option must be set in order to make the 'ignore_environments' + # option work. + # https://github.com/airbrake/airbrake-ruby#environment + # c.environment = Rails.env + + # Setting this option allows Airbrake to filter exceptions occurring in + # unwanted environments such as :test. By default, it is equal to an empty + # Array, which means Airbrake Ruby sends exceptions occurring in all + # environments. + # NOTE: This option *does not* work if you don't set the 'environment' option. + # https://github.com/airbrake/airbrake-ruby#ignore_environments + c.ignore_environments = %w(test) + + # A list of parameters that should be filtered out of what is sent to + # Airbrake. By default, all "password" attributes will have their contents + # replaced. + # https://github.com/airbrake/airbrake-ruby#blacklist_keys + c.blacklist_keys = [/password/i] +end + +# If Airbrake doesn't send any expected exceptions, we suggest to uncomment the +# line below. It might simplify debugging of background Airbrake workers, which +# can silently die. +# Thread.abort_on_exception = ['test', 'development'].include?(Rails.env) diff --git a/no_light_sinatra.rb b/no_light_sinatra.rb index 0f65f37..e68750d 100644 --- a/no_light_sinatra.rb +++ b/no_light_sinatra.rb @@ -3,6 +3,8 @@ class NoLightSinatra < Sinatra::Base set public_folder: 'public', static: true + use Airbrake::Sinatra + configure do DEFAULT_BRANDING = 'dell' ENVIRONMENTS = {