Skip to content

Commit

Permalink
Resque instrumentation now uses the resque-multi-job-forks plugin whe…
Browse files Browse the repository at this point in the history
…n available
  • Loading branch information
staugaard committed Apr 6, 2010
1 parent 9b64688 commit db190c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Version 1.0.7

Resque instrumentation now supports the resque-multi-job-forks plugin

* Version 1.0.6

Update newrelic dependency: depends on 2.11.1
Expand Down
38 changes: 16 additions & 22 deletions lib/rpm_contrib/instrumentation/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@
module RPMContrib
module Instrumentation
module ResqueInstrumentation

::Resque::Worker.class_eval do
::Resque::Job.class_eval do
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
old_process_method = instance_method(:process)
define_method(:process) do | *args |
if args[0]
class_name = args[0].payload_class.name
else
class_name = 'Resque::Job'
end
name = 'process'

old_perform_method = instance_method(:perform)

define_method(:perform) do
class_name = (payload_class ||self.class).name
NewRelic::Agent.reset_stats if NewRelic::Agent.respond_to? :reset_stats
perform_action_with_newrelic_trace(:name => name, :class_name => class_name,
perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name,
:category => 'OtherTransaction/ResqueJob') do
old_process_method.bind(self).call(*args)
old_perform_method.bind(self).call
end
NewRelic::Agent.shutdown

NewRelic::Agent.shutdown unless defined?(::Resque.before_child_exit)
end

old_work_method = instance_method(:work)

define_method(:work) do | *args |
RAILS_DEFAULT_LOGGER.info "Sarting Resque monitoring"
old_work_method.bind(self).call(*args)
end

if defined?(::Resque.before_child_exit)
::Resque.before_child_exit do |worker|
NewRelic::Agent.shutdown
end
end

end
end
end if defined?(::Resque::Worker) and not NewRelic::Control.instance['disable_resque']

end if defined?(::Resque::Job) and not NewRelic::Control.instance['disable_resque']

0 comments on commit db190c0

Please sign in to comment.