newrelic_rpm 3.5.4.35.beta → 3.5.5.38
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +42 -0
- data/GUIDELINES_FOR_CONTRIBUTING.md +3 -0
- data/Rakefile +8 -0
- data/bin/mongrel_rpm +1 -1
- data/init.rb +1 -8
- data/lib/new_relic/agent.rb +11 -13
- data/lib/new_relic/agent/agent.rb +89 -110
- data/lib/new_relic/agent/agent_logger.rb +165 -0
- data/lib/new_relic/agent/audit_logger.rb +72 -0
- data/lib/new_relic/agent/beacon_configuration.rb +4 -4
- data/lib/new_relic/agent/browser_monitoring.rb +13 -7
- data/lib/new_relic/agent/busy_calculator.rb +2 -2
- data/lib/new_relic/agent/configuration.rb +25 -0
- data/lib/new_relic/agent/configuration/defaults.rb +45 -8
- data/lib/new_relic/agent/configuration/environment_source.rb +8 -15
- data/lib/new_relic/agent/configuration/manager.rb +22 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +10 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +4 -2
- data/lib/new_relic/agent/cross_process_monitoring.rb +43 -0
- data/lib/new_relic/agent/database.rb +2 -4
- data/lib/new_relic/agent/error_collector.rb +4 -9
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -1
- data/lib/new_relic/agent/instrumentation/authlogic.rb +1 -1
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +41 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -7
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +4 -4
- 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/pop.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +4 -4
- 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 +3 -3
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +2 -2
- data/lib/new_relic/agent/method_tracer.rb +6 -8
- data/lib/new_relic/agent/new_relic_service.rb +94 -106
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
- data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -6
- data/lib/new_relic/agent/sql_sampler.rb +3 -18
- data/lib/new_relic/agent/stats_engine.rb +0 -5
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +3 -3
- data/lib/new_relic/agent/stats_engine/samplers.rb +2 -4
- data/lib/new_relic/agent/thread.rb +8 -3
- data/lib/new_relic/agent/thread_profiler.rb +38 -27
- data/lib/new_relic/agent/transaction_info.rb +1 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -7
- data/lib/new_relic/agent/worker_loop.rb +3 -11
- data/lib/new_relic/control.rb +0 -2
- data/lib/new_relic/control/class_methods.rb +8 -2
- data/lib/new_relic/control/frameworks/merb.rb +0 -6
- data/lib/new_relic/control/frameworks/rails.rb +8 -29
- data/lib/new_relic/control/frameworks/rails3.rb +8 -20
- data/lib/new_relic/control/frameworks/rails4.rb +23 -0
- data/lib/new_relic/control/frameworks/ruby.rb +1 -22
- data/lib/new_relic/control/instance_methods.rb +12 -34
- data/lib/new_relic/control/instrumentation.rb +7 -12
- data/lib/new_relic/control/server_methods.rb +5 -8
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/local_environment.rb +30 -64
- data/lib/new_relic/metric_data.rb +1 -1
- data/lib/new_relic/metric_spec.rb +1 -1
- data/lib/new_relic/noticed_error.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +5 -5
- data/lib/new_relic/stats.rb +9 -7
- data/lib/new_relic/transaction_sample.rb +2 -7
- data/lib/new_relic/version.rb +1 -1
- data/lib/newrelic_rpm.rb +1 -1
- data/newrelic_rpm.gemspec.erb +15 -17
- data/test/config/newrelic.yml +1 -1
- data/test/config/test_control.rb +18 -18
- data/test/fixtures/gemspec_no_build.rb +0 -2
- data/test/fixtures/gemspec_with_build.rb +0 -2
- data/test/fixtures/gemspec_with_build_and_stage.rb +0 -2
- data/test/multiverse/README.md +3 -8
- data/test/multiverse/suites/agent_only/Envfile +1 -0
- data/test/multiverse/suites/agent_only/audit_log_test.rb +99 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/config_file_loading/Envfile +7 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +106 -0
- data/test/multiverse/suites/logging/Envfile +4 -0
- data/test/multiverse/suites/logging/config/newrelic.yml +22 -0
- data/test/multiverse/suites/logging/logging_test.rb +143 -0
- data/test/multiverse/suites/no_load/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +0 -13
- data/test/new_relic/agent/agent/connect_test.rb +30 -92
- data/test/new_relic/agent/agent/start_test.rb +4 -84
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +8 -43
- data/test/new_relic/agent/agent_logger_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +10 -9
- data/test/new_relic/agent/audit_logger_test.rb +105 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +2 -1
- data/test/new_relic/agent/busy_calculator_test.rb +7 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +25 -20
- data/test/new_relic/agent/configuration/manager_test.rb +59 -4
- data/test/new_relic/agent/configuration/yaml_source_test.rb +20 -1
- data/test/new_relic/agent/cross_process_monitoring_test.rb +77 -0
- data/test/new_relic/agent/database_test.rb +0 -11
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -3
- data/test/new_relic/agent/error_collector_test.rb +11 -7
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +39 -19
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +39 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -6
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +3 -15
- data/test/new_relic/agent/new_relic_service_test.rb +48 -8
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +1 -1
- data/test/new_relic/agent/thread_profiler_test.rb +46 -45
- data/test/new_relic/agent/thread_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -1
- data/test/new_relic/agent/worker_loop_test.rb +4 -9
- data/test/new_relic/agent_test.rb +6 -9
- data/test/new_relic/control/class_methods_test.rb +0 -18
- data/test/new_relic/control_test.rb +6 -9
- data/test/new_relic/dispatcher_test.rb +54 -0
- data/test/new_relic/fake_collector.rb +15 -14
- data/test/new_relic/fake_service.rb +4 -1
- data/test/new_relic/fakes_sending_data.rb +30 -0
- data/test/new_relic/framework_test.rb +53 -0
- data/test/new_relic/local_environment_test.rb +5 -2
- data/test/new_relic/rack/browser_monitoring_test.rb +2 -1
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/stats_test.rb +10 -0
- data/test/new_relic/transaction_sample_test.rb +2 -2
- data/test/script/ci.sh +1 -1
- data/test/test_helper.rb +23 -0
- data/ui/views/newrelic/file/images/arrow-close.png +0 -0
- data/ui/views/newrelic/file/images/arrow-open.png +0 -0
- data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/file/images/file_icon.png +0 -0
- data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
- metadata +47 -41
- data/InstallationNotes.md +0 -15
- data/lib/new_relic/control/logging_methods.rb +0 -125
- data/test/multiverse/Rakefile +0 -17
- data/test/multiverse/suites/rum_auto_instrumentation/problem_response.html +0 -422
- data/test/new_relic/control/logging_methods_test.rb +0 -211
@@ -34,7 +34,7 @@ class NewRelic::Agent::Instrumentation::MetricFrame::PopTest < Test::Unit::TestC
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_log_underflow
|
37
|
-
|
37
|
+
expects_logging(:error, regexp_matches(/Underflow in metric frames: /))
|
38
38
|
log_underflow
|
39
39
|
end
|
40
40
|
|
@@ -47,9 +47,6 @@ module NewRelic
|
|
47
47
|
self.class.expects(:method_defined?).returns(false)
|
48
48
|
self.class.expects(:private_method_defined?).returns(false)
|
49
49
|
|
50
|
-
fake_log = mock('log')
|
51
|
-
NewRelic::Control.instance.expects(:log).returns(fake_log)
|
52
|
-
fake_log.expects(:warn).with("Did not trace #{self.class.name}#test_method because that method does not exist")
|
53
50
|
assert !self.class.newrelic_method_exists?('test_method')
|
54
51
|
end
|
55
52
|
|
@@ -111,9 +108,6 @@ module NewRelic
|
|
111
108
|
def test_traced_method_exists_positive
|
112
109
|
self.expects(:_traced_method_name)
|
113
110
|
self.expects(:method_defined?).returns(true)
|
114
|
-
fake_log = mock('log')
|
115
|
-
NewRelic::Control.instance.expects(:log).returns(fake_log)
|
116
|
-
fake_log.expects(:warn).with('Attempt to trace a method twice with the same metric: Method = test_method, Metric Name = Custom/Test/test_method')
|
117
111
|
assert traced_method_exists?('test_method', 'Custom/Test/test_method')
|
118
112
|
end
|
119
113
|
|
@@ -104,7 +104,6 @@ class NewRelic::Agent::MethodTracer::InstanceMethods::TraceExecutionScopedTest <
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_log_errors_base
|
107
|
-
NewRelic::Control.instance.expects(:log).never
|
108
107
|
ran = false
|
109
108
|
log_errors("name", "metric") do
|
110
109
|
ran = true
|
@@ -113,7 +112,6 @@ class NewRelic::Agent::MethodTracer::InstanceMethods::TraceExecutionScopedTest <
|
|
113
112
|
end
|
114
113
|
|
115
114
|
def test_log_errors_with_return
|
116
|
-
NewRelic::Control.instance.expects(:log).never
|
117
115
|
ran = false
|
118
116
|
return_val = log_errors('name', 'metric') do
|
119
117
|
ran = true
|
@@ -125,13 +123,9 @@ class NewRelic::Agent::MethodTracer::InstanceMethods::TraceExecutionScopedTest <
|
|
125
123
|
end
|
126
124
|
|
127
125
|
def test_log_errors_with_error
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
# backtrace looks like, beyond that it actually gets logged. Also,
|
132
|
-
# the mocks are reversed because apparently order matters.
|
133
|
-
fakelog.expects(:error).with(any_parameters)
|
134
|
-
fakelog.expects(:error).with("Caught exception in name. Metric name = metric, exception = should not propagate out of block")
|
126
|
+
expects_logging(:error,
|
127
|
+
includes("Caught exception in name. Metric name = metric"),
|
128
|
+
instance_of(RuntimeError))
|
135
129
|
|
136
130
|
log_errors("name", "metric") do
|
137
131
|
raise "should not propagate out of block"
|
@@ -221,12 +215,6 @@ class NewRelic::Agent::MethodTracer::InstanceMethods::TraceExecutionScopedTest <
|
|
221
215
|
object
|
222
216
|
end
|
223
217
|
|
224
|
-
|
225
|
-
def mocked_log
|
226
|
-
mocked_object('log')
|
227
|
-
end
|
228
|
-
|
229
|
-
|
230
218
|
def mocked_control
|
231
219
|
mocked_object('control')
|
232
220
|
end
|
@@ -35,6 +35,12 @@ class NewRelicServiceTest < Test::Unit::TestCase
|
|
35
35
|
'agent_run_id' => 1
|
36
36
|
}
|
37
37
|
@http_handle.respond_to(:connect, connect_response)
|
38
|
+
|
39
|
+
@reverse_encoder = Module.new do
|
40
|
+
def self.encode(data)
|
41
|
+
data.reverse
|
42
|
+
end
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
def test_initialize_uses_correct_license_key_settings
|
@@ -122,8 +128,8 @@ class NewRelicServiceTest < Test::Unit::TestCase
|
|
122
128
|
end
|
123
129
|
|
124
130
|
|
125
|
-
# Thread profiling only available in
|
126
|
-
if
|
131
|
+
# Thread profiling only available in certain versions
|
132
|
+
if NewRelic::Agent::ThreadProfiler.is_supported?
|
127
133
|
def test_profile_data
|
128
134
|
@http_handle.respond_to(:profile_data, 'profile' => 123)
|
129
135
|
response = @service.profile_data(NewRelic::Agent::ThreadProfile.new(0, 0, 0, true))
|
@@ -234,12 +240,46 @@ end
|
|
234
240
|
end
|
235
241
|
end
|
236
242
|
|
237
|
-
def
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
assert_equal
|
242
|
-
|
243
|
+
def test_compress_request_if_needed_compresses_large_payloads
|
244
|
+
large_payload = 'a' * 65 * 1024
|
245
|
+
body, encoding = @service.compress_request_if_needed(large_payload)
|
246
|
+
assert_equal(large_payload, Zlib::Inflate.inflate(body))
|
247
|
+
assert_equal('deflate', encoding)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_compress_request_if_needed_passes_thru_small_payloads
|
251
|
+
payload = 'a' * 100
|
252
|
+
body, encoding = @service.compress_request_if_needed(payload)
|
253
|
+
assert_equal(payload, body)
|
254
|
+
assert_equal('identity', encoding)
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_marshaller_obeys_requested_encoder
|
258
|
+
dummy = ['hello there']
|
259
|
+
def dummy.to_collector_array(encoder)
|
260
|
+
self.map { |x| encoder.encode(x) }
|
261
|
+
end
|
262
|
+
marshaller = NewRelic::Agent::NewRelicService::Marshaller.new
|
263
|
+
|
264
|
+
identity_encoder = NewRelic::Agent::NewRelicService::Encoders::Identity
|
265
|
+
|
266
|
+
prepared = marshaller.prepare(dummy, :encoder => identity_encoder)
|
267
|
+
assert_equal(dummy, prepared)
|
268
|
+
|
269
|
+
prepared = marshaller.prepare(dummy, :encoder => @reverse_encoder)
|
270
|
+
decoded = prepared.map { |x| x.reverse }
|
271
|
+
assert_equal(dummy, decoded)
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_marshaller_prepare_passes_on_options
|
275
|
+
inner_array = ['abcd']
|
276
|
+
def inner_array.to_collector_array(encoder)
|
277
|
+
self.map { |x| encoder.encode(x) }
|
278
|
+
end
|
279
|
+
dummy = [[inner_array]]
|
280
|
+
marshaller = NewRelic::Agent::NewRelicService::Marshaller.new
|
281
|
+
prepared = marshaller.prepare(dummy, :encoder => @reverse_encoder)
|
282
|
+
assert_equal([[['dcba']]], prepared)
|
243
283
|
end
|
244
284
|
|
245
285
|
def test_marshaller_handles_known_errors
|
@@ -4,7 +4,7 @@ require 'new_relic/agent/pipe_channel_manager'
|
|
4
4
|
|
5
5
|
class NewRelic::Agent::PipeChannelManagerTest < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@test_config = {
|
7
|
+
@test_config = { :developer_mode => true }
|
8
8
|
NewRelic::Agent.config.apply_config(@test_config)
|
9
9
|
NewRelic::Agent::PipeChannelManager.listener.close_all_pipes
|
10
10
|
NewRelic::Agent.manual_start
|
@@ -211,7 +211,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
|
|
211
211
|
marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
|
212
212
|
end
|
213
213
|
|
214
|
-
assert_equal expected, sql_traces[0].to_collector_array(marshaller)
|
214
|
+
assert_equal expected, sql_traces[0].to_collector_array(marshaller.default_encoder)
|
215
215
|
end
|
216
216
|
end
|
217
217
|
end
|
@@ -6,7 +6,38 @@ require 'zlib'
|
|
6
6
|
require 'new_relic/agent/threaded_test'
|
7
7
|
require 'new_relic/agent/thread_profiler'
|
8
8
|
|
9
|
-
|
9
|
+
START_COMMAND = [[666,{
|
10
|
+
"name" => "start_profiler",
|
11
|
+
"arguments" => {
|
12
|
+
"profile_id" => 42,
|
13
|
+
"sample_period" => 0.02,
|
14
|
+
"duration" => 0.025,
|
15
|
+
"only_runnable_threads" => false,
|
16
|
+
"only_request_threads" => false,
|
17
|
+
"profile_agent_code" => false,
|
18
|
+
}
|
19
|
+
}]]
|
20
|
+
|
21
|
+
STOP_COMMAND = [[666,{
|
22
|
+
"name" => "stop_profiler",
|
23
|
+
"arguments" => {
|
24
|
+
"profile_id" => 42,
|
25
|
+
"report_data" => true,
|
26
|
+
}
|
27
|
+
}]]
|
28
|
+
|
29
|
+
STOP_AND_DISCARD_COMMAND = [[666,{
|
30
|
+
"name" => "stop_profiler",
|
31
|
+
"arguments" => {
|
32
|
+
"profile_id" => 42,
|
33
|
+
"report_data" => false,
|
34
|
+
}
|
35
|
+
}]]
|
36
|
+
|
37
|
+
NO_COMMAND = []
|
38
|
+
|
39
|
+
if !NewRelic::Agent::ThreadProfiler.is_supported?
|
40
|
+
|
10
41
|
class ThreadProfilerUnsupportedTest < Test::Unit::TestCase
|
11
42
|
def setup
|
12
43
|
@profiler = NewRelic::Agent::ThreadProfiler.new
|
@@ -26,44 +57,20 @@ class ThreadProfilerUnsupportedTest < Test::Unit::TestCase
|
|
26
57
|
@profiler.stop(true)
|
27
58
|
end
|
28
59
|
|
60
|
+
def test_wont_start_and_reports_error
|
61
|
+
errors = nil
|
62
|
+
@profiler.respond_to_commands(START_COMMAND) { |_, err| errors = err }
|
63
|
+
assert_equal false, errors.nil?
|
64
|
+
assert_equal false, @profiler.running?
|
65
|
+
end
|
66
|
+
|
29
67
|
end
|
30
|
-
end
|
31
68
|
|
32
|
-
|
69
|
+
else
|
70
|
+
|
33
71
|
require 'json'
|
34
72
|
|
35
73
|
class ThreadProfilerTest < ThreadedTest
|
36
|
-
|
37
|
-
START_COMMAND = [[666,{
|
38
|
-
"name" => "start_profiler",
|
39
|
-
"arguments" => {
|
40
|
-
"profile_id" => 42,
|
41
|
-
"sample_period" => 0.02,
|
42
|
-
"duration" => 0.025,
|
43
|
-
"only_runnable_threads" => false,
|
44
|
-
"only_request_threads" => false,
|
45
|
-
"profile_agent_code" => false,
|
46
|
-
}
|
47
|
-
}]]
|
48
|
-
|
49
|
-
STOP_COMMAND = [[666,{
|
50
|
-
"name" => "stop_profiler",
|
51
|
-
"arguments" => {
|
52
|
-
"profile_id" => 42,
|
53
|
-
"report_data" => true,
|
54
|
-
}
|
55
|
-
}]]
|
56
|
-
|
57
|
-
STOP_AND_DISCARD_COMMAND = [[666,{
|
58
|
-
"name" => "stop_profiler",
|
59
|
-
"arguments" => {
|
60
|
-
"profile_id" => 42,
|
61
|
-
"report_data" => false,
|
62
|
-
}
|
63
|
-
}]]
|
64
|
-
|
65
|
-
NO_COMMAND = []
|
66
|
-
|
67
74
|
def setup
|
68
75
|
super
|
69
76
|
@profiler = NewRelic::Agent::ThreadProfiler.new
|
@@ -116,7 +123,7 @@ class ThreadProfilerTest < ThreadedTest
|
|
116
123
|
end
|
117
124
|
|
118
125
|
def test_respond_to_commands_starts_running
|
119
|
-
@profiler.respond_to_commands(START_COMMAND)
|
126
|
+
@profiler.respond_to_commands(START_COMMAND) {|_, err| start_error = err}
|
120
127
|
assert_equal true, @profiler.running?
|
121
128
|
end
|
122
129
|
|
@@ -419,7 +426,7 @@ class ThreadProfileTest < ThreadedTest
|
|
419
426
|
assert_equal [], @profile.traces[:other][0].children
|
420
427
|
end
|
421
428
|
|
422
|
-
def
|
429
|
+
def test_to_collector_array
|
423
430
|
@profile.instance_variable_set(:@start_time, 1350403938892.524)
|
424
431
|
@profile.instance_variable_set(:@stop_time, 1350403939904.375)
|
425
432
|
@profile.instance_variable_set(:@poll_count, 10)
|
@@ -447,14 +454,8 @@ class ThreadProfileTest < ThreadedTest
|
|
447
454
|
0
|
448
455
|
]]
|
449
456
|
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
def test_compress
|
454
|
-
original = '{"OTHER": [[["thread_profiler.py", "<module>", 1], 10, 0, []]], "REQUEST": [], "AGENT": [[["/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", "__bootstrap", 489], 10, 0, [[["/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", "__bootstrap_inner", 512], 10, 0, [[["/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", "run", 480], 10, 0, [[["thread_profiler.py", "_profiler_loop", 76], 10, 0, [[["thread_profiler.py", "_run_profiler", 103], 10, 0, [[["thread_profiler.py", "collect_thread_stacks", 165], 10, 0, []]]]]]]]]]]]], "BACKGROUND": []}'
|
455
|
-
assert_equal(
|
456
|
-
"eJy9UtFOwjAU/ZWlz2QdKKCGmKBOTDSgY/iyLM02ijR0vcttiVmM/047J0LiA080bdJz2nPPbe/9IrP4KYzIjZckCTFr5NmSVQgrITn6VU06HhmVsNxKfmv33dSuoOPZmaSpBSQK3xbhPHYBHBxPwmncRqPzWhte0heRY4Y1fcSs5J+AG01fa7MG5a9+GfrOUQtQmvb8IZUip1Vzw6GfpIT6aNNhLAcw2mBWWXh5dX2Q01lcmVCKoyX73d5ZvHGrmpcGx27/V2uPmQRwPzQcnCSzJnvOVTq4OEVWgJS8MKw91SYrNtrJB/3jVvkbVnU3vn+eRLPF9KHpm+8dYyPRqg==",
|
457
|
-
NewRelic::Agent::ThreadProfile.compress(original).gsub(/\n/, ''))
|
457
|
+
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
458
|
+
assert_equal expected, @profile.to_collector_array(marshaller.default_encoder)
|
458
459
|
end
|
459
460
|
end
|
460
461
|
|
@@ -520,7 +521,7 @@ class ThreadProfileNodeTest < Test::Unit::TestCase
|
|
520
521
|
assert_equal [], parent.children
|
521
522
|
end
|
522
523
|
|
523
|
-
def
|
524
|
+
def test_prune_removes_grandchildren
|
524
525
|
parent = NewRelic::Agent::ThreadProfile::Node.new(SINGLE_LINE)
|
525
526
|
child = NewRelic::Agent::ThreadProfile::Node.new(SINGLE_LINE, parent)
|
526
527
|
grandchild = NewRelic::Agent::ThreadProfile::Node.new(SINGLE_LINE, child)
|
@@ -72,5 +72,18 @@ class ThreadTest < Test::Unit::TestCase
|
|
72
72
|
assert_equal TRACE, result
|
73
73
|
end
|
74
74
|
|
75
|
+
def test_scrub_backtrace_handles_errors_during_backtrace
|
76
|
+
dummy_thread = stub
|
77
|
+
dummy_thread.stubs(:backtrace).raises(StandardError.new('nah'))
|
78
|
+
assert_nothing_raised do
|
79
|
+
NewRelic::Agent::AgentThread.scrub_backtrace(dummy_thread, true)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_scrub_backtrace_handles_nil_backtrace
|
84
|
+
bt = NewRelic::Agent::AgentThread.scrub_backtrace(stub(:backtrace => nil), false)
|
85
|
+
assert_nil(bt)
|
86
|
+
end
|
87
|
+
|
75
88
|
DONT_CARE = true
|
76
89
|
end
|
@@ -180,7 +180,7 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
|
|
180
180
|
# regression
|
181
181
|
def test_trace_should_log_segment_reached_once
|
182
182
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
183
|
-
|
183
|
+
expects_logging(:debug, includes("Segment limit"))
|
184
184
|
8.times {|i| build_segment i.to_s }
|
185
185
|
end
|
186
186
|
end
|
@@ -3,10 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
|
|
3
3
|
|
4
4
|
class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
|
5
5
|
def setup
|
6
|
-
@log = ""
|
7
|
-
@logger = Logger.new(StringIO.new(@log))
|
8
6
|
@worker_loop = NewRelic::Agent::WorkerLoop.new
|
9
|
-
@worker_loop.stubs(:log).returns(@logger)
|
10
7
|
@test_start_time = Time.now
|
11
8
|
end
|
12
9
|
|
@@ -52,8 +49,7 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_task_error__standard
|
55
|
-
|
56
|
-
@logger.expects(:error)
|
52
|
+
expects_logging(:error, any_parameters)
|
57
53
|
# This loop task will run twice
|
58
54
|
done = false
|
59
55
|
@worker_loop.run(0) do
|
@@ -67,8 +63,7 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
|
|
67
63
|
class BadBoy < StandardError; end
|
68
64
|
|
69
65
|
def test_task_error__exception
|
70
|
-
|
71
|
-
@logger.expects(:debug).once
|
66
|
+
expects_logging(:error, any_parameters)
|
72
67
|
@worker_loop.run(0) do
|
73
68
|
@worker_loop.stop
|
74
69
|
raise BadBoy, "oops"
|
@@ -76,8 +71,8 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
|
|
76
71
|
end
|
77
72
|
|
78
73
|
def test_task_error__server
|
79
|
-
|
80
|
-
|
74
|
+
expects_no_logging(:error, any_parameters)
|
75
|
+
expects_logging(:debug, any_parameters)
|
81
76
|
@worker_loop.run(0) do
|
82
77
|
@worker_loop.stop
|
83
78
|
raise NewRelic::Agent::ServerError, "Runtime Error Test"
|
@@ -2,11 +2,14 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
module NewRelic
|
5
|
+
# mostly this class just passes through to the active agent
|
6
|
+
# through the agent method or the control instance through
|
7
|
+
# NewRelic::Control.instance . But it's nice to make sure.
|
5
8
|
class MainAgentTest < Test::Unit::TestCase
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
def setup
|
11
|
+
NewRelic::Agent.reset_config
|
12
|
+
end
|
10
13
|
|
11
14
|
def teardown
|
12
15
|
super
|
@@ -124,12 +127,6 @@ module NewRelic
|
|
124
127
|
NewRelic::Agent.shutdown
|
125
128
|
end
|
126
129
|
|
127
|
-
def test_logger
|
128
|
-
control = mocked_control
|
129
|
-
control.expects(:log)
|
130
|
-
NewRelic::Agent.logger
|
131
|
-
end
|
132
|
-
|
133
130
|
def test_browser_timing_header
|
134
131
|
agent = mocked_agent
|
135
132
|
agent.expects(:browser_timing_header)
|
@@ -18,24 +18,6 @@ class NewRelic::Control::ClassMethodsTest < Test::Unit::TestCase
|
|
18
18
|
assert_equal('a new instance', @base.instance, "should return the result from the #new_instance call")
|
19
19
|
end
|
20
20
|
|
21
|
-
def test_new_instance_non_test
|
22
|
-
local_env = mock('local env')
|
23
|
-
@base.expects(:local_env).returns(local_env).at_least_once
|
24
|
-
local_env.expects(:framework).returns('nontest').twice
|
25
|
-
mock_klass = mock('klass')
|
26
|
-
mock_klass.expects(:new).with(local_env)
|
27
|
-
@base.expects(:load_framework_class).with('nontest').returns(mock_klass)
|
28
|
-
@base.new_instance
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_new_instance_test_framework
|
32
|
-
local_env = mock('local env')
|
33
|
-
local_env.expects(:framework).returns(:test)
|
34
|
-
@base.expects(:local_env).returns(local_env)
|
35
|
-
@base.expects(:load_test_framework)
|
36
|
-
@base.new_instance
|
37
|
-
end
|
38
|
-
|
39
21
|
def test_load_test_framework
|
40
22
|
local_env = mock('local env')
|
41
23
|
# a loose requirement here because the tests will *all* break if
|
@@ -50,9 +50,11 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_test_config
|
53
|
-
if defined?(Rails) && Rails::VERSION::MAJOR.to_i ==
|
53
|
+
if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 4
|
54
|
+
assert_equal :rails4, control.app
|
55
|
+
elsif defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
54
56
|
assert_equal :rails3, control.app
|
55
|
-
elsif defined?(Rails)
|
57
|
+
elsif defined?(::Rails)
|
56
58
|
assert_equal :rails, control.app
|
57
59
|
else
|
58
60
|
assert_equal :test, control.app
|
@@ -61,7 +63,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
61
63
|
assert_match /test/i, control.local_env.dispatcher_instance_id
|
62
64
|
assert("" == NewRelic::Agent.config[:dispatcher].to_s,
|
63
65
|
"Expected dispatcher to be empty, but was #{NewRelic::Agent.config[:dispatcher].to_s}")
|
64
|
-
|
66
|
+
assert !NewRelic::Agent.config[:monitor_mode]
|
65
67
|
control.local_env
|
66
68
|
end
|
67
69
|
|
@@ -147,11 +149,6 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
147
149
|
assert_equal old_ipsocket, IPSocket
|
148
150
|
end
|
149
151
|
|
150
|
-
def test_log_file_name
|
151
|
-
NewRelic::Control.instance.setup_log
|
152
|
-
assert_match /newrelic_agent.log$/, control.instance_variable_get('@log_file')
|
153
|
-
end
|
154
|
-
|
155
152
|
def test_transaction_threshold__override
|
156
153
|
with_config(:transaction_tracer => { :transaction_threshold => 1}) do
|
157
154
|
assert_equal 1, NewRelic::Agent.config[:'transaction_tracer.transaction_threshold']
|
@@ -212,7 +209,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
212
209
|
NewRelic::Agent.shutdown
|
213
210
|
with_config(:disable_samplers => true, :agent_enabled => true) do
|
214
211
|
NewRelic::Control.instance.init_plugin
|
215
|
-
|
212
|
+
assert NewRelic::Agent.instance.stats_engine.send(:harvest_samplers).empty?
|
216
213
|
end
|
217
214
|
end
|
218
215
|
end
|