wireframe-rpm_contrib 1.0.12.7 → 2.1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CHANGELOG +69 -3
  2. data/Gemfile +13 -0
  3. data/README.md +137 -14
  4. data/Rakefile +5 -3
  5. data/lib/rpm_contrib.rb +17 -24
  6. data/lib/rpm_contrib/agent_compatibility.rb +11 -0
  7. data/lib/rpm_contrib/detection.rb +5 -0
  8. data/lib/rpm_contrib/detection/camping.rb +1 -1
  9. data/lib/rpm_contrib/instrumentation.rb +16 -0
  10. data/lib/rpm_contrib/instrumentation/active_messaging.rb +22 -0
  11. data/lib/rpm_contrib/instrumentation/aws.rb +68 -0
  12. data/lib/rpm_contrib/instrumentation/camping.rb +7 -10
  13. data/lib/rpm_contrib/instrumentation/cassandra.rb +26 -19
  14. data/lib/rpm_contrib/instrumentation/crack.rb +41 -0
  15. data/lib/rpm_contrib/instrumentation/curb.rb +52 -0
  16. data/lib/rpm_contrib/instrumentation/elastic_search.rb +26 -0
  17. data/lib/rpm_contrib/instrumentation/kyototycoon.rb +28 -0
  18. data/lib/rpm_contrib/instrumentation/mongo.rb +54 -0
  19. data/lib/rpm_contrib/instrumentation/mongoid.rb +12 -44
  20. data/lib/rpm_contrib/instrumentation/paperclip.rb +25 -18
  21. data/lib/rpm_contrib/instrumentation/picky.rb +41 -0
  22. data/lib/rpm_contrib/instrumentation/redis.rb +29 -20
  23. data/lib/rpm_contrib/instrumentation/resque.rb +78 -42
  24. data/lib/rpm_contrib/instrumentation/riak_client.rb +48 -0
  25. data/lib/rpm_contrib/instrumentation/ripple.rb +37 -0
  26. data/lib/rpm_contrib/instrumentation/sinatra.rb +30 -0
  27. data/lib/rpm_contrib/instrumentation/thinking_sphinx.rb +22 -0
  28. data/lib/rpm_contrib/instrumentation/typhoeus.rb +33 -0
  29. data/lib/rpm_contrib/instrumentation/ultrasphinx.rb +22 -0
  30. data/lib/rpm_contrib/instrumentation/workling.rb +27 -0
  31. data/lib/rpm_contrib/instrumentation/yajl.rb +41 -0
  32. data/lib/rpm_contrib/language_support.rb +31 -0
  33. data/lib/rpm_contrib/samplers.rb +17 -0
  34. data/test/helper.rb +1 -1
  35. data/test/schema.rb +1 -1
  36. data/test/test_curb.rb +69 -0
  37. data/test/test_picky.rb +55 -0
  38. data/test/test_redis.rb +2 -2
  39. data/test/test_resque.rb +74 -0
  40. data/test/{test_mongoid.rb → test_workling.rb} +6 -14
  41. metadata +74 -64
  42. data/lib/rpm_contrib/detection/resque.rb +0 -15
  43. data/lib/rpm_contrib/instrumentation/aws/s3.rb +0 -56
  44. data/lib/rpm_contrib/instrumentation/mongo_mapper.rb +0 -44
@@ -0,0 +1,68 @@
1
+ # AWS Instrumentation by Brian Doll of New Relic
2
+ DependencyDetection.defer do
3
+ @name = :aws
4
+
5
+ depends_on do
6
+ defined?(::AWS::S3) && !NewRelic::Control.instance['disable_aws-s3']
7
+ end
8
+
9
+ executes do
10
+ NewRelic::Agent.logger.debug 'Installing AWS instrumentation'
11
+ end
12
+
13
+
14
+ executes do
15
+ # Instrument connections to the AWS-S3 service
16
+ ::AWS::S3::Connection::Management::ClassMethods.module_eval do
17
+ add_method_tracer :establish_connection!, 'AWS-S3/establish_connection!'
18
+ end
19
+
20
+ # Instrument methods on Bucket
21
+ ::AWS::S3::Bucket.instance_eval do
22
+ class << self
23
+ add_method_tracer :create, 'AWS-S3/Bucket/create'
24
+ add_method_tracer :find, 'AWS-S3/Bucket/find'
25
+ add_method_tracer :objects, 'AWS-S3/Bucket/objects'
26
+ add_method_tracer :delete, 'AWS-S3/Bucket/delete'
27
+ add_method_tracer :list, 'AWS-S3/Bucket/list'
28
+ end
29
+ end
30
+
31
+ # Instrument methods on Bucket instances
32
+ ::AWS::S3::Bucket.class_eval do
33
+ add_method_tracer :[], 'AWS-S3/Bucket/#{self.name}/[]'
34
+ add_method_tracer :new_object,'AWS-S3/Bucket/#{self.name}/new_objects'
35
+ add_method_tracer :objects, 'AWS-S3/Bucket/#{self.name}/objects'
36
+ add_method_tracer :delete, 'AWS-S3/Bucket/#{self.name}/delete'
37
+ add_method_tracer :delete_all,'AWS-S3/Bucket/#{self.name}/delete_all'
38
+ add_method_tracer :update, 'AWS-S3/Bucket/#{self.name}/update'
39
+ end
40
+
41
+ # Instrument methods on S3Object
42
+ ::AWS::S3::S3Object.instance_eval do
43
+ class << self
44
+ add_method_tracer :about, 'AWS-S3/S3Object/about'
45
+ add_method_tracer :copy, 'AWS-S3/S3Object/copy'
46
+ add_method_tracer :delete, 'AWS-S3/S3Object/delete'
47
+ add_method_tracer :rename, 'AWS-S3/S3Object/rename'
48
+ add_method_tracer :store, 'AWS-S3/S3Object/store'
49
+ end
50
+ end
51
+
52
+ # Instrument methods on S3Object instances
53
+ # Metric names are aggregated across all S3Objects since having a metric for
54
+ # every single S3Object instance and method pair would be fairly useless
55
+ ::AWS::S3::S3Object.class_eval do
56
+ add_method_tracer :value, 'AWS-S3/S3Objects/value'
57
+ add_method_tracer :about, 'AWS-S3/S3Objects/about'
58
+ add_method_tracer :metadata, 'AWS-S3/S3Objects/metadata'
59
+ add_method_tracer :store, 'AWS-S3/S3Objects/store'
60
+ add_method_tracer :delete, 'AWS-S3/S3Objects/delete'
61
+ add_method_tracer :copy, 'AWS-S3/S3Objects/copy'
62
+ add_method_tracer :rename, 'AWS-S3/S3Objects/rename'
63
+ add_method_tracer :etag, 'AWS-S3/S3Objects/etag'
64
+ add_method_tracer :owner, 'AWS-S3/S3Objects/owner'
65
+ end
66
+ end
67
+ end
68
+
@@ -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,34 +18,33 @@ 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
- # into the main module (the mod passed in) of a Camping app
38
+ # into the main module (the mod passed in) of a Camping app
42
39
  # using the Camping.goes :NewRelicCampingTest syntax
43
40
  # we need to evaluate "weld" the NewRelic plugin in the context of the new Base
44
-
41
+
45
42
  (Kernel.const_get(mod.name)::Base).module_eval do
46
43
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
47
44
  add_transaction_tracer :service
48
45
  end
49
46
  end
50
-
47
+
51
48
  end #RPMContrib::Instrumentation::Camping
52
49
  end
53
50
  end
@@ -1,23 +1,30 @@
1
- # == Cassandra Instrumentation
2
- #
3
-
4
- if defined?(::Cassandra) and not NewRelic::Control.instance['disable_cassandra_instrumentation']
1
+ DependencyDetection.defer do
2
+ @name = :cassandra
3
+
4
+ depends_on do
5
+ defined?(::Cassandra) && !NewRelic::Control.instance['disable_cassandra_instrumentation']
6
+ end
5
7
 
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'
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Cassandra instrumentation'
21
10
  end
22
11
 
12
+ executes do
13
+ ::Cassandra.class_eval do
14
+ add_method_tracer :insert, 'Database/Cassandra/insert'
15
+ add_method_tracer :remove, 'Database/Cassandra/remove'
16
+ add_method_tracer :clear_column_family!, 'Database/Cassandra/clear_column_family!'
17
+ add_method_tracer :clear_keyspace!, 'Database/Cassandra/clear_keyspace!'
18
+ add_method_tracer :count_columns, 'Database/Cassandra/count_columns'
19
+ add_method_tracer :multi_count_columns, 'Database/Cassandra/multi_count_columns'
20
+ add_method_tracer :get_columns, 'Database/Cassandra/get_columns'
21
+ add_method_tracer :multi_get_columns, 'Database/Cassandra/multi_get_columns'
22
+ add_method_tracer :get, 'Database/Cassandra/get'
23
+ add_method_tracer :multi_get, 'Database/Cassandra/multi_get'
24
+ add_method_tracer :exists?, 'Database/Cassandra/exists?'
25
+ add_method_tracer :get_range, 'Database/Cassandra/get_range'
26
+ add_method_tracer :count_range, 'Database/Cassandra/count_range'
27
+ add_method_tracer :batch, 'Database/Cassandra/batch'
28
+ end
29
+ end
23
30
  end
@@ -0,0 +1,41 @@
1
+ DependencyDetection.defer do
2
+ @name = :crack_json
3
+
4
+ depends_on do
5
+ defined?(::Crack::JSON) && !NewRelic::Control.instance['disable_crack']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Crack::JSON instrumentation'
10
+ end
11
+
12
+ executes do
13
+ ::Crack::JSON.class_eval do
14
+ class << self
15
+ include NewRelic::Agent::MethodTracer
16
+ add_method_tracer :parse, 'Parser/#{self.name}/parse'
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ DependencyDetection.defer do
23
+ @name = :crack_xml
24
+
25
+ depends_on do
26
+ defined?(::Crack::XML) && !NewRelic::Control.instance['disable_crack']
27
+ end
28
+
29
+ executes do
30
+ NewRelic::Agent.logger.debug 'Installing Crack::XML instrumentation'
31
+ end
32
+
33
+ executes do
34
+ ::Crack::XML.class_eval do
35
+ class << self
36
+ include NewRelic::Agent::MethodTracer
37
+ add_method_tracer :parse, 'Parser/#{self.name}/parse'
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,52 @@
1
+ DependencyDetection.defer do
2
+ @name = :curb
3
+
4
+ depends_on do
5
+ defined?(::Curl) and not NewRelic::Control.instance['disable_curb']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Curb instrumentation'
10
+ end
11
+
12
+ executes do
13
+ ::Curl::Easy.class_eval do
14
+ def host
15
+ URI.parse(self.url).host
16
+ end
17
+
18
+ # TODO: http, http_delete, http_get, http_post, http_head, http_put
19
+ def perform_with_newrelic_trace(*args, &block)
20
+ metrics = ["External/#{host}/Curl::Easy","External/#{host}/all"]
21
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
22
+ metrics << "External/allWeb"
23
+ else
24
+ metrics << "External/allOther"
25
+ end
26
+ self.class.trace_execution_scoped metrics do
27
+ perform_without_newrelic_trace(*args, &block)
28
+ end
29
+ end
30
+ alias perform_without_newrelic_trace perform
31
+ alias perform perform_with_newrelic_trace
32
+ end
33
+
34
+ ::Curl::Multi.class_eval do
35
+ # TODO: http
36
+ def perform_with_newrelic_trace(*args, &block)
37
+ metrics = ["External/Curl::Multi"]
38
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
39
+ metrics << "External/allWeb"
40
+ else
41
+ metrics << "External/allOther"
42
+ end
43
+ self.class.trace_execution_scoped metrics do
44
+ perform_without_newrelic_trace(*args, &block)
45
+ end
46
+ end
47
+ alias perform_without_newrelic_trace perform
48
+ alias perform perform_with_newrelic_trace
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,26 @@
1
+ # == Elastic Search Instrumentation
2
+ #
3
+ DependencyDetection.defer do
4
+ @name = :elastic_search
5
+
6
+ depends_on do
7
+ defined?(::ElasticSearch::Client) && !NewRelic::Control.instance['disable_elastic_search_instrumentation']
8
+ end
9
+
10
+ executes do
11
+ NewRelic::Agent.logger.debug 'Installing Elastic Search instrumentation'
12
+ end
13
+
14
+ executes do
15
+ ::ElasticSearch::Client.class_eval do
16
+ add_method_tracer :index, 'ActiveRecord/ElasticSearch/index'
17
+ add_method_tracer :get, 'ActiveRecord/ElasticSearch/get'
18
+ add_method_tracer :delete, 'ActiveRecord/ElasticSearch/delete'
19
+ add_method_tracer :search, 'ActiveRecord/ElasticSearch/search'
20
+ add_method_tracer :scroll, 'ActiveRecord/ElasticSearch/scroll'
21
+ add_method_tracer :count, 'ActiveRecord/ElasticSearch/count'
22
+ add_method_tracer :bulk, 'ActiveRecord/ElasticSearch/bulk'
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,28 @@
1
+ # KyotoTycoon instrumentation
2
+
3
+ DependencyDetection.defer do
4
+ @name = :kyototycoon
5
+
6
+ depends_on do
7
+ defined?(::KyotoTycoon) && !NewRelic::Control.instance['disable_kyototycoon']
8
+ end
9
+
10
+ executes do
11
+ NewRelic::Agent.logger.debug 'Installing KyotoTycoon instrumentation'
12
+ end
13
+
14
+ executes do
15
+ ::KyotoTycoon.class_eval do
16
+ require 'new_relic/agent/method_tracer'
17
+ include NewRelic::Agent::MethodTracer
18
+
19
+ [:get, :remove, :set, :add, :replace,
20
+ :append, :cas, :increment, :decrement, :increment_double,
21
+ :set_bulk, :get_bulk, :remove_bulk, :clear, :vacuum,
22
+ :sync, :report, :status, :match_prefix, :match_regex,
23
+ :keys].each do |method|
24
+ add_method_tracer method
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,54 @@
1
+ # Mongo Instrumentation contributed by Alexey Palazhchenko
2
+ DependencyDetection.defer do
3
+ @name = :mongodb
4
+
5
+ depends_on do
6
+ defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
7
+ end
8
+
9
+ executes do
10
+ NewRelic::Agent.logger.debug 'Installing MongoDB instrumentation'
11
+ end
12
+
13
+ executes do
14
+ ::Mongo::Logging.class_eval do
15
+ include NewRelic::Agent::MethodTracer
16
+
17
+ def instrument_with_newrelic_trace(name, payload = {}, &blk)
18
+ collection = payload[:collection]
19
+ if collection == '$cmd'
20
+ f = payload[:selector].first
21
+ name, collection = f if f
22
+ end
23
+
24
+ trace_execution_scoped("Database/#{collection}/#{name}") do
25
+ t0 = Time.now
26
+ res = instrument_without_newrelic_trace(name, payload, &blk)
27
+ NewRelic::Agent.instance.transaction_sampler.notice_sql(payload.inspect, nil, (Time.now - t0).to_f)
28
+ res
29
+ end
30
+ end
31
+
32
+ alias_method :instrument_without_newrelic_trace, :instrument
33
+ alias_method :instrument, :instrument_with_newrelic_trace
34
+ end
35
+ class Mongo::Collection; include Mongo::Logging; end
36
+ class Mongo::Connection; include Mongo::Logging; end
37
+ class Mongo::Cursor; include Mongo::Logging; end
38
+
39
+ # cursor refresh is not currently instrumented in mongo driver, so not picked up by above - have to add our own here
40
+ ::Mongo::Cursor.class_eval do
41
+ include NewRelic::Agent::MethodTracer
42
+
43
+ def send_get_more_with_newrelic_trace
44
+ trace_execution_scoped("Database/#{collection.name}/refresh") do
45
+ send_get_more_without_newrelic_trace
46
+ end
47
+ end
48
+ alias_method :send_get_more_without_newrelic_trace, :send_get_more
49
+ alias_method :send_get_more, :send_get_more_with_newrelic_trace
50
+ add_method_tracer :close, 'Database/#{collection.name}/close'
51
+ end
52
+ end
53
+
54
+ end
@@ -1,53 +1,21 @@
1
- if defined?(::Mongoid) && !NewRelic::Control.instance['disable_mongodb']
1
+ DependencyDetection.defer do
2
+ @name = :mongoid
2
3
 
3
- module Mongoid #:nodoc:
4
- module Document
5
-
6
- #adding call to super
7
- class << self
8
- alias :old_included :included
9
-
10
- def included(model)
11
- old_included(model)
12
- super
13
- end
14
- end
15
- end
4
+ depends_on do
5
+ defined?(::Mongoid) and not NewRelic::Control.instance['disable_mongoid']
16
6
  end
17
7
 
18
- module RPMContrib::Instrumentation
19
-
20
- module Mongoid
21
- def included(model)
22
- model.metaclass.class_eval do
23
- puts "adding mongoid method tracers for #{model.name}"
24
- add_method_tracer :create, 'Database/#{self.name}/create'
25
- add_method_tracer :create!, 'Database/#{self.name}/create!'
26
- add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
27
- add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
28
- add_method_tracer :all, 'Database/#{self.name}/all'
29
- add_method_tracer :find, 'Database/#{self.name}/find'
30
- add_method_tracer :first, 'Database/#{self.name}/first'
31
- add_method_tracer :last, 'Database/#{self.name}/last'
32
- add_method_tracer :find_or_create_by, 'Database/#{self.name}/find_or_create_by'
33
- add_method_tracer :find_or_initialize_by, 'Database/#{self.name}/find_or_initialize_by'
34
- add_method_tracer :min, 'Database/#{self.name}/min'
35
- add_method_tracer :max, 'Database/#{self.name}/max'
36
- add_method_tracer :sum, 'Database/#{self.name}/sum'
37
- end
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Mongoid instrumentation'
10
+ end
38
11
 
39
- model.class_eval do
40
- add_method_tracer :update_attributes, 'Database/#{self.class.name}/update_attributes'
41
- add_method_tracer :update_attributes!, 'Database/#{self.class.name}/update_attributes!'
42
- add_method_tracer :save, 'Database/#{self.class.name}/save'
43
- add_method_tracer :save!, 'Database/#{self.class.name}/save!'
44
- add_method_tracer :delete, 'Database/#{self.class.name}/delete'
45
- add_method_tracer :destroy, 'Database/#{self.class.name}/destroy'
12
+ executes do
13
+ Mongoid::Collection.class_eval do
14
+ include NewRelic::Agent::MethodTracer
46
15
 
47
- end
48
- super
16
+ (Mongoid::Collections::Operations::ALL - [:<<, :[]]).each do |method|
17
+ add_method_tracer method, "ActiveRecord/\#{@klass}/#{method}"
49
18
  end
50
19
  end
51
- ::Mongoid::Document.extend(RPMContrib::Instrumentation::Mongoid)
52
20
  end
53
21
  end
@@ -1,22 +1,29 @@
1
- # Paperclip Instrumentation.
2
-
3
- if defined?(::Paperclip) && !NewRelic::Control.instance['disable_paperclip']
4
-
5
- ::Paperclip::Attachment.class_eval do
6
- add_method_tracer :save, 'Paperclip/#{name}/save'
7
- add_method_tracer :assign, 'Paperclip/#{name}/assign'
8
- add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
9
- end
10
-
11
- ::Paperclip::Storage::Filesystem.class_eval do
12
- add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
13
- add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
1
+ DependencyDetection.defer do
2
+ @name = :paperclip
3
+
4
+ depends_on do
5
+ defined?(::Paperclip) && !NewRelic::Control.instance['disable_paperclip']
14
6
  end
15
-
16
- ::Paperclip::Storage::S3.class_eval do
17
- add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
18
- add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Paperclip instrumentation'
19
10
  end
20
11
 
12
+ executes do
13
+ ::Paperclip::Attachment.class_eval do
14
+ add_method_tracer :save, 'Paperclip/#{name}/save'
15
+ add_method_tracer :assign, 'Paperclip/#{name}/assign'
16
+ add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
17
+ end
18
+
19
+ ::Paperclip::Storage::Filesystem.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
23
+
24
+ ::Paperclip::Storage::S3.class_eval do
25
+ add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
26
+ add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
27
+ end
28
+ end
21
29
  end
22
-