dolores_rpm 3.2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +559 -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/dolores_rpm-3.3.4.fork.gem +0 -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/agent.rb +1311 -0
- data/lib/new_relic/agent/beacon_configuration.rb +110 -0
- data/lib/new_relic/agent/browser_monitoring.rb +102 -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 +203 -0
- data/lib/new_relic/agent/error_collector.rb +251 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +27 -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 +424 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +57 -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/pop.rb +80 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +332 -0
- data/lib/new_relic/agent/instrumentation/net.rb +29 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +36 -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/active_record_instrumentation.rb +115 -0
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +42 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +118 -0
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +122 -0
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +37 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +58 -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/instrumentation.rb +9 -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 +144 -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 +267 -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 +208 -0
- data/lib/new_relic/agent/stats_engine.rb +25 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
- data/lib/new_relic/agent/transaction_sampler.rb +397 -0
- data/lib/new_relic/agent/worker_loop.rb +89 -0
- data/lib/new_relic/agent.rb +454 -0
- data/lib/new_relic/collection_helper.rb +75 -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/class_methods.rb +53 -0
- data/lib/new_relic/control/configuration.rb +202 -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/frameworks.rb +10 -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/control.rb +46 -0
- data/lib/new_relic/data_serialization.rb +157 -0
- data/lib/new_relic/delayed_job_injection.rb +46 -0
- data/lib/new_relic/language_support.rb +69 -0
- data/lib/new_relic/local_environment.rb +414 -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 +75 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +24 -0
- data/lib/new_relic/rack/browser_monitoring.rb +68 -0
- data/lib/new_relic/rack/developer_mode.rb +268 -0
- data/lib/new_relic/recipes.rb +73 -0
- data/lib/new_relic/stats.rb +388 -0
- data/lib/new_relic/timer_lib.rb +27 -0
- data/lib/new_relic/transaction_analysis/segment_summary.rb +49 -0
- data/lib/new_relic/transaction_analysis.rb +77 -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 +201 -0
- data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
- data/lib/new_relic/transaction_sample.rb +245 -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/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/new_relic/agent/agent/connect_test.rb +410 -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 +139 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +363 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +108 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +278 -0
- data/test/new_relic/agent/busy_calculator_test.rb +81 -0
- data/test/new_relic/agent/database_test.rb +162 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
- data/test/new_relic/agent/error_collector_test.rb +175 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +538 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +172 -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 +387 -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 +160 -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 +185 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +195 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +955 -0
- data/test/new_relic/agent/worker_loop_test.rb +66 -0
- data/test/new_relic/agent_test.rb +175 -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 +72 -0
- data/test/new_relic/control/logging_methods_test.rb +185 -0
- data/test/new_relic/control_test.rb +254 -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 +72 -0
- data/test/new_relic/metric_data_test.rb +125 -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 +84 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +43 -0
- data/test/new_relic/stats_test.rb +426 -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 +164 -0
- data/test/new_relic/version_number_test.rb +89 -0
- data/test/test_contexts.rb +29 -0
- data/test/test_helper.rb +154 -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/version.rb +3 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +62 -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/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 +122 -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
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
- metadata +398 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
|
2
|
+
class NewRelic::Agent::Agent::StartWorkerThreadTest < Test::Unit::TestCase
|
|
3
|
+
require 'new_relic/agent/agent'
|
|
4
|
+
include NewRelic::Agent::Agent::StartWorkerThread
|
|
5
|
+
|
|
6
|
+
def test_deferred_work_connects
|
|
7
|
+
self.expects(:catch_errors).yields
|
|
8
|
+
self.expects(:connect).with('connection_options')
|
|
9
|
+
@connected = true
|
|
10
|
+
self.expects(:check_transaction_sampler_status)
|
|
11
|
+
self.expects(:check_sql_sampler_status)
|
|
12
|
+
self.expects(:log_worker_loop_start)
|
|
13
|
+
self.expects(:create_and_run_worker_loop)
|
|
14
|
+
deferred_work!('connection_options')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_deferred_work_connect_failed
|
|
18
|
+
self.expects(:catch_errors).yields
|
|
19
|
+
self.expects(:connect).with('connection_options')
|
|
20
|
+
@connected = false
|
|
21
|
+
fake_log = mocked_log
|
|
22
|
+
fake_log.expects(:debug).with("No connection. Worker thread ending.")
|
|
23
|
+
deferred_work!('connection_options')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_check_transaction_sampler_status_enabled
|
|
27
|
+
control = mocked_control
|
|
28
|
+
control.expects(:developer_mode?).returns(false)
|
|
29
|
+
@should_send_samples = true
|
|
30
|
+
@transaction_sampler = mock('transaction_sampler')
|
|
31
|
+
@transaction_sampler.expects(:enable)
|
|
32
|
+
check_transaction_sampler_status
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_check_transaction_sampler_status_devmode
|
|
36
|
+
control = mocked_control
|
|
37
|
+
control.expects(:developer_mode?).returns(true)
|
|
38
|
+
@should_send_samples = false
|
|
39
|
+
@transaction_sampler = mock('transaction_sampler')
|
|
40
|
+
@transaction_sampler.expects(:enable)
|
|
41
|
+
check_transaction_sampler_status
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_check_transaction_sampler_status_disabled
|
|
45
|
+
control = mocked_control
|
|
46
|
+
control.expects(:developer_mode?).returns(false)
|
|
47
|
+
@should_send_samples = false
|
|
48
|
+
@transaction_sampler = mock('transaction_sampler')
|
|
49
|
+
@transaction_sampler.expects(:disable)
|
|
50
|
+
check_transaction_sampler_status
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_log_worker_loop_start
|
|
54
|
+
@report_period = 30
|
|
55
|
+
log = mocked_log
|
|
56
|
+
log.expects(:info).with("Reporting performance data every 30 seconds.")
|
|
57
|
+
log.expects(:debug).with("Running worker loop")
|
|
58
|
+
log_worker_loop_start
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_create_and_run_worker_loop
|
|
62
|
+
@report_period = 30
|
|
63
|
+
@should_send_samples = true
|
|
64
|
+
wl = mock('worker loop')
|
|
65
|
+
NewRelic::Agent::WorkerLoop.expects(:new).returns(wl)
|
|
66
|
+
wl.expects(:run).with(30).yields
|
|
67
|
+
self.expects(:save_or_transmit_data)
|
|
68
|
+
create_and_run_worker_loop
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_handle_force_restart
|
|
72
|
+
# hooray for methods with no branches
|
|
73
|
+
error = mock('exception')
|
|
74
|
+
log = mocked_log
|
|
75
|
+
error.expects(:message).returns('a message')
|
|
76
|
+
log.expects(:info).with('a message')
|
|
77
|
+
self.expects(:reset_stats)
|
|
78
|
+
self.expects(:sleep).with(30)
|
|
79
|
+
|
|
80
|
+
@metric_ids = 'this is not an empty hash'
|
|
81
|
+
@connected = true
|
|
82
|
+
|
|
83
|
+
handle_force_restart(error)
|
|
84
|
+
|
|
85
|
+
assert_equal({}, @metric_ids)
|
|
86
|
+
assert @connected.nil?
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_handle_force_disconnect
|
|
90
|
+
error = mock('exception')
|
|
91
|
+
error.expects(:message).returns('a message')
|
|
92
|
+
log = mocked_log
|
|
93
|
+
log.expects(:error).with("New Relic forced this agent to disconnect (a message)")
|
|
94
|
+
self.expects(:disconnect)
|
|
95
|
+
handle_force_disconnect(error)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_handle_server_connection_problem
|
|
99
|
+
error_class = mock('class of exception')
|
|
100
|
+
error = mock('exception')
|
|
101
|
+
log = mocked_log
|
|
102
|
+
log.expects(:error).with('Unable to establish connection with the server. Run with log level set to debug for more information.')
|
|
103
|
+
error.expects(:class).returns(error_class)
|
|
104
|
+
error_class.expects(:name).returns('an error class')
|
|
105
|
+
error.expects(:message).returns('a message')
|
|
106
|
+
error.expects(:backtrace).returns(['first line', 'second line'])
|
|
107
|
+
log.expects(:debug).with("an error class: a message\nfirst line")
|
|
108
|
+
self.expects(:disconnect)
|
|
109
|
+
handle_server_connection_problem(error)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_handle_other_error
|
|
113
|
+
error_class = mock('class of exception')
|
|
114
|
+
error = mock('exception')
|
|
115
|
+
log = mocked_log
|
|
116
|
+
error.expects(:class).returns(error_class)
|
|
117
|
+
error_class.expects(:name).returns('an error class')
|
|
118
|
+
error.expects(:message).returns('a message')
|
|
119
|
+
error.expects(:backtrace).returns(['first line', 'second line'])
|
|
120
|
+
log.expects(:error).with("Terminating worker loop: an error class: a message\n first line\n second line")
|
|
121
|
+
self.expects(:disconnect)
|
|
122
|
+
handle_other_error(error)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_catch_errors_force_restart
|
|
126
|
+
@runs = 0
|
|
127
|
+
error = NewRelic::Agent::ForceRestartException.new
|
|
128
|
+
# twice, because we expect it to retry the block
|
|
129
|
+
self.expects(:handle_force_restart).with(error).twice
|
|
130
|
+
catch_errors do
|
|
131
|
+
# needed to keep it from looping infinitely in the test
|
|
132
|
+
@runs += 1
|
|
133
|
+
raise error unless @runs > 2
|
|
134
|
+
end
|
|
135
|
+
assert_equal 3, @runs, 'should retry the block when it fails'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
private
|
|
139
|
+
|
|
140
|
+
def mocked_log
|
|
141
|
+
fake_log = mock('log')
|
|
142
|
+
self.stubs(:log).returns(fake_log)
|
|
143
|
+
fake_log
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def mocked_control
|
|
148
|
+
fake_control = mock('control')
|
|
149
|
+
self.stubs(:control).returns(fake_control)
|
|
150
|
+
fake_control
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
|
2
|
+
module NewRelic
|
|
3
|
+
module Agent
|
|
4
|
+
class AgentTest < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
super
|
|
8
|
+
@agent = NewRelic::Agent::Agent.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_save_or_transmit_data_should_save
|
|
12
|
+
NewRelic::Agent.expects(:save_data).once
|
|
13
|
+
@agent.expects(:harvest_and_send_timeslice_data).never
|
|
14
|
+
NewRelic::DataSerialization.expects(:should_send_data?).returns(false)
|
|
15
|
+
@agent.instance_eval { save_or_transmit_data }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_save_or_transmit_data_should_transmit
|
|
19
|
+
NewRelic::Agent.expects(:load_data)
|
|
20
|
+
@agent.expects(:harvest_and_send_timeslice_data)
|
|
21
|
+
@agent.expects(:harvest_and_send_slowest_sample)
|
|
22
|
+
@agent.expects(:harvest_and_send_errors)
|
|
23
|
+
NewRelic::DataSerialization.expects(:should_send_data?).returns(true)
|
|
24
|
+
@agent.instance_eval { save_or_transmit_data }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_serialize
|
|
28
|
+
assert_equal([{}, [], []], @agent.send(:serialize), "should return nil when shut down")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_harvest_transaction_traces
|
|
32
|
+
assert_equal([], @agent.send(:harvest_transaction_traces), 'should return transaction traces')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_harvest_timeslice_data
|
|
36
|
+
assert_equal({}, @agent.send(:harvest_timeslice_data),
|
|
37
|
+
'should return timeslice data')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_harvest_timelice_data_should_be_thread_safe
|
|
41
|
+
2000.times do |i|
|
|
42
|
+
@agent.stats_engine.stats_hash[i.to_s] = NewRelic::StatsBase.new
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
harvest = Thread.new do
|
|
46
|
+
@agent.send(:harvest_timeslice_data)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
app = Thread.new do
|
|
50
|
+
@agent.stats_engine.stats_hash["a"] = NewRelic::StatsBase.new
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
assert_nothing_raised do
|
|
54
|
+
[app, harvest].each{|t| t.join}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_harvest_errors
|
|
59
|
+
assert_equal([], @agent.send(:harvest_errors), 'should return errors')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_merge_data_from_empty
|
|
63
|
+
unsent_timeslice_data = mock('unsent timeslice data')
|
|
64
|
+
unsent_errors = mock('unsent errors')
|
|
65
|
+
unsent_traces = mock('unsent traces')
|
|
66
|
+
@agent.instance_eval {
|
|
67
|
+
@unsent_errors = unsent_errors
|
|
68
|
+
@unsent_timeslice_data = unsent_timeslice_data
|
|
69
|
+
@traces = unsent_traces
|
|
70
|
+
}
|
|
71
|
+
# nb none of the others should receive merge requests
|
|
72
|
+
@agent.merge_data_from([{}])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_unsent_errors_size_empty
|
|
76
|
+
@agent.instance_eval {
|
|
77
|
+
@unsent_errors = nil
|
|
78
|
+
}
|
|
79
|
+
assert_equal(nil, @agent.unsent_errors_size)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_unsent_errors_size_with_errors
|
|
83
|
+
@agent.instance_eval {
|
|
84
|
+
@unsent_errors = ['an error']
|
|
85
|
+
}
|
|
86
|
+
assert_equal(1, @agent.unsent_errors_size)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_unsent_traces_size_empty
|
|
90
|
+
@agent.instance_eval {
|
|
91
|
+
@traces = nil
|
|
92
|
+
}
|
|
93
|
+
assert_equal(nil, @agent.unsent_traces_size)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_unsent_traces_size_with_traces
|
|
97
|
+
@agent.instance_eval {
|
|
98
|
+
@traces = ['a trace']
|
|
99
|
+
}
|
|
100
|
+
assert_equal(1, @agent.unsent_traces_size)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_unsent_timeslice_data_empty
|
|
104
|
+
@agent.instance_eval {
|
|
105
|
+
@unsent_timeslice_data = nil
|
|
106
|
+
}
|
|
107
|
+
assert_equal(0, @agent.unsent_timeslice_data, "should have zero timeslice data to start")
|
|
108
|
+
assert_equal({}, @agent.instance_variable_get('@unsent_timeslice_data'), "should initialize the timeslice data to an empty hash if it is empty")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_unsent_timeslice_data_with_errors
|
|
112
|
+
@agent.instance_eval {
|
|
113
|
+
@unsent_timeslice_data = {:key => 'value'}
|
|
114
|
+
}
|
|
115
|
+
assert_equal(1, @agent.unsent_timeslice_data, "should have the key from above")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_merge_data_from_all_three_empty
|
|
119
|
+
unsent_timeslice_data = mock('unsent timeslice data')
|
|
120
|
+
unsent_errors = mock('unsent errors')
|
|
121
|
+
unsent_traces = mock('unsent traces')
|
|
122
|
+
@agent.instance_eval {
|
|
123
|
+
@unsent_errors = unsent_errors
|
|
124
|
+
@unsent_timeslice_data = unsent_timeslice_data
|
|
125
|
+
@traces = unsent_traces
|
|
126
|
+
}
|
|
127
|
+
unsent_errors.expects(:+).with([])
|
|
128
|
+
unsent_traces.expects(:+).with([])
|
|
129
|
+
@agent.merge_data_from([{}, [], []])
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_should_not_log_log_file_location_if_no_log_file
|
|
133
|
+
NewRelic::Control.instance.stubs(:log_file).returns('/vasrkjn4b3b4')
|
|
134
|
+
@agent.expects(:log).never
|
|
135
|
+
@agent.notify_log_file_location
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Defining a test controller class with a superclass, used to
|
|
2
|
+
# verify correct attribute inheritence
|
|
3
|
+
class NewRelic::Agent::SuperclassController < ActionController::Base
|
|
4
|
+
def base_action
|
|
5
|
+
render :text => 'none'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
# This is a controller class used in testing controller instrumentation
|
|
9
|
+
class NewRelic::Agent::AgentTestController < NewRelic::Agent::SuperclassController
|
|
10
|
+
# filter_parameter_logging :social_security_number
|
|
11
|
+
|
|
12
|
+
@@headers_to_add = nil
|
|
13
|
+
|
|
14
|
+
def index
|
|
15
|
+
sleep params['wait'].to_i if params['wait']
|
|
16
|
+
render :text => params.inspect
|
|
17
|
+
end
|
|
18
|
+
def _filter_parameters(params)
|
|
19
|
+
filter_parameters params
|
|
20
|
+
end
|
|
21
|
+
def action_inline
|
|
22
|
+
render(:inline => "<%= 'foo' %>fah")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def action_to_render
|
|
26
|
+
render :text => params.inspect
|
|
27
|
+
end
|
|
28
|
+
def action_to_ignore
|
|
29
|
+
render :text => 'unmeasured'
|
|
30
|
+
end
|
|
31
|
+
def action_to_ignore_apdex
|
|
32
|
+
render :text => 'unmeasured'
|
|
33
|
+
end
|
|
34
|
+
before_filter :oops, :only => :action_with_before_filter_error
|
|
35
|
+
def action_with_before_filter_error
|
|
36
|
+
render :text => 'nothing'
|
|
37
|
+
end
|
|
38
|
+
def oops
|
|
39
|
+
raise "error in before filter"
|
|
40
|
+
end
|
|
41
|
+
class TestException < RuntimeError
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def rescue_action_locally(exception)
|
|
45
|
+
if exception.is_a? TestException
|
|
46
|
+
raise "error in the handler"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
def action_with_error
|
|
50
|
+
raise "error in action"
|
|
51
|
+
end
|
|
52
|
+
def entry_action
|
|
53
|
+
perform_action_with_newrelic_trace('internal_action') do
|
|
54
|
+
internal_action
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.set_some_headers(hash_of_headers)
|
|
59
|
+
@@headers_to_add ||= {}
|
|
60
|
+
@@headers_to_add.merge!(hash_of_headers)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.clear_headers
|
|
64
|
+
@@headers_to_add = nil
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def newrelic_request_headers
|
|
68
|
+
@@headers_to_add ||= {}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
def internal_action
|
|
73
|
+
perform_action_with_newrelic_trace(:name => 'internal_traced_action', :force => true) do
|
|
74
|
+
render :text => 'internal action'
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|