wireframe-rpm_contrib 1.0.12.3 → 1.0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,4 +1,4 @@
1
- * Version 1.0.12.3
1
+ * Version 1.0.12.4
2
2
 
3
3
  Add backgrounded resque support
4
4
 
@@ -13,15 +13,35 @@ module RPMContrib
13
13
  old_perform_method = instance_method(:perform)
14
14
 
15
15
  define_method(:perform) do
16
- class_name = (payload_class ||self.class).name
17
16
  NewRelic::Agent.reset_stats if NewRelic::Agent.respond_to? :reset_stats
18
- perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name,
19
- :category => 'OtherTransaction/ResqueJob') do
17
+ perform_action_with_newrelic_trace(trace_options) do
20
18
  old_perform_method.bind(self).call
21
19
  end
22
20
 
23
21
  NewRelic::Agent.shutdown unless defined?(::Resque.before_child_exit)
24
22
  end
23
+
24
+ private
25
+ def backgrounded_job?
26
+ if defined?(::Backgrounded::Handler::ResqueHandler) && self.is_a?(::Backgrounded::Handler::ResqueHandler)
27
+ end
28
+ def trace_options
29
+ if backgrounded_job?
30
+ {
31
+ :class_name => args[0],
32
+ :name => args[2].to_s,
33
+ :params => @payload,
34
+ :category => 'OtherTransaction/BackgroundedResqueJob'
35
+ }
36
+ else
37
+ class_name = (payload_class ||self.class).name
38
+ {
39
+ :class_name => class_name,
40
+ :name => 'perform',
41
+ :category => 'OtherTransaction/ResqueJob'
42
+ }
43
+ end
44
+ end
25
45
  end
26
46
 
27
47
  if defined?(::Resque.before_child_exit)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wireframe-rpm_contrib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 105
4
+ hash: 103
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 12
10
- - 3
11
- version: 1.0.12.3
10
+ - 4
11
+ version: 1.0.12.4
12
12
  platform: ruby
13
13
  authors:
14
14
  - Bill Kayser
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-02 00:00:00 -05:00
19
+ date: 2010-10-03 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -55,11 +55,9 @@ files:
55
55
  - Rakefile
56
56
  - lib/new_relic/control/camping.rb
57
57
  - lib/rpm_contrib.rb
58
- - lib/rpm_contrib/detection/backgrounded_resque.rb
59
58
  - lib/rpm_contrib/detection/camping.rb
60
59
  - lib/rpm_contrib/detection/resque.rb
61
60
  - lib/rpm_contrib/instrumentation/aws/s3.rb
62
- - lib/rpm_contrib/instrumentation/backgrounded_resque.rb
63
61
  - lib/rpm_contrib/instrumentation/camping.rb
64
62
  - lib/rpm_contrib/instrumentation/cassandra.rb
65
63
  - lib/rpm_contrib/instrumentation/mongo_mapper.rb
@@ -1,15 +0,0 @@
1
- # Detect when running backgrounded with resque and set the framework and dispatcher.
2
-
3
- module NewRelic
4
- class LocalEnvironment
5
- module BackgroundedResque
6
- def discover_dispatcher
7
- super
8
- if defined?(::Backgrounded::Handler::ResqueHandler) && @dispatcher.nil?
9
- @dispatcher = 'backgrounded_resque'
10
- end
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,38 +0,0 @@
1
-
2
- module RPMContrib
3
- module Instrumentation
4
- # == Backgrounded Resque Instrumentation
5
- #
6
- # Installs a hook to ensure the agent starts manually when the worker
7
- # starts and also adds the tracer to the process method which executes
8
- # in the forked task.
9
- module BackgroundedResqueInstrumentation
10
- ::Resque::Job.class_eval do
11
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
12
-
13
- old_perform_method = instance_method(:perform)
14
-
15
- define_method(:perform) do
16
- options = {
17
- :class_name => args[0],
18
- :name => args[2].to_s,
19
- :params => {:id => args[1]},
20
- :category => 'OtherTransaction/BackgroundedResqueJob'
21
- }
22
- NewRelic::Agent.reset_stats if NewRelic::Agent.respond_to? :reset_stats
23
- perform_action_with_newrelic_trace(options) do
24
- old_perform_method.bind(self).call
25
- end
26
-
27
- NewRelic::Agent.shutdown unless defined?(::Resque.before_child_exit)
28
- end
29
- end
30
-
31
- if defined?(::Resque.before_child_exit)
32
- ::Resque.before_child_exit do |worker|
33
- NewRelic::Agent.shutdown
34
- end
35
- end
36
- end
37
- end
38
- end if defined?(::Backgrounded::Handler::ResqueHandler) and not NewRelic::Control.instance['disable_backgrounded_resque']