newrelic_rpm 3.1.2 → 3.2.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 +9 -0
- data/lib/new_relic/agent.rb +12 -3
- data/lib/new_relic/agent/agent.rb +99 -97
- data/lib/new_relic/agent/database.rb +203 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -0
- data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +2 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +23 -13
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +2 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +2 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +7 -1
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +1 -0
- data/lib/new_relic/agent/instrumentation/net.rb +2 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +63 -36
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +2 -0
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +4 -2
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +56 -2
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +3 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +2 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +2 -1
- data/lib/new_relic/agent/shim_agent.rb +1 -0
- data/lib/new_relic/agent/sql_sampler.rb +230 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +10 -0
- data/lib/new_relic/agent/transaction_sampler.rb +11 -6
- data/lib/new_relic/collection_helper.rb +7 -4
- data/lib/new_relic/commands/deployments.rb +1 -1
- data/lib/new_relic/commands/install.rb +2 -13
- data/lib/new_relic/control/class_methods.rb +4 -3
- data/lib/new_relic/control/configuration.rb +21 -0
- data/lib/new_relic/control/frameworks/rails.rb +1 -1
- data/lib/new_relic/control/logging_methods.rb +17 -6
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/local_environment.rb +8 -14
- data/lib/new_relic/rack/developer_mode.rb +1 -0
- data/lib/new_relic/stats.rb +1 -0
- data/lib/new_relic/transaction_sample.rb +5 -60
- data/lib/new_relic/transaction_sample/segment.rb +7 -82
- data/lib/new_relic/version.rb +3 -3
- data/newrelic_rpm.gemspec +8 -3
- data/test/new_relic/agent/agent/connect_test.rb +95 -0
- data/test/new_relic/agent/agent/start_test.rb +0 -85
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -0
- data/test/new_relic/agent/agent_test.rb +0 -73
- data/test/new_relic/agent/browser_monitoring_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +160 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +3 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +14 -15
- data/test/new_relic/agent/sql_sampler_test.rb +135 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +12 -3
- data/test/new_relic/collection_helper_test.rb +4 -4
- data/test/new_relic/control/configuration_test.rb +31 -0
- data/test/new_relic/control/logging_methods_test.rb +20 -4
- data/test/new_relic/delayed_job_injection_test.rb +1 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/stats_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +4 -92
- data/test/new_relic/transaction_sample_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/ui/helpers/developer_mode_helper.rb +14 -8
- data/ui/helpers/google_pie_chart.rb +0 -1
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +5 -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/view.rb +4 -0
- metadata +15 -10
@@ -0,0 +1,135 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
+
|
3
|
+
class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
agent = NewRelic::Agent.instance
|
7
|
+
stats_engine = NewRelic::Agent::StatsEngine.new
|
8
|
+
agent.stubs(:stats_engine).returns(stats_engine)
|
9
|
+
@sampler = NewRelic::Agent::SqlSampler.new
|
10
|
+
stats_engine.sql_sampler = @sampler
|
11
|
+
@connection = stub('ActiveRecord connection', :execute => 'result')
|
12
|
+
NewRelic::Agent::Database.stubs(:get_connection).returns(@connection)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_notice_first_scope_push
|
16
|
+
assert_nil @sampler.transaction_data
|
17
|
+
@sampler.notice_first_scope_push nil
|
18
|
+
assert_not_nil @sampler.transaction_data
|
19
|
+
@sampler.notice_scope_empty
|
20
|
+
assert_nil @sampler.transaction_data
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_notice_sql_no_transaction
|
24
|
+
assert_nil @sampler.transaction_data
|
25
|
+
@sampler.notice_sql "select * from test", "Database/test/select", nil, 10
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_notice_sql
|
29
|
+
@sampler.notice_first_scope_push nil
|
30
|
+
@sampler.notice_sql "select * from test", "Database/test/select", nil, 1.5
|
31
|
+
@sampler.notice_sql "select * from test2", "Database/test2/select", nil, 1.3
|
32
|
+
# this sql will not be captured
|
33
|
+
@sampler.notice_sql "select * from test", "Database/test/select", nil, 0
|
34
|
+
assert_not_nil @sampler.transaction_data
|
35
|
+
assert_equal 2, @sampler.transaction_data.sql_data.count
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_harvest_slow_sql
|
39
|
+
data = NewRelic::Agent::TransactionSqlData.new
|
40
|
+
data.set_transaction_info "WebTransaction/Controller/c/a", "/c/a", {}
|
41
|
+
data.sql_data.concat [
|
42
|
+
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
|
43
|
+
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.2),
|
44
|
+
NewRelic::Agent::SlowSql.new("select * from test2", "Database/test2/select", {}, 1.1)
|
45
|
+
]
|
46
|
+
@sampler.harvest_slow_sql data
|
47
|
+
|
48
|
+
assert_equal 2, @sampler.sql_traces.count
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_sql_aggregation
|
52
|
+
sql_trace = NewRelic::Agent::SqlTrace.new("select * from test",
|
53
|
+
NewRelic::Agent::SlowSql.new("select * from test",
|
54
|
+
"Database/test/select", {}, 1.2),
|
55
|
+
"tx_name", "uri")
|
56
|
+
|
57
|
+
sql_trace.aggregate NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5), "slowest_tx_name", "slow_uri"
|
58
|
+
sql_trace.aggregate NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.1), "other_tx_name", "uri2"
|
59
|
+
|
60
|
+
assert_equal 3, sql_trace.call_count
|
61
|
+
assert_equal "slowest_tx_name", sql_trace.path
|
62
|
+
assert_equal "slow_uri", sql_trace.url
|
63
|
+
assert_equal 1.5, sql_trace.max_call_time
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_harvest
|
67
|
+
data = NewRelic::Agent::TransactionSqlData.new
|
68
|
+
data.set_transaction_info "WebTransaction/Controller/c/a", "/c/a", {}
|
69
|
+
|
70
|
+
data.sql_data.concat [NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
|
71
|
+
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.2),
|
72
|
+
NewRelic::Agent::SlowSql.new("select * from test2", "Database/test2/select", {}, 1.1)]
|
73
|
+
@sampler.harvest_slow_sql data
|
74
|
+
|
75
|
+
sql_traces = @sampler.harvest
|
76
|
+
assert_equal 2, sql_traces.count
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_harvest_should_not_take_more_than_10
|
80
|
+
data = NewRelic::Agent::TransactionSqlData.new
|
81
|
+
data.set_transaction_info("WebTransaction/Controller/c/a", "/c/a", {})
|
82
|
+
15.times do |i|
|
83
|
+
data.sql_data << NewRelic::Agent::SlowSql.new("select * from test#{(i+97).chr}",
|
84
|
+
"Database/test#{(i+97).chr}/select", {}, i)
|
85
|
+
end
|
86
|
+
|
87
|
+
@sampler.harvest_slow_sql data
|
88
|
+
result = @sampler.harvest
|
89
|
+
|
90
|
+
assert_equal(10, result.size)
|
91
|
+
assert_equal(14, result.sort{|a,b| b.max_call_time <=> a.max_call_time}.first.total_call_time)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_harvest_should_aggregate_similar_queries
|
95
|
+
data = NewRelic::Agent::TransactionSqlData.new
|
96
|
+
data.set_transaction_info "WebTransaction/Controller/c/a", "/c/a", {}
|
97
|
+
queries = [
|
98
|
+
NewRelic::Agent::SlowSql.new("select * from test where foo in (1, 2)", "Database/test/select", {}, 1.5),
|
99
|
+
NewRelic::Agent::SlowSql.new("select * from test where foo in (1,2, 3 ,4, 5,6, 'snausage')", "Database/test/select", {}, 1.2),
|
100
|
+
NewRelic::Agent::SlowSql.new("select * from test2 where foo in (1,2)", "Database/test2/select", {}, 1.1)
|
101
|
+
]
|
102
|
+
data.sql_data.concat(queries)
|
103
|
+
@sampler.harvest_slow_sql data
|
104
|
+
|
105
|
+
sql_traces = @sampler.harvest
|
106
|
+
assert_equal 2, sql_traces.count
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_harvest_should_collect_explain_plans
|
110
|
+
@connection.expects(:execute).with("EXPLAIN select * from test") \
|
111
|
+
.returns([{"header0" => 'foo0', "header1" => 'foo1', "header2" => 'foo2'}])
|
112
|
+
@connection.expects(:execute).with("EXPLAIN select * from test2") \
|
113
|
+
.returns([{"header0" => 'bar0', "header1" => 'bar1', "header2" => 'bar2'}])
|
114
|
+
|
115
|
+
data = NewRelic::Agent::TransactionSqlData.new
|
116
|
+
data.set_transaction_info "WebTransaction/Controller/c/a", "/c/a", {}
|
117
|
+
|
118
|
+
queries = [
|
119
|
+
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
|
120
|
+
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.2),
|
121
|
+
NewRelic::Agent::SlowSql.new("select * from test2", "Database/test2/select", {}, 1.1)
|
122
|
+
]
|
123
|
+
data.sql_data.concat(queries)
|
124
|
+
@sampler.harvest_slow_sql data
|
125
|
+
sql_traces = @sampler.harvest
|
126
|
+
assert_equal(["header0", "header1", "header2"],
|
127
|
+
sql_traces[0].params[:explain_plan][0].sort)
|
128
|
+
assert_equal(["header0", "header1", "header2"],
|
129
|
+
sql_traces[1].params[:explain_plan][0].sort)
|
130
|
+
assert_equal(["foo0", "foo1", "foo2"],
|
131
|
+
sql_traces[0].params[:explain_plan][1][0].sort)
|
132
|
+
assert_equal(["bar0", "bar1", "bar2"],
|
133
|
+
sql_traces[1].params[:explain_plan][1][0].sort)
|
134
|
+
end
|
135
|
+
end
|
@@ -57,6 +57,15 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
57
57
|
assert(lock.is_a?(Mutex), "Samples lock should be a mutex, is: #{lock.inspect}")
|
58
58
|
end
|
59
59
|
|
60
|
+
def test_configure
|
61
|
+
control = NewRelic::Control.instance
|
62
|
+
control.merge_options('transaction_tracer' => {'stack_trace_threshold' => 5.0, 'limit_segments' => 20, 'explain_threshold' => 4.0})
|
63
|
+
@sampler.configure!
|
64
|
+
assert_equal 20, @sampler.instance_variable_get('@segment_limit')
|
65
|
+
assert_equal 5.0, @sampler.instance_variable_get('@stack_trace_threshold')
|
66
|
+
assert_equal 4.0, @sampler.instance_variable_get('@explain_threshold')
|
67
|
+
end
|
68
|
+
|
60
69
|
def test_current_sample_id_default
|
61
70
|
builder = mock('builder')
|
62
71
|
builder.expects(:sample_id).returns(11111)
|
@@ -77,10 +86,10 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
77
86
|
end
|
78
87
|
|
79
88
|
def test_disable
|
80
|
-
|
89
|
+
assert_nil @sampler.instance_variable_get('@disabled')
|
81
90
|
@sampler.disable
|
82
|
-
|
83
|
-
|
91
|
+
assert @sampler.instance_variable_get('@disabled')
|
92
|
+
assert_nil NewRelic::Agent.instance.stats_engine.instance_variable_get('@transaction_sampler')
|
84
93
|
end
|
85
94
|
|
86
95
|
def test_sampling_rate_equals_default
|
@@ -15,12 +15,12 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
include NewRelic::CollectionHelper
|
17
17
|
def test_string
|
18
|
-
val = (('A'..'Z').to_a.join *
|
19
|
-
assert_equal val[0...
|
18
|
+
val = (('A'..'Z').to_a.join * 1024).to_s
|
19
|
+
assert_equal val[0...16384] + "...", normalize_params(val)
|
20
20
|
end
|
21
21
|
def test_array
|
22
22
|
new_array = normalize_params [ 1000 ] * 2000
|
23
|
-
assert_equal
|
23
|
+
assert_equal 128, new_array.size
|
24
24
|
assert_equal '1000', new_array[0]
|
25
25
|
end
|
26
26
|
def test_boolean
|
@@ -55,7 +55,7 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
def test_hash
|
57
57
|
val = ('A'..'Z').to_a.join * 100
|
58
|
-
assert_equal Hash["
|
58
|
+
assert_equal Hash[(val[0..63] + "...") => (("0"*16384) + "...")], normalize_params({ val => '0' * (16384*2) })
|
59
59
|
end
|
60
60
|
class MyHash < Hash
|
61
61
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
|
2
|
+
|
2
3
|
class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
|
3
4
|
require 'new_relic/control/configuration'
|
4
5
|
include NewRelic::Control::Configuration
|
@@ -37,4 +38,34 @@ class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
|
|
37
38
|
assert_match(/\/lerg\/newrelic_agent.log/,
|
38
39
|
NewRelic::Control.instance.log_file)
|
39
40
|
end
|
41
|
+
|
42
|
+
def test_server_side_config_ignores_yaml
|
43
|
+
settings.merge! 'ssl' => false, 'transaction_tracer' => {'enabled' => true, 'stack_trace_threshold' => 1.0}, 'error_collector' => {'enabled' => true, 'ignore_errors' => 'ActiveRecord::RecordNotFound'}, 'capture_params' => false
|
44
|
+
merge_server_side_config 'transaction_tracer.enabled' => false, 'error_collector.enabled' => false
|
45
|
+
assert_equal({'ssl' => false, 'transaction_tracer' => {'enabled' => false}, 'error_collector' => {'enabled' => false}}, settings)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_install_browser_monitoring
|
49
|
+
require(File.expand_path(File.join(File.dirname(__FILE__),
|
50
|
+
'/../../../lib/new_relic/rack/browser_monitoring')))
|
51
|
+
middleware = stub('middleware config')
|
52
|
+
config = stub('rails config', :middleware => middleware)
|
53
|
+
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
|
54
|
+
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => true }
|
55
|
+
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
56
|
+
|
57
|
+
NewRelic::Control.instance.install_browser_monitoring(config)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_install_browser_monitoring_should_not_install_when_not_configured
|
61
|
+
middleware = stub('middleware config')
|
62
|
+
config = stub('rails config', :middleware => middleware)
|
63
|
+
middleware.expects(:use).never
|
64
|
+
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => false }
|
65
|
+
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
66
|
+
|
67
|
+
NewRelic::Control.instance.install_browser_monitoring(config)
|
68
|
+
|
69
|
+
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => true }
|
70
|
+
end
|
40
71
|
end
|
@@ -117,7 +117,6 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_log_path_path_exists
|
120
|
-
@base.instance_eval { @log_path = nil }
|
121
120
|
@base.settings['log_file_path'] = 'log'
|
122
121
|
assert File.directory?('log')
|
123
122
|
assert_equal File.expand_path('log'), @base.log_path
|
@@ -138,8 +137,8 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
138
137
|
@base.instance_eval { @log_path = nil }
|
139
138
|
@base.settings['log_file_path'] = 'tmp/log_path_test'
|
140
139
|
assert !File.directory?(path) || FileUtils.rmdir(path)
|
141
|
-
@base.expects(:log!).with("Error creating log directory
|
142
|
-
Dir.expects(:mkdir).with(path).raises('cannot make directory bro!').
|
140
|
+
@base.expects(:log!).with("Error creating log directory tmp/log_path_test, using standard out for logging.", :warn)
|
141
|
+
Dir.expects(:mkdir).with(path).raises('cannot make directory bro!').twice # once for the relative directory, once for the directory relative to Rails.root
|
143
142
|
assert_nil @base.log_path
|
144
143
|
assert !File.directory?(path)
|
145
144
|
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
@@ -165,5 +164,22 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
165
164
|
@base.setup_log
|
166
165
|
@base.log.info('whee')
|
167
166
|
end
|
168
|
-
end
|
169
167
|
|
168
|
+
def test_set_stdout_destination_from_NEW_RELIC_LOG_env_var
|
169
|
+
@base.stubs(:fetch).returns('whatever')
|
170
|
+
ENV['NEW_RELIC_LOG'] = 'stdout'
|
171
|
+
Dir.expects(:mkdir).never
|
172
|
+
@base.setup_log
|
173
|
+
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
174
|
+
ENV['NEW_RELIC_LOG'] = nil
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_set_file_destination_from_NEW_RELIC_LOG_env_var
|
178
|
+
@base.stubs(:fetch).returns('whatever')
|
179
|
+
ENV['NEW_RELIC_LOG'] = 'log/file.log'
|
180
|
+
@base.setup_log
|
181
|
+
assert_equal 'log', File.basename(@base.log_path)
|
182
|
+
assert_equal 'file.log', @base.log_file_name
|
183
|
+
ENV['NEW_RELIC_LOG'] = nil
|
184
|
+
end
|
185
|
+
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
|
3
3
|
class NewRelic::DelayedJobInstrumentationTest < Test::Unit::TestCase
|
4
4
|
def test_skip_logging_if_no_logger_found
|
5
5
|
Object.const_set('Delayed', Module.new) unless defined?(Delayed)
|
6
|
-
::Delayed.const_set('Worker', Class.new)
|
6
|
+
::Delayed.const_set('Worker', Class.new) unless defined?(::Delayed::Worker)
|
7
7
|
|
8
8
|
NewRelic::Agent.stubs(:logger).raises(NoMethodError,
|
9
9
|
'tempoarily not allowed')
|
@@ -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
|
@@ -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
|
|
@@ -199,9 +202,6 @@ class NewRelic::StatsTest < Test::Unit::TestCase
|
|
199
202
|
def test_apdex_score
|
200
203
|
s1 = NewRelic::MethodTraceStats.new
|
201
204
|
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
205
|
assert_in_delta(s1.apdex_score, 0.285714285714286, 0.0000001)
|
206
206
|
end
|
207
207
|
|