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
@@ -1,84 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
|
2
|
-
|
3
|
-
class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
|
4
|
-
require 'new_relic/control/configuration'
|
5
|
-
include NewRelic::Control::Configuration
|
6
|
-
|
7
|
-
def setup
|
8
|
-
# The log stuff is memoized so let's clear it each time.
|
9
|
-
NewRelic::Control.instance.instance_variable_set '@log_path', nil
|
10
|
-
NewRelic::Control.instance.instance_variable_set '@log_file', nil
|
11
|
-
@root = ::Rails::VERSION::MAJOR == 3 ? Rails.root : RAILS_ROOT
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
NewRelic::Control.instance.settings.delete('log_file_path')
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_license_key_defaults_to_env_variable
|
19
|
-
ENV['NEWRELIC_LICENSE_KEY'] = nil
|
20
|
-
self.expects(:fetch).with('license_key', nil)
|
21
|
-
license_key
|
22
|
-
|
23
|
-
ENV['NEWRELIC_LICENSE_KEY'] = "a string"
|
24
|
-
self.expects(:fetch).with('license_key', 'a string')
|
25
|
-
license_key
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_log_path_uses_default_if_not_set
|
29
|
-
NewRelic::Control.instance.setup_log
|
30
|
-
assert_equal(File.expand_path("log/newrelic_agent.log"),
|
31
|
-
NewRelic::Control.instance.log_file)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_log_file_path_uses_given_value
|
35
|
-
Dir.stubs(:mkdir).returns(true)
|
36
|
-
NewRelic::Control.instance['log_file_path'] = 'lerg'
|
37
|
-
NewRelic::Control.instance.setup_log
|
38
|
-
assert_match(/\/lerg\/newrelic_agent.log/,
|
39
|
-
NewRelic::Control.instance.log_file)
|
40
|
-
NewRelic::Control.instance.settings.delete('log_file_path') # = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_server_side_config_ignores_yaml
|
44
|
-
settings.merge! 'ssl' => false, 'transaction_tracer' => {'enabled' => true, 'stack_trace_threshold' => 1.0}, 'error_collector' => {'enabled' => true, 'ignore_errors' => 'ActiveRecord::RecordNotFound'}, 'capture_params' => false
|
45
|
-
merge_server_side_config 'transaction_tracer.enabled' => false, 'error_collector.enabled' => false
|
46
|
-
assert_equal({'ssl' => false, 'transaction_tracer' => {'enabled' => false}, 'error_collector' => {'enabled' => false}}, settings)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_install_browser_monitoring
|
50
|
-
require(File.expand_path(File.join(File.dirname(__FILE__),
|
51
|
-
'/../../../lib/new_relic/rack/browser_monitoring')))
|
52
|
-
middleware = stub('middleware config')
|
53
|
-
config = stub('rails config', :middleware => middleware)
|
54
|
-
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
|
55
|
-
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => true }
|
56
|
-
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
57
|
-
|
58
|
-
NewRelic::Control.instance.install_browser_monitoring(config)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_install_browser_monitoring_should_not_install_when_not_configured
|
62
|
-
middleware = stub('middleware config')
|
63
|
-
config = stub('rails config', :middleware => middleware)
|
64
|
-
middleware.expects(:use).never
|
65
|
-
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => false }
|
66
|
-
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
67
|
-
|
68
|
-
NewRelic::Control.instance.install_browser_monitoring(config)
|
69
|
-
|
70
|
-
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => true }
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_data_serialization_default_off
|
74
|
-
DependencyDetection.send(:class_variable_set, '@@items', [])
|
75
|
-
assert NewRelic::Control.instance.disable_serialization?
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_data_serialization_default_on_when_using_resque
|
79
|
-
DependencyDetection.defer { @name = :resque }
|
80
|
-
DependencyDetection.dependency_by_name(:resque).executed!
|
81
|
-
assert !NewRelic::Control.instance.disable_serialization?
|
82
|
-
DependencyDetection.send(:class_variable_set, '@@items', [])
|
83
|
-
end
|
84
|
-
end
|
@@ -1,185 +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
|
-
include NewRelic::Control::Configuration
|
9
|
-
def root; "."; end
|
10
|
-
end
|
11
|
-
|
12
|
-
class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@base = BaseLoggingMethods.new
|
15
|
-
@base.settings['log_file_path'] = 'log/'
|
16
|
-
@base.settings['log_file_name'] = 'newrelic_agent.log'
|
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
|
-
@base.expects(:agent_enabled?).returns(false)
|
64
|
-
assert !@base.should_log?
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_should_log_agent_enabled
|
68
|
-
@base.instance_eval { @settings = true }
|
69
|
-
@base.expects(:agent_enabled?).returns(true)
|
70
|
-
assert @base.should_log?
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_set_log_level_base
|
74
|
-
fake_logger = mock('logger')
|
75
|
-
# bad configuration
|
76
|
-
@base.expects(:fetch).with('log_level', 'info').returns('whee')
|
77
|
-
fake_logger.expects(:level=).with(Logger::INFO)
|
78
|
-
assert_equal fake_logger, @base.set_log_level!(fake_logger)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_set_log_level_with_each_level
|
82
|
-
fake_logger = mock('logger')
|
83
|
-
%w[debug info warn error fatal].each do |level|
|
84
|
-
@base.expects(:fetch).with('log_level', 'info').returns(level)
|
85
|
-
fake_logger.expects(:level=).with(Logger.const_get(level.upcase))
|
86
|
-
assert_equal fake_logger, @base.set_log_level!(fake_logger)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_set_log_format
|
91
|
-
fake_logger = Object.new
|
92
|
-
assert !fake_logger.respond_to?(:format_message)
|
93
|
-
assert_equal fake_logger, @base.set_log_format!(fake_logger)
|
94
|
-
assert fake_logger.respond_to?(:format_message)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_setup_log_existing_file
|
98
|
-
fake_logger = mock('logger')
|
99
|
-
Logger.expects(:new).with('logpath/logfilename').returns(fake_logger)
|
100
|
-
@base.expects(:log_path).returns('logpath').at_least_once
|
101
|
-
@base.expects(:log_file_name).returns('logfilename')
|
102
|
-
@base.expects(:set_log_format!).with(fake_logger)
|
103
|
-
@base.expects(:set_log_level!).with(fake_logger)
|
104
|
-
assert_equal fake_logger, @base.setup_log
|
105
|
-
assert_equal fake_logger, @base.instance_eval { @log }
|
106
|
-
assert_equal 'logpath/logfilename', @base.instance_eval { @log_file }
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_to_stdout
|
110
|
-
STDOUT.expects(:puts).with('** [NewRelic] whee')
|
111
|
-
@base.to_stdout('whee')
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_log_path_exists
|
115
|
-
@base.instance_eval { @log_path = 'logpath' }
|
116
|
-
assert_equal 'logpath', @base.log_path
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_log_path_path_exists
|
120
|
-
@base.settings['log_file_path'] = 'log'
|
121
|
-
assert File.directory?('log')
|
122
|
-
assert_equal File.expand_path('log'), @base.log_path
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_log_path_path_created
|
126
|
-
path = File.expand_path('tmp/log_path_test')
|
127
|
-
@base.instance_eval { @log_path = nil }
|
128
|
-
@base.settings['log_file_path'] = 'tmp/log_path_test'
|
129
|
-
assert !File.directory?(path) || FileUtils.rmdir(path)
|
130
|
-
@base.expects(:log!).never
|
131
|
-
assert_equal path, @base.log_path
|
132
|
-
assert File.directory?(path)
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_log_path_path_unable_to_create
|
136
|
-
path = File.expand_path('tmp/log_path_test')
|
137
|
-
@base.instance_eval { @log_path = nil }
|
138
|
-
@base.settings['log_file_path'] = 'tmp/log_path_test'
|
139
|
-
assert !File.directory?(path) || FileUtils.rmdir(path)
|
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
|
142
|
-
assert_nil @base.log_path
|
143
|
-
assert !File.directory?(path)
|
144
|
-
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_log_file_name
|
148
|
-
@base.expects(:fetch).with('log_file_name', 'newrelic_agent.log').returns('log_file_name')
|
149
|
-
assert_equal 'log_file_name', @base.log_file_name
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_log_to_stdout_when_log_file_path_set_to_STDOUT
|
153
|
-
@base.stubs(:fetch).returns('whatever')
|
154
|
-
@base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
|
155
|
-
Dir.expects(:mkdir).never
|
156
|
-
@base.setup_log
|
157
|
-
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_logs_to_stdout_include_newrelic_prefix
|
161
|
-
@base.stubs(:fetch).returns('whatever')
|
162
|
-
@base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
|
163
|
-
STDOUT.expects(:write).with(regexp_matches(/\*\* \[NewRelic\].*whee/))
|
164
|
-
@base.setup_log
|
165
|
-
@base.log.info('whee')
|
166
|
-
end
|
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
|
@@ -1,208 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
2
|
-
require 'new_relic/data_serialization'
|
3
|
-
class NewRelic::DataSerializationTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
attr_reader :file, :path
|
6
|
-
|
7
|
-
def setup
|
8
|
-
NewRelic::Control.instance['log_file_path'] = './log'
|
9
|
-
@path = NewRelic::Control.instance.log_path
|
10
|
-
@file = "#{path}/newrelic_agent_store.db"
|
11
|
-
Dir.mkdir(path) if !File.directory?(path)
|
12
|
-
FileUtils.rm_rf(@file)
|
13
|
-
FileUtils.rm_rf("#{@path}/newrelic_agent_store.pid")
|
14
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
# this gets set to true in some tests
|
18
|
-
NewRelic::Control.instance['disable_serialization'] = false
|
19
|
-
mocha_teardown
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_read_and_write_from_file_read_only
|
23
|
-
File.open(file, 'w') do |f|
|
24
|
-
f.write(Marshal.dump('a happy string'))
|
25
|
-
end
|
26
|
-
NewRelic::DataSerialization.read_and_write_to_file do |data|
|
27
|
-
assert_equal('a happy string', data, "should pull the dumped item from the file")
|
28
|
-
nil # must explicitly return nil or the return value will be dumped
|
29
|
-
end
|
30
|
-
assert_equal(0, File.size(file), "Should not leave any data in the file")
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_read_and_write_to_file_dumping_contents
|
34
|
-
expected_contents = Marshal.dump('a happy string')
|
35
|
-
NewRelic::DataSerialization.read_and_write_to_file do
|
36
|
-
'a happy string'
|
37
|
-
end
|
38
|
-
assert_equal(expected_contents, File.read(file), "should have dumped the contents")
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_read_and_write_to_file_yields_old_data
|
42
|
-
expected_contents = 'a happy string'
|
43
|
-
File.open(file, 'w') do |f|
|
44
|
-
f.write(Marshal.dump(expected_contents))
|
45
|
-
end
|
46
|
-
contents = nil
|
47
|
-
NewRelic::DataSerialization.read_and_write_to_file do |old_data|
|
48
|
-
contents = old_data
|
49
|
-
'a happy string'
|
50
|
-
end
|
51
|
-
assert_equal(contents, expected_contents, "should have dumped the contents")
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_read_and_write_to_file_round_trip
|
55
|
-
old_data = nil
|
56
|
-
NewRelic::DataSerialization.read_and_write_to_file do |data|
|
57
|
-
old_data = data
|
58
|
-
'a' * 30
|
59
|
-
end
|
60
|
-
NewRelic::DataSerialization.read_and_write_to_file do |data|
|
61
|
-
assert_equal('a'*30, data, "should be the same after serialization")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_should_send_data_when_over_limit
|
66
|
-
NewRelic::DataSerialization.stubs(:max_size).returns(20)
|
67
|
-
NewRelic::DataSerialization.read_and_write_to_file do
|
68
|
-
"a" * 30
|
69
|
-
end
|
70
|
-
assert(NewRelic::DataSerialization.should_send_data?, 'Should be over limit')
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_read_until_eoferror
|
74
|
-
File.open(file, 'w') do |f|
|
75
|
-
f.write("a" * 10_001)
|
76
|
-
end
|
77
|
-
value = ""
|
78
|
-
File.open(file,'r') do |f|
|
79
|
-
value << NewRelic::DataSerialization.instance_eval { read_until_eof_error(f) }
|
80
|
-
end
|
81
|
-
assert_equal('a' * 10_001, value, "should retrieve all the contents from the string and not raise EOFerrors")
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_write_contents_nonblockingly
|
85
|
-
File.open(file, 'w') do |f|
|
86
|
-
f.write("") # write nothing! NOTHING
|
87
|
-
end
|
88
|
-
|
89
|
-
File.open(file, 'w') do |f|
|
90
|
-
NewRelic::DataSerialization.instance_eval { write_contents_nonblockingly(f, 'a' * 10_001) }
|
91
|
-
end
|
92
|
-
value = File.read(file)
|
93
|
-
assert_equal('a' * 10_001, value, "should write a couple thousand 'a's to a file without exploding")
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_should_send_data_disabled
|
97
|
-
NewRelic::Control.instance.disable_serialization = true
|
98
|
-
assert(NewRelic::DataSerialization.should_send_data?,
|
99
|
-
'should send data when disabled')
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_should_send_data_under_limit
|
103
|
-
NewRelic::DataSerialization.expects(:max_size).returns(2000)
|
104
|
-
NewRelic::DataSerialization.read_and_write_to_file do |old_data|
|
105
|
-
"a" * 5
|
106
|
-
end
|
107
|
-
|
108
|
-
assert(!NewRelic::DataSerialization.store_too_large?,
|
109
|
-
'Should be under the limit')
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_should_handle_empty_spool_file
|
113
|
-
NewRelic::Control.instance.log.expects(:error).never
|
114
|
-
assert_nil NewRelic::DataSerialization.instance_eval { load('') }
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_spool_file_location_respects_log_file_path_setting
|
118
|
-
NewRelic::Control.instance.expects(:log_path).returns('./tmp')
|
119
|
-
Dir.mkdir('./tmp') if !File.directory?('./tmp')
|
120
|
-
NewRelic::DataSerialization.read_and_write_to_file do |_|
|
121
|
-
'a' * 30
|
122
|
-
end
|
123
|
-
assert(File.exists?('./tmp/newrelic_agent_store.db'),
|
124
|
-
"Spool file not created at user specified location")
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_age_file_location_respects_log_file_path_setting
|
128
|
-
NewRelic::Control.instance.expects(:log_path).returns('./tmp')
|
129
|
-
Dir.mkdir('./tmp') if !File.directory?('./tmp')
|
130
|
-
NewRelic::DataSerialization.update_last_sent!
|
131
|
-
assert(File.exists?('./tmp/newrelic_agent_store.pid'),
|
132
|
-
"Age file not created at user specified location")
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_pid_age_creates_pid_file_if_none_exists
|
136
|
-
assert(!File.exists?("#{@path}/newrelic_agent_store.pid"),
|
137
|
-
'pid file found, should not be there')
|
138
|
-
NewRelic::DataSerialization.update_last_sent!
|
139
|
-
assert(File.exists?("#{@path}/newrelic_agent_store.pid"),
|
140
|
-
'pid file not found, should be there')
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_should_not_create_files_if_serialization_disabled
|
144
|
-
NewRelic::Control.instance['disable_serialization'] = true
|
145
|
-
NewRelic::DataSerialization.should_send_data?
|
146
|
-
assert(!File.exists?("#{@path}/newrelic_agent_store.db"),
|
147
|
-
'db file created when serialization disabled')
|
148
|
-
assert(!File.exists?("#{@path}/newrelic_agent_store.pid"),
|
149
|
-
'pid file created when serialization disabled')
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_loading_does_not_seg_fault_if_gc_triggers
|
153
|
-
return if NewRelic::LanguageSupport.using_version?('1.8.6')
|
154
|
-
require 'timeout'
|
155
|
-
|
156
|
-
Thread.abort_on_exception = true
|
157
|
-
rcv,snd = IO.pipe
|
158
|
-
|
159
|
-
write = Thread.new do
|
160
|
-
obj = ('a'..'z').inject({}){|h,s|h[s.intern]=s*1024;h}
|
161
|
-
data = Marshal.dump(obj)
|
162
|
-
snd.write(data[0,data.size/2])
|
163
|
-
sleep(0.1)
|
164
|
-
snd.write(data[(data.size/2)..-1])
|
165
|
-
snd.close
|
166
|
-
end
|
167
|
-
|
168
|
-
read = Thread.new do
|
169
|
-
lock = Mutex.new
|
170
|
-
lock.synchronize do
|
171
|
-
NewRelic::DataSerialization.class_eval { load(rcv) }
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
gc = Thread.new do
|
176
|
-
10.times do
|
177
|
-
GC.start
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
Timeout::timeout(5) do
|
182
|
-
write.join
|
183
|
-
read.join
|
184
|
-
gc.join
|
185
|
-
end
|
186
|
-
# should not seg fault
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_dump_should_be_thread_safe
|
190
|
-
stats_hash = {}
|
191
|
-
|
192
|
-
2000.times do |i|
|
193
|
-
stats_hash[i.to_s] = NewRelic::StatsBase.new
|
194
|
-
end
|
195
|
-
|
196
|
-
harvest = Thread.new do
|
197
|
-
NewRelic::DataSerialization.class_eval { dump(stats_hash) }
|
198
|
-
end
|
199
|
-
|
200
|
-
app = Thread.new do
|
201
|
-
stats_hash["a"] = NewRelic::StatsBase.new
|
202
|
-
end
|
203
|
-
|
204
|
-
assert_nothing_raised do
|
205
|
-
[app, harvest].each{|t| t.join}
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|