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
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'multiverse/color'
|
2
|
+
|
3
|
+
class MethodVisibilityTest < Test::Unit::TestCase
|
4
|
+
extend Multiverse::Color
|
5
|
+
|
6
|
+
class InstrumentedClass
|
7
|
+
include NewRelic::Agent::MethodTracer
|
8
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
9
|
+
|
10
|
+
def public_method!
|
11
|
+
end
|
12
|
+
|
13
|
+
def public_transaction!
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def private_method!
|
18
|
+
end
|
19
|
+
|
20
|
+
def private_transaction!
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def protected_method!
|
25
|
+
end
|
26
|
+
|
27
|
+
def protected_transaction!
|
28
|
+
end
|
29
|
+
|
30
|
+
add_method_tracer :public_method!
|
31
|
+
add_method_tracer :private_method!
|
32
|
+
add_method_tracer :protected_method!
|
33
|
+
|
34
|
+
add_transaction_tracer :public_transaction!
|
35
|
+
add_transaction_tracer :private_transaction!
|
36
|
+
add_transaction_tracer :protected_transaction!
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
class ObjectWithInstrumentation
|
41
|
+
include NewRelic::Agent::MethodTracer
|
42
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
43
|
+
end
|
44
|
+
|
45
|
+
class ObjectWithTracers < ObjectWithInstrumentation
|
46
|
+
private
|
47
|
+
def a_private_method
|
48
|
+
end
|
49
|
+
def a_private_transaction
|
50
|
+
end
|
51
|
+
protected
|
52
|
+
def a_protected_method
|
53
|
+
end
|
54
|
+
def a_protected_transaction
|
55
|
+
end
|
56
|
+
|
57
|
+
add_method_tracer :a_private_method
|
58
|
+
add_method_tracer :a_protected_method
|
59
|
+
add_transaction_tracer :a_private_transaction
|
60
|
+
add_transaction_tracer :a_protected_transaction
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def setup
|
65
|
+
@instance = InstrumentedClass.new
|
66
|
+
end
|
67
|
+
|
68
|
+
if NewRelic::VERSION::STRING >= '3.4.0.2'
|
69
|
+
%w| public private protected |.each do |visibility|
|
70
|
+
define_method "test_should_preserve_visibility_of_#{visibility}_traced_method" do
|
71
|
+
assert @instance.send("#{visibility}_methods").map{|s|s.to_sym}.include?(:"#{visibility}_method!"), "Method #{visibility}_method should be #{visibility}"
|
72
|
+
end
|
73
|
+
|
74
|
+
define_method "test_should_preserve_visibility_of_#{visibility}_traced_transaction" do
|
75
|
+
assert @instance.send("#{visibility}_methods").map{|s|s.to_sym}.include?(:"#{visibility}_transaction!"), "Transcation #{visibility}_transaction should be #{visibility}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_tracing_non_public_methods_doesnt_add_public_methods
|
80
|
+
assert_equal [], ObjectWithTracers.public_instance_methods - ObjectWithInstrumentation.public_instance_methods
|
81
|
+
end
|
82
|
+
|
83
|
+
# FIXME: Currently including MethodTracer and ControllerInstrumentation
|
84
|
+
# adds a bunch of public methods to the class. It probably shouldn't do this.
|
85
|
+
#def test_instrumentation_doesnt_add_any_public_methods
|
86
|
+
# assert_equal [], ObjectWithInstrumentation.public_instance_methods - Object.public_instance_methods
|
87
|
+
#end
|
88
|
+
#
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
else
|
93
|
+
def test_truth
|
94
|
+
assert true # jruby freaks out if there are no tests defined in the test class
|
95
|
+
end
|
96
|
+
puts yellow('SKIPPED! 3.4.0.1 and earlier fail preserve_visibility tests')
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# https://newrelic.atlassian.net/browse/RUBY-669
|
2
|
+
|
3
|
+
class PipeManagerTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@listener = NewRelic::Agent::PipeChannelManager.listener
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
@listener.stop
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_old_pipes_are_cleaned_up_after_timeout
|
13
|
+
@listener.timeout = 1
|
14
|
+
NewRelic::Agent::PipeChannelManager.register_report_channel(:timeout_test)
|
15
|
+
sleep 2
|
16
|
+
@listener.start
|
17
|
+
sleep 0.5 # give the thread some time to start, and clean things up
|
18
|
+
assert_nil NewRelic::Agent::PipeChannelManager.channels[:timeout_test]
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_pipes_are_regularly_checked_for_freshness
|
22
|
+
@listener.select_timeout = 1
|
23
|
+
@listener.timeout = 2
|
24
|
+
NewRelic::Agent::PipeChannelManager.register_report_channel(:select_test)
|
25
|
+
|
26
|
+
sleep 1.5
|
27
|
+
@listener.start
|
28
|
+
assert NewRelic::Agent::PipeChannelManager.channels[:select_test]
|
29
|
+
|
30
|
+
sleep 1.5
|
31
|
+
assert_nil NewRelic::Agent::PipeChannelManager.channels[:select_test]
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
class ServiceTimeoutTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
hk = TCPServer.new('127.0.0.1',8081)
|
6
|
+
|
7
|
+
Thread.new {
|
8
|
+
client = hk.accept
|
9
|
+
what = client.gets
|
10
|
+
sleep 4
|
11
|
+
client.close
|
12
|
+
Thread.exit
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_service_timeout
|
17
|
+
server = NewRelic::Control::Server.new('localhost', 8081,'127.0.0.1')
|
18
|
+
NewRelic::Agent.config.apply_config(:timeout => 2)
|
19
|
+
|
20
|
+
service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
|
21
|
+
|
22
|
+
assert_raise Timeout::Error do
|
23
|
+
service.send('send_request',
|
24
|
+
:uri => '/agent_listener/8/bd0e1d52adade840f7ca727d29a86249e89a6f1c/get_redirect_host',
|
25
|
+
:encoding => 'UTF-8', :collector => server, :data => 'blah')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'newrelic_rpm'
|
4
|
+
require 'new_relic/agent/method_tracer'
|
5
|
+
|
6
|
+
|
7
|
+
class MethodInterrobangTest < Test::Unit::TestCase
|
8
|
+
include NewRelic::Agent::MethodTracer
|
9
|
+
|
10
|
+
def interrogate?
|
11
|
+
"say what?"
|
12
|
+
end
|
13
|
+
|
14
|
+
def mutate!
|
15
|
+
"oh yeah!"
|
16
|
+
end
|
17
|
+
|
18
|
+
add_method_tracer :interrogate?
|
19
|
+
add_method_tracer :mutate!
|
20
|
+
|
21
|
+
def test_alias_method_ending_in_question_mark
|
22
|
+
assert_respond_to self,:interrogate?
|
23
|
+
assert_equal "say what?", interrogate?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_aliase_method_ending_in_exclamation_makr
|
27
|
+
assert_respond_to self,:mutate!
|
28
|
+
assert_equal "oh yeah!",mutate!
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'newrelic_rpm'
|
4
|
+
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
5
|
+
|
6
|
+
|
7
|
+
class TransactionInterrobangTest < Test::Unit::TestCase
|
8
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
9
|
+
|
10
|
+
def interrogate?
|
11
|
+
"say what?"
|
12
|
+
end
|
13
|
+
|
14
|
+
def mutate!
|
15
|
+
"oh yeah!"
|
16
|
+
end
|
17
|
+
|
18
|
+
add_transaction_tracer :interrogate?
|
19
|
+
add_transaction_tracer :mutate!
|
20
|
+
|
21
|
+
def test_alias_method_ending_in_question_mark
|
22
|
+
assert_respond_to self,:interrogate?
|
23
|
+
assert_respond_to self, :interrogate_with_newrelic_transaction_trace?
|
24
|
+
assert_equal "say what?", interrogate?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_aliase_method_ending_in_exclamation_makr
|
28
|
+
assert_respond_to self,:mutate!
|
29
|
+
assert_respond_to self, :mutate_with_newrelic_transaction_trace!
|
30
|
+
assert_equal "oh yeah!",mutate!
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# https://newrelic.atlassian.net/wiki/display/eng/Agent+Thread+Profiling
|
2
|
+
# https://newrelic.atlassian.net/browse/RUBY-917
|
3
|
+
|
4
|
+
if RUBY_VERSION >= '1.9'
|
5
|
+
class ThreadProfilingTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
NewRelic::Agent.manual_start(:'thread_profiler.enabled' => true)
|
8
|
+
|
9
|
+
@agent = NewRelic::Agent.instance
|
10
|
+
@thread_profiler = @agent.thread_profiler
|
11
|
+
|
12
|
+
$collector ||= NewRelic::FakeCollector.new
|
13
|
+
$collector.reset
|
14
|
+
$collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
|
15
|
+
$collector.mock['get_agent_commands'] = [200, {'return_value' => START_COMMAND}]
|
16
|
+
$collector.mock['agent_command_results'] = [200, {'return_value' => []}]
|
17
|
+
$collector.run
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
$collector.reset
|
22
|
+
end
|
23
|
+
|
24
|
+
START_COMMAND = [[666,{
|
25
|
+
"name" => "start_profiler",
|
26
|
+
"arguments" => {
|
27
|
+
"profile_id" => -1,
|
28
|
+
"sample_period" => 0.01,
|
29
|
+
"duration" => 0.5,
|
30
|
+
"only_runnable_threads" => false,
|
31
|
+
"only_request_threads" => false,
|
32
|
+
"profile_agent_code" => false
|
33
|
+
}
|
34
|
+
}]]
|
35
|
+
|
36
|
+
STOP_COMMAND = [[666,{
|
37
|
+
"name" => "stop_profiler",
|
38
|
+
"arguments" => {
|
39
|
+
"profile_id" => -1,
|
40
|
+
"report_data" => true
|
41
|
+
}
|
42
|
+
}]]
|
43
|
+
|
44
|
+
# These are potentially fragile for being timing based
|
45
|
+
# START_COMMAND with 0.01 sampling and 0.5 duration expects to get
|
46
|
+
# roughly 50 polling cycles in. We check signficiantly less than that.
|
47
|
+
|
48
|
+
# STOP_COMMAND when immediately issued after a START_COMMAND is expected
|
49
|
+
# go only let a few cycles through, so we check less than 10
|
50
|
+
|
51
|
+
def test_thread_profiling
|
52
|
+
@agent.send(:check_for_agent_commands)
|
53
|
+
sleep(1)
|
54
|
+
NewRelic::Agent.shutdown
|
55
|
+
|
56
|
+
profile_data = $collector.calls_for('profile_data')[0]
|
57
|
+
assert_equal(666, profile_data[0])
|
58
|
+
|
59
|
+
poll_count = profile_data[1][0][3]
|
60
|
+
assert poll_count > 25, "Expected poll_count > 25, but was #{poll_count}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_thread_profiling_can_stop
|
64
|
+
@agent.send(:check_for_agent_commands)
|
65
|
+
|
66
|
+
$collector.mock['get_agent_commands'] = [200, {'return_value' => STOP_COMMAND}]
|
67
|
+
@agent.send(:check_for_agent_commands)
|
68
|
+
|
69
|
+
sleep(0.1)
|
70
|
+
NewRelic::Agent.shutdown
|
71
|
+
|
72
|
+
profile_data = $collector.calls_for('profile_data')[0]
|
73
|
+
assert_equal(666, profile_data[0])
|
74
|
+
|
75
|
+
poll_count = profile_data[1][0][3]
|
76
|
+
assert poll_count < 10, "Expected poll_count < 10, but was #{poll_count}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# Test the logic for loading the newrelic.yml config file.
|
2
|
+
#
|
3
|
+
# We will look at (in this priority):
|
4
|
+
# 1. ENV['NRCONFIG'] (if set)
|
5
|
+
# 2. ./config/newrelic.yml
|
6
|
+
# 3. ./newrelic.yml
|
7
|
+
# 4. ~/.newrelic/newrelic.yml
|
8
|
+
# 5. ~/newrelic.yml
|
9
|
+
#
|
10
|
+
# If this fails the agent will attempt to dial Lew Cirne's cell phone and ask
|
11
|
+
# that he verbally describe how it should be configured.
|
12
|
+
class ConfigFileLoadingTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
# While FakeFS stubs out all the File system related libraries (i.e. File,
|
16
|
+
# FileUtils, Dir, etc.) It doesn't handle the Logger library that is used
|
17
|
+
# to create the agent log file. Therefore we check for the presence of the
|
18
|
+
# log directory in the FakeFS, then error when we try to open the file in
|
19
|
+
# the Real FS. Set the log file to /dev/null to work around this issue.
|
20
|
+
# It's incidental to the functionality being tested.
|
21
|
+
#
|
22
|
+
# '/dev/null' can be changed to 'stdout' if more debugging output is needed
|
23
|
+
# in these tests.
|
24
|
+
ENV['NEW_RELIC_LOG'] = '/dev/null'
|
25
|
+
|
26
|
+
# Figure out where multiverse is in the real file system.
|
27
|
+
@cwd = Dir.pwd
|
28
|
+
# Use a fake file system so we don't damage the real one.
|
29
|
+
FakeFS.activate!
|
30
|
+
FakeFS::FileSystem.clear
|
31
|
+
|
32
|
+
# require the agent after we're in FakeFS
|
33
|
+
require 'newrelic_rpm'
|
34
|
+
|
35
|
+
FileUtils.mkdir_p(@cwd)
|
36
|
+
end
|
37
|
+
|
38
|
+
def teardown
|
39
|
+
ENV['NEW_RELIC_LOG'] = nil
|
40
|
+
FakeFS.deactivate!
|
41
|
+
end
|
42
|
+
|
43
|
+
def setup_config(path, manual_config_options = {})
|
44
|
+
NewRelic::Agent.shutdown
|
45
|
+
FileUtils.mkdir_p(File.dirname(path))
|
46
|
+
Dir.chdir @cwd
|
47
|
+
File.open(path, 'w') do |f|
|
48
|
+
f.print <<-YAML
|
49
|
+
development:
|
50
|
+
foo: "success!!"
|
51
|
+
test:
|
52
|
+
foo: "success!!"
|
53
|
+
bazbangbarn:
|
54
|
+
i_am: "bazbangbarn"
|
55
|
+
YAML
|
56
|
+
end
|
57
|
+
NewRelic::Agent.reset_config
|
58
|
+
NewRelic::Agent.manual_start(manual_config_options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def assert_config_read_from(path)
|
62
|
+
setup_config(path)
|
63
|
+
assert NewRelic::Agent.config[:foo] == "success!!", "Failed to read yaml config from #{path.inspect}\n\n#{NewRelic::Agent.config.inspect}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_config_not_read_from(path)
|
67
|
+
setup_config(path)
|
68
|
+
assert NewRelic::Agent.config[:foo] != "success!!", "Read yaml config from #{path.inspect}\n\n#{NewRelic::Agent.config.inspect}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_config_loads_from_config_newrelic_yml
|
72
|
+
assert_config_read_from(File.dirname(__FILE__) + "/config/newrelic.yml")
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_config_loads_from_newrelic_yml
|
76
|
+
assert_config_read_from(File.dirname(__FILE__) + "/newrelic.yml")
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_config_loads_from_home_newrelic_yml
|
80
|
+
assert_config_read_from(ENV['HOME'] + "/newrelic.yml")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_config_loads_from_home_dot_newrelic_newrelic_yml
|
84
|
+
assert_config_read_from(ENV['HOME'] + "/.newrelic/newrelic.yml")
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_config_loads_from_env_NRCONFIG
|
88
|
+
ENV["NRCONFIG"] = "/tmp/foo/bar.yml"
|
89
|
+
assert_config_read_from("/tmp/foo/bar.yml")
|
90
|
+
ensure
|
91
|
+
ENV["NRCONFIG"] = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_config_isnt_loaded_from_somewhere_crazy
|
95
|
+
assert_config_not_read_from(File.dirname(__FILE__) + "/somewhere/crazy/newrelic.yml")
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_config_will_load_settings_for_environment_passed_manual_start
|
99
|
+
path = File.dirname(__FILE__) + "/config/newrelic.yml"
|
100
|
+
|
101
|
+
# pass an env key to NewRelic::Agent.manual_start which should cause it to
|
102
|
+
# load that section of newrelic.yml
|
103
|
+
setup_config(path, {:env => 'bazbangbarn'} )
|
104
|
+
assert_equal 'bazbangbarn', NewRelic::Agent.config[:i_am], "Agent.config did not load bazbangbarn config as requested"
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
development:
|
3
|
+
error_collector:
|
4
|
+
capture_source: true
|
5
|
+
enabled: true
|
6
|
+
apdex_t: 0.5
|
7
|
+
ssl: false
|
8
|
+
monitor_mode: true
|
9
|
+
license_key: bootstrap_newrelic_admin_license_key_000
|
10
|
+
developer_mode: false
|
11
|
+
app_name: test
|
12
|
+
host: 127.0.0.1
|
13
|
+
api_host: 127.0.0.1
|
14
|
+
port: 30303
|
15
|
+
transaction_tracer:
|
16
|
+
record_sql: obfuscated
|
17
|
+
enabled: true
|
18
|
+
stack_trace_threshold: 0.5
|
19
|
+
transaction_threshold: 1.0
|
20
|
+
capture_params: false
|
21
|
+
log_level: debug
|
22
|
+
log_file_path: agent.log
|