rpm_contrib 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/README.md +7 -0
- data/lib/rpm_contrib/instrumentation/active_mq.rb +17 -0
- data/lib/rpm_contrib/instrumentation/camping.rb +6 -6
- data/lib/rpm_contrib/instrumentation/cassandra.rb +1 -1
- data/lib/rpm_contrib/instrumentation/crack.rb +26 -0
- data/lib/rpm_contrib/instrumentation/curb.rb +45 -0
- data/lib/rpm_contrib/instrumentation/elastic_search.rb +24 -0
- data/lib/rpm_contrib/instrumentation/mongo.rb +32 -0
- data/lib/rpm_contrib/instrumentation/paperclip.rb +10 -10
- data/lib/rpm_contrib/instrumentation/redis.rb +4 -4
- data/lib/rpm_contrib/instrumentation/resque.rb +18 -18
- data/lib/rpm_contrib/instrumentation/sinatra.rb +27 -0
- data/lib/rpm_contrib/instrumentation/typhoeus.rb +28 -0
- data/lib/rpm_contrib/instrumentation/ultrasphinx.rb +18 -0
- data/lib/rpm_contrib/instrumentation/workling.rb +21 -0
- data/lib/rpm_contrib/instrumentation/yajl.rb +15 -0
- data/lib/rpm_contrib/instrumentation.rb +13 -2
- data/test/schema.rb +1 -1
- data/test/test_curb.rb +66 -0
- data/test/test_redis.rb +2 -2
- data/test/{test_mongoid.rb → test_workling.rb} +6 -14
- metadata +17 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
* Version 2.1.0
|
2
|
+
|
3
|
+
Included instrumentation from the community:
|
4
|
+
- Alexey Palazhchenko - mongo ORM-agnostic instrumentation
|
5
|
+
- Michael Breen - Elastic Search
|
6
|
+
- Paul Ingles - Sinatra Template instrumentation
|
7
|
+
- Siddharth Dawara - Typhoeus instrumentation
|
8
|
+
- Rob Meyer - ActiveMQ instrumentation
|
9
|
+
- Greg Hazel - Curb instrumentation
|
10
|
+
- Ben Poweski - Crack and Yajl instrumentation
|
11
|
+
- Chad Ingram and Scott Fleckenstein - Workling instrumentation
|
12
|
+
- Adam Weller - UltraSphinx instrumentation
|
13
|
+
- Liron Yahdav - work on the Resque instrumentation
|
14
|
+
|
1
15
|
* Version 2.0.1
|
2
16
|
|
3
17
|
Fixed an error with Bundler and RubyGems 1.8.2 which caused the gem to always fail to load
|
data/README.md
CHANGED
@@ -48,6 +48,13 @@ Both MongoMapper and Mongoid are supported. You can disable them both by settin
|
|
48
48
|
|
49
49
|
### Resque
|
50
50
|
|
51
|
+
Make sure that your jobs either inherit from Resque::Job or else include our instrumentation:
|
52
|
+
|
53
|
+
class MyJob
|
54
|
+
require 'rpm_contrib/instrumentation/resque'
|
55
|
+
include Resque::Plugins::NewRelicInstrumentation
|
56
|
+
end
|
57
|
+
|
51
58
|
To disable resque, set 'disable_resque' to true in your newrelic.yml file.
|
52
59
|
|
53
60
|
### Redis
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# == ActiveMQ Instrumentation ==
|
2
|
+
# Robert R. Meyer
|
3
|
+
# Blue-Dog-Archolite @ GitHub
|
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
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -32,22 +32,22 @@ module RPMContrib
|
|
32
32
|
# end
|
33
33
|
#
|
34
34
|
#
|
35
|
-
|
35
|
+
|
36
36
|
module Camping
|
37
|
-
|
37
|
+
|
38
38
|
def self.included(mod)
|
39
|
-
|
39
|
+
|
40
40
|
# Since the Camping::Base module is essentially copied
|
41
|
-
# into the main module (the mod passed in) of a Camping app
|
41
|
+
# into the main module (the mod passed in) of a Camping app
|
42
42
|
# using the Camping.goes :NewRelicCampingTest syntax
|
43
43
|
# we need to evaluate "weld" the NewRelic plugin in the context of the new Base
|
44
|
-
|
44
|
+
|
45
45
|
(Kernel.const_get(mod.name)::Base).module_eval do
|
46
46
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
47
47
|
add_transaction_tracer :service
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end #RPMContrib::Instrumentation::Camping
|
52
52
|
end
|
53
53
|
end
|
@@ -5,7 +5,7 @@ module RpmContrib
|
|
5
5
|
#
|
6
6
|
|
7
7
|
if defined?(::Cassandra) and not NewRelic::Control.instance['disable_cassandra_instrumentation']
|
8
|
-
|
8
|
+
|
9
9
|
::Cassandra.class_eval do
|
10
10
|
add_method_tracer :insert, 'Database/Cassandra/insert'
|
11
11
|
add_method_tracer :remove, 'Database/Cassandra/remove'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RpmContrib
|
2
|
+
module Instrumentation
|
3
|
+
module Crack
|
4
|
+
|
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
|
14
|
+
|
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
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
9
|
+
|
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
|
24
|
+
end
|
25
|
+
|
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
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# == Elastic Search Instrumentation
|
2
|
+
#
|
3
|
+
|
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
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,32 @@
|
|
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
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,27 +2,27 @@ module RpmContrib
|
|
2
2
|
module Instrumentation
|
3
3
|
module Paperclip
|
4
4
|
# Paperclip Instrumentation.
|
5
|
-
|
5
|
+
|
6
6
|
if defined?(::Paperclip) && !NewRelic::Control.instance['disable_paperclip']
|
7
|
-
|
7
|
+
|
8
8
|
::Paperclip::Attachment.class_eval do
|
9
9
|
add_method_tracer :save, 'Paperclip/#{name}/save'
|
10
10
|
add_method_tracer :assign, 'Paperclip/#{name}/assign'
|
11
11
|
add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
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'
|
15
|
+
add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
|
16
|
+
add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
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'
|
20
|
+
add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
|
21
|
+
add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -8,14 +8,14 @@ module RpmContrib
|
|
8
8
|
|
9
9
|
|
10
10
|
::Redis::Client.class_eval do
|
11
|
-
|
11
|
+
|
12
12
|
include NewRelic::Agent::MethodTracer
|
13
13
|
|
14
|
-
def self.redis_call_method
|
14
|
+
def self.redis_call_method
|
15
15
|
::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
|
19
19
|
def raw_call_command_with_newrelic_trace *args
|
20
20
|
method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
|
21
21
|
metrics = ["Database/Redis/#{method_name}",
|
@@ -28,7 +28,7 @@ module RpmContrib
|
|
28
28
|
|
29
29
|
alias_method :raw_call_command_without_newrelic_trace, redis_call_method
|
30
30
|
alias_method redis_call_method, :raw_call_command_with_newrelic_trace
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
33
|
|
34
34
|
|
@@ -1,32 +1,32 @@
|
|
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
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
1
14
|
|
2
15
|
module RPMContrib
|
3
16
|
module Instrumentation
|
4
|
-
module
|
5
|
-
Resque.before_first_fork do
|
17
|
+
module Resque
|
18
|
+
::Resque.before_first_fork do
|
6
19
|
NewRelic::Agent.manual_start(:dispatcher => :resque)
|
7
20
|
end
|
8
21
|
|
9
|
-
Resque.after_fork do
|
22
|
+
::Resque.after_fork do
|
10
23
|
NewRelic::Agent.after_fork(:force_reconnect => false)
|
11
24
|
end
|
12
25
|
|
13
|
-
Resque.
|
14
|
-
|
26
|
+
::Resque::Job.class_eval do
|
27
|
+
include Resque::Plugins::NewRelicInstrumentation
|
15
28
|
end
|
16
29
|
end
|
17
30
|
end
|
18
31
|
end if defined?(::Resque) and not NewRelic::Control.instance['disable_resque']
|
19
32
|
|
20
|
-
module Resque
|
21
|
-
module Plugins
|
22
|
-
module NewRelicInstrumentation
|
23
|
-
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
24
|
-
|
25
|
-
def around_perform_with_monitoring(*args)
|
26
|
-
perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name, :category => 'OtherTransaction/ResqueJob') do
|
27
|
-
yield(*args)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -0,0 +1,27 @@
|
|
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"
|
10
|
+
|
11
|
+
file = "Proc" if file.is_a?(Proc)
|
12
|
+
metrics = ["Sinatra/#{engine}/#{file}"]
|
13
|
+
|
14
|
+
self.class.trace_execution_scoped metrics do
|
15
|
+
render_without_newrelic_trace(*args, &block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias render_without_newrelic_trace render
|
20
|
+
alias render render_with_newrelic_trace
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RpmContrib
|
2
|
+
module Instrumentation
|
3
|
+
module Typhoeus
|
4
|
+
if defined?(::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
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'new_relic/agent/method_tracer'
|
2
|
+
|
3
|
+
module RpmContrib
|
4
|
+
module Instrumentation
|
5
|
+
module UltraSphinx
|
6
|
+
if defined?(::UltraSphinx)
|
7
|
+
module ::Ultrasphinx
|
8
|
+
class Search
|
9
|
+
include NewRelic::Agent::MethodTracer
|
10
|
+
|
11
|
+
add_method_tracer :run
|
12
|
+
add_method_tracer :results
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Workling instrumentation contributed by Chad Ingram of Aurora Feint
|
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
|
10
|
+
|
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
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,15 @@
|
|
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
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -1,9 +1,20 @@
|
|
1
|
-
require 'rpm_contrib/instrumentation/
|
1
|
+
require 'rpm_contrib/instrumentation/active_mq'
|
2
|
+
require 'rpm_contrib/instrumentation/aws'
|
2
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'
|
3
9
|
require 'rpm_contrib/instrumentation/paperclip'
|
4
10
|
require 'rpm_contrib/instrumentation/redis'
|
5
11
|
require 'rpm_contrib/instrumentation/resque'
|
6
|
-
require 'rpm_contrib/instrumentation/
|
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
|
+
|
7
18
|
|
8
19
|
module RpmContrib
|
9
20
|
module Instrumentation
|
data/test/schema.rb
CHANGED
data/test/test_curb.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/helper"
|
2
|
+
require 'curb'
|
3
|
+
|
4
|
+
class NewRelic::Agent::NetInstrumentationTest < Test::Unit::TestCase
|
5
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
6
|
+
def setup
|
7
|
+
NewRelic::Agent.manual_start
|
8
|
+
@engine = NewRelic::Agent.instance.stats_engine
|
9
|
+
@engine.clear_stats
|
10
|
+
end
|
11
|
+
def test_get
|
12
|
+
curl = Curl::Easy.new('http://www.google.com/index.html')
|
13
|
+
curl.perform
|
14
|
+
assert_match /<head>/, curl.body_str
|
15
|
+
assert_equal %w[External/www.google.com/Curl::Easy External/Curl::Multi
|
16
|
+
External/allOther External/www.google.com/all].sort,
|
17
|
+
@engine.metrics.sort
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_multi
|
21
|
+
multi = Curl::Multi.new
|
22
|
+
curl1 = Curl::Easy.new('http://www.google.com/index.html')
|
23
|
+
multi.add curl1
|
24
|
+
curl2 = Curl::Easy.new('http://www.yahoo.com/')
|
25
|
+
multi.add curl2
|
26
|
+
multi.perform
|
27
|
+
assert_match /<head>/, curl1.body_str
|
28
|
+
assert_match /<head>/, curl2.body_str
|
29
|
+
assert_equal %w[External/Curl::Multi External/allOther].sort,
|
30
|
+
@engine.metrics.sort
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_background
|
34
|
+
perform_action_with_newrelic_trace("task", :category => :task) do
|
35
|
+
curl = Curl::Easy.new('http://www.google.com/index.html')
|
36
|
+
curl.perform
|
37
|
+
assert_match /<head>/, curl.body_str
|
38
|
+
end
|
39
|
+
assert_equal %w[External/Curl::Multi
|
40
|
+
External/Curl::Multi:OtherTransaction/Background/NewRelic::Agent::NetInstrumentationTest/task
|
41
|
+
External/www.google.com/Curl::Easy External/allOther External/www.google.com/all
|
42
|
+
External/www.google.com/Curl::Easy:OtherTransaction/Background/NewRelic::Agent::NetInstrumentationTest/task].sort,
|
43
|
+
@engine.metrics.select{|m| m =~ /^External/}.sort
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_transactional
|
47
|
+
perform_action_with_newrelic_trace("task") do
|
48
|
+
curl = Curl::Easy.new('http://www.google.com/index.html')
|
49
|
+
curl.perform
|
50
|
+
assert_match /<head>/, curl.body_str
|
51
|
+
end
|
52
|
+
assert_equal %w[External/Curl::Multi
|
53
|
+
External/Curl::Multi:Controller/NewRelic::Agent::NetInstrumentationTest/task
|
54
|
+
External/www.google.com/Curl::Easy External/allWeb External/www.google.com/all
|
55
|
+
External/www.google.com/Curl::Easy:Controller/NewRelic::Agent::NetInstrumentationTest/task].sort,
|
56
|
+
@engine.metrics.select{|m| m =~ /^External/}.sort
|
57
|
+
end
|
58
|
+
def test_ignore
|
59
|
+
NewRelic::Agent.disable_all_tracing do
|
60
|
+
curl = Curl::Easy.new('http://www.google.com/index.html')
|
61
|
+
curl.http_post('data')
|
62
|
+
end
|
63
|
+
assert_equal 0, @engine.metrics.size
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/test/test_redis.rb
CHANGED
@@ -8,7 +8,7 @@ end
|
|
8
8
|
require "#{File.dirname(__FILE__)}/../lib/rpm_contrib/instrumentation/redis"
|
9
9
|
|
10
10
|
if defined?(::Redis)
|
11
|
-
|
11
|
+
|
12
12
|
|
13
13
|
class RedisTest < Test::Unit::TestCase
|
14
14
|
|
@@ -27,7 +27,7 @@ if defined?(::Redis)
|
|
27
27
|
|
28
28
|
# Fake test
|
29
29
|
def test_fail
|
30
|
-
|
30
|
+
|
31
31
|
|
32
32
|
end
|
33
33
|
end
|
@@ -1,24 +1,16 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/helper"
|
2
2
|
begin
|
3
|
-
require '
|
3
|
+
require 'redis'
|
4
|
+
require 'ruby-debug'
|
4
5
|
rescue LoadError
|
5
6
|
end
|
6
7
|
|
7
|
-
require "#{File.dirname(__FILE__)}/../lib/rpm_contrib/instrumentation/
|
8
|
+
require "#{File.dirname(__FILE__)}/../lib/rpm_contrib/instrumentation/workling"
|
8
9
|
|
9
|
-
if defined?(::
|
10
|
-
|
11
|
-
Mongoid.configure do |config|
|
12
|
-
config.master = Mongo::Connection.new.db('animals')
|
13
|
-
end
|
14
|
-
|
15
|
-
class Dog
|
16
|
-
include Mongoid::Document
|
10
|
+
if defined?(::Workling)
|
17
11
|
|
18
|
-
field :name
|
19
|
-
end
|
20
12
|
|
21
|
-
class
|
13
|
+
class WorklingTest < Test::Unit::TestCase
|
22
14
|
|
23
15
|
# Called before every test method runs. Can be used
|
24
16
|
# to set up fixture information.
|
@@ -35,7 +27,7 @@ if defined?(::Mongoid)
|
|
35
27
|
|
36
28
|
# Fake test
|
37
29
|
def test_fail
|
38
|
-
|
30
|
+
|
39
31
|
|
40
32
|
end
|
41
33
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpm_contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bill Kayser
|
@@ -58,17 +58,28 @@ files:
|
|
58
58
|
- lib/rpm_contrib/detection/camping.rb
|
59
59
|
- lib/rpm_contrib/detection/resque.rb
|
60
60
|
- lib/rpm_contrib/instrumentation.rb
|
61
|
+
- lib/rpm_contrib/instrumentation/active_mq.rb
|
61
62
|
- lib/rpm_contrib/instrumentation/aws.rb
|
62
63
|
- lib/rpm_contrib/instrumentation/aws/s3.rb
|
63
64
|
- lib/rpm_contrib/instrumentation/camping.rb
|
64
65
|
- lib/rpm_contrib/instrumentation/cassandra.rb
|
66
|
+
- lib/rpm_contrib/instrumentation/crack.rb
|
67
|
+
- lib/rpm_contrib/instrumentation/curb.rb
|
68
|
+
- lib/rpm_contrib/instrumentation/elastic_search.rb
|
69
|
+
- lib/rpm_contrib/instrumentation/mongo.rb
|
65
70
|
- lib/rpm_contrib/instrumentation/paperclip.rb
|
66
71
|
- lib/rpm_contrib/instrumentation/redis.rb
|
67
72
|
- lib/rpm_contrib/instrumentation/resque.rb
|
73
|
+
- lib/rpm_contrib/instrumentation/sinatra.rb
|
74
|
+
- lib/rpm_contrib/instrumentation/typhoeus.rb
|
75
|
+
- lib/rpm_contrib/instrumentation/ultrasphinx.rb
|
76
|
+
- lib/rpm_contrib/instrumentation/workling.rb
|
77
|
+
- lib/rpm_contrib/instrumentation/yajl.rb
|
68
78
|
- test/helper.rb
|
69
79
|
- test/schema.rb
|
70
|
-
- test/
|
80
|
+
- test/test_curb.rb
|
71
81
|
- test/test_redis.rb
|
82
|
+
- test/test_workling.rb
|
72
83
|
has_rdoc: true
|
73
84
|
homepage: http://github.com/newrelic/rpm_contrib
|
74
85
|
licenses: []
|
@@ -112,5 +123,6 @@ summary: Contributed Instrumentation for New Relic RPM
|
|
112
123
|
test_files:
|
113
124
|
- test/helper.rb
|
114
125
|
- test/schema.rb
|
115
|
-
- test/
|
126
|
+
- test/test_curb.rb
|
116
127
|
- test/test_redis.rb
|
128
|
+
- test/test_workling.rb
|