ghazel-newrelic_rpm 3.1.0.1 → 3.4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +120 -35
- data/LICENSE +29 -2
- data/README.rdoc +2 -2
- data/bin/mongrel_rpm +0 -0
- data/bin/newrelic +0 -0
- data/bin/newrelic_cmd +0 -0
- data/lib/new_relic/agent.rb +50 -38
- data/lib/new_relic/agent/agent.rb +459 -337
- data/lib/new_relic/agent/beacon_configuration.rb +71 -11
- data/lib/new_relic/agent/browser_monitoring.rb +73 -14
- data/lib/new_relic/agent/busy_calculator.rb +11 -3
- data/lib/new_relic/agent/chained_call.rb +2 -2
- data/lib/new_relic/agent/database.rb +223 -0
- data/lib/new_relic/agent/error_collector.rb +231 -183
- data/lib/new_relic/agent/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +10 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +138 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +7 -1
- data/lib/new_relic/agent/instrumentation/authlogic.rb +6 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +46 -14
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +8 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +11 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +49 -25
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +7 -2
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +31 -4
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +1 -5
- data/lib/new_relic/agent/instrumentation/net.rb +8 -2
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +66 -35
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +121 -1
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +21 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +80 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +46 -20
- data/lib/new_relic/agent/instrumentation/sunspot.rb +6 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +7 -2
- data/lib/new_relic/agent/method_tracer.rb +205 -99
- data/lib/new_relic/agent/new_relic_service.rb +221 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +161 -0
- data/lib/new_relic/agent/pipe_service.rb +54 -0
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +89 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -7
- data/lib/new_relic/agent/shim_agent.rb +5 -5
- data/lib/new_relic/agent/sql_sampler.rb +282 -0
- data/lib/new_relic/agent/stats_engine.rb +2 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +35 -30
- data/lib/new_relic/agent/stats_engine/samplers.rb +10 -4
- data/lib/new_relic/agent/stats_engine/transactions.rb +28 -87
- data/lib/new_relic/agent/transaction_info.rb +74 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +18 -3
- data/lib/new_relic/agent/transaction_sampler.rb +108 -20
- data/lib/new_relic/agent/worker_loop.rb +14 -6
- data/lib/new_relic/collection_helper.rb +19 -11
- data/lib/new_relic/command.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +2 -2
- data/lib/new_relic/commands/install.rb +2 -13
- data/lib/new_relic/control.rb +2 -3
- data/lib/new_relic/control/class_methods.rb +12 -6
- data/lib/new_relic/control/configuration.rb +57 -8
- data/lib/new_relic/control/frameworks.rb +10 -0
- data/lib/new_relic/control/frameworks/external.rb +4 -4
- data/lib/new_relic/control/frameworks/merb.rb +2 -1
- data/lib/new_relic/control/frameworks/rails.rb +35 -22
- data/lib/new_relic/control/frameworks/rails3.rb +12 -7
- data/lib/new_relic/control/frameworks/ruby.rb +5 -5
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -4
- data/lib/new_relic/control/instance_methods.rb +38 -12
- data/lib/new_relic/control/instrumentation.rb +23 -4
- data/lib/new_relic/control/logging_methods.rb +70 -15
- data/lib/new_relic/control/server_methods.rb +22 -9
- data/lib/new_relic/delayed_job_injection.rb +16 -3
- data/lib/new_relic/helper.rb +21 -0
- data/lib/new_relic/language_support.rb +95 -0
- data/lib/new_relic/local_environment.rb +92 -48
- data/lib/new_relic/metric_data.rb +7 -2
- data/lib/new_relic/metric_spec.rb +12 -9
- data/lib/new_relic/noticed_error.rb +6 -1
- data/lib/new_relic/rack/browser_monitoring.rb +18 -19
- data/lib/new_relic/rack/developer_mode.rb +3 -2
- data/lib/new_relic/recipes.rb +8 -4
- data/lib/new_relic/stats.rb +17 -60
- data/lib/new_relic/transaction_analysis.rb +2 -1
- data/lib/new_relic/transaction_analysis/segment_summary.rb +4 -2
- data/lib/new_relic/transaction_sample.rb +60 -75
- data/lib/new_relic/transaction_sample/segment.rb +31 -79
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/newrelic.yml +2 -2
- data/newrelic_rpm.gemspec +46 -54
- data/test/active_record_fixtures.rb +3 -3
- data/test/config/newrelic.yml +1 -1
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/new_relic/agent/agent/connect_test.rb +128 -25
- data/test/new_relic/agent/agent/start_test.rb +9 -94
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +2 -4
- data/test/new_relic/agent/agent_test.rb +51 -78
- data/test/new_relic/agent/agent_test_controller.rb +1 -1
- data/test/new_relic/agent/agent_test_controller_test.rb +49 -33
- data/test/new_relic/agent/beacon_configuration_test.rb +12 -5
- data/test/new_relic/agent/browser_monitoring_test.rb +99 -50
- data/test/new_relic/agent/database_test.rb +161 -0
- data/test/new_relic/agent/error_collector_test.rb +47 -23
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +96 -42
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +0 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +3 -11
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +9 -9
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +6 -11
- data/test/new_relic/agent/memcache_instrumentation_test.rb +54 -18
- 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 +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +3 -2
- data/test/new_relic/agent/new_relic_service_test.rb +151 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +114 -0
- data/test/new_relic/agent/pipe_service_test.rb +113 -0
- data/test/new_relic/agent/rpm_agent_test.rb +4 -31
- data/test/new_relic/agent/sql_sampler_test.rb +192 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +19 -18
- data/test/new_relic/agent/stats_engine_test.rb +41 -6
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +27 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +68 -46
- data/test/new_relic/agent/worker_loop_test.rb +3 -3
- data/test/new_relic/agent_test.rb +242 -0
- data/test/new_relic/collection_helper_test.rb +50 -28
- data/test/new_relic/control/configuration_test.rb +77 -0
- data/test/new_relic/control/logging_methods_test.rb +49 -21
- data/test/new_relic/control_test.rb +115 -54
- data/test/new_relic/delayed_job_injection_test.rb +21 -0
- data/test/new_relic/fake_collector.rb +210 -0
- data/test/new_relic/fake_service.rb +44 -0
- data/test/new_relic/local_environment_test.rb +14 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +84 -23
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +31 -0
- data/test/new_relic/stats_test.rb +3 -18
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +14 -0
- data/test/new_relic/transaction_analysis_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +15 -80
- data/test/new_relic/transaction_sample_test.rb +25 -18
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +140 -0
- data/test/script/ci_agent-tests_runner.sh +82 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/script/ci_multiverse_runner.sh +63 -0
- data/test/test_contexts.rb +1 -0
- data/test/test_helper.rb +18 -5
- data/ui/helpers/developer_mode_helper.rb +14 -8
- data/ui/helpers/google_pie_chart.rb +0 -1
- data/ui/views/newrelic/index.rhtml +2 -2
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +4 -18
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +10 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +11 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +17 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +4 -0
- metadata +50 -36
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +0 -108
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +0 -112
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +0 -40
- data/lib/new_relic/data_serialization.rb +0 -84
- data/lib/new_relic/histogram.rb +0 -91
- data/lib/new_relic/rack/metric_app.rb +0 -65
- data/lib/new_relic/rack/mongrel_rpm.ru +0 -28
- data/lib/new_relic/rack/newrelic.yml +0 -27
- data/lib/new_relic/rack_app.rb +0 -6
- data/test/new_relic/data_serialization_test.rb +0 -70
- data/vendor/gems/dependency_detection-0.0.1.build/README +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/LICENSE +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/README +0 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
class FakeService
|
5
|
+
attr_accessor :request_timeout, :agent_id, :agent_data, :collector, :mock
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@agent_data = []
|
9
|
+
@supported_methods = [ :connect, :metric_data, :transaction_sample_data,
|
10
|
+
:error_data, :sql_trace_data, :shutdown ]
|
11
|
+
@collector = NewRelic::Control::Server.new(:name => 'fakehost', :port => 0)
|
12
|
+
@id_counter = 0
|
13
|
+
@base_expectations = {
|
14
|
+
'get_redirect_host' => 'localhost',
|
15
|
+
'connect' => { 'agent_run_id' => agent_run_id },
|
16
|
+
'metric_data' => { 'Some/Metric/Spec' => 1 },
|
17
|
+
'sql_trace_data' => nil,
|
18
|
+
'transaction_sample_data' => nil,
|
19
|
+
'error_data' => nil,
|
20
|
+
'shutdown' => nil,
|
21
|
+
}
|
22
|
+
reset
|
23
|
+
end
|
24
|
+
|
25
|
+
def agent_run_id
|
26
|
+
@id_counter += 1
|
27
|
+
end
|
28
|
+
|
29
|
+
def reset
|
30
|
+
@mock = @base_expectations.dup
|
31
|
+
@id_counter = 0
|
32
|
+
@agent_data = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def method_missing(method, *args)
|
36
|
+
if @supported_methods.include?(method)
|
37
|
+
@agent_data << OpenStruct.new(:action => method, :params => args)
|
38
|
+
@mock[method.to_s]
|
39
|
+
else
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -46,6 +46,7 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
46
46
|
|
47
47
|
::Passenger.class_eval { remove_const :AbstractServer }
|
48
48
|
end
|
49
|
+
|
49
50
|
def test_snapshot
|
50
51
|
e = NewRelic::LocalEnvironment.new
|
51
52
|
s = e.snapshot
|
@@ -60,6 +61,19 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
64
|
+
def test_gather_cpu_info_successful
|
65
|
+
e = NewRelic::LocalEnvironment.new
|
66
|
+
e.gather_cpu_info(File.expand_path(File.join(File.dirname(__FILE__),'..', 'fixtures', 'proc_cpuinfo.txt')))
|
67
|
+
s = e.snapshot
|
68
|
+
assert_equal 24, s.assoc('Processors').last.to_i
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_gather_cpu_info_failure
|
72
|
+
e = NewRelic::LocalEnvironment.new
|
73
|
+
e.gather_cpu_info(File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper.rb')))
|
74
|
+
s = e.snapshot
|
75
|
+
assert_equal 1, s.assoc('Processors').last.to_i
|
76
|
+
end
|
63
77
|
|
64
78
|
def test_default_port
|
65
79
|
e = NewRelic::LocalEnvironment.new
|
@@ -68,5 +82,4 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
68
82
|
assert_equal '3121', e.send(:default_port)
|
69
83
|
ARGV.pop
|
70
84
|
end
|
71
|
-
|
72
85
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..', 'test_helper'))
|
2
|
+
class NewRelic::MetricParser::MetricParserTest < Test::Unit::TestCase
|
3
|
+
class ::AnApplicationClass
|
4
|
+
end
|
5
|
+
|
6
|
+
def test_metric_parser_does_not_instantiate_non_metric_parsing_classes
|
7
|
+
assert NewRelic::MetricParser::MetricParser.for_metric_named('AnApplicationClass/Foo/Bar').
|
8
|
+
is_a? NewRelic::MetricParser::MetricParser
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -5,11 +5,24 @@ require 'new_relic/rack/browser_monitoring'
|
|
5
5
|
|
6
6
|
ENV['RACK_ENV'] = 'test'
|
7
7
|
|
8
|
+
# we should expand the environments we support, any rack app could
|
9
|
+
# benefit from auto-rum, but the truth of the matter is that atm
|
10
|
+
# we only support Rails >= 2.3
|
11
|
+
def middleware_supported?
|
12
|
+
::Rails::VERSION::STRING >= '2.3'
|
13
|
+
end
|
14
|
+
|
15
|
+
if middleware_supported?
|
8
16
|
class BrowserMonitoringTest < Test::Unit::TestCase
|
9
17
|
include Rack::Test::Methods
|
10
18
|
|
11
|
-
|
12
|
-
|
19
|
+
class TestApp
|
20
|
+
def self.doc=(other)
|
21
|
+
@@doc = other
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(env)
|
25
|
+
@@doc ||= <<-EOL
|
13
26
|
<html>
|
14
27
|
<head>
|
15
28
|
<title>im a title</title>
|
@@ -21,38 +34,62 @@ class BrowserMonitoringTest < Test::Unit::TestCase
|
|
21
34
|
<body>im some body text</body>
|
22
35
|
</html>
|
23
36
|
EOL
|
24
|
-
|
25
|
-
[200, {'Content-Type' => 'text/html'}, Rack::Response.new(@doc)]
|
37
|
+
[200, {'Content-Type' => 'text/html'}, Rack::Response.new(@@doc)]
|
26
38
|
end
|
27
|
-
NewRelic::Rack
|
39
|
+
include NewRelic::Agent::Instrumentation::Rack
|
40
|
+
end
|
41
|
+
|
42
|
+
def app
|
43
|
+
NewRelic::Rack::BrowserMonitoring.new(TestApp.new)
|
28
44
|
end
|
29
45
|
|
30
46
|
def setup
|
31
|
-
|
32
|
-
|
33
|
-
NewRelic::Agent.
|
34
|
-
|
47
|
+
super
|
48
|
+
clear_cookies
|
49
|
+
NewRelic::Agent.manual_start
|
50
|
+
config = NewRelic::Agent::BeaconConfiguration.new("browser_key" => "browserKey",
|
51
|
+
"application_id" => "apId",
|
52
|
+
"beacon"=>"beacon",
|
53
|
+
"episodes_url"=>"this_is_my_file")
|
54
|
+
NewRelic::Agent.instance.stubs(:beacon_configuration).returns(config)
|
55
|
+
NewRelic::Agent.stubs(:is_transaction_traced?).returns(true)
|
35
56
|
end
|
36
|
-
|
57
|
+
|
37
58
|
def teardown
|
59
|
+
super
|
60
|
+
clear_cookies
|
38
61
|
mocha_teardown
|
62
|
+
TestApp.doc = nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_make_sure_header_is_set
|
66
|
+
assert NewRelic::Agent.browser_timing_header.size > 0
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_make_sure_footer_is_set
|
70
|
+
assert NewRelic::Agent.browser_timing_footer.size > 0
|
39
71
|
end
|
40
|
-
|
72
|
+
|
41
73
|
def test_should_only_instrument_successfull_html_requests
|
42
74
|
assert app.should_instrument?(200, {'Content-Type' => 'text/html'})
|
43
75
|
assert !app.should_instrument?(500, {'Content-Type' => 'text/html'})
|
44
76
|
assert !app.should_instrument?(200, {'Content-Type' => 'text/xhtml'})
|
45
77
|
end
|
46
78
|
|
79
|
+
def test_should_not_instrument_when_content_disposition
|
80
|
+
assert !app.should_instrument?(200, {'Content-Type' => 'text/html', 'Content-Disposition' => 'attachment; filename=test.html'})
|
81
|
+
end
|
82
|
+
|
47
83
|
def test_insert_timing_header_right_after_open_head_if_no_meta_tags
|
48
84
|
get '/'
|
49
|
-
|
50
|
-
assert(last_response.body.include?("head>#{NewRelic::Agent.browser_timing_header}"),
|
51
|
-
|
52
|
-
|
53
|
-
|
85
|
+
|
86
|
+
assert(last_response.body.include?("head>#{NewRelic::Agent.browser_timing_header}"),
|
87
|
+
last_response.body)
|
88
|
+
TestApp.doc = nil
|
89
|
+
end
|
90
|
+
|
54
91
|
def test_insert_timing_header_right_before_head_close_if_ua_compatible_found
|
55
|
-
|
92
|
+
TestApp.doc = <<-EOL
|
56
93
|
<html>
|
57
94
|
<head>
|
58
95
|
<title>im a title</title>
|
@@ -65,20 +102,44 @@ EOL
|
|
65
102
|
</html>
|
66
103
|
EOL
|
67
104
|
get '/'
|
68
|
-
|
69
|
-
assert(last_response.body.include?("#{NewRelic::Agent.browser_timing_header}</head>"),
|
105
|
+
|
106
|
+
assert(last_response.body.include?("#{NewRelic::Agent.browser_timing_header}</head>"),
|
107
|
+
last_response.body)
|
70
108
|
end
|
71
|
-
|
109
|
+
|
72
110
|
def test_insert_timing_footer_right_before_html_body_close
|
73
111
|
get '/'
|
74
|
-
|
75
|
-
|
112
|
+
|
113
|
+
assert_match(/.*NREUMQ\.push.*new Date\(\)\.getTime\(\),"","","","",""\]\)<\/script><\/body>/,
|
114
|
+
last_response.body)
|
76
115
|
end
|
77
116
|
|
78
117
|
def test_should_not_throw_exception_on_empty_reponse
|
79
|
-
|
118
|
+
TestApp.doc = ''
|
80
119
|
get '/'
|
81
120
|
|
82
121
|
assert last_response.ok?
|
83
122
|
end
|
123
|
+
|
124
|
+
def test_token_is_set_in_footer_when_set_by_cookie
|
125
|
+
token = '1234567890987654321'
|
126
|
+
set_cookie "NRAGENT=tk=#{token}"
|
127
|
+
get '/'
|
128
|
+
|
129
|
+
assert(last_response.body.include?(token), last_response.body)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_guid_is_set_in_footer_when_token_is_set
|
133
|
+
guid = 'abcdefgfedcba'
|
134
|
+
NewRelic::TransactionSample.any_instance.stubs(:generate_guid).returns(guid)
|
135
|
+
NewRelic::Control.instance.stubs(:apdex_t).returns(0.0001)
|
136
|
+
set_cookie "NRAGENT=tk=token"
|
137
|
+
get '/'
|
138
|
+
|
139
|
+
assert(last_response.body.include?(guid), last_response.body)
|
140
|
+
end
|
84
141
|
end
|
142
|
+
else
|
143
|
+
warn "Skipping rum auto instrumentation tests"
|
144
|
+
end
|
145
|
+
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# ENV['SKIP_RAILS'] = 'true'
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..',
|
3
|
+
'test_helper'))
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','ui',
|
5
|
+
'helpers','developer_mode_helper.rb'))
|
6
|
+
|
7
|
+
ENV['RACK_ENV'] = 'test'
|
8
|
+
class DeveloperModeTest < Test::Unit::TestCase
|
9
|
+
include NewRelic::DeveloperModeHelper
|
10
|
+
|
11
|
+
|
12
|
+
def test_application_caller
|
13
|
+
assert_equal "/opt/ruby/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'", application_caller(Fixtures::NORMAL_TRACE)
|
14
|
+
assert_equal "c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'", application_caller(Fixtures::WINDOWS_TRACE)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_application_stack_trace
|
18
|
+
trace = application_stack_trace(Fixtures::NORMAL_TRACE)
|
19
|
+
assert_equal 29, trace.size
|
20
|
+
trace = application_stack_trace(Fixtures::WINDOWS_TRACE)
|
21
|
+
assert_equal 14, trace.size
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_url_for_source
|
26
|
+
for line in Fixtures::NORMAL_TRACE + Fixtures::WINDOWS_TRACE do
|
27
|
+
line = url_for_source(line)
|
28
|
+
assert line =~ /^show_source\?file=.*&line=\d+&/, line
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def params; {} end
|
34
|
+
module Fixtures
|
35
|
+
WINDOWS_TRACE = <<-EOF.split("\n")
|
36
|
+
newrelic_rpm (3.1.1) ui/helpers/developer_mode_helper.rb:234:in `file_and_line'
|
37
|
+
newrelic_rpm (3.1.1) ui/helpers/developer_mode_helper.rb:30:in `block in application_caller'
|
38
|
+
newrelic_rpm (3.1.1) ui/helpers/developer_mode_helper.rb:29:in `each'
|
39
|
+
newrelic_rpm (3.1.1) ui/helpers/developer_mode_helper.rb:29:in `application_caller'
|
40
|
+
newrelic_rpm (3.1.1) ui/helpers/developer_mode_helper.rb:111:in `link_to_source'
|
41
|
+
(erb):5:in `render'
|
42
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'
|
43
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `result'
|
44
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:155:in `render_without_layout'
|
45
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:136:in `render'
|
46
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:121:in `block in render'
|
47
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:120:in `map'
|
48
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:120:in `render'
|
49
|
+
(erb):22:in `render'
|
50
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'
|
51
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `result'
|
52
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:155:in `render_without_layout'
|
53
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:136:in `render'
|
54
|
+
(erb):77:in `block in render'
|
55
|
+
(erb):74:in `collect'
|
56
|
+
(erb):74:in `render'
|
57
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'
|
58
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `result'
|
59
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:155:in `render_without_layout'
|
60
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:133:in `block in render'
|
61
|
+
(erb):38:in `render_with_layout'
|
62
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'
|
63
|
+
c:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `result'
|
64
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:149:in `render_with_layout'
|
65
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:132:in `render'
|
66
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:232:in `show_sample_data'
|
67
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:47:in `_call'
|
68
|
+
newrelic_rpm (3.1.1) lib/new_relic/rack/developer_mode.rb:25:in `call'
|
69
|
+
warden (1.0.5) lib/warden/manager.rb:35:in `block in call'
|
70
|
+
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
|
71
|
+
warden (1.0.5) lib/warden/manager.rb:34:in `call'
|
72
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
|
73
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/head.rb:14:in `call'
|
74
|
+
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
|
75
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
|
76
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/flash.rb:182:in `call'
|
77
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
|
78
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/cookies.rb:302:in `call'
|
79
|
+
activerecord (3.0.9) lib/active_record/query_cache.rb:32:in `block in call'
|
80
|
+
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
|
81
|
+
activerecord (3.0.9) lib/active_record/query_cache.rb:12:in `cache'
|
82
|
+
activerecord (3.0.9) lib/active_record/query_cache.rb:31:in `call'
|
83
|
+
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
|
84
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
|
85
|
+
activesupport (3.0.9) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
|
86
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
|
87
|
+
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
|
88
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
|
89
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
|
90
|
+
railties (3.0.9) lib/rails/rack/logger.rb:13:in `call'
|
91
|
+
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
|
92
|
+
activesupport (3.0.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
|
93
|
+
rack (1.2.3) lib/rack/lock.rb:11:in `block in call'
|
94
|
+
<internal:prelude>:10:in `synchronize'
|
95
|
+
rack (1.2.3) lib/rack/lock.rb:11:in `call'
|
96
|
+
actionpack (3.0.9) lib/action_dispatch/middleware/static.rb:30:in `call'
|
97
|
+
railties (3.0.9) lib/rails/application.rb:168:in `call'
|
98
|
+
railties (3.0.9) lib/rails/application.rb:77:in `method_missing'
|
99
|
+
railties (3.0.9) lib/rails/rack/log_tailer.rb:14:in `call'
|
100
|
+
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
|
101
|
+
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
|
102
|
+
c:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
|
103
|
+
c:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
|
104
|
+
c:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
|
105
|
+
EOF
|
106
|
+
|
107
|
+
NORMAL_TRACE = <<-EOF.split("\n")
|
108
|
+
/opt/ruby/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
|
109
|
+
/opt/ruby/lib/ruby/1.8/timeout.rb:101:in `timeout'
|
110
|
+
/opt/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
|
111
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
|
112
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:1051:in `request_without_newrelic_trace'
|
113
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/instrumentation/net.rb:20:in `request_without_fakeweb'
|
114
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
|
115
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/instrumentation/net.rb:19:in `request_without_fakeweb'
|
116
|
+
/opt/ruby/gems/fakeweb-1.3.0/lib/fake_web/ext/net_http.rb:50:in `request'
|
117
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:1037:in `request_without_newrelic_trace'
|
118
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:543:in `start'
|
119
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:1035:in `request_without_newrelic_trace'
|
120
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/instrumentation/net.rb:20:in `request_without_fakeweb'
|
121
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
|
122
|
+
/opt/bundler/gems/ruby_agent-705a7cf29207/lib/new_relic/agent/instrumentation/net.rb:19:in `request_without_fakeweb'
|
123
|
+
/opt/ruby/gems/fakeweb-1.3.0/lib/fake_web/ext/net_http.rb:50:in `request'
|
124
|
+
/opt/ruby/lib/ruby/1.8/net/http.rb:992:in `post2'
|
125
|
+
/opt/ruby/gems/rforce-0.4.1/lib/rforce/binding.rb:141:in `call_remote'
|
126
|
+
/opt/ruby/gems/rforce-0.4.1/lib/rforce/binding.rb:208:in `method_missing'
|
127
|
+
/Users/joe/dev/workspace/lib/lead_lover/base.rb:135:in `update'
|
128
|
+
/Users/joe/dev/workspace/lib/lead_lover/base.rb:123:in `update_filtered_attributes'
|
129
|
+
/Users/joe/dev/workspace/lib/lead_lover/lead.rb:62:in `assign_to_owner'
|
130
|
+
/Users/joe/dev/workspace/app/models/account.rb:1968:in `link_to_leadlover_lead'
|
131
|
+
/Users/joe/dev/workspace/app/models/account.rb:1956:in `link_to_leadlover'
|
132
|
+
/opt/ruby/gems/activerecord-2.3.14/lib/active_record/associations/association_proxy.rb:215:in `send'
|
133
|
+
/opt/ruby/gems/activerecord-2.3.14/lib/active_record/associations/association_proxy.rb:215:in `method_missing'
|
134
|
+
/Users/joe/dev/workspace/app/models/subscription.rb:883:in `link_to_leadlover'
|
135
|
+
/opt/ruby/gems/delayed_job-2.0.6/lib/delayed/performable_method.rb:35:in `send'
|
136
|
+
/opt/ruby/gems/delayed_job-2.0.6/lib/delayed/performable_method.rb:35:in `perform'
|
137
|
+
/Users/joe/dev/workspace/config/initializers/delayed_job_with_shards.rb:17:in `perform'
|
138
|
+
/opt/ruby/gems/delayed_job-2.0.6/lib/delayed/backend/base.rb:74:in `invoke_job'
|
139
|
+
EOF
|
140
|
+
end
|
141
|
+
end
|
@@ -40,4 +40,35 @@ class DeveloperModeTest < Test::Unit::TestCase
|
|
40
40
|
assert last_response.body.include?('SandwichesController')
|
41
41
|
assert last_response.body.include?('index')
|
42
42
|
end
|
43
|
+
|
44
|
+
def test_explain_sql_displays_query_plan
|
45
|
+
sample = @sampler.samples[0]
|
46
|
+
sql_segment = sample.sql_segments[0]
|
47
|
+
explain_results = NewRelic::Agent::Database.process_resultset(example_explain_as_hashes)
|
48
|
+
|
49
|
+
NewRelic::TransactionSample::Segment.any_instance.expects(:explain_sql).returns(explain_results)
|
50
|
+
get "/newrelic/explain_sql?id=#{sample.sample_id}&segment=#{sql_segment.segment_id}"
|
51
|
+
|
52
|
+
assert last_response.ok?
|
53
|
+
assert last_response.body.include?('PRIMARY')
|
54
|
+
assert last_response.body.include?('Key Length')
|
55
|
+
assert last_response.body.include?('Using index')
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def example_explain_as_hashes
|
61
|
+
[{
|
62
|
+
'Id' => '1',
|
63
|
+
'Select Type' => 'SIMPLE',
|
64
|
+
'Table' => 'sandwiches',
|
65
|
+
'Type' => 'range',
|
66
|
+
'Possible Keys' => 'PRIMARY',
|
67
|
+
'Key' => 'PRIMARY',
|
68
|
+
'Key Length' => '4',
|
69
|
+
'Ref' => '',
|
70
|
+
'Rows' => '1',
|
71
|
+
'Extra' => 'Using index'
|
72
|
+
}]
|
73
|
+
end
|
43
74
|
end
|
@@ -34,9 +34,12 @@ class NewRelic::StatsTest < Test::Unit::TestCase
|
|
34
34
|
def test_sum_attributes
|
35
35
|
first = NewRelic::TestObjectForStats.new
|
36
36
|
second = mock('other object')
|
37
|
+
first.expects(:call_count).returns(6)
|
38
|
+
second.expects(:call_count).returns(8)
|
37
39
|
first.expects(:update_totals).with(second)
|
38
40
|
first.expects(:stack_min_max_from).with(second)
|
39
41
|
first.expects(:update_boundaries).with(second)
|
42
|
+
first.expects(:call_count=).with(8)
|
40
43
|
first.sum_attributes(second)
|
41
44
|
end
|
42
45
|
|
@@ -169,21 +172,6 @@ class NewRelic::StatsTest < Test::Unit::TestCase
|
|
169
172
|
assert_equal(s1.time_str(20000), "20.0 s")
|
170
173
|
end
|
171
174
|
|
172
|
-
def test_fraction_of
|
173
|
-
s1 = NewRelic::MethodTraceStats.new
|
174
|
-
s2 = NewRelic::MethodTraceStats.new
|
175
|
-
s1.trace_call 10
|
176
|
-
s2.trace_call 20
|
177
|
-
assert_equal(s1.fraction_of(s2).to_s, 'NaN')
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_fraction_of2
|
181
|
-
s1 = NewRelic::MethodTraceStats.new
|
182
|
-
s1.trace_call 10
|
183
|
-
s2 = NewRelic::MethodTraceStats.new
|
184
|
-
assert_equal(s1.fraction_of(s2).to_s, 'NaN')
|
185
|
-
end
|
186
|
-
|
187
175
|
def test_multiply_by
|
188
176
|
s1 = NewRelic::MethodTraceStats.new
|
189
177
|
s1.trace_call 10
|
@@ -199,9 +187,6 @@ class NewRelic::StatsTest < Test::Unit::TestCase
|
|
199
187
|
def test_apdex_score
|
200
188
|
s1 = NewRelic::MethodTraceStats.new
|
201
189
|
s1.trace_call 10
|
202
|
-
# FIXME make this test the real logic
|
203
|
-
# don't ask me what this means, but it's what's coming out the
|
204
|
-
# other end when I actually run it.
|
205
190
|
assert_in_delta(s1.apdex_score, 0.285714285714286, 0.0000001)
|
206
191
|
end
|
207
192
|
|