Created
August 22, 2011 13:56
-
-
Save shedd/1162432 to your computer and use it in GitHub Desktop.
Wrap New Relic Instrumentation around Hoptoad Rake wrapper
This file contains 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
# Add New Relic instrumentation | |
# ** define this before the lib/tasks are included | |
def task_with_new_relic_and_hoptoad(options) | |
caller_method = options.keys.first | |
task(options) do | |
require 'newrelic_rpm' | |
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | |
NewRelic::Agent.manual_start | |
perform_action_with_newrelic_trace :name=> caller_method.to_s, :category=>:task, :force => true do | |
begin | |
yield | |
rescue Exception => msg | |
require 'config/initializers/hoptoad' | |
HoptoadNotifier.notify(msg) | |
end | |
end | |
NewRelic::Agent.shutdown | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment