wd_newrelic_rpm 3.3.4.1 → 3.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.project +23 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +317 -39
- data/GUIDELINES_FOR_CONTRIBUTING.md +76 -0
- data/Gemfile +16 -0
- data/LICENSE +1 -1
- data/{README.rdoc → README.md} +71 -55
- data/Rakefile +62 -0
- data/bin/mongrel_rpm +1 -1
- data/config.dot +290 -0
- data/config/database.yml +5 -0
- data/init.rb +31 -0
- data/lib/new_relic/agent.rb +31 -60
- data/lib/new_relic/agent/agent.rb +277 -502
- 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 +36 -50
- data/lib/new_relic/agent/browser_monitoring.rb +114 -61
- data/lib/new_relic/agent/busy_calculator.rb +14 -6
- data/lib/new_relic/agent/configuration.rb +74 -0
- data/lib/new_relic/agent/configuration/defaults.rb +126 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +49 -0
- data/lib/new_relic/agent/configuration/manager.rb +136 -0
- data/lib/new_relic/agent/configuration/mask_defaults.rb +10 -0
- data/lib/new_relic/agent/configuration/server_source.rb +27 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +63 -0
- data/lib/new_relic/agent/cross_process_monitoring.rb +43 -0
- data/lib/new_relic/agent/database.rb +39 -26
- data/lib/new_relic/agent/error_collector.rb +48 -49
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +4 -7
- 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 +35 -12
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -12
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache.rb +6 -6
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +4 -14
- 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 +6 -20
- data/lib/new_relic/agent/instrumentation/queue_time.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -7
- 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 +5 -5
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +6 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +81 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -10
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +5 -4
- data/lib/new_relic/agent/method_tracer.rb +11 -9
- data/lib/new_relic/agent/new_relic_service.rb +379 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +175 -0
- data/lib/new_relic/agent/pipe_service.rb +58 -0
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +86 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -8
- data/lib/new_relic/agent/sql_sampler.rb +31 -74
- data/lib/new_relic/agent/stats_engine.rb +0 -5
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +40 -24
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +89 -14
- data/lib/new_relic/agent/stats_engine/samplers.rb +9 -7
- data/lib/new_relic/agent/stats_engine/transactions.rb +20 -12
- data/lib/new_relic/agent/thread.rb +32 -0
- data/lib/new_relic/agent/thread_profiler.rb +306 -0
- data/lib/new_relic/agent/transaction_info.rb +24 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +12 -13
- data/lib/new_relic/agent/transaction_sampler.rb +49 -65
- data/lib/new_relic/agent/worker_loop.rb +31 -25
- data/lib/new_relic/collection_helper.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +19 -10
- data/lib/new_relic/control.rb +1 -3
- data/lib/new_relic/control/class_methods.rb +10 -5
- data/lib/new_relic/control/frameworks/merb.rb +0 -6
- data/lib/new_relic/control/frameworks/rails.rb +30 -45
- data/lib/new_relic/control/frameworks/rails3.rb +23 -18
- data/lib/new_relic/control/frameworks/rails4.rb +23 -0
- data/lib/new_relic/control/frameworks/ruby.rb +2 -23
- data/lib/new_relic/control/instance_methods.rb +35 -73
- data/lib/new_relic/control/instrumentation.rb +7 -12
- data/lib/new_relic/control/server_methods.rb +17 -19
- data/lib/new_relic/delayed_job_injection.rb +2 -2
- data/lib/new_relic/helper.rb +34 -0
- data/lib/new_relic/language_support.rb +56 -37
- data/lib/new_relic/local_environment.rb +32 -67
- data/lib/new_relic/metric_data.rb +10 -2
- data/lib/new_relic/metric_spec.rb +7 -3
- data/lib/new_relic/noticed_error.rb +32 -9
- data/lib/new_relic/rack.rb +4 -0
- data/lib/new_relic/rack/browser_monitoring.rb +34 -25
- data/lib/new_relic/rack/developer_mode.rb +3 -0
- data/lib/new_relic/rack/error_collector.rb +56 -0
- data/lib/new_relic/stats.rb +9 -7
- data/lib/new_relic/transaction_sample.rb +19 -18
- data/lib/new_relic/transaction_sample/segment.rb +13 -15
- data/lib/new_relic/version.rb +19 -3
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/tasks/tests.rake +6 -8
- data/newrelic.yml +15 -32
- data/newrelic_rpm.gemspec +224 -43
- data/newrelic_rpm.gemspec.erb +54 -0
- data/test/config/newrelic.yml +4 -3
- data/test/config/test_control.rb +18 -18
- data/test/fixtures/gemspec_no_build.rb +442 -0
- data/test/fixtures/gemspec_with_build.rb +442 -0
- data/test/fixtures/gemspec_with_build_and_stage.rb +442 -0
- data/test/intentional_fail.rb +10 -0
- data/test/multiverse/.gitignore +10 -0
- data/test/multiverse/README.md +85 -0
- data/test/multiverse/lib/multiverse/color.rb +13 -0
- data/test/multiverse/lib/multiverse/envfile.rb +66 -0
- data/test/multiverse/lib/multiverse/environment.rb +16 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
- data/test/multiverse/lib/multiverse/runner.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +162 -0
- data/test/multiverse/script/run_one +3 -0
- data/test/multiverse/script/runner +9 -0
- data/test/multiverse/suites/active_record/Envfile +13 -0
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
- data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
- data/test/multiverse/suites/agent_only/Envfile +4 -0
- data/test/multiverse/suites/agent_only/audit_log_test.rb +99 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +22 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +109 -0
- data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +29 -0
- data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
- data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +80 -0
- 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/datamapper/Envfile +8 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
- data/test/multiverse/suites/datamapper/encoding_test.rb +36 -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/monitor_mode_false/Envfile +2 -0
- data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +25 -0
- data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +29 -0
- data/test/multiverse/suites/no_load/Envfile +2 -0
- data/test/multiverse/suites/no_load/config/newrelic.yml +22 -0
- data/test/multiverse/suites/no_load/start_up_test.rb +14 -0
- data/test/multiverse/suites/rails_3_error_tracing/Envfile +15 -0
- data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +165 -0
- data/test/multiverse/suites/rails_3_error_tracing/error_tracing_test.rb +236 -0
- data/test/multiverse/suites/rails_3_gc/Envfile +8 -0
- data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +167 -0
- data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +92 -0
- data/test/multiverse/suites/rails_3_queue_time/Envfile +15 -0
- data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +165 -0
- data/test/multiverse/suites/rails_3_queue_time/queue_time_test.rb +75 -0
- data/test/multiverse/suites/rails_3_views/.gitignore +3 -0
- data/test/multiverse/suites/rails_3_views/Envfile +16 -0
- data/test/multiverse/suites/rails_3_views/app/views/foos/_foo.html.haml +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_mid_partial.html.erb +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_top_partial.html.erb +3 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/deep_partial.html.erb +3 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/haml_view.html.haml +6 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/index.html.erb +4 -0
- data/test/multiverse/suites/rails_3_views/config/newrelic.yml +164 -0
- data/test/multiverse/suites/rails_3_views/view_instrumentation_test.rb +245 -0
- data/test/multiverse/suites/resque/Envfile +21 -0
- data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
- data/test/multiverse/suites/resque/dump.rdb +0 -0
- data/test/multiverse/suites/resque/instrumentation_test.rb +73 -0
- data/test/multiverse/suites/rum_auto_instrumentation/Envfile +4 -0
- data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +24 -0
- data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +5000 -0
- data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +102 -0
- data/test/multiverse/suites/sinatra/Envfile +13 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +77 -0
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
- data/test/multiverse/suites/sinatra/sinatra_test.rb +55 -0
- data/test/multiverse/test/multiverse_test.rb +55 -0
- data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
- data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
- data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
- data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
- data/test/new_relic/agent/agent/connect_test.rb +151 -227
- data/test/new_relic/agent/agent/start_test.rb +68 -118
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +12 -74
- data/test/new_relic/agent/agent_logger_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +116 -30
- data/test/new_relic/agent/agent_test_controller.rb +1 -1
- data/test/new_relic/agent/agent_test_controller_test.rb +42 -10
- data/test/new_relic/agent/audit_logger_test.rb +105 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +63 -67
- data/test/new_relic/agent/browser_monitoring_test.rb +151 -79
- data/test/new_relic/agent/busy_calculator_test.rb +7 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +79 -0
- data/test/new_relic/agent/configuration/manager_test.rb +204 -0
- data/test/new_relic/agent/configuration/server_source_test.rb +45 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +75 -0
- data/test/new_relic/agent/cross_process_monitoring_test.rb +77 -0
- data/test/new_relic/agent/database_test.rb +12 -11
- data/test/new_relic/agent/error_collector/notice_error_test.rb +64 -53
- data/test/new_relic/agent/error_collector_test.rb +33 -19
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +60 -30
- 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/instrumentation/metric_frame_test.rb +6 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +14 -0
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +25 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -10
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +3 -15
- data/test/new_relic/agent/method_tracer_test.rb +7 -6
- data/test/new_relic/agent/mock_scope_listener.rb +3 -0
- data/test/new_relic/agent/new_relic_service_test.rb +376 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +131 -0
- data/test/new_relic/agent/pipe_service_test.rb +113 -0
- data/test/new_relic/agent/rpm_agent_test.rb +27 -50
- data/test/new_relic/agent/sql_sampler_test.rb +81 -56
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +3 -20
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +12 -1
- data/test/new_relic/agent/stats_engine_test.rb +17 -8
- data/test/new_relic/agent/thread_profiler_test.rb +537 -0
- data/test/new_relic/agent/thread_test.rb +89 -0
- data/test/new_relic/agent/threaded_test.rb +65 -0
- data/test/new_relic/agent/transaction_info_test.rb +45 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +8 -7
- data/test/new_relic/agent/transaction_sampler_test.rb +193 -204
- data/test/new_relic/agent/worker_loop_test.rb +26 -11
- data/test/new_relic/agent_test.rb +113 -33
- data/test/new_relic/collection_helper_test.rb +7 -8
- data/test/new_relic/command/deployments_test.rb +18 -2
- data/test/new_relic/control/class_methods_test.rb +0 -18
- data/test/new_relic/control/frameworks/rails_test.rb +26 -0
- data/test/new_relic/control_test.rb +96 -137
- data/test/new_relic/delayed_job_injection_test.rb +6 -1
- data/test/new_relic/dispatcher_test.rb +54 -0
- data/test/new_relic/fake_collector.rb +283 -0
- data/test/new_relic/fake_service.rb +53 -0
- data/test/new_relic/fakes_sending_data.rb +30 -0
- data/test/new_relic/framework_test.rb +53 -0
- data/test/new_relic/load_test.rb +13 -0
- data/test/new_relic/local_environment_test.rb +11 -11
- data/test/new_relic/metric_data_test.rb +45 -16
- data/test/new_relic/noticed_error_test.rb +24 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +20 -10
- data/test/new_relic/rack/developer_mode_test.rb +13 -7
- data/test/new_relic/rack/error_collector_test.rb +74 -0
- data/test/new_relic/stats_test.rb +10 -0
- data/test/new_relic/transaction_sample/segment_test.rb +23 -4
- data/test/new_relic/transaction_sample_test.rb +47 -2
- data/test/new_relic/version_number_test.rb +32 -0
- data/test/script/build_test_gem.sh +9 -3
- data/test/script/ci.sh +108 -35
- data/test/script/ci_agent-tests_runner.sh +82 -0
- data/test/script/ci_multiverse_runner.sh +63 -0
- data/test/test_contexts.rb +1 -0
- data/test/test_helper.rb +68 -18
- data/ui/helpers/developer_mode_helper.rb +21 -11
- data/ui/views/layouts/newrelic_default.rhtml +1 -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
- data/ui/views/newrelic/show_sample.rhtml +1 -1
- data/ui/views/newrelic/threads.rhtml +2 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/.specification +116 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +7 -0
- metadata +191 -65
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +0 -40
- data/lib/new_relic/control/configuration.rb +0 -206
- data/lib/new_relic/control/logging_methods.rb +0 -143
- data/lib/new_relic/data_serialization.rb +0 -151
- data/test/new_relic/control/configuration_test.rb +0 -84
- data/test/new_relic/control/logging_methods_test.rb +0 -185
- data/test/new_relic/data_serialization_test.rb +0 -208
@@ -0,0 +1,204 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
|
+
require 'new_relic/agent/configuration/manager'
|
3
|
+
require 'new_relic/agent/configuration/mask_defaults'
|
4
|
+
|
5
|
+
module NewRelic::Agent::Configuration
|
6
|
+
class ManagerTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@manager = NewRelic::Agent::Configuration::Manager.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_use_indifferent_access
|
12
|
+
config = NewRelic::Agent::Configuration::DottedHash.new('string' => 'string', :symbol => 'symbol')
|
13
|
+
@manager.apply_config(config)
|
14
|
+
assert_equal 'string', @manager[:string]
|
15
|
+
assert_equal 'symbol', @manager['symbol']
|
16
|
+
@manager.remove_config(config)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_apply_config_sources_in_order
|
20
|
+
config0 = {
|
21
|
+
:foo => 'default foo',
|
22
|
+
:bar => 'default bar',
|
23
|
+
:baz => 'default baz'
|
24
|
+
}
|
25
|
+
@manager.apply_config(config0)
|
26
|
+
config1 = { :foo => 'real foo' }
|
27
|
+
@manager.apply_config(config1)
|
28
|
+
config2 = { :foo => 'wrong foo', :bar => 'real bar' }
|
29
|
+
@manager.apply_config(config2, 1)
|
30
|
+
|
31
|
+
assert_equal 'real foo', @manager['foo']
|
32
|
+
assert_equal 'real bar', @manager['bar']
|
33
|
+
assert_equal 'default baz', @manager['baz']
|
34
|
+
|
35
|
+
@manager.remove_config(config0)
|
36
|
+
@manager.remove_config(config1)
|
37
|
+
@manager.remove_config(config2)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_identifying_config_source
|
41
|
+
hash_source = {:foo => 'foo', :bar => 'default'}
|
42
|
+
@manager.apply_config(hash_source)
|
43
|
+
test_source = TestSource.new
|
44
|
+
test_source[:bar] = 'bar'
|
45
|
+
test_source[:baz] = 'baz'
|
46
|
+
@manager.apply_config(test_source)
|
47
|
+
|
48
|
+
assert_not_equal test_source, @manager.source(:foo)
|
49
|
+
assert_equal test_source, @manager.source(:bar)
|
50
|
+
assert_equal test_source, @manager.source(:baz)
|
51
|
+
|
52
|
+
@manager.remove_config(hash_source)
|
53
|
+
@manager.remove_config(test_source)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_callable_value_for_config_should_return_computed_value
|
57
|
+
source = {
|
58
|
+
:foo => 'bar',
|
59
|
+
:simple_value => Proc.new { '666' },
|
60
|
+
:reference => Proc.new { self['foo'] }
|
61
|
+
}
|
62
|
+
@manager.apply_config(source)
|
63
|
+
|
64
|
+
assert_equal 'bar', @manager[:foo]
|
65
|
+
assert_equal '666', @manager[:simple_value]
|
66
|
+
assert_equal 'bar', @manager[:reference]
|
67
|
+
|
68
|
+
@manager.remove_config(source)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_should_not_apply_removed_sources
|
72
|
+
test_source = TestSource.new
|
73
|
+
@manager.apply_config(test_source)
|
74
|
+
@manager.remove_config(test_source)
|
75
|
+
|
76
|
+
assert_equal nil, @manager['test_config_accessor']
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_should_read_license_key_from_env
|
80
|
+
ENV['NEWRELIC_LICENSE_KEY'] = 'right'
|
81
|
+
manager = NewRelic::Agent::Configuration::Manager.new
|
82
|
+
manager.apply_config({:license_key => 'wrong'}, 1)
|
83
|
+
|
84
|
+
assert_equal 'right', manager['license_key']
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_config_values_should_be_memoized
|
88
|
+
@manager.apply_config(:setting => 'correct value')
|
89
|
+
assert_equal 'correct value', @manager[:setting]
|
90
|
+
|
91
|
+
@manager.config_stack.unshift(:setting => 'wrong value')
|
92
|
+
assert_equal 'correct value', @manager[:setting]
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_dotted_hash_to_hash_is_plain_hash
|
96
|
+
dotted = NewRelic::Agent::Configuration::DottedHash.new({})
|
97
|
+
assert_equal(::Hash, dotted.to_hash.class)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_to_collector_hash
|
101
|
+
@manager.instance_variable_set(:@config_stack, [])
|
102
|
+
@manager.apply_config(:eins => Proc.new { self[:one] })
|
103
|
+
@manager.apply_config(:one => 1)
|
104
|
+
@manager.apply_config(:two => 2)
|
105
|
+
@manager.apply_config(:nested => {:madness => 'test'})
|
106
|
+
@manager.apply_config(:'nested.madness' => 'test')
|
107
|
+
|
108
|
+
assert_equal({ :eins => 1, :one => 1, :two => 2, :'nested.madness' => 'test' },
|
109
|
+
@manager.to_collector_hash)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Necessary to keep the pruby marshaller happy
|
113
|
+
def test_to_collector_hash_returns_bare_hash
|
114
|
+
@manager.instance_variable_set(:@config_stack, [])
|
115
|
+
@manager.apply_config(:eins => Proc.new { self[:one] })
|
116
|
+
|
117
|
+
assert_equal(::Hash, @manager.to_collector_hash.class)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_config_masks
|
121
|
+
NewRelic::Agent::Configuration::MASK_DEFAULTS[:boo] = Proc.new { true }
|
122
|
+
|
123
|
+
@manager.apply_config(:boo => 1)
|
124
|
+
|
125
|
+
assert_equal false, @manager.to_collector_hash.has_key?(:boo)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_config_masks_conditionally
|
129
|
+
NewRelic::Agent::Configuration::MASK_DEFAULTS[:boo] = Proc.new { false }
|
130
|
+
|
131
|
+
@manager.apply_config(:boo => 1)
|
132
|
+
|
133
|
+
assert @manager.to_collector_hash.has_key?(:boo)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_config_masks_thread_profiler
|
137
|
+
supported = NewRelic::Agent::ThreadProfiler.is_supported?
|
138
|
+
reported_config = @manager.to_collector_hash
|
139
|
+
|
140
|
+
if supported
|
141
|
+
assert_not_nil reported_config[:'thread_profiler.enabled']
|
142
|
+
else
|
143
|
+
assert_equal nil, reported_config[:'thread_profiler.enabled']
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_replacing_a_layer_by_class
|
148
|
+
old_config = NewRelic::Agent::Configuration::ManualSource.new(:test => 'wrong')
|
149
|
+
@manager.apply_config(old_config, 1)
|
150
|
+
new_config = NewRelic::Agent::Configuration::ManualSource.new(:test => 'right')
|
151
|
+
@manager.replace_or_add_config(new_config)
|
152
|
+
|
153
|
+
assert_equal 'right', @manager[:test]
|
154
|
+
assert_equal 3, @manager.config_stack.size
|
155
|
+
assert_equal 1, @manager.config_stack.map{|s| s.class} \
|
156
|
+
.index(NewRelic::Agent::Configuration::ManualSource)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_registering_a_callback
|
160
|
+
observed_value = 'old'
|
161
|
+
@manager.apply_config(:test => 'original')
|
162
|
+
|
163
|
+
@manager.register_callback(:test) do |value|
|
164
|
+
observed_value = value
|
165
|
+
end
|
166
|
+
assert_equal 'original', observed_value
|
167
|
+
|
168
|
+
@manager.apply_config(:test => 'new')
|
169
|
+
assert_equal 'new', observed_value
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_callback_not_called_if_no_change
|
173
|
+
@manager.apply_config(:test => true, :other => false)
|
174
|
+
@manager.register_callback(:test) do |value|
|
175
|
+
state = 'wrong'
|
176
|
+
end
|
177
|
+
state = 'right'
|
178
|
+
config = {:test => true}
|
179
|
+
@manager.apply_config(config)
|
180
|
+
@manager.remove_config(config)
|
181
|
+
|
182
|
+
assert_equal 'right', state
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_should_log_when_applying
|
186
|
+
expects_logging(:debug, anything, includes("asdf"))
|
187
|
+
@manager.apply_config(:test => "asdf")
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_should_log_when_removing
|
191
|
+
config = { :test => "asdf" }
|
192
|
+
@manager.apply_config(config)
|
193
|
+
|
194
|
+
expects_logging(:debug, anything, Not(includes("asdf")))
|
195
|
+
@manager.remove_config(config)
|
196
|
+
end
|
197
|
+
|
198
|
+
class TestSource < ::Hash
|
199
|
+
def test_config_accessor
|
200
|
+
'some value'
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
|
+
require 'new_relic/agent/configuration/server_source'
|
3
|
+
|
4
|
+
module NewRelic::Agent::Configuration
|
5
|
+
class ServerSourceTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
config = {
|
8
|
+
'agent_config' => {
|
9
|
+
'slow_sql.enabled' => true,
|
10
|
+
'transaction_tracer.transaction_threshold' => 'apdex_f',
|
11
|
+
'transaction_tracer.record_sql' => 'raw',
|
12
|
+
'error_collector.enabled' => true
|
13
|
+
},
|
14
|
+
'apdex_t' => 1.0,
|
15
|
+
'collect_errors' => false,
|
16
|
+
'collect_traces' => true
|
17
|
+
}
|
18
|
+
@source = ServerSource.new(config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_set_apdex_t
|
22
|
+
assert_equal 1.0, @source[:apdex_t]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_set_agent_config_values
|
26
|
+
assert_equal 'raw', @source[:'transaction_tracer.record_sql']
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_not_dot_the_agent_config_sub_hash
|
30
|
+
assert_nil @source[:'agent_config.slow_sql.enabled']
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_should_enable_tracer_as_configured
|
34
|
+
assert @source[:'slow_sql.enabled']
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_disable_tracer_as_configured
|
38
|
+
assert !@source[:'error_collector.enabled']
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_ignore_apdex_f_setting_for_transaction_threshold
|
42
|
+
assert_equal nil, @source[:'transaction_tracer.transaction_threshold']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
|
+
require 'new_relic/agent/configuration/yaml_source'
|
3
|
+
|
4
|
+
module NewRelic::Agent::Configuration
|
5
|
+
class YamlSourceTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
test_yml_path = File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
'..','..','..',
|
9
|
+
'config','newrelic.yml'))
|
10
|
+
@source = YamlSource.new(test_yml_path, 'test')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_load_given_yaml_file
|
14
|
+
assert_equal '127.0.0.1', @source[:api_host]
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_apply_erb_transformations
|
18
|
+
assert_equal 'heyheyhey', @source[:erb_value]
|
19
|
+
assert_equal '', @source[:message]
|
20
|
+
assert_equal '', @source[:license_key]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_config_booleans
|
24
|
+
assert_equal true, @source[:tval]
|
25
|
+
assert_equal false, @source[:fval]
|
26
|
+
assert_nil @source[:not_in_yaml_val]
|
27
|
+
assert_equal true, @source[:yval]
|
28
|
+
assert_equal 'sure', @source[:sval]
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_appnames
|
32
|
+
assert_equal %w[a b c], @source[:app_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_load_the_config_for_the_correct_env
|
36
|
+
assert_not_equal 'the.wrong.host', @source[:host]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_convert_to_dot_notation
|
40
|
+
assert_equal 'raw', @source[:'transaction_tracer.record_sql']
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_should_ignore_apdex_f_setting_for_transaction_threshold
|
44
|
+
assert_equal nil, @source[:'transaction_tracer.transaction_threshold']
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_correctly_handle_floats
|
48
|
+
assert_equal 1.1, @source[:apdex_t]
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_should_log_if_no_file_is_found
|
52
|
+
expects_logging(:error, any_parameters)
|
53
|
+
source = YamlSource.new('no_such_file.yml', 'test')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_should_not_fail_to_log_missing_file_during_startup
|
57
|
+
without_logger do
|
58
|
+
::NewRelic::Agent::StartupLogger.any_instance.expects(:error)
|
59
|
+
source = YamlSource.new('no_such_file.yml', 'test')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_not_fail_to_log_invalid_file_during_startup
|
64
|
+
without_logger do
|
65
|
+
::NewRelic::Agent::StartupLogger.any_instance.expects(:error)
|
66
|
+
|
67
|
+
File.stubs(:exists?).returns(true)
|
68
|
+
File.stubs(:read).raises(StandardError.new("boo"))
|
69
|
+
|
70
|
+
source = YamlSource.new('fake.yml', 'test')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
+
|
3
|
+
module NewRelic::Agent
|
4
|
+
class CrossProcessMonitoringTest < Test::Unit::TestCase
|
5
|
+
AGENT_CROSS_PROCESS_ID = "qwerty"
|
6
|
+
REQUEST_CROSS_PROCESS_ID = "asdf"
|
7
|
+
|
8
|
+
def setup
|
9
|
+
NewRelic::Agent.instance.stubs(:cross_process_id).returns(AGENT_CROSS_PROCESS_ID)
|
10
|
+
NewRelic::Agent.instance.stubs(:cross_process_encoding_bytes).returns([0])
|
11
|
+
|
12
|
+
@request_with_id = stub(:env => {'X-NewRelic-ID' => REQUEST_CROSS_PROCESS_ID})
|
13
|
+
@empty_request = stub(:env => {})
|
14
|
+
|
15
|
+
@response = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_adds_response_header
|
19
|
+
timings = stub(
|
20
|
+
:transaction_name => "transaction",
|
21
|
+
:queue_time_in_millis => 1000,
|
22
|
+
:app_time_in_millis => 2000)
|
23
|
+
|
24
|
+
NewRelic::Agent::BrowserMonitoring.stubs(:timings).returns(timings)
|
25
|
+
|
26
|
+
CrossProcessMonitoring.insert_response_header(@request_with_id, @response)
|
27
|
+
|
28
|
+
assert unpacked_response.include?("transaction")
|
29
|
+
assert unpacked_response.include?("1000")
|
30
|
+
assert unpacked_response.include?("2000")
|
31
|
+
assert unpacked_response.include?(AGENT_CROSS_PROCESS_ID)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_doesnt_add_header_if_no_id_in_request
|
35
|
+
CrossProcessMonitoring.insert_response_header(@empty_request, @response)
|
36
|
+
assert_nil response_app_data
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_doesnt_add_header_if_no_id_on_agent
|
40
|
+
NewRelic::Agent.instance.stubs(:cross_process_id).returns(nil)
|
41
|
+
|
42
|
+
CrossProcessMonitoring.insert_response_header(@request_with_id, @response)
|
43
|
+
assert_nil response_app_data
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_doesnt_add_header_if_config_disabled
|
47
|
+
with_config(:'cross_process.enabled' => false) do
|
48
|
+
CrossProcessMonitoring.insert_response_header(@request_with_id, @response)
|
49
|
+
assert_nil response_app_data
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_finds_id_from_headers
|
54
|
+
%w{X-NewRelic-ID HTTP_X_NEWRELIC_ID X_NEWRELIC_ID}.each do |key|
|
55
|
+
request = stub(:env => { key => REQUEST_CROSS_PROCESS_ID })
|
56
|
+
|
57
|
+
assert_equal(
|
58
|
+
REQUEST_CROSS_PROCESS_ID, \
|
59
|
+
CrossProcessMonitoring.id_from_request(request),
|
60
|
+
"Failed to find header on key #{key}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_doesnt_find_id_in_headers
|
65
|
+
request = stub(:env => {})
|
66
|
+
assert_nil CrossProcessMonitoring.id_from_request(request)
|
67
|
+
end
|
68
|
+
|
69
|
+
def response_app_data
|
70
|
+
@response['X-NewRelic-App-Data']
|
71
|
+
end
|
72
|
+
|
73
|
+
def unpacked_response
|
74
|
+
response_app_data.unpack("m0").first
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -73,17 +73,6 @@ class NewRelic::Agent::DatabaseTest < Test::Unit::TestCase
|
|
73
73
|
assert_equal([], NewRelic::Agent::Database.explain_sql('SELECT', config))
|
74
74
|
end
|
75
75
|
|
76
|
-
def test_handle_exception_in_explain
|
77
|
-
fake_error = StandardError.new('a message')
|
78
|
-
NewRelic::Control.instance.log.expects(:error).with('Error getting query plan: a message')
|
79
|
-
# backtrace can be basically any string, just should get logged
|
80
|
-
NewRelic::Control.instance.log.expects(:debug).with(instance_of(String))
|
81
|
-
|
82
|
-
NewRelic::Agent::Database.handle_exception_in_explain do
|
83
|
-
raise(fake_error)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
76
|
def test_obfuscation_mysql_basic
|
88
77
|
insert = %q[INSERT INTO `X` values("test",0, 1 , 2, 'test')]
|
89
78
|
assert_equal("INSERT INTO `X` values(?,?, ? , ?, ?)",
|
@@ -146,4 +135,16 @@ class NewRelic::Agent::DatabaseTest < Test::Unit::TestCase
|
|
146
135
|
|
147
136
|
NewRelic::Agent::Database::Obfuscator.instance.reset
|
148
137
|
end
|
138
|
+
|
139
|
+
def test_close_connections_closes_all_held_db_connections
|
140
|
+
foo_connection = mock('foo connection')
|
141
|
+
bar_connection = mock('bar connection')
|
142
|
+
NewRelic::Agent::Database::ConnectionManager.instance.instance_eval do
|
143
|
+
@connections = { :foo => foo_connection, :bar => bar_connection }
|
144
|
+
end
|
145
|
+
foo_connection.expects(:disconnect!)
|
146
|
+
bar_connection.expects(:disconnect!)
|
147
|
+
|
148
|
+
NewRelic::Agent::Database.close_connections
|
149
|
+
end
|
149
150
|
end
|
@@ -57,47 +57,51 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_request_params_from_opts_positive
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert_equal({}, val, "should delete request_params key from hash")
|
60
|
+
with_config(:capture_params => true) do
|
61
|
+
val = {:request_params => 'foo'}
|
62
|
+
assert_equal('foo', request_params_from_opts(val))
|
63
|
+
assert_equal({}, val, "should delete request_params key from hash")
|
64
|
+
end
|
66
65
|
end
|
67
66
|
|
68
67
|
def test_request_params_from_opts_negative
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
assert_equal({}, val, "should delete request_params key from hash")
|
68
|
+
with_config(:capture_params => false) do
|
69
|
+
val = {:request_params => 'foo'}
|
70
|
+
assert_equal(nil, request_params_from_opts(val))
|
71
|
+
assert_equal({}, val, "should delete request_params key from hash")
|
72
|
+
end
|
75
73
|
end
|
76
74
|
|
77
75
|
def test_normalized_request_and_custom_params_base
|
78
76
|
self.expects(:normalize_params).with(nil).returns(nil)
|
79
77
|
self.expects(:normalize_params).with({}).returns({})
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
with_config(:capture_params => true) do
|
79
|
+
assert_equal({:request_params => nil, :custom_params => {}},
|
80
|
+
normalized_request_and_custom_params({}))
|
81
|
+
end
|
84
82
|
end
|
85
83
|
|
86
84
|
def test_extract_source_base
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
with_config(:'error_collector.capture_source' => true) do
|
86
|
+
error_collector = NewRelic::Agent::ErrorCollector.new
|
87
|
+
error_collector.expects(:sense_method).with(nil, 'source_extract')
|
88
|
+
assert_equal(nil, error_collector.extract_source(nil))
|
89
|
+
end
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_extract_source_disabled
|
93
|
-
|
94
|
-
|
93
|
+
with_config(:'error_collector.capture_source' => false) do
|
94
|
+
error_collector = NewRelic::Agent::ErrorCollector.new
|
95
|
+
assert_equal(nil, error_collector.extract_source(mock('exception')))
|
96
|
+
end
|
95
97
|
end
|
96
98
|
|
97
99
|
def test_extract_source_with_source
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
with_config(:'error_collector.capture_source' => true) do
|
101
|
+
error_collector = NewRelic::Agent::ErrorCollector.new
|
102
|
+
error_collector.expects(:sense_method).with('happy', 'source_extract').returns('THE SOURCE')
|
103
|
+
assert_equal('THE SOURCE', error_collector.extract_source('happy'))
|
104
|
+
end
|
101
105
|
end
|
102
106
|
|
103
107
|
def test_extract_stack_trace
|
@@ -122,9 +126,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
122
126
|
|
123
127
|
def test_over_queue_limit_positive
|
124
128
|
@errors = %w(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
|
125
|
-
|
126
|
-
self.expects(:log).returns(fake_log)
|
127
|
-
fake_log.expects(:warn).with('The error reporting queue has reached 20. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: hooray')
|
129
|
+
expects_logging(:warn, includes('The error reporting queue has reached 20'))
|
128
130
|
assert over_queue_limit?('hooray')
|
129
131
|
end
|
130
132
|
|
@@ -160,53 +162,56 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
160
162
|
|
161
163
|
def test_should_exit_notice_error_disabled
|
162
164
|
error = mocked_error
|
163
|
-
|
164
|
-
|
165
|
+
with_error_collector_config(:'error_collector.enabled' => false) do |error_collector|
|
166
|
+
assert error_collector.should_exit_notice_error?(error)
|
167
|
+
end
|
165
168
|
end
|
166
169
|
|
167
170
|
def test_should_exit_notice_error_nil
|
168
171
|
error = nil
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
172
|
+
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
173
|
+
error_collector.expects(:error_is_ignored?).with(error).returns(false)
|
174
|
+
# we increment it for the case that someone calls
|
175
|
+
# NewRelic::Agent.notice_error(foo) # foo is nil
|
176
|
+
# (which is probably not a good idea but is the existing api)
|
177
|
+
error_collector.expects(:increment_error_count!)
|
178
|
+
assert error_collector.should_exit_notice_error?(error)
|
179
|
+
end
|
176
180
|
end
|
177
181
|
|
178
182
|
def test_should_exit_notice_error_positive
|
179
183
|
error = mocked_error
|
180
|
-
|
181
|
-
|
182
|
-
|
184
|
+
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
185
|
+
error_collector.expects(:error_is_ignored?).with(error).returns(true)
|
186
|
+
assert error_collector.should_exit_notice_error?(error)
|
187
|
+
end
|
183
188
|
end
|
184
189
|
|
185
190
|
def test_should_exit_notice_error_negative
|
186
191
|
error = mocked_error
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
192
|
+
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
193
|
+
error_collector.expects(:error_is_ignored?).with(error).returns(false)
|
194
|
+
error_collector.expects(:increment_error_count!)
|
195
|
+
assert !error_collector.should_exit_notice_error?(error)
|
196
|
+
end
|
191
197
|
end
|
192
198
|
|
193
199
|
def test_filtered_error_positive
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
+
with_error_collector_config(:'error_collector.ignore_errors' => 'an_error') do |error_collector|
|
201
|
+
error = mocked_error
|
202
|
+
error_class = mock('error class')
|
203
|
+
error.expects(:class).returns(error_class)
|
204
|
+
error_class.expects(:name).returns('an_error')
|
205
|
+
assert error_collector.filtered_error?(error)
|
206
|
+
end
|
200
207
|
end
|
201
208
|
|
202
209
|
def test_filtered_error_negative
|
203
|
-
@ignore = {}
|
204
210
|
error = mocked_error
|
205
211
|
error_class = mock('error class')
|
206
212
|
error.expects(:class).returns(error_class)
|
207
213
|
error_class.expects(:name).returns('an_error')
|
208
|
-
|
209
|
-
assert !filtered_error?(error)
|
214
|
+
assert !NewRelic::Agent::ErrorCollector.new.filtered_error?(error)
|
210
215
|
end
|
211
216
|
|
212
217
|
def test_filtered_by_error_filter_empty
|
@@ -251,7 +256,13 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
251
256
|
|
252
257
|
def mocked_control
|
253
258
|
fake_control = mock('control')
|
254
|
-
|
259
|
+
NewRelic::Control.stubs(:instance).returns(fake_control)
|
255
260
|
fake_control
|
256
261
|
end
|
262
|
+
|
263
|
+
def with_error_collector_config(config)
|
264
|
+
with_config(config) do
|
265
|
+
yield NewRelic::Agent::ErrorCollector.new
|
266
|
+
end
|
267
|
+
end
|
257
268
|
end
|