rpm_contrib 2.1.3 → 2.1.4.beta

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,3 +1,10 @@
1
+ * Version 2.1.4.beta
2
+
3
+ Updated requirements to latest agent with some bug fixes for background jobs
4
+ Converted instrumentation to install with DependencyDetection in the latest Agent
5
+ Changed Resque instrumentation from a plugin back to method chaining
6
+ Fixed several reported bugs related to resque
7
+
1
8
  * Version 2.1.3
2
9
 
3
10
  Fixed typo in Resque instrumentation
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake'
3
3
  # See http://www.rubygems.org/read/chapter/20
4
4
 
5
5
  def version
6
- @rpm_contrib_version ||= File.read("CHANGELOG")[/Version ([\d\.]+)$/, 1]
6
+ @rpm_contrib_version ||= File.read("CHANGELOG")[/Version ([\d\.]+\w*)$/, 1]
7
7
  end
8
8
 
9
9
  RDOC_FILES = FileList['README*','LICENSE','CHANGELOG']
@@ -22,7 +22,7 @@ begin
22
22
  gem.email = "support@newrelic.com"
23
23
  gem.homepage = "http://github.com/newrelic/rpm_contrib"
24
24
  gem.author = "Bill Kayser"
25
- gem.add_dependency 'newrelic_rpm', '>=3.0.0'
25
+ gem.add_dependency 'newrelic_rpm', '>=3.1.1'
26
26
  gem.version = version
27
27
  gem.files = FileList['LICENSE', 'README*', 'lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
28
28
  gem.rdoc_options <<
@@ -1,6 +1,6 @@
1
1
  module NewRelic #:nodoc:
2
2
  # The class defined in the
3
- # newrelic_rpm[http://newrelic.github.com/rpm] which can be ammended
3
+ # newrelic_rpm[http://newrelic.github.com/rpm] which can be amended
4
4
  # to support new frameworks by defining modules in this namespace.
5
5
  class LocalEnvironment #:nodoc:
6
6
  module Camping
@@ -2,15 +2,15 @@
2
2
  # Robert R. Meyer
3
3
  # Blue-Dog-Archolite @ GitHub
4
4
 
5
- module RpmContrib
6
- module Instrumentation
7
- module ActiveMessaging
8
- if defined?(::ActiveMessaging::Processor) and not NewRelic::Control.instance['disable_active_mq']
9
- ::ActiveMessaging::Processor.class_eval do
10
- class << self
11
- add_method_tracer :on_message, 'ActiveMessaging/OnMessage'
12
- end
13
- end
5
+ DependencyDetection.defer do
6
+ depends_on do
7
+ defined?(::ActiveMessaging::Processor) && !NewRelic::Control.instance['disable_active_mq']
8
+ end
9
+
10
+ executes do
11
+ ::ActiveMessaging::Processor.class_eval do
12
+ class << self
13
+ add_method_tracer :on_message, 'ActiveMessaging/OnMessage'
14
14
  end
15
15
  end
16
16
  end
@@ -1,6 +1,63 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Aws
1
+ # AWS Instrumentation by Brian Doll of New Relic
2
+ DependencyDetection.defer do
3
+
4
+ depends_on do
5
+ defined?(::AWS::S3) && !NewRelic::Control.instance['disable_aws-s3']
6
+ end
7
+
8
+ executes do
9
+
10
+ # Instrument connections to the AWS-S3 service
11
+ ::AWS::S3::Connection::Management::ClassMethods.module_eval do
12
+ add_method_tracer :establish_connection!, 'AWS-S3/establish_connection!'
13
+ end
14
+
15
+ # Instrument methods on Bucket
16
+ ::AWS::S3::Bucket.instance_eval do
17
+ class << self
18
+ add_method_tracer :create, 'AWS-S3/Bucket/create'
19
+ add_method_tracer :find, 'AWS-S3/Bucket/find'
20
+ add_method_tracer :objects, 'AWS-S3/Bucket/objects'
21
+ add_method_tracer :delete, 'AWS-S3/Bucket/delete'
22
+ add_method_tracer :list, 'AWS-S3/Bucket/list'
23
+ end
24
+ end
25
+
26
+ # Instrument methods on Bucket instances
27
+ ::AWS::S3::Bucket.class_eval do
28
+ add_method_tracer :[], 'AWS-S3/Bucket/#{self.name}/[]'
29
+ add_method_tracer :new_object,'AWS-S3/Bucket/#{self.name}/new_objects'
30
+ add_method_tracer :objects, 'AWS-S3/Bucket/#{self.name}/objects'
31
+ add_method_tracer :delete, 'AWS-S3/Bucket/#{self.name}/delete'
32
+ add_method_tracer :delete_all,'AWS-S3/Bucket/#{self.name}/delete_all'
33
+ add_method_tracer :update, 'AWS-S3/Bucket/#{self.name}/update'
34
+ end
35
+
36
+ # Instrument methods on S3Object
37
+ ::AWS::S3::S3Object.instance_eval do
38
+ class << self
39
+ add_method_tracer :about, 'AWS-S3/S3Object/about'
40
+ add_method_tracer :copy, 'AWS-S3/S3Object/copy'
41
+ add_method_tracer :delete, 'AWS-S3/S3Object/delete'
42
+ add_method_tracer :rename, 'AWS-S3/S3Object/rename'
43
+ add_method_tracer :store, 'AWS-S3/S3Object/store'
44
+ end
45
+ end
46
+
47
+ # Instrument methods on S3Object instances
48
+ # Metric names are aggregated across all S3Objects since having a metric for
49
+ # every single S3Object instance and method pair would be fairly useless
50
+ ::AWS::S3::S3Object.class_eval do
51
+ add_method_tracer :value, 'AWS-S3/S3Objects/value'
52
+ add_method_tracer :about, 'AWS-S3/S3Objects/about'
53
+ add_method_tracer :metadata, 'AWS-S3/S3Objects/metadata'
54
+ add_method_tracer :store, 'AWS-S3/S3Objects/store'
55
+ add_method_tracer :delete, 'AWS-S3/S3Objects/delete'
56
+ add_method_tracer :copy, 'AWS-S3/S3Objects/copy'
57
+ add_method_tracer :rename, 'AWS-S3/S3Objects/rename'
58
+ add_method_tracer :etag, 'AWS-S3/S3Objects/etag'
59
+ add_method_tracer :owner, 'AWS-S3/S3Objects/owner'
4
60
  end
5
61
  end
6
62
  end
63
+
@@ -1,5 +1,3 @@
1
- require 'new_relic/agent/instrumentation/controller_instrumentation'
2
-
3
1
  module RPMContrib
4
2
  module Instrumentation
5
3
  # == Instrumentation for Camping
@@ -20,23 +18,22 @@ module RPMContrib
20
18
  # Camping code example:
21
19
  # -------------------------------------------------------------------------------------
22
20
  #
23
- # require "newrelic_rpm"
21
+ # require "rpm_contrib"
24
22
  #
25
23
  # Camping.goes :NewRelicCampingTest
26
24
  #
27
25
  # module NewRelicCampingTest
28
26
  # # your code
29
27
  #
30
- # include NewRelic::Agent::Instrumentation::Camping
28
+ # include RPMContrib::Instrumentation::Camping
31
29
  #
32
30
  # end
33
31
  #
34
32
  #
35
-
36
33
  module Camping
37
34
 
38
35
  def self.included(mod)
39
-
36
+ require 'new_relic/agent/instrumentation/controller_instrumentation'
40
37
  # Since the Camping::Base module is essentially copied
41
38
  # into the main module (the mod passed in) of a Camping app
42
39
  # using the Camping.goes :NewRelicCampingTest syntax
@@ -1,29 +1,23 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Cassandra
4
- # == Cassandra Instrumentation
5
- #
6
-
7
- if defined?(::Cassandra) and not NewRelic::Control.instance['disable_cassandra_instrumentation']
8
-
9
- ::Cassandra.class_eval do
10
- add_method_tracer :insert, 'Database/Cassandra/insert'
11
- add_method_tracer :remove, 'Database/Cassandra/remove'
12
- add_method_tracer :clear_column_family!, 'Database/Cassandra/clear_column_family!'
13
- add_method_tracer :clear_keyspace!, 'Database/Cassandra/clear_keyspace!'
14
- add_method_tracer :count_columns, 'Database/Cassandra/count_columns'
15
- add_method_tracer :multi_count_columns, 'Database/Cassandra/multi_count_columns'
16
- add_method_tracer :get_columns, 'Database/Cassandra/get_columns'
17
- add_method_tracer :multi_get_columns, 'Database/Cassandra/multi_get_columns'
18
- add_method_tracer :get, 'Database/Cassandra/get'
19
- add_method_tracer :multi_get, 'Database/Cassandra/multi_get'
20
- add_method_tracer :exists?, 'Database/Cassandra/exists?'
21
- add_method_tracer :get_range, 'Database/Cassandra/get_range'
22
- add_method_tracer :count_range, 'Database/Cassandra/count_range'
23
- add_method_tracer :batch, 'Database/Cassandra/batch'
24
- end
25
-
26
- end
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Cassandra) && !NewRelic::Control.instance['disable_cassandra_instrumentation']
4
+ end
5
+ executes do
6
+ ::Cassandra.class_eval do
7
+ add_method_tracer :insert, 'Database/Cassandra/insert'
8
+ add_method_tracer :remove, 'Database/Cassandra/remove'
9
+ add_method_tracer :clear_column_family!, 'Database/Cassandra/clear_column_family!'
10
+ add_method_tracer :clear_keyspace!, 'Database/Cassandra/clear_keyspace!'
11
+ add_method_tracer :count_columns, 'Database/Cassandra/count_columns'
12
+ add_method_tracer :multi_count_columns, 'Database/Cassandra/multi_count_columns'
13
+ add_method_tracer :get_columns, 'Database/Cassandra/get_columns'
14
+ add_method_tracer :multi_get_columns, 'Database/Cassandra/multi_get_columns'
15
+ add_method_tracer :get, 'Database/Cassandra/get'
16
+ add_method_tracer :multi_get, 'Database/Cassandra/multi_get'
17
+ add_method_tracer :exists?, 'Database/Cassandra/exists?'
18
+ add_method_tracer :get_range, 'Database/Cassandra/get_range'
19
+ add_method_tracer :count_range, 'Database/Cassandra/count_range'
20
+ add_method_tracer :batch, 'Database/Cassandra/batch'
27
21
  end
28
22
  end
29
23
  end
@@ -1,25 +1,28 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Crack
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Crack::JSON) && !NewRelic::Control.instance['disable_crack']
4
+ end
4
5
 
5
- if defined?(::Crack) && !NewRelic::Control.instance['disable_crack']
6
- if defined?(::Crack::JSON)
7
- ::Crack::JSON.class_eval do
8
- class << self
9
- include NewRelic::Agent::MethodTracer
10
- add_method_tracer :parse, 'Parser/#{self.name}/parse'
11
- end
12
- end
13
- end
6
+ executes do
7
+ ::Crack::JSON.class_eval do
8
+ class << self
9
+ include NewRelic::Agent::MethodTracer
10
+ add_method_tracer :parse, 'Parser/#{self.name}/parse'
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ DependencyDetection.defer do
17
+ depends_on do
18
+ defined?(::Crack::XML) && !NewRelic::Control.instance['disable_crack']
19
+ end
14
20
 
15
- if defined?(::Crack::XML)
16
- ::Crack::XML.class_eval do
17
- class << self
18
- include NewRelic::Agent::MethodTracer
19
- add_method_tracer :parse, 'Parser/#{self.name}/parse'
20
- end
21
- end
22
- end
21
+ executes do
22
+ ::Crack::XML.class_eval do
23
+ class << self
24
+ include NewRelic::Agent::MethodTracer
25
+ add_method_tracer :parse, 'Parser/#{self.name}/parse'
23
26
  end
24
27
  end
25
28
  end
@@ -1,45 +1,47 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Curl
4
- if defined?(::Curl) and not NewRelic::Control.instance['disable_curb']
5
- ::Curl::Easy.class_eval do
6
- def host
7
- URI.parse(self.url).host
8
- end
1
+ DependencyDetection.defer do
9
2
 
10
- # TODO: http, http_delete, http_get, http_post, http_head, http_put
11
- def perform_with_newrelic_trace(*args, &block)
12
- metrics = ["External/#{host}/Curl::Easy","External/#{host}/all"]
13
- if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
14
- metrics << "External/allWeb"
15
- else
16
- metrics << "External/allOther"
17
- end
18
- self.class.trace_execution_scoped metrics do
19
- perform_without_newrelic_trace(*args, &block)
20
- end
21
- end
22
- alias perform_without_newrelic_trace perform
23
- alias perform perform_with_newrelic_trace
3
+ depends_on do
4
+ defined?(::Curl) and not NewRelic::Control.instance['disable_curb']
5
+ end
6
+
7
+ executes do
8
+ ::Curl::Easy.class_eval do
9
+ def host
10
+ URI.parse(self.url).host
11
+ end
12
+
13
+ # TODO: http, http_delete, http_get, http_post, http_head, http_put
14
+ def perform_with_newrelic_trace(*args, &block)
15
+ metrics = ["External/#{host}/Curl::Easy","External/#{host}/all"]
16
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
17
+ metrics << "External/allWeb"
18
+ else
19
+ metrics << "External/allOther"
20
+ end
21
+ self.class.trace_execution_scoped metrics do
22
+ perform_without_newrelic_trace(*args, &block)
24
23
  end
24
+ end
25
+ alias perform_without_newrelic_trace perform
26
+ alias perform perform_with_newrelic_trace
27
+ end
25
28
 
26
- ::Curl::Multi.class_eval do
27
- # TODO: http
28
- def perform_with_newrelic_trace(*args, &block)
29
- metrics = ["External/Curl::Multi"]
30
- if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
31
- metrics << "External/allWeb"
32
- else
33
- metrics << "External/allOther"
34
- end
35
- self.class.trace_execution_scoped metrics do
36
- perform_without_newrelic_trace(*args, &block)
37
- end
38
- end
39
- alias perform_without_newrelic_trace perform
40
- alias perform perform_with_newrelic_trace
29
+ ::Curl::Multi.class_eval do
30
+ # TODO: http
31
+ def perform_with_newrelic_trace(*args, &block)
32
+ metrics = ["External/Curl::Multi"]
33
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
34
+ metrics << "External/allWeb"
35
+ else
36
+ metrics << "External/allOther"
37
+ end
38
+ self.class.trace_execution_scoped metrics do
39
+ perform_without_newrelic_trace(*args, &block)
41
40
  end
42
41
  end
42
+ alias perform_without_newrelic_trace perform
43
+ alias perform perform_with_newrelic_trace
43
44
  end
44
45
  end
45
46
  end
47
+
@@ -1,23 +1,19 @@
1
1
  # == Elastic Search Instrumentation
2
2
  #
3
+ DependencyDetection.defer do
4
+ depends_on do
5
+ defined?(::ElasticSearch::Client) && !NewRelic::Control.instance['disable_elastic_search_instrumentation']
6
+ end
3
7
 
4
- module RpmContrib
5
- module Instrumentation
6
- module ElasticSearch
7
-
8
- if defined?(::ElasticSearch) and not NewRelic::Control.instance['disable_elastic_search_instrumentation']
9
-
10
- ::ElasticSearch::Client.class_eval do
11
- add_method_tracer :index, 'ActiveRecord/ElasticSearch/index'
12
- add_method_tracer :get, 'ActiveRecord/ElasticSearch/get'
13
- add_method_tracer :delete, 'ActiveRecord/ElasticSearch/delete'
14
- add_method_tracer :search, 'ActiveRecord/ElasticSearch/search'
15
- add_method_tracer :scroll, 'ActiveRecord/ElasticSearch/scroll'
16
- add_method_tracer :count, 'ActiveRecord/ElasticSearch/count'
17
- add_method_tracer :bulk, 'ActiveRecord/ElasticSearch/bulk'
18
- end
19
-
20
- end
8
+ executes do
9
+ ::ElasticSearch::Client.class_eval do
10
+ add_method_tracer :index, 'ActiveRecord/ElasticSearch/index'
11
+ add_method_tracer :get, 'ActiveRecord/ElasticSearch/get'
12
+ add_method_tracer :delete, 'ActiveRecord/ElasticSearch/delete'
13
+ add_method_tracer :search, 'ActiveRecord/ElasticSearch/search'
14
+ add_method_tracer :scroll, 'ActiveRecord/ElasticSearch/scroll'
15
+ add_method_tracer :count, 'ActiveRecord/ElasticSearch/count'
16
+ add_method_tracer :bulk, 'ActiveRecord/ElasticSearch/bulk'
21
17
  end
22
18
  end
23
19
  end
@@ -1,47 +1,47 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Mongo
4
- # Mongo Instrumentation contributed by Alexey Palazhchenko
5
-
6
- if defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
7
- ::Mongo::Connection.class_eval do
8
- include NewRelic::Agent::MethodTracer
9
-
10
- def instrument_with_newrelic_trace(name, payload = {}, &blk)
11
- collection = payload[:collection]
12
- if collection == '$cmd'
13
- f = payload[:selector].first
14
- name, collection = f if f
15
- end
16
-
17
- trace_execution_scoped("Database/#{collection}/#{name}") do
18
- t0 = Time.now
19
- res = instrument_without_newrelic_trace(name, payload, &blk)
20
- NewRelic::Agent.instance.transaction_sampler.notice_sql(payload.inspect, nil, (Time.now - t0).to_f)
21
- res
22
- end
23
- end
24
-
25
- alias_method :instrument_without_newrelic_trace, :instrument
26
- alias_method :instrument, :instrument_with_newrelic_trace
1
+ # Mongo Instrumentation contributed by Alexey Palazhchenko
2
+ DependencyDetection.defer do
3
+
4
+ depends_on do
5
+ defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
6
+ end
7
+
8
+ executes do
9
+ ::Mongo::Connection.class_eval do
10
+ include NewRelic::Agent::MethodTracer
11
+
12
+ def instrument_with_newrelic_trace(name, payload = {}, &blk)
13
+ collection = payload[:collection]
14
+ if collection == '$cmd'
15
+ f = payload[:selector].first
16
+ name, collection = f if f
27
17
  end
28
18
 
29
- ::Mongo::Cursor.class_eval do
30
- include NewRelic::Agent::MethodTracer
19
+ trace_execution_scoped("Database/#{collection}/#{name}") do
20
+ t0 = Time.now
21
+ res = instrument_without_newrelic_trace(name, payload, &blk)
22
+ NewRelic::Agent.instance.transaction_sampler.notice_sql(payload.inspect, nil, (Time.now - t0).to_f)
23
+ res
24
+ end
25
+ end
26
+
27
+ alias_method :instrument_without_newrelic_trace, :instrument
28
+ alias_method :instrument, :instrument_with_newrelic_trace
29
+ end
31
30
 
32
- def refresh_with_newrelic_trace
33
- return if send_initial_query || @cursor_id.zero? # don't double report the initial query
31
+ ::Mongo::Cursor.class_eval do
32
+ include NewRelic::Agent::MethodTracer
34
33
 
35
- trace_execution_scoped("Database/#{collection.name}/refresh") do
36
- refresh_without_newrelic_trace
37
- end
38
- end
34
+ def refresh_with_newrelic_trace
35
+ return if send_initial_query || @cursor_id.zero? # don't double report the initial query
39
36
 
40
- alias_method :refresh_without_newrelic_trace, :refresh
41
- alias_method :refresh, :refresh_with_newrelic_trace
42
- add_method_tracer :close, 'Database/#{collection.name}/close'
37
+ trace_execution_scoped("Database/#{collection.name}/refresh") do
38
+ refresh_without_newrelic_trace
43
39
  end
44
40
  end
41
+ alias_method :refresh_without_newrelic_trace, :refresh
42
+ alias_method :refresh, :refresh_with_newrelic_trace
43
+ add_method_tracer :close, 'Database/#{collection.name}/close'
45
44
  end
46
45
  end
46
+
47
47
  end
@@ -1,28 +1,23 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Paperclip
4
- # Paperclip Instrumentation.
5
-
6
- if defined?(::Paperclip) && !NewRelic::Control.instance['disable_paperclip']
7
-
8
- ::Paperclip::Attachment.class_eval do
9
- add_method_tracer :save, 'Paperclip/#{name}/save'
10
- add_method_tracer :assign, 'Paperclip/#{name}/assign'
11
- add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
12
- end
13
-
14
- ::Paperclip::Storage::Filesystem.class_eval do
15
- add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
16
- add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
17
- end
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Paperclip) && !NewRelic::Control.instance['disable_paperclip']
4
+ end
18
5
 
19
- ::Paperclip::Storage::S3.class_eval do
20
- add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
21
- add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
22
- end
6
+ executes do
7
+ ::Paperclip::Attachment.class_eval do
8
+ add_method_tracer :save, 'Paperclip/#{name}/save'
9
+ add_method_tracer :assign, 'Paperclip/#{name}/assign'
10
+ add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
11
+ end
23
12
 
24
- end
13
+ ::Paperclip::Storage::Filesystem.class_eval do
14
+ add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
15
+ add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
16
+ end
25
17
 
18
+ ::Paperclip::Storage::S3.class_eval do
19
+ add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
20
+ add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
26
21
  end
27
22
  end
28
23
  end
@@ -1,39 +1,37 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Redis
4
- # Redis instrumentation contributed by Ashley Martens of ngmoco
5
- #
1
+ # Redis instrumentation contributed by Ashley Martens of ngmoco
2
+ #
3
+ DependencyDetection.defer do
6
4
 
7
- if defined?(::Redis) and not NewRelic::Control.instance['disable_redis']
8
-
9
-
10
- ::Redis::Client.class_eval do
11
-
12
- include NewRelic::Agent::MethodTracer
5
+ depends_on do
6
+ defined?(::Redis) && !NewRelic::Control.instance['disable_redis']
7
+ end
13
8
 
14
- def self.redis_call_method
15
- ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
16
- end
9
+ executes do
10
+ ::Redis::Client.class_eval do
17
11
 
12
+ include NewRelic::Agent::MethodTracer
18
13
 
19
- def raw_call_command_with_newrelic_trace *args
20
- method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
21
- metrics = ["Database/Redis/#{method_name}",
22
- (NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Database/Redis/allWeb' : 'Database/Redis/allOther')]
23
- self.class.trace_execution_scoped(metrics) do
24
- # NewRelic::Control.instance.log.debug("Instrumenting Redis Call[#{method_name}]: #{args[0].inspect}")
25
- raw_call_command_without_newrelic_trace(*args)
26
- end
27
- end
14
+ def self.redis_call_method
15
+ ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
16
+ end
28
17
 
29
- alias_method :raw_call_command_without_newrelic_trace, redis_call_method
30
- alias_method redis_call_method, :raw_call_command_with_newrelic_trace
31
18
 
19
+ def raw_call_command_with_newrelic_trace *args
20
+ method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
21
+ metrics = ["Database/Redis/#{method_name}",
22
+ (NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Database/Redis/allWeb' : 'Database/Redis/allOther')]
23
+ self.class.trace_execution_scoped(metrics) do
24
+ # NewRelic::Control.instance.log.debug("Instrumenting Redis Call[#{method_name}]: #{args[0].inspect}")
25
+ raw_call_command_without_newrelic_trace(*args)
32
26
  end
27
+ end
33
28
 
29
+ alias_method :raw_call_command_without_newrelic_trace, redis_call_method
30
+ alias_method redis_call_method, :raw_call_command_with_newrelic_trace
34
31
 
35
-
36
- end
37
32
  end
38
33
  end
39
34
  end
35
+
36
+
37
+
@@ -1,34 +1,64 @@
1
- module Resque
2
- module Plugins
3
- module NewRelicInstrumentation
4
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
5
-
6
- def around_perform_with_monitoring(*args)
7
- perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name, :category => 'OtherTransaction/ResqueJob') do
8
- yield(*args)
9
- end
10
-
11
- NewRelic::Agent.shutdown
12
- end
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Resque)
4
+ end
5
+ executes do
6
+ module Resque::Plugins
7
+ # The plugin definition is a no-op but left in empty for backward compatibility.
8
+ # We were using the plugin to install instrumentation but it required you either
9
+ # extend Resque::Job or extend this module. Using the method chaining approach
10
+ # means you don't have to make any modifications to your job classes.
11
+ module NewRelicInstrumentation; end
13
12
  end
14
13
  end
15
14
  end
16
15
 
17
- module RPMContrib
18
- module Instrumentation
19
- module Resque
20
- ::Resque.before_first_fork do
21
- NewRelic::Agent.manual_start(:dispatcher => :resque)
22
- end
16
+ DependencyDetection.defer do
17
+ depends_on do
18
+ defined?(::Resque::Job) and not NewRelic::Control.instance['disable_resque']
19
+ end
20
+
21
+ executes do
22
+ # == Resque Instrumentation
23
+ #
24
+ # Installs a hook to ensure the agent starts manually when the worker
25
+ # starts and also adds the tracer to the process method which executes
26
+ # in the forked task.
23
27
 
24
- ::Resque.after_fork do
25
- NewRelic::Agent.after_fork(:force_reconnect => false)
28
+ # Resque also works in a non forking mode when fork is not supported
29
+ begin
30
+ # IronRuby/JRuby don't support `Kernel.fork` yet
31
+ if Kernel.respond_to?(:fork)
32
+ Kernel.fork{exit!}
33
+ else
34
+ raise NotImplementedError
26
35
  end
36
+ rescue NotImplementedError
37
+ $rpm_cant_fork = true
38
+ end
27
39
 
28
- ::Resque::Job.class_eval do
29
- extend ::Resque::Plugins::NewRelicInstrumentation
40
+ ::Resque::Job.class_eval do
41
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
42
+ old_perform_method = instance_method(:perform)
43
+ define_method(:perform) do
44
+ class_name = (payload_class ||self.class).name
45
+ perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name,
46
+ :category => 'OtherTransaction/ResqueJob') do
47
+ old_perform_method.bind(self).call
48
+ end
49
+ # If we aren't doing true forks, then the shutdown message would end up
50
+ # shutting down the agent in the parent which would cause us to stop sending
51
+ # data. Data is not sent from the child.
52
+ NewRelic::Agent.shutdown unless $rpm_cant_fork
30
53
  end
31
54
  end
32
- end
33
- end if defined?(::Resque) and not NewRelic::Control.instance['disable_resque']
34
55
 
56
+ ::Resque.before_first_fork do
57
+ NewRelic::Agent.manual_start(:dispatcher => :resque)
58
+ end
59
+
60
+ ::Resque.after_fork do
61
+ NewRelic::Agent.after_fork(:force_reconnect => false)
62
+ end
63
+ end
64
+ end
@@ -1,27 +1,24 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Sinatra
4
- if defined?(::Sinatra::Base) and not NewRelic::Control.instance['disable_sinatra_template']
5
- module ::Sinatra
6
- Base.class_eval do
7
- def render_with_newrelic_trace(*args, &block)
8
- engine, file = *args
9
- return render_without_newrelic_trace(*args, &block) if file == "= yield"
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Sinatra::Base) and not NewRelic::Control.instance['disable_sinatra_template']
4
+ end
10
5
 
11
- file = "Proc" if file.is_a?(Proc)
12
- metrics = ["Sinatra/#{engine}/#{file}"]
6
+ executes do
7
+ ::Sinatra::Base.class_eval do
8
+ def render_with_newrelic_trace(*args, &block)
9
+ engine, file = *args
10
+ return render_without_newrelic_trace(*args, &block) if file == "= yield"
13
11
 
14
- self.class.trace_execution_scoped metrics do
15
- render_without_newrelic_trace(*args, &block)
16
- end
17
- end
12
+ file = "Proc" if file.is_a?(Proc)
13
+ metrics = ["Sinatra/#{engine}/#{file}"]
18
14
 
19
- alias render_without_newrelic_trace render
20
- alias render render_with_newrelic_trace
21
- end
15
+ self.class.trace_execution_scoped metrics do
16
+ render_without_newrelic_trace(*args, &block)
22
17
  end
23
18
  end
19
+
20
+ alias render_without_newrelic_trace render
21
+ alias render render_with_newrelic_trace
24
22
  end
25
23
  end
26
24
  end
27
-
@@ -1,28 +1,28 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Typhoeus
4
- if defined?(::Typhoeus) and not ::NewRelic::Control.instance['disable_typhoeus']
5
- require 'uri'
6
- module ::Typhoeus
7
- Request.instance_eval do
8
- def get_with_newrelic_trace(*args, &block)
9
- uri = URI.parse(args.first)
10
- metrics = ["External/#{uri.host}/Typhoeus/GET","External/#{uri.host}/all"]
11
- if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
12
- metrics << "External/allWeb"
13
- else
14
- metrics << "External/allOther"
15
- end
16
- self.class.trace_execution_scoped metrics do
17
- get_without_newrelic_trace(*args, &block)
18
- end
19
- end
20
- alias get_without_newrelic_trace get
21
- alias get get_with_newrelic_trace
22
- end
1
+ DependencyDetection.defer do
2
+
3
+ depends_on do
4
+ defined?(::Typhoeus) and not ::NewRelic::Control.instance['disable_typhoeus']
5
+ end
6
+
7
+ executes do
8
+ require 'uri'
9
+ ::Typhoeus::Request.instance_eval do
10
+ def get_with_newrelic_trace(*args, &block)
11
+ uri = URI.parse(args.first)
12
+ metrics = ["External/#{uri.host}/Typhoeus/GET","External/#{uri.host}/all"]
13
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
14
+ metrics << "External/allWeb"
15
+ else
16
+ metrics << "External/allOther"
17
+ end
18
+ self.class.trace_execution_scoped metrics do
19
+ get_without_newrelic_trace(*args, &block)
23
20
  end
24
21
  end
22
+ alias get_without_newrelic_trace get
23
+ alias get get_with_newrelic_trace
25
24
  end
26
25
  end
27
26
  end
28
27
 
28
+
@@ -1,18 +1,17 @@
1
- require 'new_relic/agent/method_tracer'
1
+ DependencyDetection.defer do
2
2
 
3
- module RpmContrib
4
- module Instrumentation
5
- module UltraSphinx
6
- if defined?(::UltraSphinx) and not ::NewRelic::Control.instance['disable_ultrasphinx']
7
- module ::Ultrasphinx
8
- class Search
9
- include NewRelic::Agent::MethodTracer
3
+ depends_on do
4
+ defined?(::UltraSphinx) and not ::NewRelic::Control.instance['disable_ultrasphinx']
5
+ end
6
+
7
+ executes do
8
+ class ::Ultrasphinx::Search
9
+ include NewRelic::Agent::MethodTracer
10
10
 
11
- add_method_tracer :run
12
- add_method_tracer :results
13
- end
14
- end
15
- end
11
+ add_method_tracer :run
12
+ add_method_tracer :results
16
13
  end
17
14
  end
18
15
  end
16
+
17
+
@@ -1,21 +1,23 @@
1
1
  # Workling instrumentation contributed by Chad Ingram of Aurora Feint
2
2
  #
3
- module RpmContrib
4
- module Instrumentation
5
- module Workling
6
- if defined?(::Workling) and not ::NewRelic::Control.instance['disable_workling']
7
- ::Workling::Base.class_eval do
8
- include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
- end
3
+ DependencyDetection.defer do
10
4
 
11
- ::Workling::Discovery.discovered.each do |clazz|
12
- (clazz.public_instance_methods - ::Workling::Base.public_instance_methods).each do |method|
13
- puts "added method tracer Workling/#{clazz.name}/#{method}"
14
- clazz.send(:add_method_tracer, method, "Workling/#{clazz.name}/#{method}", :category => :task)
15
- end
16
- end
5
+ depends_on do
6
+ defined?(::Workling) and not ::NewRelic::Control.instance['disable_workling']
7
+ end
8
+
9
+ executes do
10
+
11
+ ::Workling::Base.class_eval do
12
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
13
+ end
14
+
15
+ ::Workling::Discovery.discovered.each do |clazz|
16
+ (clazz.public_instance_methods - ::Workling::Base.public_instance_methods).each do |method|
17
+ puts "added method tracer Workling/#{clazz.name}/#{method}"
18
+ clazz.send(:add_method_tracer, method, "Workling/#{clazz.name}/#{method}", :category => :task)
17
19
  end
18
20
  end
19
21
  end
20
- end
21
22
 
23
+ end
@@ -1,15 +1,14 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Yajl
4
- if defined?(::Yajl::Encoder) and not ::NewRelic::Control.instance['disable_yajl_instrumentation']
5
- ::Yajl::Encoder.class_eval do
6
- class << self
7
- include ::NewRelic::Agent::MethodTracer
8
- add_method_tracer :parse, 'Encoder/Yajl/encode'
9
- end
10
- end
1
+ DependencyDetection.defer do
2
+ depends_on do
3
+ defined?(::Yajl::Encoder) and not ::NewRelic::Control.instance['disable_yajl_instrumentation']
4
+ end
5
+
6
+ executes do
7
+ ::Yajl::Encoder.class_eval do
8
+ class << self
9
+ include ::NewRelic::Agent::MethodTracer
10
+ add_method_tracer :parse, 'Encoder/Yajl/encode'
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
-
@@ -1,22 +1,16 @@
1
- require 'rpm_contrib/instrumentation/active_mq'
2
- require 'rpm_contrib/instrumentation/aws'
3
- require 'rpm_contrib/instrumentation/camping'
4
- require 'rpm_contrib/instrumentation/cassandra'
5
- require 'rpm_contrib/instrumentation/crack'
6
- require 'rpm_contrib/instrumentation/curb'
7
- require 'rpm_contrib/instrumentation/elastic_search'
8
- require 'rpm_contrib/instrumentation/mongo'
9
- require 'rpm_contrib/instrumentation/paperclip'
10
- require 'rpm_contrib/instrumentation/redis'
11
- require 'rpm_contrib/instrumentation/resque'
12
- require 'rpm_contrib/instrumentation/sinatra'
13
- require 'rpm_contrib/instrumentation/typhoeus'
14
- require 'rpm_contrib/instrumentation/ultrasphinx'
15
- require 'rpm_contrib/instrumentation/workling'
16
- require 'rpm_contrib/instrumentation/yajl'
17
-
18
-
1
+ require 'newrelic_rpm'
19
2
  module RpmContrib
3
+ # Contributed instrumentation files for use with newrelic_rpm gem
20
4
  module Instrumentation
21
5
  end
22
6
  end
7
+
8
+ pattern = File.expand_path "../instrumentation/**/*.rb", __FILE__
9
+ Dir.glob pattern do |file|
10
+ begin
11
+ require file.to_s
12
+ rescue Exception => e
13
+ NewRelic::Agent.logger.error "Skipping instrumentation file '#{file}': #{e}"
14
+ NewRelic::Agent.logger.debug e.backtrace.join("\n")
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module RpmContrib
2
+ # Samplers are subclasses of NewRelic::Agent::Sampler which periodically collect metric data in a
3
+ # background thread. Sampler classes belong in the sampler subdirectory and must be loaded before
4
+ # the agent starts.
5
+ module Samplers
6
+ end
7
+ end
8
+
9
+ pattern = File.expand_path "../samplers/**/*.rb", __FILE__
10
+ Dir.glob pattern do |file|
11
+ begin
12
+ require file.to_s
13
+ rescue Exception => e
14
+ NewRelic::Agent.logger.error "Skipping instrumentation file '#{file}': #{e}"
15
+ NewRelic::Agent.logger.debug e.backtrace.join("\n")
16
+ end
17
+ end
data/lib/rpm_contrib.rb CHANGED
@@ -1,39 +1,40 @@
1
1
  RPM_CONTRIB_LIB = File.dirname(__FILE__)
2
2
 
3
- module RPMContrib
4
- VERSION = File.read(RPM_CONTRIB_LIB+"/../CHANGELOG")[/Version ([\d\.]+)$/, 1]
3
+ module RPMContrib; end
5
4
 
6
- def self.init_sequence
7
- Proc.new do
8
- # Tell the agent to load all the files in the
9
- # rpm_contrib/instrumentation directory.
10
- NewRelic::Agent.add_instrumentation(RPM_CONTRIB_LIB+"/rpm_contrib/instrumentation/**/*.rb")
11
-
12
- # Load all the Sampler class definitions. These will register
13
- # automatically with the agent.
14
- Dir.glob(RPM_CONTRIB_LIB + "/rpm_contrib/samplers/**/*.rb") { |file| require file }
15
- end
16
- end
17
-
18
- end
19
5
  # Perform any framework/dispatcher detection before loading the rpm gem.
20
6
  require 'rpm_contrib/detection'
21
- puts "Warning! The rpm_contrib gem should be loaded before the newrelic_rpm gem if you are using Resque or Camping." if defined?(::NewRelic) && defined?(::NewRelic::Control)
7
+ if defined?(::NewRelic) && defined?(::NewRelic::Control)
8
+ puts "Warning! The rpm_contrib gem should be loaded before the newrelic_rpm gem if you are using Resque or Camping."
9
+ end
10
+
22
11
  require 'newrelic_rpm'
12
+ require 'rpm_contrib/instrumentation'
13
+
14
+ # Load all the Sampler class definitions. These will register
15
+ # automatically with the agent.
16
+ require 'rpm_contrib/samplers'
17
+
23
18
  if defined? Rails
24
19
  # Rails 3.x+
25
20
  if Rails.respond_to?(:version) && Rails.version =~ /^3/
26
21
  module NewRelic
27
22
  class Railtie < Rails::Railtie
28
- initializer("rpm_contrib.start_plugin", &RPMContrib.init_sequence)
23
+ initializer("rpm_contrib.start_plugin"){ NewRelic::Control.instance.init_plugin }
29
24
  end
30
25
  end
31
26
  # Rails 2.x
32
27
  elsif defined?(Rails) && Rails.respond_to?(:configuration)
33
- Rails.configuration.after_initialize &RPMContrib.init_sequence
28
+
29
+ Rails.configuration.after_initialize { NewRelic::Control.instance.init_plugin }
34
30
  else
35
31
  raise "The rpm_contrib gem supports Rails 2.2+ only."
36
32
  end
37
33
  else
38
- RPMContrib.init_sequence.call
34
+ # If not running Rails, it is important that you load the contrib gem as late
35
+ # as possible so the agent initializes after everything else. Either that
36
+ # or make the following call yourself at the end of your startup sequence
37
+ # (it is idempotent).
38
+ NewRelic::Control.instance.init_plugin
39
39
  end
40
+
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpm_contrib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease:
4
+ hash: 31098233
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 3
10
- version: 2.1.3
9
+ - 4
10
+ - beta
11
+ version: 2.1.4.beta
11
12
  platform: ruby
12
13
  authors:
13
14
  - Bill Kayser
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-06-14 00:00:00 -07:00
19
+ date: 2011-08-01 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -26,12 +27,12 @@ dependencies:
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
29
- hash: 7
30
+ hash: 1
30
31
  segments:
31
32
  - 3
32
- - 0
33
- - 0
34
- version: 3.0.0
33
+ - 1
34
+ - 1
35
+ version: 3.1.1
35
36
  type: :runtime
36
37
  version_requirements: *id001
37
38
  description: |
@@ -60,7 +61,6 @@ files:
60
61
  - lib/rpm_contrib/instrumentation.rb
61
62
  - lib/rpm_contrib/instrumentation/active_mq.rb
62
63
  - lib/rpm_contrib/instrumentation/aws.rb
63
- - lib/rpm_contrib/instrumentation/aws/s3.rb
64
64
  - lib/rpm_contrib/instrumentation/camping.rb
65
65
  - lib/rpm_contrib/instrumentation/cassandra.rb
66
66
  - lib/rpm_contrib/instrumentation/crack.rb
@@ -75,6 +75,7 @@ files:
75
75
  - lib/rpm_contrib/instrumentation/ultrasphinx.rb
76
76
  - lib/rpm_contrib/instrumentation/workling.rb
77
77
  - lib/rpm_contrib/instrumentation/yajl.rb
78
+ - lib/rpm_contrib/samplers.rb
78
79
  - test/helper.rb
79
80
  - test/schema.rb
80
81
  - test/test_curb.rb
@@ -106,22 +107,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  none: false
108
109
  requirements:
109
- - - ">="
110
+ - - ">"
110
111
  - !ruby/object:Gem::Version
111
- hash: 3
112
+ hash: 25
112
113
  segments:
113
- - 0
114
- version: "0"
114
+ - 1
115
+ - 3
116
+ - 1
117
+ version: 1.3.1
115
118
  requirements: []
116
119
 
117
120
  rubyforge_project:
118
- rubygems_version: 1.4.2
121
+ rubygems_version: 1.6.2
119
122
  signing_key:
120
123
  specification_version: 3
121
124
  summary: Contributed Instrumentation for New Relic RPM
122
- test_files:
123
- - test/helper.rb
124
- - test/schema.rb
125
- - test/test_curb.rb
126
- - test/test_redis.rb
127
- - test/test_workling.rb
125
+ test_files: []
126
+
@@ -1,64 +0,0 @@
1
- module RpmContrib
2
- module Instrumentation
3
- module Aws
4
- module S3
5
- # Instrumentation for the AWS-S3 gem for New Relic RPM by Brian Doll
6
- if defined?(::AWS::S3) && !NewRelic::Control.instance['disable_aws-s3']
7
-
8
- # Instrument connections to the AWS-S3 service
9
- ::AWS::S3::Connection::Management::ClassMethods.module_eval do
10
- add_method_tracer :establish_connection!, 'AWS-S3/establish_connection!'
11
- end
12
-
13
- # Instrument methods on Bucket
14
- ::AWS::S3::Bucket.instance_eval do
15
- class << self
16
- add_method_tracer :create, 'AWS-S3/Bucket/create'
17
- add_method_tracer :find, 'AWS-S3/Bucket/find'
18
- add_method_tracer :objects, 'AWS-S3/Bucket/objects'
19
- add_method_tracer :delete, 'AWS-S3/Bucket/delete'
20
- add_method_tracer :list, 'AWS-S3/Bucket/list'
21
- end
22
- end
23
-
24
- # Instrument methods on Bucket instances
25
- ::AWS::S3::Bucket.class_eval do
26
- add_method_tracer :[], 'AWS-S3/Bucket/#{self.name}/[]'
27
- add_method_tracer :new_object,'AWS-S3/Bucket/#{self.name}/new_objects'
28
- add_method_tracer :objects, 'AWS-S3/Bucket/#{self.name}/objects'
29
- add_method_tracer :delete, 'AWS-S3/Bucket/#{self.name}/delete'
30
- add_method_tracer :delete_all,'AWS-S3/Bucket/#{self.name}/delete_all'
31
- add_method_tracer :update, 'AWS-S3/Bucket/#{self.name}/update'
32
- end
33
-
34
- # Instrument methods on S3Object
35
- ::AWS::S3::S3Object.instance_eval do
36
- class << self
37
- add_method_tracer :about, 'AWS-S3/S3Object/about'
38
- add_method_tracer :copy, 'AWS-S3/S3Object/copy'
39
- add_method_tracer :delete, 'AWS-S3/S3Object/delete'
40
- add_method_tracer :rename, 'AWS-S3/S3Object/rename'
41
- add_method_tracer :store, 'AWS-S3/S3Object/store'
42
- end
43
- end
44
-
45
- # Instrument methods on S3Object instances
46
- # Metric names are aggregated across all S3Objects since having a metric for
47
- # every single S3Object instance and method pair would be fairly useless
48
- ::AWS::S3::S3Object.class_eval do
49
- add_method_tracer :value, 'AWS-S3/S3Objects/value'
50
- add_method_tracer :about, 'AWS-S3/S3Objects/about'
51
- add_method_tracer :metadata, 'AWS-S3/S3Objects/metadata'
52
- add_method_tracer :store, 'AWS-S3/S3Objects/store'
53
- add_method_tracer :delete, 'AWS-S3/S3Objects/delete'
54
- add_method_tracer :copy, 'AWS-S3/S3Objects/copy'
55
- add_method_tracer :rename, 'AWS-S3/S3Objects/rename'
56
- add_method_tracer :etag, 'AWS-S3/S3Objects/etag'
57
- add_method_tracer :owner, 'AWS-S3/S3Objects/owner'
58
- end
59
-
60
- end
61
- end
62
- end
63
- end
64
- end