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
@@ -9,17 +9,12 @@ module NewRelic
|
|
9
9
|
# This requires the files within a rescue block, so that any
|
10
10
|
# errors within instrumentation files do not affect the overall
|
11
11
|
# agent or application in which it runs.
|
12
|
-
#
|
13
|
-
# Logs at debug level for each file loaded, and logs errors in
|
14
|
-
# file loading at error level
|
15
12
|
def load_instrumentation_files pattern
|
16
13
|
Dir.glob(pattern) do |file|
|
17
14
|
begin
|
18
|
-
log.debug "Processing instrumentation file '#{file}'"
|
19
15
|
require file.to_s
|
20
16
|
rescue => e
|
21
|
-
|
22
|
-
log.debug e.backtrace.join("\n")
|
17
|
+
::NewRelic::Agent.logger.warn "Error loading instrumentation file '#{file}':", e
|
23
18
|
end
|
24
19
|
end
|
25
20
|
end
|
@@ -60,19 +55,19 @@ module NewRelic
|
|
60
55
|
agent = NewRelic::Agent.instance
|
61
56
|
NewRelic::Agent::Sampler.sampler_classes.each do | subclass |
|
62
57
|
begin
|
63
|
-
|
58
|
+
::NewRelic::Agent.logger.debug "#{subclass.name} not supported on this platform." and next if not subclass.supported_on_this_platform?
|
64
59
|
sampler = subclass.new
|
65
60
|
if subclass.use_harvest_sampler?
|
66
61
|
agent.stats_engine.add_harvest_sampler sampler
|
67
|
-
|
62
|
+
::NewRelic::Agent.logger.debug "Registered #{subclass.name} for harvest time sampling"
|
68
63
|
else
|
69
64
|
agent.stats_engine.add_sampler sampler
|
70
|
-
|
65
|
+
::NewRelic::Agent.logger.debug "Registered #{subclass.name} for periodic sampling"
|
71
66
|
end
|
72
67
|
rescue NewRelic::Agent::Sampler::Unsupported => e
|
73
|
-
|
68
|
+
::NewRelic::Agent.logger.info "#{subclass} sampler not available: #{e}"
|
74
69
|
rescue => e
|
75
|
-
|
70
|
+
::NewRelic::Agent.logger.error "Error registering sampler:", e
|
76
71
|
end
|
77
72
|
end
|
78
73
|
end
|
@@ -92,7 +87,7 @@ module NewRelic
|
|
92
87
|
File.join(instrumentation_path, app.to_s, '*.rb')
|
93
88
|
@instrumentation_files.each { | pattern | load_instrumentation_files pattern }
|
94
89
|
DependencyDetection.detect!
|
95
|
-
|
90
|
+
::NewRelic::Agent.logger.info "Finished instrumentation"
|
96
91
|
end
|
97
92
|
end
|
98
93
|
include Instrumentation
|
@@ -18,29 +18,27 @@ module NewRelic
|
|
18
18
|
# the server we should contact for api requests, like uploading
|
19
19
|
# deployments and the like
|
20
20
|
def api_server
|
21
|
-
|
22
|
-
@api_server ||=
|
23
|
-
NewRelic::Control::Server.new \
|
24
|
-
api_host,
|
25
|
-
(self['api_port'] || self['port'] || (use_ssl? ? 443 : 80)).to_i,
|
26
|
-
nil
|
21
|
+
@api_server ||= NewRelic::Control::Server.new(Agent.config[:api_host], Agent.config[:api_port], nil)
|
27
22
|
end
|
28
23
|
|
29
24
|
# a new instances of the proxy server - this passes through if
|
30
25
|
# there is no proxy, otherwise it has proxy configuration
|
31
26
|
# information pulled from the config file
|
32
27
|
def proxy_server
|
33
|
-
@proxy_server ||=
|
34
|
-
|
28
|
+
@proxy_server ||= NewRelic::Control::ProxyServer.new(Agent.config[:proxy_host],
|
29
|
+
Agent.config[:proxy_port],
|
30
|
+
Agent.config[:proxy_user],
|
31
|
+
Agent.config[:proxy_pass])
|
35
32
|
end
|
36
33
|
|
37
34
|
# turns a hostname into an ip address and returns a
|
38
35
|
# NewRelic::Control::Server that contains the configuration info
|
39
36
|
def server_from_host(hostname=nil)
|
40
|
-
host = hostname ||
|
37
|
+
host = hostname || Agent.config[:host]
|
41
38
|
|
42
39
|
# if the host is not an IP address, turn it into one
|
43
|
-
NewRelic::Control::Server.new
|
40
|
+
NewRelic::Control::Server.new(host, Agent.config[:port],
|
41
|
+
convert_to_ip_address(host))
|
44
42
|
end
|
45
43
|
|
46
44
|
# Check to see if we need to look up the IP address
|
@@ -50,10 +48,11 @@ module NewRelic
|
|
50
48
|
def convert_to_ip_address(host)
|
51
49
|
# here we leave it as a host name since the cert verification
|
52
50
|
# needs it in host form
|
53
|
-
return host if verify_certificate
|
51
|
+
return host if Agent.config[:ssl] && Agent.config[:verify_certificate]
|
54
52
|
return nil if host.nil? || host.downcase == "localhost"
|
55
53
|
ip = resolve_ip_address(host)
|
56
|
-
|
54
|
+
|
55
|
+
::NewRelic::Agent.logger.debug "Resolved #{host} to #{ip}"
|
57
56
|
ip
|
58
57
|
end
|
59
58
|
|
@@ -64,13 +63,12 @@ module NewRelic
|
|
64
63
|
def resolve_ip_address(host)
|
65
64
|
Resolv.getaddress(host)
|
66
65
|
rescue => e
|
67
|
-
|
68
|
-
log.debug(e.backtrace.join("\n "))
|
66
|
+
::NewRelic::Agent.logger.warn("DNS Error caching IP address:", e)
|
69
67
|
begin
|
70
|
-
|
68
|
+
::NewRelic::Agent.logger.debug("Trying native DNS lookup since Resolv failed")
|
71
69
|
IPSocket.getaddress(host)
|
72
70
|
rescue => e
|
73
|
-
|
71
|
+
::NewRelic::Agent.logger.error("Could not look up server address: #{e}")
|
74
72
|
nil
|
75
73
|
end
|
76
74
|
end
|
@@ -94,10 +92,10 @@ module NewRelic
|
|
94
92
|
http_class = Net::HTTP::Proxy(proxy_server.name, proxy_server.port,
|
95
93
|
proxy_server.user, proxy_server.password)
|
96
94
|
http = http_class.new(host.ip || host.name, host.port)
|
97
|
-
|
98
|
-
if
|
95
|
+
::NewRelic::Agent.logger.debug("Http Connection opened to #{host.ip||host.name}:#{host.port}")
|
96
|
+
if Agent.config[:ssl]
|
99
97
|
http.use_ssl = true
|
100
|
-
if verify_certificate
|
98
|
+
if Agent.config[:verify_certificate]
|
101
99
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
102
100
|
http.ca_file = cert_file_path
|
103
101
|
else
|
@@ -15,12 +15,12 @@ DependencyDetection.defer do
|
|
15
15
|
@name = :delayed_job_injection
|
16
16
|
|
17
17
|
depends_on do
|
18
|
-
defined?(::Delayed) && defined?(::Delayed::Worker) && !NewRelic::
|
18
|
+
defined?(::Delayed) && defined?(::Delayed::Worker) && !NewRelic::Agent.config[:disable_dj]
|
19
19
|
end
|
20
20
|
|
21
21
|
executes do
|
22
22
|
if NewRelic::Agent.respond_to?(:logger)
|
23
|
-
NewRelic::Agent.logger.
|
23
|
+
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation hooks'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module NewRelic
|
2
|
+
# A singleton for shared generic helper methods
|
3
|
+
module Helper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# confirm a string is correctly encoded (in >= 1.9)
|
7
|
+
# If not force the encoding to ASCII-8BIT (binary)
|
8
|
+
if RUBY_VERSION >= '1.9'
|
9
|
+
def correctly_encoded(string)
|
10
|
+
return string unless string.is_a? String
|
11
|
+
string.valid_encoding? ? string : string.force_encoding("ASCII-8BIT")
|
12
|
+
end
|
13
|
+
else
|
14
|
+
#noop
|
15
|
+
def correctly_encoded(string)
|
16
|
+
string
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def instance_method_visibility(klass, method_name)
|
21
|
+
if klass.private_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
|
22
|
+
:private
|
23
|
+
elsif klass.protected_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
|
24
|
+
:protected
|
25
|
+
else
|
26
|
+
:public
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def time_to_millis(time)
|
31
|
+
(time.to_f * 1000).round
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,28 +1,6 @@
|
|
1
1
|
module NewRelic::LanguageSupport
|
2
2
|
extend self
|
3
|
-
|
4
|
-
module DataSerialization
|
5
|
-
def self.included(base)
|
6
|
-
# need to disable GC during marshal load in 1.8.7
|
7
|
-
if NewRelic::LanguageSupport.using_version?('1.8.7') &&
|
8
|
-
!NewRelic::LanguageSupport.using_engine?('jruby') &&
|
9
|
-
!NewRelic::LanguageSupport.using_engine?('rbx')
|
10
|
-
base.class_eval do
|
11
|
-
def self.load(*args)
|
12
|
-
if defined?(::GC) && ::GC.respond_to?(:disable)
|
13
|
-
::GC.disable
|
14
|
-
val = super
|
15
|
-
::GC.enable
|
16
|
-
val
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
3
|
+
|
26
4
|
module Control
|
27
5
|
def self.included(base)
|
28
6
|
# need to use syck rather than psych when possible
|
@@ -43,21 +21,22 @@ module NewRelic::LanguageSupport
|
|
43
21
|
end
|
44
22
|
end
|
45
23
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
24
|
+
|
25
|
+
@@forkable = nil
|
26
|
+
def can_fork?
|
27
|
+
# this is expensive to check, so we should only check once
|
28
|
+
return @@forkable if @@forkable != nil
|
29
|
+
|
30
|
+
if Process.respond_to?(:fork)
|
31
|
+
# if this is not 1.9.2 or higher, we have to make sure
|
32
|
+
@@forkable = ::RUBY_VERSION < '1.9.2' ? test_forkability : true
|
33
|
+
else
|
34
|
+
@@forkable = false
|
58
35
|
end
|
36
|
+
|
37
|
+
@@forkable
|
59
38
|
end
|
60
|
-
|
39
|
+
|
61
40
|
def using_engine?(engine)
|
62
41
|
if defined?(::RUBY_ENGINE)
|
63
42
|
::RUBY_ENGINE == engine
|
@@ -65,9 +44,49 @@ module NewRelic::LanguageSupport
|
|
65
44
|
engine == 'ruby'
|
66
45
|
end
|
67
46
|
end
|
68
|
-
|
47
|
+
|
48
|
+
def broken_gc?
|
49
|
+
NewRelic::LanguageSupport.using_version?('1.8.7') &&
|
50
|
+
RUBY_PATCHLEVEL < 348 &&
|
51
|
+
!NewRelic::LanguageSupport.using_engine?('jruby') &&
|
52
|
+
!NewRelic::LanguageSupport.using_engine?('rbx')
|
53
|
+
end
|
54
|
+
|
55
|
+
def with_disabled_gc
|
56
|
+
if defined?(::GC) && ::GC.respond_to?(:disable)
|
57
|
+
val = nil
|
58
|
+
begin
|
59
|
+
::GC.disable
|
60
|
+
val = yield
|
61
|
+
ensure
|
62
|
+
::GC.enable
|
63
|
+
end
|
64
|
+
val
|
65
|
+
else
|
66
|
+
yield
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def with_cautious_gc
|
71
|
+
if broken_gc?
|
72
|
+
with_disabled_gc { yield }
|
73
|
+
else
|
74
|
+
yield
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
69
78
|
def using_version?(version)
|
70
79
|
numbers = version.split('.')
|
71
80
|
numbers == ::RUBY_VERSION.split('.')[0, numbers.size]
|
72
81
|
end
|
82
|
+
|
83
|
+
def test_forkability
|
84
|
+
child = Process.fork { exit! }
|
85
|
+
# calling wait here doesn't seem like it should necessary, but it seems to
|
86
|
+
# resolve some weird edge cases with resque forking.
|
87
|
+
Process.wait child
|
88
|
+
true
|
89
|
+
rescue NotImplementedError
|
90
|
+
false
|
91
|
+
end
|
73
92
|
end
|
@@ -5,7 +5,6 @@ module NewRelic
|
|
5
5
|
# An instance of LocalEnvironment is responsible for determining
|
6
6
|
# three things:
|
7
7
|
#
|
8
|
-
# * Framework - :rails, :rails3, :merb, :ruby, :external, :test
|
9
8
|
# * Dispatcher - A supported dispatcher, or nil (:mongrel, :thin, :passenger, :webrick, etc)
|
10
9
|
# * Dispatcher Instance ID, which distinguishes agents on a single host from each other
|
11
10
|
#
|
@@ -14,17 +13,17 @@ module NewRelic
|
|
14
13
|
#
|
15
14
|
# NewRelic::LocalEnvironment should be accessed through NewRelic::Control#env (via the NewRelic::Control singleton).
|
16
15
|
class LocalEnvironment
|
17
|
-
|
18
16
|
# mongrel, thin, webrick, or possibly nil
|
19
|
-
|
17
|
+
def discovered_dispatcher
|
18
|
+
discover_dispatcher unless @discovered_dispatcher
|
19
|
+
@discovered_dispatcher
|
20
|
+
end
|
21
|
+
|
20
22
|
# used to distinguish instances of a dispatcher from each other, may be nil
|
21
23
|
attr_writer :dispatcher_instance_id
|
22
|
-
# rails, rails3, merb, external, ruby, test, etc
|
23
|
-
attr_accessor :framework
|
24
24
|
# The number of cpus, if detected, or nil - many platforms do not
|
25
25
|
# support this :(
|
26
|
-
attr_reader :processors
|
27
|
-
alias environment dispatcher
|
26
|
+
attr_reader :processors
|
28
27
|
|
29
28
|
def initialize
|
30
29
|
# Extend self with any any submodules of LocalEnvironment. These can override
|
@@ -34,9 +33,7 @@ module NewRelic
|
|
34
33
|
self.extend mod if mod.instance_of? Module
|
35
34
|
end
|
36
35
|
|
37
|
-
discover_framework
|
38
36
|
discover_dispatcher
|
39
|
-
@dispatcher = nil if @dispatcher == :none
|
40
37
|
@gems = Set.new
|
41
38
|
@plugins = Set.new
|
42
39
|
@config = Hash.new
|
@@ -49,9 +46,8 @@ module NewRelic
|
|
49
46
|
def append_environment_value(name, value = nil)
|
50
47
|
value = yield if block_given?
|
51
48
|
@config[name] = value if value
|
52
|
-
rescue
|
53
|
-
|
54
|
-
raise if @framework == :test
|
49
|
+
rescue => e
|
50
|
+
Agent.logger.error e
|
55
51
|
end
|
56
52
|
|
57
53
|
# yields to the block and appends the returned value to the list
|
@@ -59,24 +55,22 @@ module NewRelic
|
|
59
55
|
def append_gem_list
|
60
56
|
@gems += yield
|
61
57
|
rescue => e
|
62
|
-
|
63
|
-
raise if @framework == :test
|
58
|
+
Agent.logger.error e
|
64
59
|
end
|
65
60
|
|
66
61
|
# yields to the block and appends the returned value to the list
|
67
62
|
# of plugins - this catches errors that might be raised in the block
|
68
63
|
def append_plugin_list
|
69
64
|
@plugins += yield
|
70
|
-
rescue
|
71
|
-
|
72
|
-
raise if @framework == :test
|
65
|
+
rescue => e
|
66
|
+
Agent.logger.error e
|
73
67
|
end
|
74
68
|
|
75
69
|
# An instance id pulled from either @dispatcher_instance_id or by
|
76
70
|
# splitting out the first part of the running file
|
77
71
|
def dispatcher_instance_id
|
78
72
|
if @dispatcher_instance_id.nil?
|
79
|
-
if @
|
73
|
+
if @discovered_dispatcher.nil?
|
80
74
|
@dispatcher_instance_id = File.basename($0).split(".").first
|
81
75
|
end
|
82
76
|
end
|
@@ -123,7 +117,7 @@ module NewRelic
|
|
123
117
|
|
124
118
|
if processors == 0
|
125
119
|
processors = 1 # assume there is at least one processor
|
126
|
-
NewRelic::Agent.logger.warn("Cannot determine the number of processors in #{proc_file}")
|
120
|
+
::NewRelic::Agent.logger.warn("Cannot determine the number of processors in #{proc_file}")
|
127
121
|
end
|
128
122
|
processors
|
129
123
|
end
|
@@ -198,8 +192,8 @@ module NewRelic
|
|
198
192
|
# Collect base statistics about the environment and record them for
|
199
193
|
# comparison and change detection.
|
200
194
|
def gather_environment_info
|
201
|
-
append_environment_value 'Framework',
|
202
|
-
append_environment_value 'Dispatcher',
|
195
|
+
append_environment_value 'Framework', Agent.config[:framework].to_s
|
196
|
+
append_environment_value 'Dispatcher', Agent.config[:dispatcher].to_s if Agent.config[:dispatcher]
|
203
197
|
append_environment_value 'Dispatcher instance id', @dispatcher_instance_id if @dispatcher_instance_id
|
204
198
|
append_environment_value('Environment') { NewRelic::Control.instance.env }
|
205
199
|
|
@@ -245,47 +239,19 @@ module NewRelic
|
|
245
239
|
|
246
240
|
private
|
247
241
|
|
248
|
-
# Although you can override the
|
242
|
+
# Although you can override the dispatcher with NEWRELIC_DISPATCHER this
|
249
243
|
# is not advisable since it implies certain api's being available.
|
250
244
|
def discover_dispatcher
|
251
|
-
@dispatcher ||= ENV['NEWRELIC_DISPATCHER'] && ENV['NEWRELIC_DISPATCHER'].to_sym
|
252
|
-
@dispatcher ||= ENV['NEW_RELIC_DISPATCHER'] && ENV['NEW_RELIC_DISPATCHER'].to_sym
|
253
245
|
dispatchers = %w[passenger torquebox glassfish thin mongrel litespeed webrick fastcgi unicorn sinatra]
|
254
|
-
while dispatchers.any? && @
|
246
|
+
while dispatchers.any? && @discovered_dispatcher.nil?
|
255
247
|
send 'check_for_'+(dispatchers.shift)
|
256
248
|
end
|
257
249
|
end
|
258
250
|
|
259
|
-
def discover_framework
|
260
|
-
# Although you can override the framework with NEWRELIC_FRAMEWORK this
|
261
|
-
# is not advisable since it implies certain api's being available.
|
262
|
-
#
|
263
|
-
# Note that the odd defined? sequence is necessary to work around a bug in an older version
|
264
|
-
# of JRuby.
|
265
|
-
@framework ||= case
|
266
|
-
when ENV['NEWRELIC_FRAMEWORK'] then ENV['NEWRELIC_FRAMEWORK'].to_sym
|
267
|
-
when ENV['NEW_RELIC_FRAMEWORK'] then ENV['NEW_RELIC_FRAMEWORK'].to_sym
|
268
|
-
when defined?(::NewRelic::TEST) then :test
|
269
|
-
when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
|
270
|
-
when defined?(::Rails) then check_rails_version
|
271
|
-
when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
|
272
|
-
when defined?(::NewRelic::IA) then :external
|
273
|
-
else :ruby
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
def check_rails_version
|
278
|
-
if Rails::VERSION::MAJOR < 3
|
279
|
-
:rails
|
280
|
-
else
|
281
|
-
:rails3
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
251
|
def check_for_torquebox
|
286
252
|
return unless defined?(::JRuby) &&
|
287
253
|
( org.torquebox::TorqueBox rescue nil)
|
288
|
-
@
|
254
|
+
@discovered_dispatcher = :torquebox
|
289
255
|
end
|
290
256
|
|
291
257
|
def check_for_glassfish
|
@@ -293,12 +259,12 @@ module NewRelic
|
|
293
259
|
(((com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory rescue nil) &&
|
294
260
|
defined?(com::sun::grizzly::jruby::rack::DefaultRackApplicationFactory)) ||
|
295
261
|
(jruby_rack? && defined?(::GlassFish::Server)))
|
296
|
-
@
|
262
|
+
@discovered_dispatcher = :glassfish
|
297
263
|
end
|
298
264
|
|
299
265
|
def check_for_trinidad
|
300
266
|
return unless defined?(::JRuby) && jruby_rack? && defined?(::Trinidad::Server)
|
301
|
-
@
|
267
|
+
@discovered_dispatcher = :trinidad
|
302
268
|
end
|
303
269
|
|
304
270
|
def jruby_rack?
|
@@ -308,7 +274,7 @@ module NewRelic
|
|
308
274
|
|
309
275
|
def check_for_webrick
|
310
276
|
return unless defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
311
|
-
@
|
277
|
+
@discovered_dispatcher = :webrick
|
312
278
|
if defined?(::OPTIONS) && OPTIONS.respond_to?(:fetch)
|
313
279
|
# OPTIONS is set by script/server
|
314
280
|
@dispatcher_instance_id = OPTIONS.fetch(:port)
|
@@ -318,13 +284,13 @@ module NewRelic
|
|
318
284
|
|
319
285
|
def check_for_fastcgi
|
320
286
|
return unless defined?(::FCGI)
|
321
|
-
@
|
287
|
+
@discovered_dispatcher = :fastcgi
|
322
288
|
end
|
323
289
|
|
324
290
|
# this case covers starting by mongrel_rails
|
325
291
|
def check_for_mongrel
|
326
292
|
return unless defined?(::Mongrel) && defined?(::Mongrel::HttpServer)
|
327
|
-
@
|
293
|
+
@discovered_dispatcher = :mongrel
|
328
294
|
|
329
295
|
# Get the port from the server if it's started
|
330
296
|
|
@@ -346,7 +312,7 @@ module NewRelic
|
|
346
312
|
def check_for_unicorn
|
347
313
|
if (defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) && working_jruby?
|
348
314
|
v = find_class_in_object_space(::Unicorn::HttpServer)
|
349
|
-
@
|
315
|
+
@discovered_dispatcher = :unicorn if v
|
350
316
|
end
|
351
317
|
end
|
352
318
|
|
@@ -363,7 +329,7 @@ module NewRelic
|
|
363
329
|
$stderr.puts("Your Sinatra version is #{version}, we highly recommend upgrading to >=0.9.2")
|
364
330
|
end
|
365
331
|
|
366
|
-
@
|
332
|
+
@discovered_dispatcher = :sinatra
|
367
333
|
end
|
368
334
|
|
369
335
|
def check_for_thin
|
@@ -371,7 +337,7 @@ module NewRelic
|
|
371
337
|
# This case covers the thin web dispatcher
|
372
338
|
# Same issue as above- we assume only one instance per process
|
373
339
|
ObjectSpace.each_object(Thin::Server) do |thin_dispatcher|
|
374
|
-
@
|
340
|
+
@discovered_dispatcher = :thin
|
375
341
|
backend = thin_dispatcher.backend
|
376
342
|
# We need a way to uniquely identify and distinguish agents. The port
|
377
343
|
# works for this. When using sockets, use the socket file name.
|
@@ -384,21 +350,21 @@ module NewRelic
|
|
384
350
|
end
|
385
351
|
end # each thin instance
|
386
352
|
end
|
387
|
-
if defined?(::Thin) && defined?(::Thin::VERSION) && !@
|
388
|
-
@
|
353
|
+
if defined?(::Thin) && defined?(::Thin::VERSION) && !@discovered_dispatcher
|
354
|
+
@discovered_dispatcher = :thin
|
389
355
|
@dispatcher_instance_id = default_port
|
390
356
|
end
|
391
357
|
end
|
392
358
|
|
393
359
|
def check_for_litespeed
|
394
360
|
if caller.pop =~ /fcgi-bin\/RailsRunner\.rb/
|
395
|
-
@
|
361
|
+
@discovered_dispatcher = :litespeed
|
396
362
|
end
|
397
363
|
end
|
398
364
|
|
399
365
|
def check_for_passenger
|
400
|
-
if
|
401
|
-
@
|
366
|
+
if defined?(::PhusionPassenger)
|
367
|
+
@discovered_dispatcher = :passenger
|
402
368
|
end
|
403
369
|
end
|
404
370
|
|
@@ -418,8 +384,7 @@ module NewRelic
|
|
418
384
|
# outputs a human-readable description
|
419
385
|
def to_s
|
420
386
|
s = "LocalEnvironment["
|
421
|
-
s << @
|
422
|
-
s << ";dispatcher=#{@dispatcher}" if @dispatcher
|
387
|
+
s << ";dispatcher=#{@discovered_dispatcher}" if @discovered_dispatcher
|
423
388
|
s << ";instance=#{@dispatcher_instance_id}" if @dispatcher_instance_id
|
424
389
|
s << "]"
|
425
390
|
end
|