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
@@ -8,7 +8,13 @@ module NewRelic
|
|
8
8
|
def instance(create=true)
|
9
9
|
@instance ||= create && new_instance
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
# clear out memoized Control and LocalEnv instances
|
13
|
+
def reset
|
14
|
+
@instance = nil
|
15
|
+
@local_env = nil
|
16
|
+
end
|
17
|
+
|
12
18
|
# Access the LocalEnvironment singleton, lazy initialized
|
13
19
|
def local_env
|
14
20
|
@local_env ||= NewRelic::LocalEnvironment.new
|
@@ -16,10 +22,10 @@ module NewRelic
|
|
16
22
|
|
17
23
|
# Create the concrete class for environment specific behavior
|
18
24
|
def new_instance
|
19
|
-
if
|
25
|
+
if Agent.config[:framework] == :test
|
20
26
|
load_test_framework
|
21
27
|
else
|
22
|
-
load_framework_class(
|
28
|
+
load_framework_class(Agent.config[:framework]).new(local_env)
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
@@ -29,7 +35,7 @@ module NewRelic
|
|
29
35
|
require "config/test_control"
|
30
36
|
NewRelic::Control::Frameworks::Test.new(local_env, config)
|
31
37
|
end
|
32
|
-
|
38
|
+
|
33
39
|
# Loads the specified framework class from the
|
34
40
|
# NewRelic::Control::Frameworks module
|
35
41
|
def load_framework_class(framework)
|
@@ -50,4 +56,3 @@ module NewRelic
|
|
50
56
|
extend ClassMethods
|
51
57
|
end
|
52
58
|
end
|
53
|
-
|
@@ -11,12 +11,6 @@ module NewRelic
|
|
11
11
|
::Merb.root
|
12
12
|
end
|
13
13
|
|
14
|
-
def to_stdout(msg)
|
15
|
-
Merb.logger.info("NewRelic ~ " + msg)
|
16
|
-
rescue => e
|
17
|
-
STDOUT.puts "NewRelic ~ " + msg
|
18
|
-
end
|
19
|
-
|
20
14
|
def init_config options={}
|
21
15
|
::Merb::Plugins.add_rakefiles File.join(newrelic_root,"lib/tasks/all.rb")
|
22
16
|
|
@@ -17,34 +17,36 @@ module NewRelic
|
|
17
17
|
super
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
def rails_config
|
22
|
+
if defined?(::Rails) && ::Rails.respond_to?(:configuration)
|
23
|
+
::Rails.configuration
|
24
|
+
else
|
25
|
+
@config
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
# In versions of Rails prior to 2.0, the rails config was only available to
|
25
|
-
# the init.rb, so it had to be passed on from there. This is a best effort to
|
30
|
+
# the init.rb, so it had to be passed on from there. This is a best effort to
|
26
31
|
# find a config and use that.
|
27
32
|
def init_config(options={})
|
28
|
-
|
29
|
-
|
30
|
-
rails_config = ::Rails.configuration
|
31
|
-
end
|
32
|
-
# Install the dependency detection,
|
33
|
+
@config = options[:config]
|
34
|
+
# Install the dependency detection,
|
33
35
|
if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
|
34
36
|
rails_config.after_initialize do
|
35
37
|
# This will insure we load all the instrumentation as late as possible. If the agent
|
36
|
-
# is not enabled, it will load a limited amount of instrumentation. See
|
38
|
+
# is not enabled, it will load a limited amount of instrumentation. See
|
37
39
|
# delayed_job_injection.rb
|
38
40
|
DependencyDetection.detect!
|
39
41
|
end
|
40
|
-
end
|
41
|
-
if !agent_enabled
|
42
|
+
end
|
43
|
+
if !Agent.config[:agent_enabled]
|
42
44
|
# Might not be running if it does not think mongrel, thin, passenger, etc
|
43
|
-
# is running, if it
|
44
|
-
|
45
|
+
# is running, if it thinks it's a rake task, or if the agent_enabled is false.
|
46
|
+
::NewRelic::Agent.logger.info("New Relic Agent not running.")
|
45
47
|
else
|
46
|
-
|
47
|
-
install_developer_mode rails_config if developer_mode
|
48
|
+
::NewRelic::Agent.logger.info("Starting the New Relic Agent.")
|
49
|
+
install_developer_mode rails_config if Agent.config[:developer_mode]
|
48
50
|
install_browser_monitoring(rails_config)
|
49
51
|
end
|
50
52
|
end
|
@@ -52,13 +54,13 @@ module NewRelic
|
|
52
54
|
def install_browser_monitoring(config)
|
53
55
|
return if @browser_monitoring_installed
|
54
56
|
@browser_monitoring_installed = true
|
55
|
-
return if config.nil? || !config.respond_to?(:middleware) || !
|
57
|
+
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
56
58
|
begin
|
57
59
|
require 'new_relic/rack/browser_monitoring'
|
58
60
|
config.middleware.use NewRelic::Rack::BrowserMonitoring
|
59
|
-
|
61
|
+
::NewRelic::Agent.logger.debug("Installed New Relic Browser Monitoring middleware")
|
60
62
|
rescue => e
|
61
|
-
|
63
|
+
::NewRelic::Agent.logger.warn("Error installing New Relic Browser Monitoring middleware: #{e.inspect}")
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
@@ -74,35 +76,17 @@ module NewRelic
|
|
74
76
|
# a webserver process
|
75
77
|
if @local_env.dispatcher_instance_id
|
76
78
|
port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
|
77
|
-
|
78
|
-
|
79
|
+
::NewRelic::Agent.logger.debug("NewRelic Agent Developer Mode enabled.")
|
80
|
+
::NewRelic::Agent.logger.debug("To view performance information, go to http://localhost#{port}/newrelic")
|
79
81
|
end
|
80
82
|
rescue => e
|
81
|
-
|
83
|
+
::NewRelic::Agent.logger.warn("Error installing New Relic Developer Mode: #{e.inspect}")
|
82
84
|
end
|
83
85
|
elsif rails_config
|
84
|
-
|
86
|
+
::NewRelic::Agent.logger.warn("Developer mode not available for Rails versions prior to 2.2")
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
|
-
def log!(msg, level=:info)
|
89
|
-
if should_log?
|
90
|
-
logger = ::Rails.respond_to?(:logger) ? ::Rails.logger : ::RAILS_DEFAULT_LOGGER
|
91
|
-
logger.send(level, msg)
|
92
|
-
else
|
93
|
-
super
|
94
|
-
end
|
95
|
-
rescue => e
|
96
|
-
super
|
97
|
-
end
|
98
|
-
|
99
|
-
def to_stdout(message)
|
100
|
-
logger = ::Rails.respond_to?(:logger) ? ::Rails.logger : ::RAILS_DEFAULT_LOGGER
|
101
|
-
logger.info(message)
|
102
|
-
rescue => e
|
103
|
-
super
|
104
|
-
end
|
105
|
-
|
106
90
|
def rails_version
|
107
91
|
@rails_version ||= NewRelic::VersionNumber.new(::Rails::VERSION::STRING)
|
108
92
|
end
|
@@ -114,7 +98,7 @@ module NewRelic
|
|
114
98
|
end
|
115
99
|
|
116
100
|
def rails_gem_list
|
117
|
-
::Rails.configuration.gems.map do |
|
101
|
+
::Rails.configuration.gems.map do |gem|
|
118
102
|
version = (gem.respond_to?(:version) && gem.version) ||
|
119
103
|
(gem.specification.respond_to?(:version) && gem.specification.version)
|
120
104
|
gem.name + (version ? "(#{version})" : "")
|
@@ -153,11 +137,12 @@ module NewRelic
|
|
153
137
|
def install_shim
|
154
138
|
super
|
155
139
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
156
|
-
|
157
|
-
include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
|
158
|
-
|
140
|
+
if ActiveSupport.respond_to?(:on_load) # rails 3+
|
141
|
+
ActiveSupport.on_load(:action_controller) { include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim }
|
142
|
+
else
|
143
|
+
ActionController::Base.class_eval { include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim }
|
144
|
+
end
|
159
145
|
end
|
160
|
-
|
161
146
|
end
|
162
147
|
end
|
163
148
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'new_relic/control/frameworks/rails'
|
2
|
+
require 'new_relic/rack/error_collector'
|
2
3
|
module NewRelic
|
3
4
|
class Control
|
4
5
|
module Frameworks
|
@@ -12,7 +13,7 @@ module NewRelic
|
|
12
13
|
def env
|
13
14
|
@env ||= ::Rails.env.to_s
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
# Rails can return an empty string from this method, causing
|
17
18
|
# the agent not to start even when it is properly in a rails 3
|
18
19
|
# application, so we test the value to make sure it actually
|
@@ -26,25 +27,18 @@ module NewRelic
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
-
::Rails.logger
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def log!(msg, level=:info)
|
35
|
-
if should_log?
|
36
|
-
logger.send(level, msg)
|
37
|
-
else
|
38
|
-
super
|
39
|
-
end
|
40
|
-
rescue => e
|
30
|
+
def init_config(options={})
|
41
31
|
super
|
32
|
+
if Agent.config[:agent_enabled] && Agent.config[:'error_collector.enabled']
|
33
|
+
if !rails_config.middleware.respond_to?(:include?) ||
|
34
|
+
!rails_config.middleware.include?(NewRelic::Rack::ErrorCollector)
|
35
|
+
add_error_collector_middleware
|
36
|
+
end
|
37
|
+
end
|
42
38
|
end
|
43
39
|
|
44
|
-
def
|
45
|
-
|
46
|
-
rescue
|
47
|
-
super
|
40
|
+
def add_error_collector_middleware
|
41
|
+
rails_config.middleware.use NewRelic::Rack::ErrorCollector
|
48
42
|
end
|
49
43
|
|
50
44
|
def vendor_root
|
@@ -59,7 +53,7 @@ module NewRelic
|
|
59
53
|
|
60
54
|
# Collect the Rails::Info into an associative array as well as the list of plugins
|
61
55
|
def append_environment_info
|
62
|
-
local_env.append_environment_value('Rails version'){
|
56
|
+
local_env.append_environment_value('Rails version'){ ::Rails::VERSION::STRING }
|
63
57
|
local_env.append_environment_value('Rails threadsafe') do
|
64
58
|
true == ::Rails.configuration.action_controller.allow_concurrency
|
65
59
|
end
|
@@ -67,8 +61,19 @@ module NewRelic
|
|
67
61
|
local_env.append_gem_list do
|
68
62
|
bundler_gem_list
|
69
63
|
end
|
64
|
+
append_plugin_list
|
65
|
+
end
|
66
|
+
|
67
|
+
def append_plugin_list
|
70
68
|
local_env.append_plugin_list { ::Rails.configuration.plugins.to_a }
|
71
69
|
end
|
70
|
+
|
71
|
+
def install_shim
|
72
|
+
super
|
73
|
+
ActiveSupport.on_load(:action_controller) do
|
74
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
|
75
|
+
end
|
76
|
+
end
|
72
77
|
end
|
73
78
|
end
|
74
79
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'new_relic/control/frameworks/rails3'
|
2
|
+
require 'new_relic/rack/error_collector'
|
3
|
+
module NewRelic
|
4
|
+
class Control
|
5
|
+
module Frameworks
|
6
|
+
class Rails4 < NewRelic::Control::Frameworks::Rails3
|
7
|
+
def rails_gem_list
|
8
|
+
Bundler.rubygems.all_specs.map do |gem|
|
9
|
+
"#{gem.name} (#{gem.version})"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_error_collector_middleware
|
14
|
+
# rails_config.middleware.use NewRelic::Rack::ErrorCollector
|
15
|
+
end
|
16
|
+
|
17
|
+
def append_plugin_list
|
18
|
+
# Rails 4 does not allow plugins
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -2,35 +2,14 @@ module NewRelic
|
|
2
2
|
class Control
|
3
3
|
module Frameworks
|
4
4
|
# A control used when no framework is detected - the default.
|
5
|
-
# Looks for a newrelic.yml file in several locations including
|
6
|
-
# ./, ./config, $HOME/.newrelic and $HOME/. It loads the
|
7
|
-
# settings from the newrelic.yml section based on the value of
|
8
|
-
# RUBY_ENV or RAILS_ENV.
|
9
5
|
class Ruby < NewRelic::Control
|
10
6
|
|
11
7
|
def env
|
12
8
|
@env ||= ENV['RUBY_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
13
9
|
end
|
10
|
+
|
14
11
|
def root
|
15
|
-
@root ||= ENV['APP_ROOT'] ||
|
16
|
-
end
|
17
|
-
# Check a sequence of file locations for newrelic.yml
|
18
|
-
def config_file
|
19
|
-
files = []
|
20
|
-
files << File.join(root,"config","newrelic.yml")
|
21
|
-
files << File.join(root,"newrelic.yml")
|
22
|
-
if ENV["HOME"]
|
23
|
-
files << File.join(ENV["HOME"], ".newrelic", "newrelic.yml")
|
24
|
-
files << File.join(ENV["HOME"], "newrelic.yml")
|
25
|
-
end
|
26
|
-
files << File.expand_path(ENV["NRCONFIG"]) if ENV["NRCONFIG"]
|
27
|
-
files.each do | file |
|
28
|
-
return File.expand_path(file) if File.exists? file
|
29
|
-
end
|
30
|
-
return File.expand_path(files.first)
|
31
|
-
end
|
32
|
-
def to_stdout(msg)
|
33
|
-
STDOUT.puts msg
|
12
|
+
@root ||= ENV['APP_ROOT'] || '.'
|
34
13
|
end
|
35
14
|
|
36
15
|
def init_config(options={})
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'new_relic/language_support'
|
2
|
+
require 'new_relic/agent/agent_logger'
|
2
3
|
|
3
4
|
module NewRelic
|
4
5
|
class Control
|
@@ -19,7 +20,6 @@ module NewRelic
|
|
19
20
|
# machine-dependent information useful in debugging
|
20
21
|
attr_reader :local_env
|
21
22
|
|
22
|
-
|
23
23
|
# Initialize the plugin/gem and start the agent. This does the
|
24
24
|
# necessary configuration based on the framework environment and
|
25
25
|
# determines whether or not to start the agent. If the agent is
|
@@ -44,41 +44,32 @@ module NewRelic
|
|
44
44
|
# init_config({}) which is called one or more times.
|
45
45
|
#
|
46
46
|
def init_plugin(options={})
|
47
|
-
|
48
|
-
|
47
|
+
yaml = Agent::Configuration::YamlSource.new(@config_file_path, options[:env] || env)
|
48
|
+
Agent.config.replace_or_add_config(yaml, 1)
|
49
|
+
|
50
|
+
Agent.config.replace_or_add_config(Agent::Configuration::ManualSource.new(options), 1)
|
51
|
+
|
52
|
+
::NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new(Agent.config, root, options.delete(:log))
|
49
53
|
|
50
54
|
# Merge the stringified options into the config as overrides:
|
51
|
-
logger_override = options.delete(:log)
|
52
55
|
environment_name = options.delete(:env) and self.env = environment_name
|
53
|
-
dispatcher = options.delete(:dispatcher) and @local_env.dispatcher = dispatcher
|
54
56
|
dispatcher_instance_id = options.delete(:dispatcher_instance_id) and @local_env.dispatcher_instance_id = dispatcher_instance_id
|
55
57
|
|
58
|
+
NewRelic::Agent::PipeChannelManager.listener.start if options.delete(:start_channel_listener)
|
56
59
|
|
57
|
-
# Clear out the settings, if they've already been loaded. It may be that
|
58
|
-
# between calling init_plugin the first time and the second time, the env
|
59
|
-
# has been overridden
|
60
|
-
@settings = nil
|
61
|
-
settings
|
62
|
-
merge_options(options)
|
63
|
-
if logger_override
|
64
|
-
@log = logger_override
|
65
|
-
# Try to grab the log filename
|
66
|
-
@log_file = @log.instance_eval { @logdev.filename rescue nil }
|
67
|
-
end
|
68
60
|
# An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
|
69
61
|
# methods in the module methods.
|
70
62
|
Module.send :include, NewRelic::Agent::MethodTracer::ClassMethods
|
71
63
|
Module.send :include, NewRelic::Agent::MethodTracer::InstanceMethods
|
72
64
|
init_config(options)
|
73
65
|
NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
|
74
|
-
if agent_enabled
|
75
|
-
setup_log unless logger_override
|
66
|
+
if Agent.config[:agent_enabled] && !NewRelic::Agent.instance.started?
|
76
67
|
start_agent
|
77
68
|
install_instrumentation
|
78
|
-
load_samplers unless
|
69
|
+
load_samplers unless Agent.config[:disable_samplers]
|
79
70
|
local_env.gather_environment_info
|
80
71
|
append_environment_info
|
81
|
-
elsif !agent_enabled
|
72
|
+
elsif !Agent.config[:agent_enabled]
|
82
73
|
install_shim
|
83
74
|
end
|
84
75
|
end
|
@@ -88,29 +79,25 @@ module NewRelic
|
|
88
79
|
NewRelic::Agent.agent.start
|
89
80
|
end
|
90
81
|
|
91
|
-
# True if dev mode or monitor mode are enabled, and we are running
|
92
|
-
# inside a valid dispatcher like mongrel or passenger. Can be overridden
|
93
|
-
# by NEWRELIC_ENABLE env variable, monitor_daemons config option when true, or
|
94
|
-
# agent_enabled config option when true or false.
|
95
|
-
def agent_enabled?
|
96
|
-
return false if !developer_mode? && !monitor_mode?
|
97
|
-
return self['agent_enabled'].to_s =~ /true|on|yes/i if !self['agent_enabled'].nil? && self['agent_enabled'] != 'auto'
|
98
|
-
return false if ENV['NEWRELIC_ENABLE'].to_s =~ /false|off|no/i
|
99
|
-
return true if self['monitor_daemons'].to_s =~ /true|on|yes/i
|
100
|
-
return true if ENV['NEWRELIC_ENABLE'].to_s =~ /true|on|yes/i
|
101
|
-
# When in 'auto' mode the agent is enabled if there is a known
|
102
|
-
# dispatcher running
|
103
|
-
return true if @local_env.dispatcher != nil
|
104
|
-
end
|
105
|
-
|
106
|
-
# Asks the LocalEnvironment instance which framework should be loaded
|
107
82
|
def app
|
108
|
-
|
83
|
+
Agent.config[:framework]
|
84
|
+
end
|
85
|
+
|
86
|
+
def framework
|
87
|
+
Agent.config[:framework]
|
88
|
+
end
|
89
|
+
|
90
|
+
# for backward compatibility with the old config interface
|
91
|
+
def [](key)
|
92
|
+
NewRelic::Agent.config[key.to_sym]
|
93
|
+
end
|
94
|
+
|
95
|
+
def settings
|
96
|
+
NewRelic::Agent.config.reported_config
|
109
97
|
end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
"Control[#{self.app}]"
|
98
|
+
|
99
|
+
def dispatcher
|
100
|
+
NewRelic::Agent.config[:dispatcher]
|
114
101
|
end
|
115
102
|
|
116
103
|
protected
|
@@ -118,12 +105,12 @@ module NewRelic
|
|
118
105
|
# Append framework specific environment information for uploading to
|
119
106
|
# the server for change detection. Override in subclasses
|
120
107
|
def append_environment_info; end
|
121
|
-
|
108
|
+
|
122
109
|
# Asks bundler to tell us which gemspecs are loaded in the
|
123
110
|
# current process
|
124
111
|
def bundler_gem_list
|
125
112
|
if defined?(Bundler) && Bundler.instance_eval do @load end
|
126
|
-
Bundler.load.specs.map do |
|
113
|
+
Bundler.load.specs.map do |spec|
|
127
114
|
version = (spec.respond_to?(:version) && spec.version)
|
128
115
|
spec.name + (version ? "(#{version})" : "")
|
129
116
|
end
|
@@ -131,39 +118,14 @@ module NewRelic
|
|
131
118
|
[]
|
132
119
|
end
|
133
120
|
end
|
134
|
-
|
135
|
-
|
136
|
-
def
|
137
|
-
File.expand_path(File.join(root,"config","newrelic.yml"))
|
138
|
-
end
|
139
|
-
|
140
|
-
# initializes the control instance with a local environment and
|
141
|
-
# an optional config file override. Checks for the config file
|
142
|
-
# and loads it.
|
143
|
-
def initialize local_env, config_file_override=nil
|
121
|
+
|
122
|
+
|
123
|
+
def initialize(local_env, config_file_override=nil)
|
144
124
|
@local_env = local_env
|
145
125
|
@instrumentation_files = []
|
146
|
-
|
147
|
-
# Next two are for populating the newrelic.yml via erb binding, necessary
|
148
|
-
# when using the default newrelic.yml file
|
149
|
-
generated_for_user = ''
|
150
|
-
license_key=''
|
151
|
-
if !File.exists?(newrelic_file)
|
152
|
-
puts "Cannot find or read #{newrelic_file}"
|
153
|
-
@yaml = {}
|
154
|
-
else
|
155
|
-
@yaml = load_newrelic_yml(newrelic_file, binding)
|
156
|
-
end
|
157
|
-
rescue ScriptError, StandardError => e
|
158
|
-
new_err = e.class.new("Error reading newrelic.yml file: #{e}")
|
159
|
-
new_err.set_backtrace(e.backtrace)
|
160
|
-
raise new_err
|
126
|
+
@config_file_path = config_file_override || Agent.config[:config_path]
|
161
127
|
end
|
162
|
-
|
163
|
-
def load_newrelic_yml(path, binding)
|
164
|
-
YAML.load(ERB.new(File.read(path)).result(binding))
|
165
|
-
end
|
166
|
-
|
128
|
+
|
167
129
|
def root
|
168
130
|
'.'
|
169
131
|
end
|