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
@@ -0,0 +1,124 @@
|
|
1
|
+
ENV['SKIP_RAILS'] = 'true'
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
3
|
+
require "new_relic/agent/browser_monitoring"
|
4
|
+
|
5
|
+
class NewRelic::Agent::BrowserMonitoringTest < Test::Unit::TestCase
|
6
|
+
include NewRelic::Agent::BrowserMonitoring
|
7
|
+
|
8
|
+
def setup
|
9
|
+
NewRelic::Agent.manual_start
|
10
|
+
@browser_monitoring_key = "fred"
|
11
|
+
@episodes_file = "this_is_my_file"
|
12
|
+
NewRelic::Agent.instance.instance_eval do
|
13
|
+
@beacon_configuration = NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => true, "browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
mocha_teardown
|
19
|
+
Thread.current[:newrelic_start_time] = nil
|
20
|
+
Thread.current[:newrelic_metric_frame] = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_browser_timing_header_with_no_beacon_configuration
|
24
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns( nil)
|
25
|
+
header = browser_timing_header
|
26
|
+
assert_equal "", header
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_browser_timing_header
|
30
|
+
header = browser_timing_header
|
31
|
+
assert_equal "<script>var NREUMQ=[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()</script>", header
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_browser_timing_header_with_rum_enabled_not_specified
|
35
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).at_least_once.returns( NewRelic::Agent::BeaconConfiguration.new({"browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"}))
|
36
|
+
header = browser_timing_header
|
37
|
+
assert_equal "<script>var NREUMQ=[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()</script>", header
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_browser_timing_header_with_rum_enabled_false
|
41
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).twice.returns( NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => false, "browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"}))
|
42
|
+
header = browser_timing_header
|
43
|
+
assert_equal "", header
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_browser_timing_header_disable_all_tracing
|
47
|
+
header = nil
|
48
|
+
NewRelic::Agent.disable_all_tracing do
|
49
|
+
header = browser_timing_header
|
50
|
+
end
|
51
|
+
assert_equal "", header
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_browser_timing_header_disable_transaction_tracing
|
55
|
+
header = nil
|
56
|
+
NewRelic::Agent.disable_transaction_tracing do
|
57
|
+
header = browser_timing_header
|
58
|
+
end
|
59
|
+
assert_equal "", header
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_browser_timing_footer
|
63
|
+
NewRelic::Control.instance.expects(:license_key).returns("a" * 13)
|
64
|
+
|
65
|
+
Thread.current[:newrelic_start_time] = Time.now
|
66
|
+
|
67
|
+
footer = browser_timing_footer
|
68
|
+
assert footer.include?("<script type=\"text/javascript\" charset=\"utf-8\">NREUMQ.push([\"nrf2\",")
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_browser_timing_footer_with_no_browser_key_rum_enabled
|
72
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns( NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => true, "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"}))
|
73
|
+
footer = browser_timing_footer
|
74
|
+
assert_equal "", footer
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_browser_timing_footer_with_no_browser_key_rum_disabled
|
78
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns( NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => false, "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"}))
|
79
|
+
footer = browser_timing_footer
|
80
|
+
assert_equal "", footer
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_browser_timing_footer_with_rum_enabled_not_specified
|
84
|
+
Thread.current[:newrelic_start_time] = Time.now
|
85
|
+
|
86
|
+
license_bytes = [];
|
87
|
+
("a" * 13).each_byte {|byte| license_bytes << byte}
|
88
|
+
config = NewRelic::Agent::BeaconConfiguration.new({"browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file", "license_bytes" => license_bytes})
|
89
|
+
config.expects(:license_bytes).returns(license_bytes)
|
90
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns(config).at_least_once
|
91
|
+
footer = browser_timing_footer
|
92
|
+
assert footer.include?("<script type=\"text/javascript\" charset=\"utf-8\">NREUMQ.push([\"nrf2\",")
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_browser_timing_footer_with_no_beacon_configuration
|
96
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns( nil)
|
97
|
+
footer = browser_timing_footer
|
98
|
+
assert_equal "", footer
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_browser_timing_footer_with_no_start_time
|
102
|
+
Thread.current[:newrelic_start_time] = nil
|
103
|
+
NewRelic::Agent.instance.expects(:beacon_configuration).returns( NewRelic::Agent::BeaconConfiguration.new({"browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"}))
|
104
|
+
footer = browser_timing_footer
|
105
|
+
assert_equal('', footer)
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def test_browser_timing_footer_disable_all_tracing
|
110
|
+
footer = nil
|
111
|
+
NewRelic::Agent.disable_all_tracing do
|
112
|
+
footer = browser_timing_footer
|
113
|
+
end
|
114
|
+
assert_equal "", footer
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_browser_timing_footer_disable_transaction_tracing
|
118
|
+
footer = nil
|
119
|
+
NewRelic::Agent.disable_transaction_tracing do
|
120
|
+
footer = browser_timing_footer
|
121
|
+
end
|
122
|
+
assert_equal "", footer
|
123
|
+
end
|
124
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Run faster standalone
|
2
2
|
ENV['SKIP_RAILS'] = 'true'
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
4
4
|
class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
5
5
|
attr_reader :now
|
6
6
|
def setup
|
@@ -9,7 +9,7 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
9
9
|
@instance_busy = NewRelic::MethodTraceStats.new
|
10
10
|
NewRelic::Agent::BusyCalculator.stubs(:instance_busy_stats).returns(@instance_busy)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_normal
|
14
14
|
# start the timewindow 10 seconds ago
|
15
15
|
# start a request at 10 seconds, 5 seconds long
|
@@ -18,7 +18,7 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
18
18
|
NewRelic::Agent::BusyCalculator.dispatcher_finish(now - 5.0)
|
19
19
|
assert_equal 5, NewRelic::Agent::BusyCalculator.accumulator
|
20
20
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
21
|
-
|
21
|
+
|
22
22
|
assert_equal 1, @instance_busy.call_count
|
23
23
|
assert_in_delta 0.50, @instance_busy.total_call_time, 0.05
|
24
24
|
end
|
@@ -28,7 +28,7 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
28
28
|
NewRelic::Agent::BusyCalculator.stubs(:harvest_start).returns(now - 10.0)
|
29
29
|
NewRelic::Agent::BusyCalculator.dispatcher_start(now - 5.0)
|
30
30
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
31
|
-
|
31
|
+
|
32
32
|
assert_equal 1, @instance_busy.call_count, @instance_busy
|
33
33
|
assert_in_delta 0.50, @instance_busy.total_call_time, 0.05
|
34
34
|
end
|
@@ -45,7 +45,7 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
45
45
|
NewRelic::Agent::BusyCalculator.dispatcher_start(now - 2.0)
|
46
46
|
NewRelic::Agent::BusyCalculator.dispatcher_finish(now - 1.0)
|
47
47
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
48
|
-
|
48
|
+
|
49
49
|
assert_equal 1, @instance_busy.call_count
|
50
50
|
assert_in_delta 0.50, @instance_busy.total_call_time, 0.05
|
51
51
|
end
|
@@ -65,7 +65,7 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
65
65
|
NewRelic::Agent::BusyCalculator.dispatcher_finish(now - 2.0)
|
66
66
|
worker.join
|
67
67
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
68
|
-
|
68
|
+
|
69
69
|
assert_equal 1, @instance_busy.call_count
|
70
70
|
# 3 + 6 = 9, or 90%
|
71
71
|
assert_in_delta 0.90, @instance_busy.total_call_time, 0.025
|
@@ -76,6 +76,6 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
76
76
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
77
77
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
78
78
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
79
|
-
assert_equal 3, @instance_busy.call_count
|
79
|
+
assert_equal 3, @instance_busy.call_count
|
80
80
|
end
|
81
81
|
end
|
@@ -1,8 +1,8 @@
|
|
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
|
class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
3
3
|
require 'new_relic/agent/error_collector'
|
4
4
|
include NewRelic::Agent::ErrorCollector::NoticeError
|
5
|
-
|
5
|
+
|
6
6
|
def test_error_params_from_options_mocked
|
7
7
|
options = {:initial => 'options'}
|
8
8
|
self.expects(:uri_ref_and_root).returns({:hi => 'there', :hello => 'bad'})
|
@@ -15,7 +15,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
15
15
|
'yay'
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_sense_method
|
20
20
|
object = Object.new
|
21
21
|
object.extend(Winner)
|
@@ -29,7 +29,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
29
29
|
assert_equal '', fetch_from_options(options, :none, '')
|
30
30
|
assert_equal({}, options)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def test_uri_ref_and_root_default
|
34
34
|
fake_control = mocked_control
|
35
35
|
fake_control.expects(:root).returns('rootbeer')
|
@@ -39,9 +39,9 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
39
39
|
|
40
40
|
def test_uri_ref_and_root_values
|
41
41
|
fake_control = mocked_control
|
42
|
-
fake_control.expects(:root).returns('rootbeer')
|
42
|
+
fake_control.expects(:root).returns('rootbeer')
|
43
43
|
options = {:uri => 'whee', :referer => 'bang'}
|
44
|
-
assert_equal({:request_referer => 'bang', :rails_root => 'rootbeer', :request_uri => 'whee'}, uri_ref_and_root(options))
|
44
|
+
assert_equal({:request_referer => 'bang', :rails_root => 'rootbeer', :request_uri => 'whee'}, uri_ref_and_root(options))
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_custom_params_from_opts_base
|
@@ -73,7 +73,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
73
73
|
assert_equal(nil, request_params_from_opts(val))
|
74
74
|
assert_equal({}, val, "should delete request_params key from hash")
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def test_normalized_request_and_custom_params_base
|
78
78
|
self.expects(:normalize_params).with(nil).returns(nil)
|
79
79
|
self.expects(:normalize_params).with({}).returns({})
|
@@ -131,7 +131,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
131
131
|
def test_exception_info
|
132
132
|
exception = mock('exception')
|
133
133
|
self.expects(:sense_method).with(exception, 'file_name').returns('file_name')
|
134
|
-
self.expects(:sense_method).with(exception, 'line_number').returns('line_number')
|
134
|
+
self.expects(:sense_method).with(exception, 'line_number').returns('line_number')
|
135
135
|
self.expects(:extract_source).with(exception).returns('source')
|
136
136
|
self.expects(:extract_stack_trace).with(exception).returns('stack_trace')
|
137
137
|
assert_equal({:file_name => 'file_name', :line_number => 'line_number', :source => 'source', :stack_trace => 'stack_trace'},
|
@@ -153,7 +153,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
153
153
|
@errors = []
|
154
154
|
self.expects(:over_queue_limit?).with(exception).returns(true)
|
155
155
|
add_to_error_queue('foo', exception)
|
156
|
-
assert_equal([], @errors)
|
156
|
+
assert_equal([], @errors)
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_should_exit_notice_error_disabled
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Run faster standalone
|
2
2
|
ENV['SKIP_RAILS'] = 'true'
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
4
4
|
|
5
5
|
class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
6
|
-
|
6
|
+
|
7
7
|
def setup
|
8
8
|
super
|
9
9
|
@error_collector = NewRelic::Agent::ErrorCollector.new
|
@@ -13,37 +13,37 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
13
13
|
@error_collector.harvest_errors([])
|
14
14
|
@error_collector.notice_error(nil, :metric=> 'path', :request_params => {:x => 'y'})
|
15
15
|
errors = @error_collector.harvest_errors([])
|
16
|
-
|
16
|
+
|
17
17
|
assert_equal 0, errors.length
|
18
18
|
|
19
19
|
@error_collector.notice_error('Some error message', :metric=> 'path', :request_params => {:x => 'y'})
|
20
20
|
errors = @error_collector.harvest_errors([])
|
21
|
-
|
21
|
+
|
22
22
|
err = errors.first
|
23
|
-
assert_equal 'Some error message', err.message
|
23
|
+
assert_equal 'Some error message', err.message
|
24
24
|
assert_equal 'y', err.params[:request_params][:x]
|
25
25
|
assert_equal '', err.params[:request_uri]
|
26
26
|
assert_equal '', err.params[:request_referer]
|
27
|
-
assert_equal 'path', err.path
|
27
|
+
assert_equal 'path', err.path
|
28
28
|
assert_equal 'Error', err.exception_class
|
29
29
|
|
30
30
|
end
|
31
31
|
def test_simple
|
32
32
|
@error_collector.notice_error(Exception.new("message"), :uri => '/myurl/', :metric => 'path', :referer => 'test_referer', :request_params => {:x => 'y'})
|
33
|
-
|
33
|
+
|
34
34
|
old_errors = []
|
35
35
|
errors = @error_collector.harvest_errors(old_errors)
|
36
|
-
|
36
|
+
|
37
37
|
assert_equal errors.length, 1
|
38
|
-
|
38
|
+
|
39
39
|
err = errors.first
|
40
|
-
assert_equal 'message', err.message
|
40
|
+
assert_equal 'message', err.message
|
41
41
|
assert_equal 'y', err.params[:request_params][:x]
|
42
42
|
assert err.params[:request_uri] == '/myurl/'
|
43
43
|
assert err.params[:request_referer] == "test_referer"
|
44
44
|
assert err.path == 'path'
|
45
45
|
assert err.exception_class == 'Exception'
|
46
|
-
|
46
|
+
|
47
47
|
# the collector should now return an empty array since nothing
|
48
48
|
# has been added since its last harvest
|
49
49
|
errors = @error_collector.harvest_errors(nil)
|
@@ -54,69 +54,69 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
54
54
|
#yes, times 500. it's a 5000 byte string. Assuming strings are
|
55
55
|
#still 1 byte / char.
|
56
56
|
@error_collector.notice_error(Exception.new("1234567890" * 500), :uri => '/myurl/', :metric => 'path', :request_params => {:x => 'y'})
|
57
|
-
|
57
|
+
|
58
58
|
old_errors = []
|
59
59
|
errors = @error_collector.harvest_errors(old_errors)
|
60
|
-
|
60
|
+
|
61
61
|
assert_equal errors.length, 1
|
62
|
-
|
62
|
+
|
63
63
|
err = errors.first
|
64
64
|
assert_equal 4096, err.message.length
|
65
65
|
assert_equal ('1234567890' * 500)[0..4095], err.message
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def test_collect_failover
|
69
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'first', :request_params => {:x => 'y'})
|
70
|
-
|
69
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'first', :request_params => {:x => 'y'})
|
70
|
+
|
71
71
|
errors = @error_collector.harvest_errors([])
|
72
|
-
|
73
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'second', :request_params => {:x => 'y'})
|
74
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
75
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
76
|
-
|
72
|
+
|
73
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'second', :request_params => {:x => 'y'})
|
74
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
75
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
76
|
+
|
77
77
|
errors = @error_collector.harvest_errors(errors)
|
78
|
-
|
78
|
+
|
79
79
|
assert_equal 1, errors.length
|
80
80
|
assert_equal 'first', errors.first.path
|
81
|
-
|
81
|
+
|
82
82
|
# add two more
|
83
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
84
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
85
|
-
|
83
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
84
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
85
|
+
|
86
86
|
errors = @error_collector.harvest_errors(nil)
|
87
87
|
assert_equal 5, errors.length
|
88
88
|
assert_equal 'second', errors.first.path
|
89
89
|
assert_equal 'last', errors.last.path
|
90
|
-
|
90
|
+
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def test_queue_overflow
|
94
|
-
|
94
|
+
|
95
95
|
max_q_length = 20 # for some reason I can't read the constant in ErrorCollector
|
96
|
-
|
96
|
+
|
97
97
|
silence_stream(::STDOUT) do
|
98
98
|
(max_q_length + 5).times do |n|
|
99
|
-
@error_collector.notice_error(Exception.new("exception #{n}"), :metric => "path", :request_params => {:x => n})
|
99
|
+
@error_collector.notice_error(Exception.new("exception #{n}"), :metric => "path", :request_params => {:x => n})
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
errors = @error_collector.harvest_errors([])
|
104
|
-
assert errors.length == max_q_length
|
104
|
+
assert errors.length == max_q_length
|
105
105
|
errors.each_index do |i|
|
106
106
|
err = errors.shift
|
107
107
|
assert_equal i.to_s, err.params[:request_params][:x], err.params.inspect
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
# Why would anyone undef these methods?
|
112
112
|
class TestClass
|
113
113
|
undef to_s
|
114
114
|
undef inspect
|
115
115
|
end
|
116
|
-
|
117
|
-
|
116
|
+
|
117
|
+
|
118
118
|
def test_supported_param_types
|
119
|
-
|
119
|
+
|
120
120
|
types = [[1, '1'],
|
121
121
|
[1.1, '1.1'],
|
122
122
|
['hi', 'hi'],
|
@@ -124,26 +124,26 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
124
124
|
[Exception.new("test"), "#<Exception>"],
|
125
125
|
[TestClass.new, "#<NewRelic::Agent::ErrorCollectorTest::TestClass>"]
|
126
126
|
]
|
127
|
-
|
128
|
-
|
127
|
+
|
128
|
+
|
129
129
|
types.each do |test|
|
130
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => test[0]})
|
131
|
-
|
130
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => test[0]})
|
131
|
+
|
132
132
|
assert_equal test[1], @error_collector.harvest_errors([])[0].params[:request_params][:x]
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
136
|
-
|
135
|
+
|
136
|
+
|
137
137
|
def test_exclude
|
138
138
|
@error_collector.ignore(["IOError"])
|
139
|
-
|
140
|
-
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
141
|
-
|
139
|
+
|
140
|
+
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
141
|
+
|
142
142
|
errors = @error_collector.harvest_errors([])
|
143
|
-
|
143
|
+
|
144
144
|
assert_equal 0, errors.length
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
def test_exclude_block
|
148
148
|
@error_collector.ignore_error_filter do |e|
|
149
149
|
if e.is_a? IOError
|
@@ -152,14 +152,14 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
152
152
|
e
|
153
153
|
end
|
154
154
|
end
|
155
|
-
|
156
|
-
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
157
|
-
|
155
|
+
|
156
|
+
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
157
|
+
|
158
158
|
errors = @error_collector.harvest_errors([])
|
159
|
-
|
159
|
+
|
160
160
|
assert_equal 0, errors.length
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
private
|
164
164
|
def silence_stream(*args)
|
165
165
|
super
|