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
@@ -1,211 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
|
2
|
-
require 'new_relic/control/logging_methods'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class BaseLoggingMethods
|
6
|
-
# stub class to enable testing of the module
|
7
|
-
include NewRelic::Control::LoggingMethods
|
8
|
-
def root; "."; end
|
9
|
-
end
|
10
|
-
|
11
|
-
class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
12
|
-
def setup
|
13
|
-
@base = BaseLoggingMethods.new
|
14
|
-
NewRelic::Control.instance.instance_variable_set '@log_path', nil
|
15
|
-
NewRelic::Control.instance.instance_variable_set '@log_file', nil
|
16
|
-
@root = ::Rails::VERSION::MAJOR == 3 ? Rails.root : RAILS_ROOT
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_log_basic
|
21
|
-
mock_logger = mock('logger')
|
22
|
-
@base.instance_eval { @log = mock_logger }
|
23
|
-
assert_equal mock_logger, @base.log
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_log_no_log
|
27
|
-
log = @base.log
|
28
|
-
assert_equal Logger, log.class
|
29
|
-
assert_equal Logger::INFO, log.level
|
30
|
-
# have to root around in the logger for the logdev
|
31
|
-
assert_equal STDOUT, log.instance_eval { @logdev }.dev
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_logbang_basic
|
35
|
-
@base.expects(:should_log?).returns(true)
|
36
|
-
@base.expects(:to_stdout).with('whee')
|
37
|
-
@base.instance_eval { @log = nil }
|
38
|
-
@base.log!('whee')
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_logbang_should_not_log
|
42
|
-
@base.expects(:should_log?).returns(false)
|
43
|
-
@base.stubs(:to_stdout)
|
44
|
-
assert_equal nil, @base.log!('whee')
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_logbang_with_log
|
48
|
-
@base.expects(:should_log?).returns(true)
|
49
|
-
@base.expects(:to_stdout).with('whee')
|
50
|
-
fake_logger = mock('log')
|
51
|
-
fake_logger.expects(:send).with(:info, 'whee')
|
52
|
-
@base.instance_eval { @log = fake_logger }
|
53
|
-
@base.log!('whee')
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_should_log_no_settings
|
57
|
-
@base.instance_eval { @settings = nil }
|
58
|
-
assert !@base.should_log?
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_should_log_agent_disabled
|
62
|
-
@base.instance_eval { @settings = true }
|
63
|
-
with_config(:agent_enabled => false) do
|
64
|
-
assert !@base.should_log?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_should_log_agent_enabled
|
69
|
-
@base.instance_eval { @settings = true }
|
70
|
-
with_config(:agent_enabled => true) do
|
71
|
-
assert @base.should_log?
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_set_log_level_base
|
76
|
-
fake_logger = mock('logger')
|
77
|
-
# bad configuration
|
78
|
-
with_config(:log_level => 'whee') do
|
79
|
-
fake_logger.expects(:level=).with(Logger::INFO)
|
80
|
-
assert_equal fake_logger, @base.set_log_level!(fake_logger)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_set_log_level_with_each_level
|
85
|
-
fake_logger = mock('logger')
|
86
|
-
%w[debug info warn error fatal].each do |level|
|
87
|
-
with_config(:log_level => level) do
|
88
|
-
fake_logger.expects(:level=).with(Logger.const_get(level.upcase))
|
89
|
-
assert_equal fake_logger, @base.set_log_level!(fake_logger)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_set_log_format
|
95
|
-
fake_logger = Object.new
|
96
|
-
assert !fake_logger.respond_to?(:format_message)
|
97
|
-
assert_equal fake_logger, @base.set_log_format!(fake_logger)
|
98
|
-
assert fake_logger.respond_to?(:format_message)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_setup_log_existing_file
|
102
|
-
fake_logger = mock('logger')
|
103
|
-
Logger.expects(:new).returns(fake_logger)
|
104
|
-
@base.expects(:set_log_format!).with(fake_logger)
|
105
|
-
@base.expects(:set_log_level!).with(fake_logger)
|
106
|
-
with_config(:log_file_path => 'logpath', :log_file_name => 'logfilename') do
|
107
|
-
assert_equal fake_logger, @base.setup_log
|
108
|
-
assert_equal fake_logger, @base.instance_eval { @log }
|
109
|
-
assert_match(/logpath\/logfilename$/, @base.instance_eval { @log_file })
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_to_stdout
|
114
|
-
STDOUT.expects(:puts).with('** [NewRelic] whee')
|
115
|
-
@base.to_stdout('whee')
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_log_path_exists
|
119
|
-
@base.instance_eval { @log_path = 'logpath' }
|
120
|
-
assert_equal 'logpath', @base.log_path
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_log_path_path_exists
|
124
|
-
with_config(:log_file_path => 'log') do
|
125
|
-
assert File.directory?('log')
|
126
|
-
assert_equal File.expand_path('log'), @base.log_path
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_log_path_path_created
|
131
|
-
path = File.expand_path('tmp/log_path_test')
|
132
|
-
FileUtils.mkdir_p(File.dirname(path))
|
133
|
-
@base.instance_eval { @log_path = nil }
|
134
|
-
with_config(:log_file_path => 'tmp/log_path_test') do
|
135
|
-
assert !File.directory?(path) || FileUtils.rmdir(path)
|
136
|
-
@base.expects(:log!).never
|
137
|
-
assert_equal path, @base.log_path
|
138
|
-
assert File.directory?(path)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_log_path_path_unable_to_create
|
143
|
-
path = File.expand_path('tmp/log_path_test')
|
144
|
-
@base.instance_eval { @log_path = nil }
|
145
|
-
with_config(:log_file_path => 'tmp/log_path_test') do
|
146
|
-
assert !File.directory?(path) || FileUtils.rmdir(path)
|
147
|
-
@base.expects(:log!).with("Error creating log directory tmp/log_path_test, using standard out for logging.", :warn)
|
148
|
-
# once for the relative directory, once for the directory relative to Rails.root
|
149
|
-
Dir.expects(:mkdir).with(path).raises('cannot make directory bro!').twice
|
150
|
-
assert_nil @base.log_path
|
151
|
-
assert !File.directory?(path)
|
152
|
-
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_log_to_stdout_when_log_file_path_set_to_STDOUT
|
157
|
-
Dir.expects(:mkdir).never
|
158
|
-
with_config(:log_file_path => 'STDOUT') do
|
159
|
-
@base.setup_log
|
160
|
-
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_logs_to_stdout_include_newrelic_prefix
|
165
|
-
with_config(:log_file_path => 'STDOUT') do
|
166
|
-
STDOUT.expects(:write).with(regexp_matches(/\*\* \[NewRelic\].*whee/))
|
167
|
-
@base.setup_log
|
168
|
-
@base.log.info('whee')
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_set_stdout_destination_from_NEW_RELIC_LOG_env_var
|
173
|
-
ENV['NEW_RELIC_LOG'] = 'stdout'
|
174
|
-
reset_environment_config
|
175
|
-
Dir.expects(:mkdir).never
|
176
|
-
@base.setup_log
|
177
|
-
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
178
|
-
ENV['NEW_RELIC_LOG'] = nil
|
179
|
-
reset_environment_config
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_set_file_destination_from_NEW_RELIC_LOG_env_var
|
183
|
-
ENV['NEW_RELIC_LOG'] = 'log/file.log'
|
184
|
-
reset_environment_config
|
185
|
-
@base.setup_log
|
186
|
-
assert_equal 'log', File.basename(@base.log_path)
|
187
|
-
assert_equal 'file.log', NewRelic::Agent.config['log_file_name']
|
188
|
-
ENV['NEW_RELIC_LOG'] = nil
|
189
|
-
reset_environment_config
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_log_path_uses_default_if_not_set
|
193
|
-
NewRelic::Control.instance.setup_log
|
194
|
-
assert_match(/log\/newrelic_agent.log$/,
|
195
|
-
NewRelic::Control.instance.log_file)
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_log_file_path_uses_given_value
|
199
|
-
Dir.stubs(:mkdir).returns(true)
|
200
|
-
with_config(:log_file_path => 'lerg') do
|
201
|
-
NewRelic::Control.instance.setup_log
|
202
|
-
assert_match(/\/lerg\/newrelic_agent.log$/,
|
203
|
-
NewRelic::Control.instance.log_file)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def reset_environment_config
|
208
|
-
NewRelic::Agent.config.config_stack[0] =
|
209
|
-
NewRelic::Agent::Configuration::EnvironmentSource.new
|
210
|
-
end
|
211
|
-
end
|