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,41 @@
1
+ if defined?(::Picky)
2
+
3
+ class Picky::NewRelic
4
+ def self.obfuscate_tokens tokens
5
+ tokens.map { |t|
6
+ o = 'xxx'
7
+ o += '~' if t.similar?
8
+ o += '*' if t.partial?
9
+ o = t.qualifiers.sort.join(',') + ':' + o if t.qualifiers && t.qualifiers.respond_to?(:join)
10
+ o
11
+ }.sort.join(' ')
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ DependencyDetection.defer do
18
+ @name = :picky
19
+
20
+ depends_on do
21
+ defined?(::Picky) && !NewRelic::Control.instance['disable_picky']
22
+ end
23
+
24
+ executes do
25
+ NewRelic::Agent.logger.debug 'Installing Picky instrumentation'
26
+ end
27
+
28
+ executes do
29
+ ::Picky::Search.class_eval do
30
+ include NewRelic::Agent::MethodTracer
31
+
32
+ def execute_with_newrelic_trace *args
33
+ metrics = "Custom/Picky/search: #{Picky::NewRelic.obfuscate_tokens args[0]}"
34
+ self.class.trace_execution_scoped(metrics){ execute_without_newrelic_trace(*args) }
35
+ end
36
+
37
+ alias_method :execute_without_newrelic_trace, :execute
38
+ alias_method :execute, :execute_with_newrelic_trace
39
+ end
40
+ end
41
+ end
@@ -1,33 +1,42 @@
1
1
  # Redis instrumentation contributed by Ashley Martens of ngmoco
2
2
  #
3
+ DependencyDetection.defer do
4
+ @name = :redis
3
5
 
4
- if defined?(::Redis) and not NewRelic::Control.instance['disable_redis']
6
+ depends_on do
7
+ defined?(::Redis) && !NewRelic::Control.instance['disable_redis']
8
+ end
5
9
 
10
+ executes do
11
+ NewRelic::Agent.logger.debug 'Installing Redis instrumentation'
12
+ end
6
13
 
7
- Redis::Client.class_eval do
8
-
9
- include NewRelic::Agent::MethodTracer
14
+ executes do
15
+ ::Redis::Client.class_eval do
10
16
 
11
- def self.redis_call_method
12
- Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
13
- end
17
+ include NewRelic::Agent::MethodTracer
14
18
 
15
-
16
- def raw_call_command_with_newrelic_trace *args
17
- method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
18
- metrics = ["Database/Redis/#{method_name}",
19
- (NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Database/Redis/allWeb' : 'Database/Redis/allOther')]
20
- self.class.trace_execution_scoped(metrics) do
21
- # NewRelic::Control.instance.log.debug("Instrumenting Redis Call[#{method_name}]: #{args[0].inspect}")
22
- raw_call_command_without_newrelic_trace(*args)
19
+ def self.redis_call_method
20
+ ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
23
21
  end
24
- end
25
22
 
26
- alias_method :raw_call_command_without_newrelic_trace, redis_call_method
27
- alias_method redis_call_method, :raw_call_command_with_newrelic_trace
28
-
29
- end
30
23
 
24
+ def raw_call_command_with_newrelic_trace *args
25
+ method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
26
+ metrics = ["Database/Redis/#{method_name}",
27
+ (NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Database/Redis/allWeb' : 'Database/Redis/allOther')]
28
+ self.class.trace_execution_scoped(metrics) do
29
+ # NewRelic::Control.instance.log.debug("Instrumenting Redis Call[#{method_name}]: #{args[0].inspect}")
30
+ raw_call_command_without_newrelic_trace(*args)
31
+ end
32
+ end
31
33
 
34
+ alias_method :raw_call_command_without_newrelic_trace, redis_call_method
35
+ alias_method redis_call_method, :raw_call_command_with_newrelic_trace
32
36
 
37
+ end
38
+ end
33
39
  end
40
+
41
+
42
+
@@ -1,54 +1,90 @@
1
+ require 'rpm_contrib/language_support'
1
2
 
2
- module RPMContrib
3
- module Instrumentation
4
- # == 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 ResqueInstrumentation
10
- ::Resque::Job.class_eval do
11
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
12
-
13
- old_perform_method = instance_method(:perform)
3
+ # call this now so it is memoized before potentially forking worker processes
4
+ RPMContrib::LanguageSupport.can_fork?
14
5
 
15
- define_method(:perform) do
16
- NewRelic::Agent.reset_stats if NewRelic::Agent.respond_to? :reset_stats
6
+ module Resque
7
+ module Plugins
8
+ module NewRelicInstrumentation
9
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
10
+
11
+ def around_perform_with_monitoring(*args)
12
+ begin
17
13
  perform_action_with_newrelic_trace(trace_options) do
18
- old_perform_method.bind(self).call
14
+ yield(*args)
19
15
  end
20
-
21
- NewRelic::Agent.shutdown unless defined?(::Resque.before_child_exit)
16
+ ensure
17
+ NewRelic::Agent.shutdown if RPMContrib::LanguageSupport.can_fork?
22
18
  end
23
-
24
- private
25
- def backgrounded_job?
26
- defined?(::Backgrounded::Handler::ResqueHandler) && payload_class == ::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
19
+ end
20
+ private
21
+ def backgrounded_job?
22
+ defined?(::Backgrounded::Handler::ResqueHandler) && payload_class == ::Backgrounded::Handler::ResqueHandler
23
+ end
24
+ def trace_options
25
+ if backgrounded_job?
26
+ {
27
+ :class_name => args[0],
28
+ :name => args[2].to_s,
29
+ :params => @payload,
30
+ :category => 'OtherTransaction/BackgroundedResqueJob'
31
+ }
32
+ else
33
+ class_name = (payload_class || self.class).name
34
+ {
35
+ :class_name => class_name,
36
+ :name => 'perform',
37
+ :category => 'OtherTransaction/ResqueJob'
38
+ }
44
39
  end
45
40
  end
41
+ end
42
+ end
43
+ end
46
44
 
47
- if defined?(::Resque.before_child_exit)
48
- ::Resque.before_child_exit do |worker|
49
- NewRelic::Agent.shutdown
45
+ module RPMContrib
46
+ module Instrumentation
47
+ module ResqueInstrumentationInstaller
48
+ def payload_class
49
+ klass = super
50
+ klass.instance_eval do
51
+ extend ::Resque::Plugins::NewRelicInstrumentation
50
52
  end
51
53
  end
52
54
  end
53
55
  end
54
- end if defined?(::Resque::Job) and not NewRelic::Control.instance['disable_resque']
56
+ end
57
+
58
+ DependencyDetection.defer do
59
+ @name = :resque
60
+
61
+ depends_on do
62
+ defined?(::Resque::Job) and not NewRelic::Control.instance['disable_resque']
63
+ end
64
+
65
+ executes do
66
+ NewRelic::Agent.logger.debug 'Installing Resque instrumentation'
67
+ end
68
+
69
+ executes do
70
+ # == Resque Instrumentation
71
+ #
72
+ # Installs a hook to ensure the agent starts manually when the worker
73
+ # starts and also adds the tracer to the process method which executes
74
+ # in the forked task.
75
+ ::Resque::Job.class_eval do
76
+ def self.new(*args)
77
+ super(*args).extend RPMContrib::Instrumentation::ResqueInstrumentationInstaller
78
+ end
79
+ end
80
+
81
+ ::Resque.before_first_fork do
82
+ NewRelic::Agent.manual_start(:dispatcher => :resque,
83
+ :sync_startup => true)
84
+ end
85
+
86
+ ::Resque.after_fork do
87
+ NewRelic::Agent.after_fork(:force_reconnect => false)
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,48 @@
1
+ DependencyDetection.defer do
2
+ @name = :riak_client
3
+
4
+ depends_on do
5
+ defined?(::Riak) and not NewRelic::Control.instance['disable_riak_client']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Riak client instrumentation'
10
+ end
11
+
12
+ executes do
13
+ backend_tracers = proc do
14
+ add_method_tracer :ping, 'Database/Riak/ping'
15
+
16
+ add_method_tracer :list_buckets, 'Database/Riak/list_buckets'
17
+ add_method_tracer :get_bucket_props, 'Database/Riak/get_bucket_props'
18
+ add_method_tracer :set_bucket_props, 'Database/Riak/set_bucket_props'
19
+
20
+ add_method_tracer :mapred, 'Database/Riak/mapred'
21
+
22
+ add_method_tracer :list_keys, 'Database/Riak/list_keys'
23
+ add_method_tracer :fetch_object, 'Database/Riak/fetch_object'
24
+ add_method_tracer :reload_object, 'Database/Riak/reload_object'
25
+ add_method_tracer :store_object, 'Database/Riak/store_object'
26
+ add_method_tracer :delete_object, 'Database/Riak/delete_object'
27
+ end
28
+
29
+ ::Riak::Client::BeefcakeProtobuffsBackend.class_eval &backend_tracers
30
+ ::Riak::Client::BeefcakeProtobuffsBackend.class_eval do
31
+ add_method_tracer :server_info, 'Database/Riak/server_info'
32
+ add_method_tracer :get_client_id, 'Database/Riak/get_client_id'
33
+ add_method_tracer :set_client_id, 'Database/Riak/set_client_id'
34
+ end
35
+ ::Riak::Client::HTTPBackend.class_eval &backend_tracers
36
+ ::Riak::Client::HTTPBackend.class_eval do
37
+ add_method_tracer :stats, 'Database/Riak/stats'
38
+ add_method_tracer :link_walk, 'Database/Riak/link_walk'
39
+ add_method_tracer :get_index, 'Database/Riak/get_index'
40
+ add_method_tracer :search, 'Database/Riak/search'
41
+ add_method_tracer :update_search_index, 'Database/Riak/update_search_index'
42
+ end
43
+
44
+ ::Riak::RObject.class_eval do
45
+ add_method_tracer :serialize, 'Database/Riak/serialize'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,37 @@
1
+ DependencyDetection.defer do
2
+ @name = :ripple
3
+
4
+ depends_on do
5
+ defined?(::Ripple) and not
6
+ NewRelic::Control.instance['disable_ripple']
7
+ end
8
+
9
+ executes do
10
+ NewRelic::Agent.logger.debug 'Installing Ripple instrumentation'
11
+ end
12
+
13
+ executes do
14
+ ::Ripple::Callbacks::InstanceMethods.class_eval do
15
+ add_method_tracer :valid?, 'Database/Riak/Ripple/valid?'
16
+ end
17
+
18
+ ::Ripple::Document::Persistence::ClassMethods.class_eval do
19
+ add_method_tracer :create, 'Database/Riak/Ripple/create'
20
+ add_method_tracer :destroy_all, 'Database/Riak/Ripple/destroy_all'
21
+ end
22
+
23
+ ::Ripple::Document::Persistence::InstanceMethods.class_eval do
24
+ add_method_tracer :really_save, 'Database/Riak/Ripple/really_save'
25
+ add_method_tracer :reload, 'Database/Riak/Ripple/reload'
26
+ add_method_tracer :delete, 'Database/Riak/Ripple/delete'
27
+ add_method_tracer :destroy, 'Database/Riak/Ripple/destroy'
28
+ add_method_tracer :update_attribute, 'Database/Riak/Ripple/update_attribute'
29
+ add_method_tracer :update_attributes, 'Database/Riak/Ripple/update_attributes'
30
+ end
31
+
32
+ ::Ripple::Document::Finders::ClassMethods.class_eval do
33
+ add_method_tracer :find, 'Database/Riak/Ripple/find'
34
+ add_method_tracer :list, 'Database/Riak/Ripple/list'
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ DependencyDetection.defer do
2
+ @name = :sinatra_view
3
+
4
+ depends_on do
5
+ defined?(::Sinatra::Base) and not NewRelic::Control.instance['disable_sinatra_template']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Sinatra view instrumentation'
10
+ end
11
+
12
+ executes do
13
+ ::Sinatra::Base.class_eval do
14
+ def render_with_newrelic_trace(*args, &block)
15
+ engine, file = *args
16
+ return render_without_newrelic_trace(*args, &block) if file == "= yield"
17
+
18
+ file = "Proc" if file.is_a?(Proc)
19
+ metrics = ["View/#{engine}/#{file}/Rendering"]
20
+
21
+ self.class.trace_execution_scoped metrics do
22
+ render_without_newrelic_trace(*args, &block)
23
+ end
24
+ end
25
+
26
+ alias render_without_newrelic_trace render
27
+ alias render render_with_newrelic_trace
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ DependencyDetection.defer do
2
+ @name = :thinking_sphinx
3
+
4
+ depends_on do
5
+ defined?(::ThinkingSphinx) and not ::NewRelic::Control.instance['disable_thinking_sphinx']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Thinking Sphinx instrumentation'
10
+ end
11
+
12
+ executes do
13
+ class ::ThinkingSphinx::Search
14
+ include NewRelic::Agent::MethodTracer
15
+
16
+ add_method_tracer :initialize
17
+ add_method_tracer :populate
18
+ add_method_tracer :results
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,33 @@
1
+ DependencyDetection.defer do
2
+ @name = :typhoeus
3
+
4
+ depends_on do
5
+ defined?(::Typhoeus) and not ::NewRelic::Control.instance['disable_typhoeus']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Typhoeus instrumentation'
10
+ end
11
+
12
+ executes do
13
+ require 'uri'
14
+ ::Typhoeus::Request.instance_eval do
15
+ def get_with_newrelic_trace(*args, &block)
16
+ uri = URI.parse(args.first)
17
+ metrics = ["External/#{uri.host}/Typhoeus/GET","External/#{uri.host}/all"]
18
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
19
+ metrics << "External/allWeb"
20
+ else
21
+ metrics << "External/allOther"
22
+ end
23
+ self.class.trace_execution_scoped metrics do
24
+ get_without_newrelic_trace(*args, &block)
25
+ end
26
+ end
27
+ alias get_without_newrelic_trace get
28
+ alias get get_with_newrelic_trace
29
+ end
30
+ end
31
+ end
32
+
33
+
@@ -0,0 +1,22 @@
1
+ DependencyDetection.defer do
2
+ @name = :ultrasphinx
3
+
4
+ depends_on do
5
+ defined?(::Ultrasphinx) and not ::NewRelic::Control.instance['disable_ultrasphinx']
6
+ end
7
+
8
+ executes do
9
+ NewRelic::Agent.logger.debug 'Installing Ultrasphinx instrumentation'
10
+ end
11
+
12
+ executes do
13
+ class ::Ultrasphinx::Search
14
+ include NewRelic::Agent::MethodTracer
15
+
16
+ add_method_tracer :run
17
+ add_method_tracer :results
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -0,0 +1,27 @@
1
+ # Workling instrumentation contributed by Chad Ingram of Aurora Feint
2
+ #
3
+ DependencyDetection.defer do
4
+ @name = :workling
5
+
6
+ depends_on do
7
+ defined?(::Workling) and not ::NewRelic::Control.instance['disable_workling']
8
+ end
9
+
10
+ executes do
11
+ NewRelic::Agent.logger.debug 'Installing Workling instrumentation'
12
+ end
13
+
14
+ executes do
15
+ ::Workling::Base.class_eval do
16
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
17
+ end
18
+
19
+ ::Workling::Discovery.discovered.each do |clazz|
20
+ (clazz.public_instance_methods - ::Workling::Base.public_instance_methods).each do |method|
21
+ puts "added method tracer Workling/#{clazz.name}/#{method}"
22
+ clazz.send(:add_method_tracer, method, "Workling/#{clazz.name}/#{method}", :category => :task)
23
+ end
24
+ end
25
+ end
26
+
27
+ end