newrelic_rpm 2.14.1 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +8 -0
- data/README.rdoc +2 -0
- data/install.rb +2 -2
- data/lib/new_relic/agent.rb +34 -1
- data/lib/new_relic/agent/agent.rb +34 -25
- data/lib/new_relic/agent/browser_monitoring.rb +111 -0
- data/lib/new_relic/agent/error_collector.rb +4 -4
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -7
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +8 -8
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +26 -26
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +15 -15
- data/lib/new_relic/agent/shim_agent.rb +2 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +3 -3
- data/lib/new_relic/agent/stats_engine/samplers.rb +2 -2
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
- data/lib/new_relic/agent/transaction_sampler.rb +299 -251
- data/lib/new_relic/control.rb +2 -2
- data/lib/new_relic/control/class_methods.rb +0 -5
- data/lib/new_relic/control/configuration.rb +4 -3
- data/lib/new_relic/control/frameworks/rails.rb +9 -12
- data/lib/new_relic/control/instance_methods.rb +2 -2
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/control/server_methods.rb +2 -2
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/local_environment.rb +7 -7
- data/lib/new_relic/rack/browser_monitoring.rb +61 -0
- data/lib/new_relic/stats.rb +6 -6
- data/lib/new_relic/version.rb +4 -4
- data/newrelic.yml +19 -0
- data/newrelic_rpm.gemspec +9 -4
- data/test/active_record_fixtures.rb +5 -5
- data/test/config/test_control.rb +3 -3
- data/test/new_relic/agent/agent/connect_test.rb +27 -6
- data/test/new_relic/agent/agent/start_test.rb +13 -13
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +8 -8
- data/test/new_relic/agent/agent_test.rb +85 -0
- data/test/new_relic/agent/agent_test_controller.rb +9 -9
- data/test/new_relic/agent/agent_test_controller_test.rb +37 -37
- data/test/new_relic/agent/browser_monitoring_test.rb +124 -0
- data/test/new_relic/agent/busy_calculator_test.rb +7 -7
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -9
- data/test/new_relic/agent/error_collector_test.rb +54 -54
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +69 -69
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +11 -11
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +38 -35
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +18 -18
- data/test/new_relic/agent/memcache_instrumentation_test.rb +12 -12
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +16 -15
- data/test/new_relic/agent/method_tracer_test.rb +60 -60
- data/test/new_relic/agent/mock_scope_listener.rb +8 -8
- data/test/new_relic/agent/rpm_agent_test.rb +26 -26
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +17 -17
- data/test/new_relic/agent/stats_engine/samplers_test.rb +4 -4
- data/test/new_relic/agent/stats_engine/stats_engine_test.rb +51 -51
- data/test/new_relic/agent/transaction_sample_builder_test.rb +36 -36
- data/test/new_relic/agent/transaction_sampler_test.rb +727 -178
- data/test/new_relic/agent/worker_loop_test.rb +4 -4
- data/test/new_relic/collection_helper_test.rb +15 -15
- data/test/new_relic/command/deployments_test.rb +5 -5
- data/test/new_relic/control_test.rb +25 -25
- data/test/new_relic/local_environment_test.rb +11 -11
- data/test/new_relic/metric_spec_test.rb +21 -21
- data/test/new_relic/rack/episodes_test.rb +35 -35
- data/test/new_relic/stats_test.rb +61 -43
- data/test/new_relic/transaction_sample_subtest_test.rb +15 -15
- data/test/new_relic/transaction_sample_test.rb +25 -25
- data/test/new_relic/version_number_test.rb +11 -11
- data/test/test_contexts.rb +7 -7
- data/test/test_helper.rb +6 -6
- data/ui/helpers/developer_mode_helper.rb +67 -67
- data/ui/helpers/google_pie_chart.rb +4 -4
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +7 -7
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +9 -9
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +9 -9
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +21 -21
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +5 -5
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +20 -20
- metadata +15 -9
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -109
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
2
|
|
3
3
|
class NewRelic::Agent::Instrumentation::MetricFrameTest < Test::Unit::TestCase
|
4
4
|
|
@@ -6,7 +6,7 @@ class NewRelic::Agent::Instrumentation::MetricFrameTest < Test::Unit::TestCase
|
|
6
6
|
def setup
|
7
7
|
@f = NewRelic::Agent::Instrumentation::MetricFrame.new
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def test_request_parsing__none
|
11
11
|
assert_nil f.uri
|
12
12
|
assert_nil f.referer
|
@@ -34,7 +34,7 @@ class NewRelic::Agent::Instrumentation::MetricFrameTest < Test::Unit::TestCase
|
|
34
34
|
assert_equal "/path", f.uri
|
35
35
|
assert_equal "/path/hello", f.referer
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def test_request_parsing__hostname_only
|
39
39
|
request = stub(:uri => 'http://creature.com')
|
40
40
|
f.request = request
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
2
|
|
3
3
|
class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::TestCase
|
4
4
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
@@ -7,13 +7,13 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
|
|
7
7
|
@engine = NewRelic::Agent.instance.stats_engine
|
8
8
|
@engine.clear_stats
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def metrics_without_gc
|
12
12
|
@engine.metrics - ['GC/cumulative']
|
13
13
|
end
|
14
14
|
|
15
15
|
private :metrics_without_gc
|
16
|
-
|
16
|
+
|
17
17
|
def test_get
|
18
18
|
url = URI.parse('http://www.google.com/index.html')
|
19
19
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
@@ -21,7 +21,7 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
|
|
21
21
|
}
|
22
22
|
assert_match /<head>/, res.body
|
23
23
|
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort,
|
24
|
-
metrics_without_gc.sort
|
24
|
+
metrics_without_gc.sort
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_background
|
@@ -49,7 +49,7 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
|
|
49
49
|
end
|
50
50
|
def test_get__simple
|
51
51
|
Net::HTTP.get URI.parse('http://www.google.com/index.html')
|
52
|
-
assert_equal metrics_without_gc.sort,
|
52
|
+
assert_equal metrics_without_gc.sort,
|
53
53
|
%w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort
|
54
54
|
end
|
55
55
|
def test_ignore
|
@@ -59,7 +59,7 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
|
|
59
59
|
http.post('/index.html','data')
|
60
60
|
}
|
61
61
|
end
|
62
|
-
assert_equal 0, metrics_without_gc.size
|
62
|
+
assert_equal 0, metrics_without_gc.size
|
63
63
|
end
|
64
64
|
def test_head
|
65
65
|
url = URI.parse('http://www.google.com/index.html')
|
@@ -67,16 +67,16 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
|
|
67
67
|
http.head('/index.html')
|
68
68
|
}
|
69
69
|
assert_equal %w[External/www.google.com/Net::HTTP/HEAD External/allOther External/www.google.com/all].sort,
|
70
|
-
metrics_without_gc.sort
|
70
|
+
metrics_without_gc.sort
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def test_post
|
74
74
|
url = URI.parse('http://www.google.com/index.html')
|
75
75
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
76
76
|
http.post('/index.html','data')
|
77
77
|
}
|
78
|
-
assert_equal %w[External/www.google.com/Net::HTTP/POST External/allOther External/www.google.com/all].sort,
|
79
|
-
metrics_without_gc.sort
|
78
|
+
assert_equal %w[External/www.google.com/Net::HTTP/POST External/allOther External/www.google.com/all].sort,
|
79
|
+
metrics_without_gc.sort
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
end
|
@@ -2,58 +2,61 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'te
|
|
2
2
|
class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
3
3
|
require 'new_relic/agent/instrumentation/queue_time'
|
4
4
|
include NewRelic::Agent::Instrumentation::QueueTime
|
5
|
-
|
5
|
+
|
6
6
|
def setup
|
7
7
|
NewRelic::Agent.instance.stats_engine.clear_stats
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def create_test_start_time(env)
|
11
11
|
env[APP_HEADER] = "t=#{convert_to_microseconds(Time.at(1002))}"
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_parse_frontend_headers
|
15
|
-
|
16
|
-
|
15
|
+
middleware_start = Time.at(1002)
|
16
|
+
queue_start = Time.at(1001)
|
17
|
+
server_start = Time.at(1000)
|
18
|
+
Time.stubs(:now).returns(Time.at(1003)) # whee!
|
19
|
+
self.expects(:add_end_time_header).with(Time.at(1003), {:env => 'hash'})
|
17
20
|
# ordering is important here, unfortunately, the mocks don't
|
18
21
|
# support that kind of checking.
|
19
|
-
self.expects(:parse_middleware_time_from).with({:env => 'hash'})
|
20
|
-
self.expects(:parse_queue_time_from).with({:env => 'hash'})
|
21
|
-
self.expects(:parse_server_time_from).with({:env => 'hash'})
|
22
|
-
parse_frontend_headers({:env => 'hash'})
|
22
|
+
self.expects(:parse_middleware_time_from).with({:env => 'hash'}).returns(middleware_start)
|
23
|
+
self.expects(:parse_queue_time_from).with({:env => 'hash'}).returns(queue_start)
|
24
|
+
self.expects(:parse_server_time_from).with({:env => 'hash'}).returns(server_start)
|
25
|
+
assert_equal(server_start, parse_frontend_headers({:env => 'hash'}), "should return the oldest start time")
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_all_combined_frontend_headers
|
26
29
|
env = {}
|
27
30
|
env[MAIN_HEADER] = "t=#{convert_to_microseconds(Time.at(1000))}"
|
28
|
-
env[QUEUE_HEADER] = "t=#{convert_to_microseconds(Time.at(1001))}"
|
31
|
+
env[QUEUE_HEADER] = "t=#{convert_to_microseconds(Time.at(1001))}"
|
29
32
|
env[MIDDLEWARE_HEADER] = "t=#{convert_to_microseconds(Time.at(1002))}"
|
30
33
|
|
31
34
|
env[APP_HEADER] = "t=#{convert_to_microseconds(Time.at(1003))}"
|
32
35
|
|
33
36
|
assert_calls_metrics('WebFrontend/WebServer/all', 'WebFrontend/QueueTime', 'Middleware/all') do
|
34
|
-
parse_middleware_time_from(env)
|
35
|
-
parse_queue_time_from(env)
|
36
|
-
parse_server_time_from(env)
|
37
|
+
assert_equal(Time.at(1002), parse_middleware_time_from(env))
|
38
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
39
|
+
assert_equal(Time.at(1000), parse_server_time_from(env))
|
37
40
|
end
|
38
|
-
|
41
|
+
|
39
42
|
check_metric_time('WebFrontend/WebServer/all', 1.0, 0.001)
|
40
|
-
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
43
|
+
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
41
44
|
check_metric_time('Middleware/all', 1.0, 0.001)
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_combined_middleware_and_queue
|
45
48
|
env = {}
|
46
49
|
env[QUEUE_HEADER] = "t=#{convert_to_microseconds(Time.at(1000))}"
|
47
|
-
env[MIDDLEWARE_HEADER] = "t=#{convert_to_microseconds(Time.at(1001))}"
|
50
|
+
env[MIDDLEWARE_HEADER] = "t=#{convert_to_microseconds(Time.at(1001))}"
|
48
51
|
create_test_start_time(env)
|
49
52
|
|
50
53
|
assert_calls_metrics('Middleware/all', 'WebFrontend/QueueTime') do
|
51
|
-
parse_middleware_time_from(env)
|
52
|
-
parse_queue_time_from(env)
|
54
|
+
parse_middleware_time_from(env)
|
55
|
+
assert_equal(Time.at(1000), parse_queue_time_from(env))
|
53
56
|
end
|
54
|
-
|
57
|
+
|
55
58
|
check_metric_time('Middleware/all', 1.0, 0.001)
|
56
|
-
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
59
|
+
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_combined_queue_and_server
|
@@ -63,12 +66,12 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
63
66
|
create_test_start_time(env)
|
64
67
|
|
65
68
|
assert_calls_metrics('WebFrontend/WebServer/all', 'WebFrontend/QueueTime') do
|
66
|
-
parse_queue_time_from(env)
|
69
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
67
70
|
parse_server_time_from(env)
|
68
71
|
end
|
69
|
-
|
72
|
+
|
70
73
|
check_metric_time('WebFrontend/WebServer/all', 1.0, 0.001)
|
71
|
-
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
74
|
+
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
72
75
|
end
|
73
76
|
|
74
77
|
def test_combined_middleware_and_server
|
@@ -81,7 +84,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
81
84
|
parse_middleware_time_from(env)
|
82
85
|
parse_server_time_from(env)
|
83
86
|
end
|
84
|
-
|
87
|
+
|
85
88
|
check_metric_time('WebFrontend/WebServer/all', 1.0, 0.001)
|
86
89
|
check_metric_time('Middleware/all', 1.0, 0.001)
|
87
90
|
end
|
@@ -110,7 +113,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
110
113
|
end
|
111
114
|
check_metric_time('WebFrontend/WebServer/all', 1.0, 0.1)
|
112
115
|
end
|
113
|
-
|
116
|
+
|
114
117
|
def test_parse_server_time_from_with_bad_header
|
115
118
|
env = {'HTTP_X_REQUEST_START' => 't=t=t=t='}
|
116
119
|
create_test_start_time(env)
|
@@ -124,7 +127,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
124
127
|
parse_server_time_from({})
|
125
128
|
end
|
126
129
|
end
|
127
|
-
|
130
|
+
|
128
131
|
def test_parse_middleware_time
|
129
132
|
env = {}
|
130
133
|
create_test_start_time(env)
|
@@ -147,9 +150,9 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
147
150
|
|
148
151
|
env['HTTP_X_QUEUE_START'] = "t=#{time1}"
|
149
152
|
assert_calls_metrics('WebFrontend/QueueTime') do
|
150
|
-
parse_queue_time_from(env)
|
153
|
+
assert_equal(Time.at(1000), parse_queue_time_from(env))
|
151
154
|
end
|
152
|
-
|
155
|
+
|
153
156
|
check_metric_time('WebFrontend/QueueTime', 2.0, 0.1)
|
154
157
|
end
|
155
158
|
|
@@ -158,7 +161,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
158
161
|
create_test_start_time(env)
|
159
162
|
env['HTTP_X_QUEUE_TIME'] = '1000000'
|
160
163
|
assert_calls_metrics('WebFrontend/QueueTime') do
|
161
|
-
parse_queue_time_from(env)
|
164
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
162
165
|
end
|
163
166
|
|
164
167
|
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
@@ -170,7 +173,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
170
173
|
env['HTTP_X_QUEUE_START'] = 't=1' # obviously incorrect
|
171
174
|
env['HTTP_X_QUEUE_TIME'] = '1000000'
|
172
175
|
assert_calls_metrics('WebFrontend/QueueTime') do
|
173
|
-
parse_queue_time_from(env)
|
176
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
174
177
|
end
|
175
178
|
|
176
179
|
# alternate queue should override normal header
|
@@ -182,10 +185,10 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
182
185
|
create_test_start_time(env)
|
183
186
|
env['HTTP_X_HEROKU_QUEUE_WAIT_TIME'] = '1000'
|
184
187
|
assert_calls_metrics('WebFrontend/QueueTime') do
|
185
|
-
parse_queue_time_from(env)
|
188
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
186
189
|
end
|
187
190
|
|
188
|
-
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
191
|
+
check_metric_time('WebFrontend/QueueTime', 1.0, 0.001)
|
189
192
|
end
|
190
193
|
|
191
194
|
def test_check_for_heroku_queue_length_override
|
@@ -194,7 +197,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
194
197
|
env['HTTP_X_QUEUE_TIME'] = '10000000' # ten MEEELION useconds
|
195
198
|
env['HTTP_X_HEROKU_QUEUE_WAIT_TIME'] = '1000'
|
196
199
|
assert_calls_metrics('WebFrontend/QueueTime') do
|
197
|
-
parse_queue_time_from(env)
|
200
|
+
assert_equal(Time.at(1001), parse_queue_time_from(env))
|
198
201
|
end
|
199
202
|
|
200
203
|
# heroku queue should override alternate queue
|
@@ -253,7 +256,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
253
256
|
check_metric_time('WebFrontend/QueueTime', 0.0, 0.001)
|
254
257
|
end
|
255
258
|
|
256
|
-
|
259
|
+
|
257
260
|
# check all the combinations to make sure that ordering doesn't
|
258
261
|
# affect the return value
|
259
262
|
def test_find_oldest_time
|
@@ -287,7 +290,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
287
290
|
record_time_stat('foo', Time.at(1001), Time.at(1000))
|
288
291
|
end
|
289
292
|
end
|
290
|
-
|
293
|
+
|
291
294
|
def test_record_time_stat_with_end_after_start
|
292
295
|
record_time_stat('WebFrontend/WebServer/foo', 2, 1)
|
293
296
|
rescue RuntimeError => e
|
@@ -338,7 +341,7 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
338
341
|
pair = convert_to_name_time_pair(name, time)
|
339
342
|
assert_equal [:foo, Time.at(1)], pair
|
340
343
|
end
|
341
|
-
|
344
|
+
|
342
345
|
def test_get_matches
|
343
346
|
str = "servera t=1000000, serverb t=1000000"
|
344
347
|
matches = get_matches(str) # start a fire
|
@@ -4,9 +4,9 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
4
4
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
5
5
|
extend TestContexts
|
6
6
|
attr_accessor :agent
|
7
|
-
|
7
|
+
|
8
8
|
with_running_agent do
|
9
|
-
|
9
|
+
|
10
10
|
should "run" do
|
11
11
|
run_task_inner 0
|
12
12
|
stat_names = %w[Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/inner_task_0
|
@@ -20,7 +20,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
20
20
|
assert_equal 0, @agent.stats_engine.get_stats_no_scope('Controller').call_count
|
21
21
|
assert_equal 1, @agent.stats_engine.get_stats_no_scope('Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/inner_task_0').call_count
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
should "run_recursive" do
|
25
25
|
run_task_inner(3)
|
26
26
|
assert_equal 1, @agent.stats_engine.lookup_stats(
|
@@ -38,7 +38,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
38
38
|
assert_equal 1, @agent.stats_engine.get_stats_no_scope('Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/inner_task_3').call_count
|
39
39
|
assert_equal 0, @agent.stats_engine.get_stats_no_scope('Controller').call_count
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
should "run_nested" do
|
43
43
|
run_task_outer(3)
|
44
44
|
@agent.stats_engine.metrics.sort.each do |n|
|
@@ -48,7 +48,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
48
48
|
assert_equal 1, @agent.stats_engine.get_stats_no_scope('Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/outer_task').call_count
|
49
49
|
assert_equal 2, @agent.stats_engine.get_stats_no_scope('Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/inner_task_0').call_count
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
should "reentrancy" do
|
53
53
|
assert_equal 0, NewRelic::Agent::BusyCalculator.busy_count
|
54
54
|
run_task_inner(1)
|
@@ -60,7 +60,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
60
60
|
Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/inner_task_1
|
61
61
|
], @agent.stats_engine.metrics.grep(/^Controller/)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
should "transaction" do
|
65
65
|
assert_equal 0, @agent.transaction_sampler.scope_depth, "existing unfinished sample"
|
66
66
|
assert_nil @agent.transaction_sampler.last_sample
|
@@ -81,7 +81,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
81
81
|
assert sample.params[:cpu_time] >= 0, "cpu time: #{sample.params[:cpu_time]},\n#{sample}"
|
82
82
|
assert_equal '10', sample.params[:request_params][:level]
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
should "abort" do
|
86
86
|
@acct = 'Redrocks'
|
87
87
|
perform_action_with_newrelic_trace(:name => 'hello', :force => true, :params => { :account => @acct}) do
|
@@ -107,9 +107,9 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
107
107
|
sample = @agent.transaction_sampler.last_sample
|
108
108
|
assert_not_nil sample
|
109
109
|
assert_equal 'Redrocks', sample.params[:request_params][:account]
|
110
|
-
|
110
|
+
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
should "error_handling" do
|
114
114
|
@agent.error_collector.ignore_error_filter
|
115
115
|
@agent.error_collector.harvest_errors([])
|
@@ -119,7 +119,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
119
119
|
run_task_exception
|
120
120
|
end
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
should "custom_params" do
|
124
124
|
@agent.error_collector.stubs(:enabled).returns(true)
|
125
125
|
@agent.error_collector.ignore_error_filter
|
@@ -135,13 +135,13 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
135
135
|
assert_not_nil error.params[:stack_trace]
|
136
136
|
assert_not_nil error.params[:custom_params]
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
should "instrument_bg" do
|
140
140
|
run_background_job
|
141
141
|
stat_names = %w[OtherTransaction/Background/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/run_background_job
|
142
142
|
OtherTransaction/Background/all
|
143
143
|
OtherTransaction/all].sort
|
144
|
-
|
144
|
+
|
145
145
|
expected_but_missing = stat_names - @agent.stats_engine.metrics
|
146
146
|
assert_equal 0, expected_but_missing.size, @agent.stats_engine.metrics.map { |n|
|
147
147
|
stat = @agent.stats_engine.get_stats_no_scope(n)
|
@@ -151,32 +151,32 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
|
|
151
151
|
assert_equal 1, @agent.stats_engine.get_stats_no_scope('OtherTransaction/Background/all').call_count
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
private
|
156
|
-
|
156
|
+
|
157
157
|
def run_task_inner(n)
|
158
158
|
sleep 0.1
|
159
159
|
return if n == 0
|
160
160
|
assert_equal 1, NewRelic::Agent::BusyCalculator.busy_count
|
161
161
|
run_task_inner(n-1)
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
def run_task_outer(n=0)
|
165
165
|
assert_equal 1, NewRelic::Agent::BusyCalculator.busy_count
|
166
166
|
run_task_inner(n)
|
167
167
|
run_task_inner(n)
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
def run_task_exception
|
171
171
|
NewRelic::Agent.add_custom_parameters(:custom_one => 'one custom val')
|
172
172
|
assert_equal 1, NewRelic::Agent::BusyCalculator.busy_count
|
173
173
|
raise "This is an error"
|
174
174
|
end
|
175
|
-
|
175
|
+
|
176
176
|
def run_background_job
|
177
177
|
"This is a background job"
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
add_transaction_tracer :run_task_exception
|
181
181
|
add_transaction_tracer :run_task_inner, :name => 'inner_task_#{args[0]}'
|
182
182
|
add_transaction_tracer :run_task_outer, :name => 'outer_task', :params => '{ :level => args[0] }'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
2
|
|
3
3
|
memcached_ready = false
|
4
4
|
classes = {
|
@@ -27,26 +27,26 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
27
27
|
def setup
|
28
28
|
NewRelic::Agent.manual_start
|
29
29
|
@engine = NewRelic::Agent.instance.stats_engine
|
30
|
-
|
30
|
+
|
31
31
|
@cache = MEMCACHED_CLASS.new('localhost')
|
32
32
|
@cache.flush_all
|
33
33
|
@key = 'schluessel'
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def _call_test_method_in_web_transaction(method, *args)
|
37
37
|
@engine.clear_stats
|
38
38
|
perform_action_with_newrelic_trace(:name=>'action', :category => :controller) do
|
39
39
|
@cache.send(method.to_sym, *[@key, *args])
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def _call_test_method_in_background_task(method, *args)
|
44
44
|
@engine.clear_stats
|
45
45
|
perform_action_with_newrelic_trace(:name => 'bg_task', :category => :task) do
|
46
46
|
@cache.send(method.to_sym, *[@key, *args])
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_reads__web
|
51
51
|
%w[get get_multi].each do |method|
|
52
52
|
if @cache.class.method_defined?(method)
|
@@ -56,7 +56,7 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def test_writes__web
|
61
61
|
%w[incr decr delete].each do |method|
|
62
62
|
if @cache.class.method_defined?(method)
|
@@ -65,7 +65,7 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
65
65
|
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
%w[set add].each do |method|
|
70
70
|
if @cache.class.method_defined?(method)
|
71
71
|
expected_metrics = ["MemCache/#{method}", "MemCache/allWeb", "MemCache/#{method}:Controller/NewRelic::Agent::MemcacheInstrumentationTest/action"]
|
@@ -74,7 +74,7 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def test_reads__background
|
79
79
|
%w[get get_multi].each do |method|
|
80
80
|
if @cache.class.method_defined?(method)
|
@@ -84,9 +84,9 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def test_writes__background
|
89
|
-
|
89
|
+
|
90
90
|
%w[incr decr delete].each do |method|
|
91
91
|
expected_metrics = ["MemCache/#{method}", "MemCache/allOther", "MemCache/#{method}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"]
|
92
92
|
if @cache.class.method_defined?(method)
|
@@ -94,7 +94,7 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
94
94
|
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
%w[set add].each do |method|
|
99
99
|
expected_metrics = ["MemCache/#{method}", "MemCache/allOther", "MemCache/#{method}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"]
|
100
100
|
if @cache.class.method_defined?(method)
|
@@ -103,5 +103,5 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
end if memcached_ready
|