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,23 +1,23 @@
|
|
1
1
|
|
2
2
|
class NewRelic::Agent::MockScopeListener
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :scope
|
5
|
-
|
5
|
+
|
6
6
|
def initialize
|
7
7
|
@scope = {}
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def notice_first_scope_push(time)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def notice_push_scope(scope, time)
|
14
14
|
@scope[scope] = true
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def notice_pop_scope(scope, time)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def notice_scope_empty(time)
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -1,43 +1,43 @@
|
|
1
1
|
ENV['SKIP_RAILS'] = 'true'
|
2
|
-
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
3
3
|
|
4
4
|
class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::TestCase
|
5
5
|
extend TestContexts
|
6
|
-
|
6
|
+
|
7
7
|
attr_reader :agent
|
8
|
-
|
8
|
+
|
9
9
|
with_running_agent do
|
10
10
|
# Fake out the agent to think mongrel is running
|
11
|
-
|
11
|
+
|
12
12
|
should "agent_setup" do
|
13
13
|
assert NewRelic::Agent.instance.class == NewRelic::Agent::Agent
|
14
14
|
assert_raise RuntimeError do
|
15
15
|
NewRelic::Control.instance.init_plugin :agent_enabled => false
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
should "public_apis" do
|
20
20
|
assert_raise RuntimeError do
|
21
21
|
NewRelic::Agent.set_sql_obfuscator(:unknown) do |sql|
|
22
22
|
puts sql
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
ignore_called = false
|
27
27
|
NewRelic::Agent.ignore_error_filter do |e|
|
28
28
|
ignore_called = true
|
29
29
|
nil
|
30
30
|
end
|
31
31
|
NewRelic::Agent.notice_error(StandardError.new("message"), :request_params => {:x => "y"})
|
32
|
-
assert ignore_called
|
32
|
+
assert ignore_called
|
33
33
|
NewRelic::Agent.instance.error_collector.instance_variable_set '@ignore_filter', nil
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
should "startup_shutdown" do
|
37
37
|
@agent = NewRelic::Agent::ShimAgent.instance
|
38
38
|
@agent.shutdown
|
39
39
|
assert (not @agent.started?)
|
40
|
-
@agent.start
|
40
|
+
@agent.start
|
41
41
|
assert !@agent.started?
|
42
42
|
# this installs the real agent:
|
43
43
|
NewRelic::Agent.manual_start
|
@@ -50,18 +50,18 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
50
50
|
assert @agent.started?
|
51
51
|
NewRelic::Agent.shutdown
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
should "manual_start" do
|
55
55
|
NewRelic::Agent.instance.expects(:connect).once
|
56
56
|
NewRelic::Agent.instance.expects(:start_worker_thread).once
|
57
57
|
NewRelic::Agent.instance.instance_variable_set '@started', nil
|
58
58
|
NewRelic::Agent.manual_start :monitor_mode => true, :license_key => ('x' * 40)
|
59
|
-
NewRelic::Agent.shutdown
|
59
|
+
NewRelic::Agent.shutdown
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
should "post_fork_handler" do
|
63
63
|
NewRelic::Agent.manual_start :monitor_mode => true, :license_key => ('x' * 40)
|
64
|
-
NewRelic::Agent.after_fork
|
64
|
+
NewRelic::Agent.after_fork
|
65
65
|
NewRelic::Agent.after_fork
|
66
66
|
NewRelic::Agent.shutdown
|
67
67
|
end
|
@@ -71,7 +71,7 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
71
71
|
assert_equal "mailer", NewRelic::Control.instance.dispatcher_instance_id
|
72
72
|
NewRelic::Agent.shutdown
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
should "restart" do
|
76
76
|
NewRelic::Agent.manual_start :app_name => "noapp", :dispatcher_instance_id => ""
|
77
77
|
NewRelic::Agent.manual_start :app_name => "testjobs", :dispatcher_instance_id => "mailer"
|
@@ -79,7 +79,7 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
79
79
|
assert_equal "mailer", NewRelic::Control.instance.dispatcher_instance_id
|
80
80
|
NewRelic::Agent.shutdown
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
should "send_timeslice_data" do
|
84
84
|
# this test fails due to a rubinius bug
|
85
85
|
return if (RUBY_DESCRIPTION =~ /rubinius/i)
|
@@ -90,22 +90,22 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
90
90
|
end
|
91
91
|
should "set_record_sql" do
|
92
92
|
@agent.set_record_sql(false)
|
93
|
-
assert !
|
93
|
+
assert !NewRelic::Agent.is_sql_recorded?
|
94
94
|
NewRelic::Agent.disable_sql_recording do
|
95
|
-
assert_equal false,
|
95
|
+
assert_equal false, NewRelic::Agent.is_sql_recorded?
|
96
96
|
NewRelic::Agent.disable_sql_recording do
|
97
|
-
assert_equal false,
|
97
|
+
assert_equal false, NewRelic::Agent.is_sql_recorded?
|
98
98
|
end
|
99
|
-
assert_equal false,
|
99
|
+
assert_equal false, NewRelic::Agent.is_sql_recorded?
|
100
100
|
end
|
101
|
-
assert !
|
101
|
+
assert !NewRelic::Agent.is_sql_recorded?
|
102
102
|
@agent.set_record_sql(nil)
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
should "version" do
|
106
106
|
assert_match /\d\.\d+\.\d+/, NewRelic::VERSION::STRING
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
should "invoke_remote__ignore_non_200_results" do
|
110
110
|
NewRelic::Agent::Agent.class_eval do
|
111
111
|
public :invoke_remote
|
@@ -113,8 +113,8 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
113
113
|
response_mock = mock()
|
114
114
|
Net::HTTP.any_instance.stubs(:request).returns(response_mock)
|
115
115
|
response_mock.stubs(:message).returns("bogus error")
|
116
|
-
|
117
|
-
for code in %w[500 504 400 302 503] do
|
116
|
+
|
117
|
+
for code in %w[500 504 400 302 503] do
|
118
118
|
assert_raise NewRelic::Agent::ServerConnectionException, "Ignore #{code}" do
|
119
119
|
response_mock.stubs(:code).returns(code)
|
120
120
|
NewRelic::Agent.agent.invoke_remote :get_data_report_period, 0
|
@@ -133,7 +133,7 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
133
133
|
NewRelic::Agent.agent.invoke_remote :get_data_report_period, 0xFEFE
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
context "with transaction api" do
|
138
138
|
should "reject empty arguments" do
|
139
139
|
assert_raises RuntimeError do
|
@@ -143,7 +143,7 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
|
|
143
143
|
should "record a transaction" do
|
144
144
|
NewRelic::Agent.record_transaction 0.5, 'uri' => "/users/create?foo=bar"
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
@@ -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
|
|
4
4
|
class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
@@ -17,57 +17,57 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
17
17
|
s1 = @engine.get_stats "a"
|
18
18
|
s2 = @engine.get_stats "a"
|
19
19
|
s3 = @engine.get_stats "b"
|
20
|
-
|
20
|
+
|
21
21
|
assert_not_nil s1
|
22
22
|
assert_not_nil s2
|
23
23
|
assert_not_nil s3
|
24
|
-
|
24
|
+
|
25
25
|
assert s1 == s2
|
26
26
|
assert s1 != s3
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def test_harvest
|
30
30
|
s1 = @engine.get_stats "a"
|
31
31
|
s2 = @engine.get_stats "c"
|
32
|
-
|
32
|
+
|
33
33
|
s1.trace_call 10
|
34
34
|
s2.trace_call 1
|
35
35
|
s2.trace_call 3
|
36
|
-
|
36
|
+
|
37
37
|
assert @engine.get_stats("a").call_count == 1
|
38
38
|
assert @engine.get_stats("a").total_call_time == 10
|
39
|
-
|
39
|
+
|
40
40
|
assert @engine.get_stats("c").call_count == 2
|
41
41
|
assert @engine.get_stats("c").total_call_time == 4
|
42
|
-
|
42
|
+
|
43
43
|
metric_data = @engine.harvest_timeslice_data({}, {}).values
|
44
|
-
|
44
|
+
|
45
45
|
# after harvest, all the metrics should be reset
|
46
46
|
assert @engine.get_stats("a").call_count == 0
|
47
47
|
assert @engine.get_stats("a").total_call_time == 0
|
48
|
-
|
48
|
+
|
49
49
|
assert @engine.get_stats("c").call_count == 0
|
50
50
|
assert @engine.get_stats("c").total_call_time == 0
|
51
|
-
|
51
|
+
|
52
52
|
metric_data = metric_data.reverse if metric_data[0].metric_spec.name != "a"
|
53
|
-
|
53
|
+
|
54
54
|
assert metric_data[0].metric_spec.name == "a"
|
55
|
-
|
55
|
+
|
56
56
|
assert metric_data[0].stats.call_count == 1
|
57
57
|
assert metric_data[0].stats.total_call_time == 10
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def test_harvest_with_merge
|
61
61
|
s = @engine.get_stats "a"
|
62
62
|
s.trace_call 1
|
63
|
-
|
63
|
+
|
64
64
|
assert @engine.get_stats("a").call_count == 1
|
65
|
-
|
65
|
+
|
66
66
|
harvest = @engine.harvest_timeslice_data({}, {})
|
67
67
|
assert s.call_count == 0
|
68
68
|
s.trace_call 2
|
69
69
|
assert s.call_count == 1
|
70
|
-
|
70
|
+
|
71
71
|
# this calk should merge the contents of the previous harvest,
|
72
72
|
# so the stats for metric "a" should have 2 data points
|
73
73
|
harvest = @engine.harvest_timeslice_data(harvest, {})
|
@@ -2,11 +2,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..', '..','..','test_
|
|
2
2
|
require 'new_relic/agent/samplers/cpu_sampler'
|
3
3
|
|
4
4
|
class NewRelic::Agent::StatsEngine::SamplersTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
class TestObject
|
7
7
|
include NewRelic::Agent::StatsEngine::Samplers
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def setup
|
11
11
|
@stats_engine = NewRelic::Agent::StatsEngine.new
|
12
12
|
NewRelic::Agent.instance.stubs(:stats_engine).returns(@stats_engine)
|
@@ -32,7 +32,7 @@ class NewRelic::Agent::StatsEngine::SamplersTest < Test::Unit::TestCase
|
|
32
32
|
object.send(:add_sampler_to, sampler_array, sampler)
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def test_cpu
|
37
37
|
s = NewRelic::Agent::Samplers::CpuSampler.new
|
38
38
|
# need to sleep because if you go to fast it will skip the points
|
@@ -94,5 +94,5 @@ class NewRelic::Agent::StatsEngine::SamplersTest < Test::Unit::TestCase
|
|
94
94
|
NewRelic::Agent::Samplers::MemorySampler.stubs(:platform).returns 'windows'
|
95
95
|
assert !NewRelic::Agent::Samplers::MemorySampler.supported_on_this_platform? || defined? JRuby
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
end
|
@@ -1,10 +1,10 @@
|
|
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
|
|
4
4
|
class NewRelic::Agent::StatsEngine::TransactionsTest < Test::Unit::TestCase
|
5
5
|
def setup
|
6
6
|
NewRelic::Agent.manual_start
|
7
|
-
@engine = NewRelic::Agent::StatsEngine.new
|
7
|
+
@engine = NewRelic::Agent::StatsEngine.new
|
8
8
|
rescue => e
|
9
9
|
puts e
|
10
10
|
puts e.backtrace.join("\n")
|
@@ -13,54 +13,54 @@ class NewRelic::Agent::StatsEngine::TransactionsTest < Test::Unit::TestCase
|
|
13
13
|
@engine.harvest_timeslice_data({},{})
|
14
14
|
super
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_scope
|
18
18
|
@engine.push_scope "scope1"
|
19
19
|
assert @engine.peek_scope.name == "scope1"
|
20
|
-
|
20
|
+
|
21
21
|
expected = @engine.push_scope "scope2"
|
22
22
|
@engine.pop_scope expected, 0
|
23
|
-
|
23
|
+
|
24
24
|
scoped = @engine.get_stats "a"
|
25
25
|
scoped.trace_call 3
|
26
|
-
|
26
|
+
|
27
27
|
assert scoped.total_call_time == 3
|
28
28
|
unscoped = @engine.get_stats "a"
|
29
|
-
|
29
|
+
|
30
30
|
assert scoped == @engine.get_stats("a")
|
31
31
|
assert unscoped.total_call_time == 3
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def test_scope__overlap
|
35
35
|
NewRelic::Agent.instance.stubs(:stats_engine).returns(@engine)
|
36
|
-
|
36
|
+
|
37
37
|
@engine.scope_name = 'orlando'
|
38
38
|
self.class.trace_execution_scoped('disney', :deduct_call_time_from_parent => false) { sleep 0.1 }
|
39
39
|
orlando_disney = @engine.get_stats 'disney'
|
40
|
-
|
40
|
+
|
41
41
|
@engine.scope_name = 'anaheim'
|
42
42
|
self.class.trace_execution_scoped('disney', :deduct_call_time_from_parent => false) { sleep 0.1 }
|
43
43
|
anaheim_disney = @engine.get_stats 'disney'
|
44
44
|
|
45
45
|
disney = @engine.get_stats_no_scope "disney"
|
46
|
-
|
46
|
+
|
47
47
|
assert_not_same orlando_disney, anaheim_disney
|
48
48
|
assert_not_equal orlando_disney, anaheim_disney
|
49
|
-
assert_equal 1, orlando_disney.call_count
|
49
|
+
assert_equal 1, orlando_disney.call_count
|
50
50
|
assert_equal 1, anaheim_disney.call_count
|
51
51
|
assert_same disney, orlando_disney.unscoped_stats
|
52
52
|
assert_same disney, anaheim_disney.unscoped_stats
|
53
53
|
assert_equal 2, disney.call_count
|
54
54
|
assert_equal disney.total_call_time, orlando_disney.total_call_time + anaheim_disney.total_call_time
|
55
|
-
|
55
|
+
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def test_simplethrowcase(depth=0)
|
59
|
-
|
59
|
+
|
60
60
|
fail "doh" if depth == 10
|
61
|
-
|
62
|
-
scope = @engine.push_scope "scope#{depth}"
|
63
|
-
|
61
|
+
|
62
|
+
scope = @engine.push_scope "scope#{depth}"
|
63
|
+
|
64
64
|
begin
|
65
65
|
test_simplethrowcase(depth+1)
|
66
66
|
rescue StandardError => e
|
@@ -70,17 +70,17 @@ class NewRelic::Agent::StatsEngine::TransactionsTest < Test::Unit::TestCase
|
|
70
70
|
ensure
|
71
71
|
@engine.pop_scope scope, 0
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
if depth == 0
|
75
75
|
assert @engine.peek_scope.nil?
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
def test_scope_failure
|
81
81
|
scope1 = @engine.push_scope "scope1"
|
82
82
|
@engine.push_scope "scope2"
|
83
|
-
|
83
|
+
|
84
84
|
begin
|
85
85
|
@engine.pop_scope scope1
|
86
86
|
fail "Didn't throw when scope push/pop mismatched"
|
@@ -88,49 +88,49 @@ class NewRelic::Agent::StatsEngine::TransactionsTest < Test::Unit::TestCase
|
|
88
88
|
# success
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
def test_children_time
|
93
93
|
t1 = Time.now
|
94
|
-
|
94
|
+
|
95
95
|
expected1 = @engine.push_scope "a"
|
96
96
|
sleep 0.1
|
97
97
|
t2 = Time.now
|
98
|
-
|
98
|
+
|
99
99
|
expected2 = @engine.push_scope "b"
|
100
100
|
sleep 0.2
|
101
101
|
t3 = Time.now
|
102
|
-
|
102
|
+
|
103
103
|
expected = @engine.push_scope "c"
|
104
104
|
sleep 0.3
|
105
105
|
scope = @engine.pop_scope expected, Time.now - t3
|
106
|
-
|
106
|
+
|
107
107
|
t4 = Time.now
|
108
|
-
|
108
|
+
|
109
109
|
check_time_approximate 0, scope.children_time
|
110
110
|
check_time_approximate 0.3, @engine.peek_scope.children_time
|
111
|
-
|
111
|
+
|
112
112
|
sleep 0.1
|
113
113
|
t5 = Time.now
|
114
|
-
|
114
|
+
|
115
115
|
expected = @engine.push_scope "d"
|
116
116
|
sleep 0.2
|
117
117
|
scope = @engine.pop_scope expected, Time.now - t5
|
118
|
-
|
118
|
+
|
119
119
|
t6 = Time.now
|
120
|
-
|
120
|
+
|
121
121
|
check_time_approximate 0, scope.children_time
|
122
|
-
|
122
|
+
|
123
123
|
scope = @engine.pop_scope expected2, Time.now - t2
|
124
124
|
assert_equal scope.name, 'b'
|
125
|
-
|
125
|
+
|
126
126
|
check_time_approximate (t4 - t3) + (t6 - t5), scope.children_time
|
127
|
-
|
127
|
+
|
128
128
|
scope = @engine.pop_scope expected1, Time.now - t1
|
129
129
|
assert_equal scope.name, 'a'
|
130
|
-
|
130
|
+
|
131
131
|
check_time_approximate (t6 - t2), scope.children_time
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
def test_simple_start_transaction
|
135
135
|
assert @engine.peek_scope.nil?
|
136
136
|
scope = @engine.push_scope "scope"
|
@@ -140,46 +140,46 @@ class NewRelic::Agent::StatsEngine::TransactionsTest < Test::Unit::TestCase
|
|
140
140
|
assert @engine.peek_scope.nil?
|
141
141
|
@engine.end_transaction
|
142
142
|
assert @engine.peek_scope.nil?
|
143
|
-
end
|
144
|
-
|
145
|
-
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
146
|
# test for when the scope stack contains an element only used for tts and not metrics
|
147
147
|
def test_simple_tt_only_scope
|
148
148
|
scope1 = @engine.push_scope "a", 0, true
|
149
149
|
scope2 = @engine.push_scope "b", 10, false
|
150
150
|
scope3 = @engine.push_scope "c", 20, true
|
151
|
-
|
151
|
+
|
152
152
|
@engine.pop_scope scope3, 10
|
153
153
|
@engine.pop_scope scope2, 10
|
154
154
|
@engine.pop_scope scope1, 10
|
155
|
-
|
155
|
+
|
156
156
|
assert_equal 0, scope3.children_time
|
157
157
|
assert_equal 10, scope2.children_time
|
158
|
-
assert_equal 10, scope1.children_time
|
158
|
+
assert_equal 10, scope1.children_time
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
def test_double_tt_only_scope
|
162
162
|
scope1 = @engine.push_scope "a", 0, true
|
163
163
|
scope2 = @engine.push_scope "b", 10, false
|
164
164
|
scope3 = @engine.push_scope "c", 20, false
|
165
165
|
scope4 = @engine.push_scope "d", 30, true
|
166
|
-
|
166
|
+
|
167
167
|
@engine.pop_scope scope4, 10
|
168
168
|
@engine.pop_scope scope3, 10
|
169
169
|
@engine.pop_scope scope2, 10
|
170
170
|
@engine.pop_scope scope1, 10
|
171
|
-
|
171
|
+
|
172
172
|
assert_equal 0, scope4.children_time
|
173
173
|
assert_equal 10, scope3.children_time
|
174
174
|
assert_equal 10, scope2.children_time
|
175
|
-
assert_equal 10, scope1.children_time
|
175
|
+
assert_equal 10, scope1.children_time
|
176
176
|
end
|
177
|
-
|
178
|
-
|
179
|
-
private
|
177
|
+
|
178
|
+
|
179
|
+
private
|
180
180
|
def check_time_approximate(expected, actual)
|
181
181
|
assert((expected - actual).abs < 0.1, "Expected between #{expected - 0.1} and #{expected + 0.1}, got #{actual}")
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
end
|
185
185
|
|