Skip to content

Instantly share code, notes, and snippets.

@benweint
Created June 11, 2014 16:54
Show Gist options
  • Save benweint/b890052576e223c08e7a to your computer and use it in GitHub Desktop.
Save benweint/b890052576e223c08e7a to your computer and use it in GitHub Desktop.
Using ControllerInstrumentation without a host class
#!/usr/bin/env ruby
require 'newrelic_rpm'
def do_something
puts 'working!'
sleep(3)
end
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
#
# These options are documented here:
# http://rubydoc.info/github/newrelic/rpm/NewRelic/Agent/Instrumentation/ControllerInstrumentation:perform_action_with_newrelic_trace
#
trace_options = {
:category => :task,
:class_name => 'MyClass',
:name => 'do_something'
}
100.times do
perform_action_with_newrelic_trace(trace_options) do
do_something
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment