Skip to content

Instantly share code, notes, and snippets.

@shedd
Created August 22, 2011 13:56
Show Gist options
  • Save shedd/1162432 to your computer and use it in GitHub Desktop.
Save shedd/1162432 to your computer and use it in GitHub Desktop.
Wrap New Relic Instrumentation around Hoptoad Rake wrapper
# 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