wd_newrelic_rpm 3.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +591 -0
- data/LICENSE +64 -0
- data/README.rdoc +179 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic +13 -0
- data/bin/newrelic_cmd +5 -0
- data/cert/cacert.pem +118 -0
- data/cert/oldsite.pem +28 -0
- data/cert/site.pem +27 -0
- data/install.rb +9 -0
- data/lib/conditional_vendored_dependency_detection.rb +3 -0
- data/lib/conditional_vendored_metric_parser.rb +5 -0
- data/lib/new_relic/agent.rb +467 -0
- data/lib/new_relic/agent/agent.rb +1325 -0
- data/lib/new_relic/agent/beacon_configuration.rb +121 -0
- data/lib/new_relic/agent/browser_monitoring.rb +142 -0
- data/lib/new_relic/agent/busy_calculator.rb +99 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/database.rb +223 -0
- data/lib/new_relic/agent/error_collector.rb +251 -0
- data/lib/new_relic/agent/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +29 -0
- data/lib/new_relic/agent/instrumentation/active_record.rb +137 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +68 -0
- data/lib/new_relic/agent/instrumentation/authlogic.rb +19 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +443 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +238 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +52 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +80 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +41 -0
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +29 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +353 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
- data/lib/new_relic/agent/instrumentation/net.rb +29 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +210 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +98 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +114 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +42 -0
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +42 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +180 -0
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +37 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +78 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +21 -0
- data/lib/new_relic/agent/method_tracer.rb +528 -0
- data/lib/new_relic/agent/sampler.rb +50 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +58 -0
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +40 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +143 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
- data/lib/new_relic/agent/shim_agent.rb +29 -0
- data/lib/new_relic/agent/sql_sampler.rb +286 -0
- data/lib/new_relic/agent/stats_engine.rb +26 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +187 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +95 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +125 -0
- data/lib/new_relic/agent/transaction_info.rb +74 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +116 -0
- data/lib/new_relic/agent/transaction_sampler.rb +468 -0
- data/lib/new_relic/agent/worker_loop.rb +89 -0
- data/lib/new_relic/collection_helper.rb +77 -0
- data/lib/new_relic/command.rb +85 -0
- data/lib/new_relic/commands/deployments.rb +105 -0
- data/lib/new_relic/commands/install.rb +80 -0
- data/lib/new_relic/control.rb +46 -0
- data/lib/new_relic/control/class_methods.rb +53 -0
- data/lib/new_relic/control/configuration.rb +206 -0
- data/lib/new_relic/control/frameworks.rb +10 -0
- data/lib/new_relic/control/frameworks/external.rb +16 -0
- data/lib/new_relic/control/frameworks/merb.rb +31 -0
- data/lib/new_relic/control/frameworks/rails.rb +164 -0
- data/lib/new_relic/control/frameworks/rails3.rb +75 -0
- data/lib/new_relic/control/frameworks/ruby.rb +42 -0
- data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +179 -0
- data/lib/new_relic/control/instrumentation.rb +100 -0
- data/lib/new_relic/control/logging_methods.rb +143 -0
- data/lib/new_relic/control/profiling.rb +25 -0
- data/lib/new_relic/control/server_methods.rb +114 -0
- data/lib/new_relic/data_serialization.rb +151 -0
- data/lib/new_relic/delayed_job_injection.rb +51 -0
- data/lib/new_relic/language_support.rb +73 -0
- data/lib/new_relic/local_environment.rb +428 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +51 -0
- data/lib/new_relic/metric_spec.rb +76 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +29 -0
- data/lib/new_relic/rack/browser_monitoring.rb +76 -0
- data/lib/new_relic/rack/developer_mode.rb +268 -0
- data/lib/new_relic/recipes.rb +77 -0
- data/lib/new_relic/stats.rb +335 -0
- data/lib/new_relic/timer_lib.rb +27 -0
- data/lib/new_relic/transaction_analysis.rb +77 -0
- data/lib/new_relic/transaction_analysis/segment_summary.rb +49 -0
- data/lib/new_relic/transaction_sample.rb +261 -0
- data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
- data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
- data/lib/new_relic/transaction_sample/segment.rb +203 -0
- data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
- data/lib/new_relic/url_rule.rb +14 -0
- data/lib/new_relic/version.rb +55 -0
- data/lib/newrelic_rpm.rb +49 -0
- data/lib/tasks/all.rb +4 -0
- data/lib/tasks/install.rake +7 -0
- data/lib/tasks/tests.rake +19 -0
- data/newrelic.yml +265 -0
- data/newrelic_rpm.gemspec +312 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +77 -0
- data/test/config/newrelic.yml +48 -0
- data/test/config/test_control.rb +48 -0
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/new_relic/agent/agent/connect_test.rb +403 -0
- data/test/new_relic/agent/agent/start_test.rb +255 -0
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +140 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +382 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +111 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +323 -0
- data/test/new_relic/agent/busy_calculator_test.rb +81 -0
- data/test/new_relic/agent/database_test.rb +149 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
- data/test/new_relic/agent/error_collector_test.rb +192 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +576 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +34 -0
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +171 -0
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +50 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +84 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +382 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +184 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +143 -0
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +164 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +234 -0
- data/test/new_relic/agent/method_tracer_test.rb +386 -0
- data/test/new_relic/agent/mock_scope_listener.rb +23 -0
- data/test/new_relic/agent/rpm_agent_test.rb +149 -0
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +20 -0
- data/test/new_relic/agent/sql_sampler_test.rb +192 -0
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +82 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
- data/test/new_relic/agent/stats_engine_test.rb +220 -0
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +219 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +967 -0
- data/test/new_relic/agent/worker_loop_test.rb +66 -0
- data/test/new_relic/agent_test.rb +187 -0
- data/test/new_relic/collection_helper_test.rb +149 -0
- data/test/new_relic/command/deployments_test.rb +68 -0
- data/test/new_relic/control/class_methods_test.rb +62 -0
- data/test/new_relic/control/configuration_test.rb +84 -0
- data/test/new_relic/control/logging_methods_test.rb +185 -0
- data/test/new_relic/control_test.rb +256 -0
- data/test/new_relic/data_serialization_test.rb +208 -0
- data/test/new_relic/delayed_job_injection_test.rb +16 -0
- data/test/new_relic/local_environment_test.rb +85 -0
- data/test/new_relic/metric_data_test.rb +125 -0
- data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
- data/test/new_relic/metric_spec_test.rb +95 -0
- data/test/new_relic/rack/all_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +142 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +74 -0
- data/test/new_relic/stats_test.rb +411 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +91 -0
- data/test/new_relic/transaction_analysis_test.rb +121 -0
- data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
- data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
- data/test/new_relic/transaction_sample/segment_test.rb +389 -0
- data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
- data/test/new_relic/transaction_sample_subtest_test.rb +56 -0
- data/test/new_relic/transaction_sample_test.rb +177 -0
- data/test/new_relic/version_number_test.rb +89 -0
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +94 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/test_contexts.rb +29 -0
- data/test/test_helper.rb +155 -0
- data/ui/helpers/developer_mode_helper.rb +357 -0
- data/ui/helpers/google_pie_chart.rb +48 -0
- data/ui/views/layouts/newrelic_default.rhtml +47 -0
- data/ui/views/newrelic/_explain_plans.rhtml +27 -0
- data/ui/views/newrelic/_sample.rhtml +20 -0
- data/ui/views/newrelic/_segment.rhtml +28 -0
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
- data/ui/views/newrelic/_segment_row.rhtml +12 -0
- data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_sql.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
- data/ui/views/newrelic/_sql_row.rhtml +16 -0
- data/ui/views/newrelic/_stack_trace.rhtml +15 -0
- data/ui/views/newrelic/_table.rhtml +12 -0
- data/ui/views/newrelic/explain_sql.rhtml +43 -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/file/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/file/images/textmate.png +0 -0
- data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +6240 -0
- data/ui/views/newrelic/file/javascript/transaction_sample.js +120 -0
- data/ui/views/newrelic/file/stylesheets/style.css +490 -0
- data/ui/views/newrelic/index.rhtml +71 -0
- data/ui/views/newrelic/sample_not_found.rhtml +2 -0
- data/ui/views/newrelic/show_sample.rhtml +80 -0
- data/ui/views/newrelic/show_source.rhtml +3 -0
- data/ui/views/newrelic/threads.rhtml +53 -0
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +5 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +67 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +3 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +1 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +33 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +89 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +46 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +67 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +43 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +48 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +24 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +28 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +11 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +135 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +15 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +54 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +5 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +70 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +18 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +133 -0
- metadata +376 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
module NewRelic
|
2
|
+
class Control
|
3
|
+
# class-level methods for lazy creation of NewRelic::Control and
|
4
|
+
# NewRelic::LocalEnvironment instances.
|
5
|
+
module ClassMethods
|
6
|
+
# Access the Control singleton, lazy initialized. Default will instantiate a new
|
7
|
+
# instance or pass false to defer
|
8
|
+
def instance(create=true)
|
9
|
+
@instance ||= create && new_instance
|
10
|
+
end
|
11
|
+
|
12
|
+
# Access the LocalEnvironment singleton, lazy initialized
|
13
|
+
def local_env
|
14
|
+
@local_env ||= NewRelic::LocalEnvironment.new
|
15
|
+
end
|
16
|
+
|
17
|
+
# Create the concrete class for environment specific behavior
|
18
|
+
def new_instance
|
19
|
+
if local_env.framework == :test
|
20
|
+
load_test_framework
|
21
|
+
else
|
22
|
+
load_framework_class(local_env.framework).new(local_env)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# nb this does not 'load test' the framework, it loads the 'test framework'
|
27
|
+
def load_test_framework
|
28
|
+
config = File.expand_path(File.join('..','..','..','..', "test","config","newrelic.yml"), __FILE__)
|
29
|
+
require "config/test_control"
|
30
|
+
NewRelic::Control::Frameworks::Test.new(local_env, config)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Loads the specified framework class from the
|
34
|
+
# NewRelic::Control::Frameworks module
|
35
|
+
def load_framework_class(framework)
|
36
|
+
begin
|
37
|
+
require "new_relic/control/frameworks/#{framework}"
|
38
|
+
rescue LoadError
|
39
|
+
# maybe it is already loaded by some external system
|
40
|
+
# i.e. rpm_contrib or user extensions?
|
41
|
+
end
|
42
|
+
NewRelic::Control::Frameworks.const_get(framework.to_s.capitalize)
|
43
|
+
end
|
44
|
+
|
45
|
+
# The root directory for the plugin or gem
|
46
|
+
def newrelic_root
|
47
|
+
File.expand_path(File.join("..", "..", "..", ".."), __FILE__)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
extend ClassMethods
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,206 @@
|
|
1
|
+
module NewRelic
|
2
|
+
class Control
|
3
|
+
# used to contain methods to look up settings from the
|
4
|
+
# configuration located in newrelic.yml
|
5
|
+
module Configuration
|
6
|
+
def settings
|
7
|
+
unless @settings
|
8
|
+
@settings = (@yaml && merge_defaults(@yaml[env])) || {}
|
9
|
+
# At the time we bind the settings, we also need to run this little piece
|
10
|
+
# of magic which allows someone to augment the id with the app name, necessary
|
11
|
+
if self['multi_homed'] && app_names.size > 0
|
12
|
+
if @local_env.dispatcher_instance_id
|
13
|
+
@local_env.dispatcher_instance_id << ":#{app_names.first}"
|
14
|
+
else
|
15
|
+
@local_env.dispatcher_instance_id = app_names.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
@settings
|
21
|
+
end
|
22
|
+
|
23
|
+
def merge_defaults(settings_hash)
|
24
|
+
s = {
|
25
|
+
'host' => 'collector.newrelic.com',
|
26
|
+
'ssl' => false,
|
27
|
+
'log_level' => 'info',
|
28
|
+
'apdex_t' => 0.5
|
29
|
+
}
|
30
|
+
s.merge! settings_hash if settings_hash
|
31
|
+
# monitor_daemons replaced with agent_enabled
|
32
|
+
s['agent_enabled'] = s.delete('monitor_daemons') if s['agent_enabled'].nil? && s.include?('monitor_daemons')
|
33
|
+
s
|
34
|
+
end
|
35
|
+
|
36
|
+
# Merge the given options into the config options.
|
37
|
+
# They might be a nested hash
|
38
|
+
def merge_options(options, hash=self)
|
39
|
+
options.each do |key, val|
|
40
|
+
case
|
41
|
+
when key == :config then next
|
42
|
+
when val.is_a?(Hash)
|
43
|
+
merge_options(val, hash[key.to_s] ||= {})
|
44
|
+
when val.nil?
|
45
|
+
hash.delete(key.to_s)
|
46
|
+
else
|
47
|
+
hash[key.to_s] = val
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def merge_server_side_config(data)
|
53
|
+
remove_server_controlled_configs
|
54
|
+
config = Hash.new
|
55
|
+
data.each_pair do |key, value|
|
56
|
+
if key.include?('.')
|
57
|
+
key = key.split('.')
|
58
|
+
config[key.first] ||= Hash.new
|
59
|
+
config[key.first][key[1]] = value
|
60
|
+
else
|
61
|
+
config[key] = value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
merge_options(config)
|
65
|
+
end
|
66
|
+
|
67
|
+
def remove_server_controlled_configs
|
68
|
+
settings.delete('transaction_tracer')
|
69
|
+
settings.delete('slow_sql')
|
70
|
+
settings.delete('error_collector')
|
71
|
+
settings.delete('capture_params')
|
72
|
+
end
|
73
|
+
|
74
|
+
def [](key)
|
75
|
+
fetch(key)
|
76
|
+
end
|
77
|
+
|
78
|
+
def []=(key, value)
|
79
|
+
settings[key] = value
|
80
|
+
end
|
81
|
+
|
82
|
+
def fetch(key, default=nil)
|
83
|
+
settings.fetch(key, default)
|
84
|
+
end
|
85
|
+
|
86
|
+
def apdex_t
|
87
|
+
# Always initialized with a default
|
88
|
+
@apdex_t_float ||= fetch('apdex_t').to_f
|
89
|
+
end
|
90
|
+
|
91
|
+
def license_key
|
92
|
+
env_setting = ENV['NEW_RELIC_LICENSE_KEY'] || ENV['NEWRELIC_LICENSE_KEY']
|
93
|
+
fetch('license_key', env_setting)
|
94
|
+
end
|
95
|
+
|
96
|
+
def capture_params
|
97
|
+
fetch('capture_params')
|
98
|
+
end
|
99
|
+
|
100
|
+
# True if we are sending data to the server, monitoring production
|
101
|
+
def monitor_mode?
|
102
|
+
fetch('monitor_mode', fetch('enabled'))
|
103
|
+
end
|
104
|
+
|
105
|
+
# True if we are capturing data and displaying in /newrelic
|
106
|
+
def developer_mode?
|
107
|
+
fetch('developer_mode', fetch('developer'))
|
108
|
+
end
|
109
|
+
|
110
|
+
# whether we should install the
|
111
|
+
# NewRelic::Rack::BrowserMonitoring middleware automatically on
|
112
|
+
# Rails applications
|
113
|
+
def browser_monitoring_auto_instrument?
|
114
|
+
fetch('browser_monitoring', {}).fetch('auto_instrument', true)
|
115
|
+
end
|
116
|
+
|
117
|
+
def multi_threaded?
|
118
|
+
fetch('multi_threaded')
|
119
|
+
end
|
120
|
+
|
121
|
+
def disable_serialization?
|
122
|
+
fetch('disable_serialization', !DependencyDetection.installed?(:resque))
|
123
|
+
end
|
124
|
+
def disable_serialization=(b)
|
125
|
+
self['disable_serialization'] = b
|
126
|
+
end
|
127
|
+
|
128
|
+
# True if we should view files in textmate
|
129
|
+
def use_textmate?
|
130
|
+
fetch('textmate')
|
131
|
+
end
|
132
|
+
|
133
|
+
# defaults to 2MiB
|
134
|
+
def post_size_limit
|
135
|
+
fetch('post_size_limit', 2 * 1024 * 1024)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Configuration option of the same name to indicate that we should connect
|
139
|
+
# to New Relic synchronously on startup. This means when the agent is loaded it
|
140
|
+
# won't return without trying to set up the server connection at least once
|
141
|
+
# which can make startup take longer. Defaults to false.
|
142
|
+
def sync_startup
|
143
|
+
fetch('sync_startup', false)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Configuration option of the same name to indicate that we should flush
|
147
|
+
# data to the server on exiting. Defaults to true.
|
148
|
+
def send_data_on_exit
|
149
|
+
fetch('send_data_on_exit', true)
|
150
|
+
end
|
151
|
+
|
152
|
+
def dispatcher_instance_id
|
153
|
+
self['dispatcher_instance_id'] || @local_env.dispatcher_instance_id
|
154
|
+
end
|
155
|
+
|
156
|
+
def dispatcher
|
157
|
+
(self['dispatcher'] && self['dispatcher'].to_sym) || @local_env.dispatcher
|
158
|
+
end
|
159
|
+
def app_names
|
160
|
+
case self['app_name']
|
161
|
+
when Array then self['app_name']
|
162
|
+
when String then self['app_name'].split(';')
|
163
|
+
else [ env ]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
def validate_seed
|
167
|
+
self['validate_seed'] || ENV['NR_VALIDATE_SEED']
|
168
|
+
end
|
169
|
+
def validate_token
|
170
|
+
self['validate_token'] || ENV['NR_VALIDATE_TOKEN']
|
171
|
+
end
|
172
|
+
|
173
|
+
def use_ssl?
|
174
|
+
@use_ssl = fetch('ssl', false) unless @use_ssl
|
175
|
+
@use_ssl
|
176
|
+
end
|
177
|
+
|
178
|
+
def log_file_path
|
179
|
+
fetch('log_file_path', 'log/')
|
180
|
+
end
|
181
|
+
|
182
|
+
# only verify certificates if you're very sure you want this
|
183
|
+
# level of security, it includes possibly app-crashing dns
|
184
|
+
# lookups every connection to the server
|
185
|
+
def verify_certificate?
|
186
|
+
unless @verify_certificate
|
187
|
+
unless use_ssl?
|
188
|
+
@verify_certificate = false
|
189
|
+
else
|
190
|
+
@verify_certificate = fetch('verify_certificate', false)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
@verify_certificate
|
194
|
+
end
|
195
|
+
|
196
|
+
def disable_backtrace_cleanup?
|
197
|
+
fetch('disable_backtrace_cleanup')
|
198
|
+
end
|
199
|
+
|
200
|
+
def has_slow_sql_config?
|
201
|
+
self['slow_sql'] && self['slow_sql'].has_key?('enabled')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
include Configuration
|
205
|
+
end
|
206
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module NewRelic
|
2
|
+
class Control
|
3
|
+
# Contains subclasses of NewRelic::Control that are used when
|
4
|
+
# starting the agent within an application. Framework-specific
|
5
|
+
# logic should be included here, as documented within the Control
|
6
|
+
# abstract parent class
|
7
|
+
module Frameworks
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'new_relic/control/frameworks/ruby'
|
2
|
+
module NewRelic
|
3
|
+
class Control
|
4
|
+
module Frameworks
|
5
|
+
# This is the control used when starting up in the context of
|
6
|
+
# The New Relic Infrastructure Agent. We want to call this
|
7
|
+
# out specifically because in this context we are not monitoring
|
8
|
+
# the running process, but actually external things.
|
9
|
+
class External < NewRelic::Control::Frameworks::Ruby
|
10
|
+
def init_config(options={})
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NewRelic
|
2
|
+
class Control
|
3
|
+
module Frameworks
|
4
|
+
# Includes limited support for Merb
|
5
|
+
class Merb < NewRelic::Control
|
6
|
+
|
7
|
+
def env
|
8
|
+
@env ||= ::Merb.env
|
9
|
+
end
|
10
|
+
def root
|
11
|
+
::Merb.root
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_stdout(msg)
|
15
|
+
Merb.logger.info("NewRelic ~ " + msg)
|
16
|
+
rescue => e
|
17
|
+
STDOUT.puts "NewRelic ~ " + msg
|
18
|
+
end
|
19
|
+
|
20
|
+
def init_config options={}
|
21
|
+
::Merb::Plugins.add_rakefiles File.join(newrelic_root,"lib/tasks/all.rb")
|
22
|
+
|
23
|
+
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
24
|
+
::Merb::Plugins.config[:newrelic] = {
|
25
|
+
:config => self
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'new_relic/control/frameworks/ruby'
|
2
|
+
module NewRelic
|
3
|
+
class Control
|
4
|
+
module Frameworks
|
5
|
+
# Control subclass instantiated when Rails is detected. Contains
|
6
|
+
# Rails specific configuration, instrumentation, environment values,
|
7
|
+
# etc.
|
8
|
+
class Rails < NewRelic::Control::Frameworks::Ruby
|
9
|
+
|
10
|
+
def env
|
11
|
+
@env ||= RAILS_ENV.dup
|
12
|
+
end
|
13
|
+
def root
|
14
|
+
if defined?(RAILS_ROOT) && RAILS_ROOT.to_s != ''
|
15
|
+
RAILS_ROOT.to_s
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
def logger
|
21
|
+
::RAILS_DEFAULT_LOGGER
|
22
|
+
end
|
23
|
+
|
24
|
+
# 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
|
26
|
+
# find a config and use that.
|
27
|
+
def init_config(options={})
|
28
|
+
rails_config = options[:config]
|
29
|
+
if !rails_config && defined?(::Rails) && ::Rails.respond_to?(:configuration)
|
30
|
+
rails_config = ::Rails.configuration
|
31
|
+
end
|
32
|
+
# Install the dependency detection,
|
33
|
+
if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
|
34
|
+
rails_config.after_initialize do
|
35
|
+
# 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
|
37
|
+
# delayed_job_injection.rb
|
38
|
+
DependencyDetection.detect!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
if !agent_enabled?
|
42
|
+
# Might not be running if it does not think mongrel, thin, passenger, etc
|
43
|
+
# is running, if it things it's a rake task, or if the agent_enabled is false.
|
44
|
+
log! "New Relic Agent not running."
|
45
|
+
else
|
46
|
+
log! "Starting the New Relic Agent."
|
47
|
+
install_developer_mode rails_config if developer_mode?
|
48
|
+
install_browser_monitoring(rails_config)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_browser_monitoring(config)
|
53
|
+
return if @browser_monitoring_installed
|
54
|
+
@browser_monitoring_installed = true
|
55
|
+
return if config.nil? || !config.respond_to?(:middleware) || ! browser_monitoring_auto_instrument?
|
56
|
+
begin
|
57
|
+
require 'new_relic/rack/browser_monitoring'
|
58
|
+
config.middleware.use NewRelic::Rack::BrowserMonitoring
|
59
|
+
log!("Installed New Relic Browser Monitoring middleware", :info)
|
60
|
+
rescue => e
|
61
|
+
log!("Error installing New Relic Browser Monitoring middleware: #{e.inspect}", :error)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def install_developer_mode(rails_config)
|
66
|
+
return if @installed
|
67
|
+
@installed = true
|
68
|
+
if rails_config && rails_config.respond_to?(:middleware)
|
69
|
+
begin
|
70
|
+
require 'new_relic/rack/developer_mode'
|
71
|
+
rails_config.middleware.use NewRelic::Rack::DeveloperMode
|
72
|
+
|
73
|
+
# inform user that the dev edition is available if we are running inside
|
74
|
+
# a webserver process
|
75
|
+
if @local_env.dispatcher_instance_id
|
76
|
+
port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
|
77
|
+
log!("NewRelic Agent Developer Mode enabled.")
|
78
|
+
log!("To view performance information, go to http://localhost#{port}/newrelic")
|
79
|
+
end
|
80
|
+
rescue => e
|
81
|
+
log!("Error installing New Relic Developer Mode: #{e.inspect}", :error)
|
82
|
+
end
|
83
|
+
elsif rails_config
|
84
|
+
log!("Developer mode not available for Rails versions prior to 2.2", :warn)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
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
|
+
def rails_version
|
107
|
+
@rails_version ||= NewRelic::VersionNumber.new(::Rails::VERSION::STRING)
|
108
|
+
end
|
109
|
+
|
110
|
+
protected
|
111
|
+
|
112
|
+
def rails_vendor_root
|
113
|
+
File.join(root,'vendor','rails')
|
114
|
+
end
|
115
|
+
|
116
|
+
def rails_gem_list
|
117
|
+
::Rails.configuration.gems.map do | gem |
|
118
|
+
version = (gem.respond_to?(:version) && gem.version) ||
|
119
|
+
(gem.specification.respond_to?(:version) && gem.specification.version)
|
120
|
+
gem.name + (version ? "(#{version})" : "")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Collect the Rails::Info into an associative array as well as the list of plugins
|
125
|
+
def append_environment_info
|
126
|
+
local_env.append_environment_value('Rails version'){ ::Rails::VERSION::STRING }
|
127
|
+
if rails_version >= NewRelic::VersionNumber.new('2.2.0')
|
128
|
+
local_env.append_environment_value('Rails threadsafe') do
|
129
|
+
::Rails.configuration.action_controller.allow_concurrency == true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
local_env.append_environment_value('Rails Env') { ENV['RAILS_ENV'] }
|
133
|
+
if rails_version >= NewRelic::VersionNumber.new('2.1.0')
|
134
|
+
local_env.append_gem_list do
|
135
|
+
(bundler_gem_list + rails_gem_list).uniq
|
136
|
+
end
|
137
|
+
# The plugins is configured manually. If it's nil, it loads everything non-deterministically
|
138
|
+
if ::Rails.configuration.plugins
|
139
|
+
local_env.append_plugin_list { ::Rails.configuration.plugins }
|
140
|
+
else
|
141
|
+
::Rails.configuration.plugin_paths.each do |path|
|
142
|
+
local_env.append_plugin_list { Dir[File.join(path, '*')].collect{ |p| File.basename p if File.directory? p }.compact }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
else
|
146
|
+
# Rails prior to 2.1, can't get the gems. Find plugins in the default location
|
147
|
+
local_env.append_plugin_list do
|
148
|
+
Dir[File.join(root, 'vendor', 'plugins', '*')].collect{ |p| File.basename p if File.directory? p }.compact
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def install_shim
|
154
|
+
super
|
155
|
+
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
156
|
+
::ActionController::Base.class_eval {
|
157
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|