Skip to content

Commit

Permalink
Try out exception notification gem
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Oct 25, 2015
1 parent fb67692 commit d6af0b6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ gem 'newrelic_rpm', group: [:production, :staging]
gem 'rack-mini-profiler'
gem 'lograge'
gem 'multi_logger'
gem 'exception_notification'

# ---------- API ----------

Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ GEM
activesupport (>= 3.2)
erubis (2.7.0)
eventmachine (1.0.4)
exception_notification (4.1.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
execjs (2.2.2)
eye (0.6.4)
celluloid (~> 0.15.0)
Expand Down Expand Up @@ -697,6 +700,7 @@ DEPENDENCIES
devise
email_spec
enumerize (>= 0.5.1)
exception_notification
eye
factory_girl_rails
fakeredis
Expand Down
6 changes: 2 additions & 4 deletions app/objects/service/fastbill_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def fastbill_create_customer
attributes[:customer_number] = @seller.id
customer = Fastbill::Automatic::Customer.create(attributes)
@seller.update_attribute :fastbill_id, customer.customer_id
Rails.logger.fastbill.info { "Fastbill profile created for user #{@seller.id}" }
rescue => e
Rails.logger.fastbill.error { "Fastbill profile creation failed for user #{@seller.id}\n#{e.inspect} #{e.backtrace}" }
ExceptionNotifier.notify_exception(e, data: { user: @seller.id })
end
end
end
Expand Down Expand Up @@ -115,9 +114,8 @@ def fastbill_create_subscription
)
@bt.send("billed_for_#{ type }=", true)
@bt.save
Rails.logger.fastbill.info { "Fastbill usage data sent for business transaction #{@bt.id}" }
rescue => e
Rails.logger.fastbill.error { "Fastbill usage data failed for business transaction #{@bt.id}\n#{e.inspect} #{e.backtrace}" }
ExceptionNotifier.notify_exception(e, data: { business_transaction: @bt.id })
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@
#Memcached
config.cache_store = :dalli_store, 'localhost', { :namespace => "fairmondo", :expires_in => 1.day, :compress => true }

config.middleware.use ExceptionNotification::Rack,
ignore_crawlers: %w{Googlebot bingbot},
email: {
email_prefix: '[Staging] ',
sender_address: %{"Exception notifier" <notifier@fairmondo.de>},
exception_recipients: %w{exceptions@fairmondo.de}
}
end
4 changes: 2 additions & 2 deletions test/objects/fastbill_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
db_business_transaction # to trigger observers before
api = FastbillAPI.new db_business_transaction
Fastbill::Automatic::Customer.stub :create, -> (_arg) { raise StandardError.new } do
Rails.logger.fastbill.expects(:error)
ExceptionNotifier.expects(:notify_exception)
api.fastbill_chain
end
end
Expand All @@ -70,7 +70,7 @@
db_business_transaction # to trigger observers before
api = FastbillAPI.new db_business_transaction
Fastbill::Automatic::Subscription.stub :setusagedata, -> (_arg) { raise StandardError.new } do
Rails.logger.fastbill.expects(:error).twice
ExceptionNotifier.expects(:notify_exception).twice
api.fastbill_chain
end
end
Expand Down

0 comments on commit d6af0b6

Please sign in to comment.