Last active
December 15, 2015 01:09
-
-
Save netshade/5177697 to your computer and use it in GitHub Desktop.
Capture Exceptions with Instrumental (tested in Rails 3.2.11)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/instrumental/exception_reporter_middleware.rb | |
module Instrumental | |
class ExceptionReporterMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
@app.call(env) | |
rescue Exception => e | |
I.increment("app.exception.#{e.class.name}") | |
Rails.logger.debug "Notifying Instrumental of #{e.class.name} exception..." | |
raise | |
end | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/instrumental.rb | |
require 'instrumental/exception_reporter_middleware' | |
I = Instrumental::Agent.new("MY_API_TOKEN") | |
Rails.application.config.middleware.use Instrumental::ExceptionReporterMiddleware |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment