sundawg_newrelic_rpm 3.5.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.project +23 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +969 -0
- data/GUIDELINES_FOR_CONTRIBUTING.md +76 -0
- data/Gemfile +20 -0
- data/LICENSE +87 -0
- data/README.md +195 -0
- data/Rakefile +58 -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/config.dot +290 -0
- data/config/database.yml +5 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +31 -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 +488 -0
- data/lib/new_relic/agent/agent.rb +1069 -0
- data/lib/new_relic/agent/agent_logger.rb +173 -0
- data/lib/new_relic/agent/audit_logger.rb +72 -0
- data/lib/new_relic/agent/beacon_configuration.rb +107 -0
- data/lib/new_relic/agent/browser_monitoring.rb +195 -0
- data/lib/new_relic/agent/busy_calculator.rb +112 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/configuration.rb +74 -0
- data/lib/new_relic/agent/configuration/defaults.rb +132 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +49 -0
- data/lib/new_relic/agent/configuration/manager.rb +148 -0
- data/lib/new_relic/agent/configuration/mask_defaults.rb +11 -0
- data/lib/new_relic/agent/configuration/server_source.rb +31 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +67 -0
- data/lib/new_relic/agent/cross_app_monitor.rb +239 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +281 -0
- data/lib/new_relic/agent/database.rb +254 -0
- data/lib/new_relic/agent/error_collector.rb +266 -0
- data/lib/new_relic/agent/event_listener.rb +43 -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 +134 -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/browser_monitoring_timings.rb +51 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +485 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +230 -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 +356 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
- data/lib/new_relic/agent/instrumentation/net.rb +31 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +23 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +68 -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 +41 -0
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +145 -0
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +45 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +81 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +107 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +22 -0
- data/lib/new_relic/agent/method_tracer.rb +530 -0
- data/lib/new_relic/agent/new_relic_service.rb +513 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +175 -0
- data/lib/new_relic/agent/pipe_service.rb +63 -0
- data/lib/new_relic/agent/rules_engine.rb +72 -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_sampler.rb +86 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +141 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
- data/lib/new_relic/agent/shim_agent.rb +28 -0
- data/lib/new_relic/agent/sql_sampler.rb +251 -0
- data/lib/new_relic/agent/stats.rb +149 -0
- data/lib/new_relic/agent/stats_engine.rb +30 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +116 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +161 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +97 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +58 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +145 -0
- data/lib/new_relic/agent/thread.rb +32 -0
- data/lib/new_relic/agent/thread_profiler.rb +319 -0
- data/lib/new_relic/agent/transaction_info.rb +119 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +126 -0
- data/lib/new_relic/agent/transaction_sampler.rb +459 -0
- data/lib/new_relic/agent/worker_loop.rb +96 -0
- data/lib/new_relic/coerce.rb +37 -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 +114 -0
- data/lib/new_relic/commands/install.rb +80 -0
- data/lib/new_relic/control.rb +44 -0
- data/lib/new_relic/control/class_methods.rb +58 -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 +25 -0
- data/lib/new_relic/control/frameworks/rails.rb +173 -0
- data/lib/new_relic/control/frameworks/rails3.rb +71 -0
- data/lib/new_relic/control/frameworks/rails4.rb +23 -0
- data/lib/new_relic/control/frameworks/ruby.rb +21 -0
- data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +145 -0
- data/lib/new_relic/control/instrumentation.rb +95 -0
- data/lib/new_relic/control/profiling.rb +25 -0
- data/lib/new_relic/control/server_methods.rb +80 -0
- data/lib/new_relic/delayed_job_injection.rb +51 -0
- data/lib/new_relic/helper.rb +66 -0
- data/lib/new_relic/language_support.rb +92 -0
- data/lib/new_relic/latest_changes.rb +31 -0
- data/lib/new_relic/local_environment.rb +385 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +70 -0
- data/lib/new_relic/metric_spec.rb +80 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +59 -0
- data/lib/new_relic/okjson.rb +599 -0
- data/lib/new_relic/rack.rb +4 -0
- data/lib/new_relic/rack/agent_hooks.rb +20 -0
- data/lib/new_relic/rack/browser_monitoring.rb +85 -0
- data/lib/new_relic/rack/developer_mode.rb +271 -0
- data/lib/new_relic/rack/error_collector.rb +66 -0
- data/lib/new_relic/recipes.rb +99 -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 +272 -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 +205 -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 +66 -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 +17 -0
- data/newrelic.yml +227 -0
- data/newrelic_rpm.gemspec +50 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +77 -0
- data/test/config/newrelic.yml +49 -0
- data/test/config/test_control.rb +48 -0
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/intentional_fail.rb +10 -0
- data/test/multiverse/.gitignore +11 -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 +164 -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 +9 -0
- data/test/multiverse/suites/agent_only/audit_log_test.rb +97 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +23 -0
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +56 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +66 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +163 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +96 -0
- data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +17 -0
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +57 -0
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +81 -0
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +32 -0
- data/test/multiverse/suites/agent_only/ssl_test.rb +22 -0
- data/test/multiverse/suites/agent_only/start_up_test.rb +21 -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/testing_app.rb +17 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +92 -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/rails/Envfile +18 -0
- data/test/multiverse/suites/rails/app.rb +49 -0
- data/test/multiverse/suites/rails/app/views/foos/_foo.html.haml +1 -0
- data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/_mid_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/_top_partial.html.erb +3 -0
- data/test/multiverse/suites/rails/app/views/views/deep_partial.html.erb +3 -0
- data/test/multiverse/suites/rails/app/views/views/haml_view.html.haml +6 -0
- data/test/multiverse/suites/rails/app/views/views/index.html.erb +4 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +32 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +211 -0
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +79 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +55 -0
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +205 -0
- data/test/multiverse/suites/resque/Envfile +24 -0
- data/test/multiverse/suites/resque/Rakefile +8 -0
- data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
- data/test/multiverse/suites/resque/instrumentation_test.rb +151 -0
- data/test/multiverse/suites/resque/resque_setup.rb +15 -0
- data/test/multiverse/suites/sinatra/Envfile +15 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +38 -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 +139 -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 +295 -0
- data/test/new_relic/agent/agent/start_test.rb +205 -0
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +88 -0
- data/test/new_relic/agent/agent_logger_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +301 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +381 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/audit_logger_test.rb +105 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +107 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +395 -0
- data/test/new_relic/agent/busy_calculator_test.rb +96 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +79 -0
- data/test/new_relic/agent/configuration/manager_test.rb +232 -0
- data/test/new_relic/agent/configuration/server_source_test.rb +50 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +85 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +237 -0
- data/test/new_relic/agent/database_test.rb +194 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +268 -0
- data/test/new_relic/agent/error_collector_test.rb +246 -0
- data/test/new_relic/agent/event_listener_test.rb +67 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +606 -0
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +66 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +107 -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 +151 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +461 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +97 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +25 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +182 -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 +158 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +222 -0
- data/test/new_relic/agent/method_tracer_test.rb +389 -0
- data/test/new_relic/agent/mock_scope_listener.rb +26 -0
- data/test/new_relic/agent/new_relic_service_test.rb +571 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +131 -0
- data/test/new_relic/agent/pipe_service_test.rb +133 -0
- data/test/new_relic/agent/rpm_agent_test.rb +115 -0
- data/test/new_relic/agent/rules_engine_test.rb +82 -0
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +16 -0
- data/test/new_relic/agent/sql_sampler_test.rb +244 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +85 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +180 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
- data/test/new_relic/agent/stats_engine_test.rb +184 -0
- data/test/new_relic/agent/stats_hash_test.rb +93 -0
- data/test/new_relic/agent/stats_test.rb +197 -0
- data/test/new_relic/agent/thread_profiler_test.rb +582 -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 +106 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +227 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +968 -0
- data/test/new_relic/agent/worker_loop_test.rb +84 -0
- data/test/new_relic/agent_test.rb +296 -0
- data/test/new_relic/coerce_test.rb +65 -0
- data/test/new_relic/collection_helper_test.rb +148 -0
- data/test/new_relic/command/deployments_test.rb +84 -0
- data/test/new_relic/control/class_methods_test.rb +44 -0
- data/test/new_relic/control/frameworks/rails_test.rb +26 -0
- data/test/new_relic/control_test.rb +194 -0
- data/test/new_relic/delayed_job_injection_test.rb +21 -0
- data/test/new_relic/dispatcher_test.rb +54 -0
- data/test/new_relic/fake_collector.rb +389 -0
- data/test/new_relic/framework_test.rb +53 -0
- data/test/new_relic/helper_test.rb +24 -0
- data/test/new_relic/load_test.rb +13 -0
- data/test/new_relic/local_environment_test.rb +85 -0
- data/test/new_relic/metric_data_test.rb +183 -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/noticed_error_test.rb +32 -0
- data/test/new_relic/rack/agent_hooks_test.rb +30 -0
- data/test/new_relic/rack/all_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +152 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +80 -0
- data/test/new_relic/rack/error_collector_test.rb +90 -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 +415 -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 +250 -0
- data/test/new_relic/version_number_test.rb +97 -0
- data/test/script/build_test_gem.sh +57 -0
- data/test/script/ci.sh +168 -0
- data/test/script/ci_agent-tests_runner.sh +82 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/script/ci_multiverse_runner.sh +63 -0
- data/test/test_contexts.rb +30 -0
- data/test/test_helper.rb +240 -0
- data/ui/helpers/developer_mode_helper.rb +367 -0
- data/ui/helpers/google_pie_chart.rb +49 -0
- data/ui/views/layouts/newrelic_default.rhtml +48 -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 +45 -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/.specification +116 -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/servlet_init.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 +494 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'/../../../lib/new_relic/command'))
|
3
|
+
|
4
|
+
class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
NewRelic::Command::Deployments.class_eval do
|
8
|
+
attr_accessor :messages, :exit_status, :errors, :revision
|
9
|
+
def err(message); @errors = @errors ? @errors + message : message; end
|
10
|
+
def info(message); @messages = @messages ? @messages + message : message; end
|
11
|
+
def just_exit(status=0); @exit_status ||= status; end
|
12
|
+
end
|
13
|
+
@config = { :license_key => 'a' * 40 }
|
14
|
+
NewRelic::Agent.config.apply_config(@config)
|
15
|
+
end
|
16
|
+
def teardown
|
17
|
+
super
|
18
|
+
return unless @deployment
|
19
|
+
puts @deployment.errors
|
20
|
+
puts @deployment.messages
|
21
|
+
puts @deployment.exit_status
|
22
|
+
NewRelic::Agent.config.remove_config(@config)
|
23
|
+
end
|
24
|
+
def test_help
|
25
|
+
begin
|
26
|
+
NewRelic::Command::Deployments.new "-h"
|
27
|
+
fail "should have thrown"
|
28
|
+
rescue NewRelic::Command::CommandFailure => c
|
29
|
+
assert_match /^Usage/, c.message
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def test_bad_command
|
33
|
+
assert_raise NewRelic::Command::CommandFailure do
|
34
|
+
NewRelic::Command::Deployments.new ["-foo", "bar"]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def test_interactive
|
38
|
+
mock_the_connection
|
39
|
+
@deployment = NewRelic::Command::Deployments.new(:appname => 'APP',
|
40
|
+
:revision => 3838,
|
41
|
+
:user => 'Bill',
|
42
|
+
:description => "Some lengthy description")
|
43
|
+
assert_nil @deployment.exit_status
|
44
|
+
assert_nil @deployment.errors
|
45
|
+
assert_equal '3838', @deployment.revision
|
46
|
+
@deployment.run
|
47
|
+
@deployment = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_command_line_run
|
51
|
+
mock_the_connection
|
52
|
+
# @mock_response.expects(:body).returns("<xml>deployment</xml>")
|
53
|
+
@deployment = NewRelic::Command::Deployments.new(%w[-a APP -r 3838 --user=Bill] << "Some lengthy description")
|
54
|
+
assert_nil @deployment.exit_status
|
55
|
+
assert_nil @deployment.errors
|
56
|
+
assert_equal '3838', @deployment.revision
|
57
|
+
@deployment.run
|
58
|
+
|
59
|
+
# This should pass because it's a bogus deployment
|
60
|
+
#assert_equal 1, @deployment.exit_status
|
61
|
+
#assert_match /Unable to upload/, @deployment.errors
|
62
|
+
|
63
|
+
@deployment = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_error_if_no_license_key
|
67
|
+
with_config(:license_key => '') do
|
68
|
+
assert_raise NewRelic::Command::CommandFailure do
|
69
|
+
deployment = NewRelic::Command::Deployments.new(%w[-a APP -r 3838 --user=Bill] << "Some lengthy description")
|
70
|
+
deployment.run
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def mock_the_connection
|
78
|
+
mock_connection = mock()
|
79
|
+
@mock_response = mock()
|
80
|
+
@mock_response.expects(:is_a?).with(Net::HTTPSuccess).returns(true)
|
81
|
+
mock_connection.expects(:request).returns(@mock_response)
|
82
|
+
NewRelic::Agent::NewRelicService.any_instance.stubs(:http_connection).returns(mock_connection)
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
|
2
|
+
require 'new_relic/control/class_methods'
|
3
|
+
|
4
|
+
class BaseClassMethods
|
5
|
+
# stub class to enable testing of the module
|
6
|
+
include NewRelic::Control::ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
class NewRelic::Control::ClassMethodsTest < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@base = ::BaseClassMethods.new
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_instance
|
16
|
+
assert_equal(nil, @base.instance_variable_get('@instance'), 'instance should start out nil')
|
17
|
+
@base.expects(:new_instance).returns('a new instance')
|
18
|
+
assert_equal('a new instance', @base.instance, "should return the result from the #new_instance call")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_load_test_framework
|
22
|
+
local_env = mock('local env')
|
23
|
+
# a loose requirement here because the tests will *all* break if
|
24
|
+
# this does not work.
|
25
|
+
NewRelic::Control::Frameworks::Test.expects(:new).with(local_env, instance_of(String))
|
26
|
+
@base.expects(:local_env).returns(local_env)
|
27
|
+
@base.load_test_framework
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_load_framework_class_existing
|
31
|
+
%w[rails rails3 sinatra ruby merb external].each do |type|
|
32
|
+
@base.load_framework_class(type)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_load_framework_class_missing
|
37
|
+
# this is used to allow other people to insert frameworks without
|
38
|
+
# having the file in our agent, i.e. define your own
|
39
|
+
# NewRelic::Control::Framework::FooBar
|
40
|
+
assert_raise(NameError) do
|
41
|
+
@base.load_framework_class('missing')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'/../../../test_helper'))
|
2
|
+
|
3
|
+
class NewRelic::Control::Frameworks::RailsTest < Test::Unit::TestCase
|
4
|
+
def test_install_browser_monitoring
|
5
|
+
require(File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
'/../../../../lib/new_relic/rack/browser_monitoring')))
|
7
|
+
middleware = stub('middleware config')
|
8
|
+
config = stub('rails config', :middleware => middleware)
|
9
|
+
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
|
10
|
+
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
11
|
+
with_config(:'browser_monitoring.auto_instrument' => true) do
|
12
|
+
NewRelic::Control.instance.install_browser_monitoring(config)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_install_browser_monitoring_should_not_install_when_not_configured
|
17
|
+
middleware = stub('middleware config')
|
18
|
+
config = stub('rails config', :middleware => middleware)
|
19
|
+
middleware.expects(:use).never
|
20
|
+
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
|
21
|
+
|
22
|
+
with_config(:'browser_monitoring.auto_instrument' => false) do
|
23
|
+
NewRelic::Control.instance.install_browser_monitoring(config)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
|
2
|
+
|
3
|
+
class NewRelic::ControlTest < Test::Unit::TestCase
|
4
|
+
attr_reader :control
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@control = NewRelic::Control.instance
|
8
|
+
raise 'oh geez, wrong class' unless NewRelic::Control.instance.is_a?(::NewRelic::Control::Frameworks::Test)
|
9
|
+
end
|
10
|
+
|
11
|
+
def shutdown
|
12
|
+
NewRelic::Agent.shutdown
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_test_config
|
17
|
+
if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 4
|
18
|
+
assert_equal :rails4, control.app
|
19
|
+
elsif defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
20
|
+
assert_equal :rails3, control.app
|
21
|
+
elsif defined?(::Rails)
|
22
|
+
assert_equal :rails, control.app
|
23
|
+
else
|
24
|
+
assert_equal :test, control.app
|
25
|
+
end
|
26
|
+
assert_equal :test, control.framework
|
27
|
+
assert_match /test/i, control.local_env.dispatcher_instance_id
|
28
|
+
assert("" == NewRelic::Agent.config[:dispatcher].to_s,
|
29
|
+
"Expected dispatcher to be empty, but was #{NewRelic::Agent.config[:dispatcher].to_s}")
|
30
|
+
assert !NewRelic::Agent.config[:monitor_mode]
|
31
|
+
control.local_env
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_settings_accessor
|
35
|
+
assert_not_nil control.settings
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_root
|
39
|
+
assert File.directory?(NewRelic::Control.newrelic_root), NewRelic::Control.newrelic_root
|
40
|
+
if defined?(Rails)
|
41
|
+
assert File.directory?(File.join(NewRelic::Control.newrelic_root, "lib")), NewRelic::Control.newrelic_root + "/lib"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_info
|
46
|
+
NewRelic::Agent.manual_start(:dispatcher_instance_id => 'test')
|
47
|
+
props = NewRelic::Control.instance.local_env.snapshot
|
48
|
+
if defined?(Rails)
|
49
|
+
assert_match /jdbc|postgres|mysql|sqlite/, props.assoc('Database adapter').last, props.inspect
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_resolve_ip_for_localhost
|
54
|
+
with_config(:ssl => false, :verify_certificate => false) do
|
55
|
+
assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_resolve_ip_for_non_existent_domain
|
60
|
+
with_config(:ssl => false, :verify_certificate => false) do
|
61
|
+
Resolv.stubs(:getaddress).raises(Resolv::ResolvError)
|
62
|
+
IPSocket.stubs(:getaddress).raises(SocketError)
|
63
|
+
assert_equal nil, control.send(:convert_to_ip_address, 'q1239988737.us')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_resolves_valid_ip
|
68
|
+
with_config(:ssl => false, :verify_certificate => false) do
|
69
|
+
Resolv.stubs(:getaddress).with('collector.newrelic.com').returns('204.93.223.153')
|
70
|
+
assert_equal '204.93.223.153', control.send(:convert_to_ip_address, 'collector.newrelic.com')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_do_not_resolve_if_we_need_to_verify_a_cert
|
75
|
+
with_config(:ssl => false, :verify_certificate => false) do
|
76
|
+
assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
|
77
|
+
end
|
78
|
+
with_config(:ssl => true, :verify_certificate => true) do
|
79
|
+
assert_equal 'localhost', control.send(:convert_to_ip_address, 'localhost')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_api_server_uses_configured_values
|
84
|
+
control.instance_variable_set(:@api_server, nil)
|
85
|
+
with_config(:api_host => 'somewhere', :api_port => 8080) do
|
86
|
+
assert_equal 'somewhere', control.api_server.name
|
87
|
+
assert_equal 8080, control.api_server.port
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_proxy_server_uses_configured_values
|
92
|
+
control.instance_variable_set(:@proxy_server, nil)
|
93
|
+
with_config(:proxy_host => 'proxytown', :proxy_port => 81) do
|
94
|
+
assert_equal 'proxytown', control.proxy_server.name
|
95
|
+
assert_equal 81, control.proxy_server.port
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_server_from_host_uses_configured_values
|
100
|
+
with_config(:host => 'donkeytown', :port => 8080) do
|
101
|
+
assert_equal 'donkeytown', control.server_from_host.name
|
102
|
+
assert_equal 8080, control.server_from_host.port
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class FakeResolv
|
107
|
+
def self.getaddress(host)
|
108
|
+
raise 'deliberately broken'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_resolve_ip_with_broken_dns
|
113
|
+
# Here be dragons: disable the ruby DNS lookup methods we use so
|
114
|
+
# that it will actually fail to resolve.
|
115
|
+
old_resolv = Resolv
|
116
|
+
old_ipsocket = IPSocket
|
117
|
+
Object.instance_eval { remove_const :Resolv}
|
118
|
+
Object.instance_eval {remove_const:'IPSocket' }
|
119
|
+
|
120
|
+
with_config(:ssl => false, :verify_certificate => false) do
|
121
|
+
assert_equal(nil, control.send(:convert_to_ip_address, 'collector.newrelic.com'), "DNS is down, should be no IP for server")
|
122
|
+
end
|
123
|
+
|
124
|
+
Object.instance_eval {const_set('Resolv', old_resolv); const_set('IPSocket', old_ipsocket)}
|
125
|
+
# these are here to make sure that the constant tomfoolery above
|
126
|
+
# has not broket the system unduly
|
127
|
+
assert_equal old_resolv, Resolv
|
128
|
+
assert_equal old_ipsocket, IPSocket
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_transaction_threshold__override
|
132
|
+
with_config(:transaction_tracer => { :transaction_threshold => 1}) do
|
133
|
+
assert_equal 1, NewRelic::Agent.config[:'transaction_tracer.transaction_threshold']
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_transaction_tracer_disabled
|
138
|
+
with_config(:'transaction_tracer.enabled' => false,
|
139
|
+
:developer_mode => false, :monitor_mode => true) do
|
140
|
+
assert(!NewRelic::Agent::Agent.instance.transaction_sampler.enabled?,
|
141
|
+
'transaction tracer enabled when config calls for disabled')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_sql_tracer_disabled
|
146
|
+
with_config(:'slow_sql.enabled' => false, :monitor_mode => true) do
|
147
|
+
assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
148
|
+
'sql tracer enabled when config calls for disabled')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_sql_tracer_disabled_with_record_sql_false
|
153
|
+
with_config(:slow_sql => { :enabled => true, :record_sql => 'off' }) do
|
154
|
+
assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
155
|
+
'sql tracer enabled when config calls for disabled')
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_sql_tracer_disabled_when_tt_disabled
|
160
|
+
with_config(:'transaction_tracer.enabled' => false,
|
161
|
+
:'slow_sql.enabled' => true,
|
162
|
+
:developer_mode => false, :monitor_mode => true) do
|
163
|
+
assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
164
|
+
'sql enabled when transaction tracer disabled')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_sql_tracer_disabled_when_tt_disabled_by_server
|
169
|
+
with_config({:'slow_sql.enabled' => true,
|
170
|
+
:'transaction_tracer.enabled' => true,
|
171
|
+
:monitor_mode => true}, :level => 2) do
|
172
|
+
NewRelic::Agent.instance.finish_setup('collect_traces' => false)
|
173
|
+
|
174
|
+
assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
175
|
+
'sql enabled when tracing disabled by server')
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_init_plugin_loads_samplers_enabled
|
180
|
+
NewRelic::Agent.shutdown
|
181
|
+
with_config(:disable_samplers => false, :agent_enabled => true) do
|
182
|
+
NewRelic::Control.instance.init_plugin
|
183
|
+
assert NewRelic::Agent.instance.stats_engine.send(:harvest_samplers).any?
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_init_plugin_loads_samplers_disabled
|
188
|
+
NewRelic::Agent.shutdown
|
189
|
+
with_config(:disable_samplers => true, :agent_enabled => true) do
|
190
|
+
NewRelic::Control.instance.init_plugin
|
191
|
+
assert NewRelic::Agent.instance.stats_engine.send(:harvest_samplers).empty?
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
2
|
+
|
3
|
+
class NewRelic::DelayedJobInstrumentationTest < Test::Unit::TestCase
|
4
|
+
def test_skip_logging_if_no_logger_found
|
5
|
+
Object.const_set('Delayed', Module.new) unless defined?(Delayed)
|
6
|
+
::Delayed.const_set('Worker', Class.new) unless defined?(::Delayed::Worker)
|
7
|
+
|
8
|
+
# on JRuby we need to make sure the worker isn't running, it might
|
9
|
+
# try to log
|
10
|
+
worker = NewRelic::Agent.agent.instance_variable_get(:@worker_loop)
|
11
|
+
worker.stop if worker
|
12
|
+
|
13
|
+
NewRelic::Agent.stubs(:logger).raises(NoMethodError,
|
14
|
+
'temporarily not allowed')
|
15
|
+
NewRelic::Agent.stubs(:respond_to?).with(:logger).returns(false)
|
16
|
+
|
17
|
+
assert DependencyDetection.detect!
|
18
|
+
|
19
|
+
Object.class_eval { remove_const('Delayed') }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
2
|
+
|
3
|
+
# Test logic around detecting or configuring dispatcher
|
4
|
+
class DispatcherTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
NewRelic::Agent.shutdown
|
8
|
+
NewRelic::Agent.reset_config
|
9
|
+
end
|
10
|
+
|
11
|
+
def assert_dispatcher_reported_to_environment_report(dispatcher)
|
12
|
+
NewRelic::Control.instance.local_env.gather_environment_info
|
13
|
+
key, value = NewRelic::Control.instance.local_env.snapshot.detect do |(k, v)|
|
14
|
+
k == "Dispatcher"
|
15
|
+
end
|
16
|
+
assert_equal dispatcher.to_s, value
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_detects_dispatcher_via_loaded_libraries
|
20
|
+
class << self
|
21
|
+
module ::PhusionPassenger
|
22
|
+
end
|
23
|
+
end
|
24
|
+
assert_equal :passenger, NewRelic::Agent.config[:dispatcher]
|
25
|
+
assert_dispatcher_reported_to_environment_report :passenger
|
26
|
+
ensure
|
27
|
+
Object.send(:remove_const, :PhusionPassenger)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_detects_dispatcher_via_ENV_NEW_RELIC_DISPATCHER
|
31
|
+
ENV['NEW_RELIC_DISPATCHER'] = "foobared"
|
32
|
+
NewRelic::Agent.reset_config
|
33
|
+
assert_equal :foobared, NewRelic::Agent.config[:dispatcher]
|
34
|
+
assert_dispatcher_reported_to_environment_report :foobared
|
35
|
+
ensure
|
36
|
+
ENV['NEW_RELIC_DISPATCHER'] = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_detects_dispatcher_via_ENV_NEWRELIC_DISPATCHER
|
40
|
+
ENV['NEWRELIC_DISPATCHER'] = "bazbang"
|
41
|
+
NewRelic::Agent.reset_config
|
42
|
+
assert_equal :bazbang, NewRelic::Agent.config[:dispatcher]
|
43
|
+
assert_dispatcher_reported_to_environment_report :bazbang
|
44
|
+
ensure
|
45
|
+
ENV['NEWRELIC_DISPATCHER'] = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_detects_dispatcher_based_on_arguments_to_manual_start
|
49
|
+
NewRelic::Agent.manual_start(:dispatcher => :resque)
|
50
|
+
assert_equal :resque, NewRelic::Agent.config[:dispatcher]
|
51
|
+
assert_dispatcher_reported_to_environment_report :resque
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,389 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rack'
|
3
|
+
require 'uri'
|
4
|
+
require 'socket'
|
5
|
+
require 'timeout'
|
6
|
+
require 'ostruct'
|
7
|
+
|
8
|
+
require 'json' if RUBY_VERSION >= '1.9'
|
9
|
+
|
10
|
+
module NewRelic
|
11
|
+
class FakeCollector
|
12
|
+
attr_accessor :agent_data, :mock
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@id_counter = 0
|
16
|
+
@base_expectations = {
|
17
|
+
'get_redirect_host' => [200, {'return_value' => 'localhost'}],
|
18
|
+
'connect' => [200, {'return_value' => {"agent_run_id" => agent_run_id}}],
|
19
|
+
'get_agent_commands' => [200, {'return_value' => []}],
|
20
|
+
'metric_data' => [200, {'return_value' => [[{'name' => 'Some/Metric/Spec'}, 1]]}],
|
21
|
+
'sql_trace_data' => [200, {'return_value' => nil}],
|
22
|
+
'transaction_sample_data' => [200, {'return_value' => nil}],
|
23
|
+
'error_data' => [200, {'return_value' => nil}],
|
24
|
+
'shutdown' => [200, {'return_value' => nil}]
|
25
|
+
}
|
26
|
+
reset
|
27
|
+
end
|
28
|
+
|
29
|
+
def agent_run_id
|
30
|
+
@id_counter += 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(env)
|
34
|
+
req = ::Rack::Request.new(env)
|
35
|
+
res = ::Rack::Response.new
|
36
|
+
uri = URI.parse(req.url)
|
37
|
+
if uri.path =~ /agent_listener\/\d+\/.+\/(\w+)/
|
38
|
+
method = $1
|
39
|
+
format = json_format?(uri) && RUBY_VERSION >= '1.9' ? :json : :pruby
|
40
|
+
if @mock.keys.include? method
|
41
|
+
res.status = @mock[method][0]
|
42
|
+
if format == :json
|
43
|
+
res.write JSON.dump(@mock[method][1])
|
44
|
+
else
|
45
|
+
res.write Marshal.dump(@mock[method][1])
|
46
|
+
end
|
47
|
+
else
|
48
|
+
res.status = 500
|
49
|
+
res.write "Method not found"
|
50
|
+
end
|
51
|
+
run_id = uri.query =~ /run_id=(\d+)/ ? $1 : nil
|
52
|
+
req.body.rewind
|
53
|
+
|
54
|
+
body = if format == :json
|
55
|
+
body = JSON.load(req.body.read)
|
56
|
+
else
|
57
|
+
body = Marshal.load(req.body.read)
|
58
|
+
end
|
59
|
+
@agent_data << AgentPost.create(:action => method,
|
60
|
+
:body => body,
|
61
|
+
:run_id => run_id,
|
62
|
+
:format => format)
|
63
|
+
end
|
64
|
+
res.finish
|
65
|
+
end
|
66
|
+
|
67
|
+
def json_format?(uri)
|
68
|
+
uri.query && uri.query.include?('marshal_format=json')
|
69
|
+
end
|
70
|
+
|
71
|
+
# We generate a "unique" port for ourselves based off our pid
|
72
|
+
# If this logic changes, look for multiverse newrelic.yml files to update
|
73
|
+
# with it duplicated (since we can't easily pull this ruby into a yml)
|
74
|
+
def self.determine_port
|
75
|
+
30_000 + ($$ % 10_000)
|
76
|
+
end
|
77
|
+
|
78
|
+
def determine_port
|
79
|
+
FakeCollector.determine_port
|
80
|
+
end
|
81
|
+
|
82
|
+
@seen_port_failure = false
|
83
|
+
|
84
|
+
def run(port=nil)
|
85
|
+
port ||= determine_port
|
86
|
+
return if @thread && @thread.alive?
|
87
|
+
serve_on_port(port) do
|
88
|
+
@thread = Thread.new do
|
89
|
+
begin
|
90
|
+
::Rack::Handler::WEBrick.run(self,
|
91
|
+
:Port => port,
|
92
|
+
:Logger => ::WEBrick::Log.new("/dev/null"),
|
93
|
+
:AccessLog => [ ['/dev/null', ::WEBrick::AccessLog::COMMON_LOG_FORMAT] ]
|
94
|
+
)
|
95
|
+
rescue Errno::EADDRINUSE => ex
|
96
|
+
msg = "Port #{port} for FakeCollector was in use"
|
97
|
+
if !@seen_port_failure
|
98
|
+
# This is slow, so only do it the first collision we detect
|
99
|
+
lsof = `lsof | grep #{port}`
|
100
|
+
msg = msg + "\n#{lsof}"
|
101
|
+
@seen_port_failure = true
|
102
|
+
end
|
103
|
+
|
104
|
+
raise Errno::EADDRINUSE.new(msg)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
@thread.abort_on_exception = true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def serve_on_port(port)
|
112
|
+
port ||= determine_port
|
113
|
+
if is_port_available?('127.0.0.1', port)
|
114
|
+
yield
|
115
|
+
loop do
|
116
|
+
break if !is_port_available?('127.0.0.1', port)
|
117
|
+
sleep 0.01
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def stop
|
123
|
+
return unless @thread.alive?
|
124
|
+
::Rack::Handler::WEBrick.shutdown
|
125
|
+
@thread.join
|
126
|
+
reset
|
127
|
+
end
|
128
|
+
|
129
|
+
def reset
|
130
|
+
@mock = @base_expectations.dup
|
131
|
+
@id_counter = 0
|
132
|
+
@agent_data = []
|
133
|
+
end
|
134
|
+
|
135
|
+
def is_port_available?(ip, port)
|
136
|
+
begin
|
137
|
+
Timeout::timeout(1) do
|
138
|
+
begin
|
139
|
+
s = TCPSocket.new(ip, port)
|
140
|
+
s.close
|
141
|
+
return false
|
142
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
143
|
+
return true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
rescue Timeout::Error
|
147
|
+
end
|
148
|
+
|
149
|
+
return true
|
150
|
+
end
|
151
|
+
|
152
|
+
def calls_for(method)
|
153
|
+
@agent_data.select {|d| d.action == method }
|
154
|
+
end
|
155
|
+
|
156
|
+
def reported_stats_for_metric(name, scope=nil)
|
157
|
+
calls_for('metric_data').map do |post|
|
158
|
+
post.body[3].find do |metric_record|
|
159
|
+
metric_record[0]['name'] == name &&
|
160
|
+
(!scope || metric_record[0]['scope'] == scope)
|
161
|
+
end
|
162
|
+
end.compact.map{|m| m[1]}
|
163
|
+
end
|
164
|
+
|
165
|
+
class AgentPost
|
166
|
+
attr_accessor :action, :body, :run_id, :format
|
167
|
+
def initialize(opts={})
|
168
|
+
@action = opts[:action]
|
169
|
+
@body = opts[:body]
|
170
|
+
@run_id = opts[:run_id]
|
171
|
+
@format = opts[:format]
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.create(opts={})
|
175
|
+
case opts[:action]
|
176
|
+
when 'connect'
|
177
|
+
ConnectPost.new(opts)
|
178
|
+
when 'metric_data'
|
179
|
+
AgentPost.new(opts)
|
180
|
+
when 'profile_data'
|
181
|
+
ProfileDataPost.new(opts)
|
182
|
+
when 'sql_trace_data'
|
183
|
+
SqlTraceDataPost.new(opts)
|
184
|
+
when 'transaction_sample_data'
|
185
|
+
TransactionSampleDataPost.new(opts)
|
186
|
+
else
|
187
|
+
new(opts)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def [](key)
|
192
|
+
@body[key]
|
193
|
+
end
|
194
|
+
|
195
|
+
def unblob(blob)
|
196
|
+
return unless blob
|
197
|
+
JSON.load(Zlib::Inflate.inflate(Base64.decode64(blob)))
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
class ConnectPost < AgentPost
|
202
|
+
def initialize(opts={})
|
203
|
+
super
|
204
|
+
@body = @body[0]
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
class ProfileDataPost < AgentPost
|
209
|
+
def initialize(opts={})
|
210
|
+
super
|
211
|
+
@body[1][0][4] = unblob(@body[1][0][4]) if @format == :json
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class SqlTraceDataPost < AgentPost
|
216
|
+
def initialize(opts={})
|
217
|
+
super
|
218
|
+
@body[0][0][9] = unblob(@body[0][0][9]) if @format == :json
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
class TransactionSampleDataPost < AgentPost
|
223
|
+
def initialize(opts={})
|
224
|
+
super
|
225
|
+
@body[4] = unblob(@body[4]) if @format == :json
|
226
|
+
end
|
227
|
+
|
228
|
+
def metric_name
|
229
|
+
@body[1][0][2]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# might we need this? I'll just leave it here for now
|
235
|
+
class FakeCollectorProcess < FakeCollector
|
236
|
+
def run(port)
|
237
|
+
serve_on_port(port) do
|
238
|
+
@pid = Process.fork do
|
239
|
+
::Rack::Handler::WEBrick.run(self, :Port => port)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def stop
|
245
|
+
return unless @pid
|
246
|
+
Process.kill('QUIT', @pid)
|
247
|
+
Process.wait(@pid)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
if $0 == __FILE__
|
253
|
+
require 'test/unit'
|
254
|
+
require 'net/http'
|
255
|
+
|
256
|
+
class FakeCollectorTest < Test::Unit::TestCase
|
257
|
+
def setup
|
258
|
+
@collector = NewRelic::FakeCollector.new
|
259
|
+
@collector.run
|
260
|
+
end
|
261
|
+
|
262
|
+
def teardown
|
263
|
+
@collector.stop
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_get_redirect
|
267
|
+
@collector.mock['get_redirect_host'] = [200, 'test.example.com']
|
268
|
+
response = invoke('get_redirect_host')
|
269
|
+
|
270
|
+
assert_equal 'test.example.com', response
|
271
|
+
assert_equal 'get_redirect_host', @collector.agent_data[0].action
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_connect
|
275
|
+
response = invoke('connect')
|
276
|
+
|
277
|
+
assert_equal 1, response['agent_run_id']
|
278
|
+
assert_equal 'connect', @collector.agent_data[0].action
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_metric_data
|
282
|
+
response = invoke('metric_data?run_id=1',
|
283
|
+
{'Foo/Bar' => [1,2,3], 'Baz/Cux' => [4,5,6]})
|
284
|
+
|
285
|
+
assert_equal 1, response['Some/Metric/Spec']
|
286
|
+
post = @collector.agent_data[0]
|
287
|
+
assert_equal 'metric_data', post.action
|
288
|
+
assert_equal({'Foo/Bar' => [1,2,3], 'Baz/Cux' => [4,5,6]}, post.body)
|
289
|
+
assert_equal 1, post.run_id.to_i
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_sql_trace_data
|
293
|
+
response = invoke('sql_trace_data?run_id=2',
|
294
|
+
['trace', 'trace', 'trace'])
|
295
|
+
|
296
|
+
assert_nil response
|
297
|
+
post = @collector.agent_data[0]
|
298
|
+
assert_equal 'sql_trace_data', post.action
|
299
|
+
assert_equal ['trace', 'trace', 'trace'], post.body
|
300
|
+
assert_equal 2, post.run_id.to_i
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_transaction_sample_data
|
304
|
+
response = invoke('transaction_sample_data?run_id=3',
|
305
|
+
['node', ['node', 'node'], 'node'])
|
306
|
+
|
307
|
+
assert_nil response
|
308
|
+
post = @collector.agent_data[0]
|
309
|
+
assert_equal 'transaction_sample_data', post.action
|
310
|
+
assert_equal ['node', ['node', 'node'], 'node'], post.body
|
311
|
+
assert_equal 3, post.run_id.to_i
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_transaction_sample_data_json
|
315
|
+
response = invoke('transaction_sample_data?run_id=3&marshal_format=json',
|
316
|
+
'["node",["node","node"],"node"]')
|
317
|
+
|
318
|
+
assert_equal '', response
|
319
|
+
post = @collector.agent_data[0]
|
320
|
+
assert_equal 'transaction_sample_data', post.action
|
321
|
+
assert_equal '["node",["node","node"],"node"]', post.body
|
322
|
+
assert_equal 3, post.run_id.to_i
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_error_data
|
326
|
+
response = invoke('error_data?run_id=4', ['error'])
|
327
|
+
|
328
|
+
assert_nil response
|
329
|
+
post = @collector.agent_data[0]
|
330
|
+
assert_equal 'error_data', post.action
|
331
|
+
assert_equal ['error'], post.body
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_shutdown
|
335
|
+
response = invoke('shutdown?run_id=1')
|
336
|
+
|
337
|
+
assert_nil response
|
338
|
+
assert_equal 'shutdown', @collector.agent_data[0].action
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_multiple_invokations
|
342
|
+
pid = Process.fork do
|
343
|
+
invoke('get_redirect_host')
|
344
|
+
invoke('connect')
|
345
|
+
invoke('metric_data?run_id=1')
|
346
|
+
invoke('transaction_sample_data?run_id=1')
|
347
|
+
invoke('shutdown?run_id=1')
|
348
|
+
end
|
349
|
+
invoke('get_redirect_host')
|
350
|
+
invoke('connect')
|
351
|
+
invoke('metric_data?run_id=2')
|
352
|
+
invoke('transaction_sample_data?run_id=2')
|
353
|
+
invoke('shutdown?run_id=2')
|
354
|
+
|
355
|
+
Process.wait(pid)
|
356
|
+
|
357
|
+
expected = ['get_redirect_host', 'connect', 'metric_data',
|
358
|
+
'transaction_sample_data', 'shutdown',
|
359
|
+
'get_redirect_host', 'connect', 'metric_data',
|
360
|
+
'transaction_sample_data', 'shutdown']
|
361
|
+
assert_equal expected.sort, @collector.agent_data.map(&:action).sort
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_reset
|
365
|
+
@collector.mock['get_redirect_host'] = [200, 'never!']
|
366
|
+
@collector.reset
|
367
|
+
assert_equal [200, 'localhost'], @collector.mock['get_redirect_host']
|
368
|
+
end
|
369
|
+
|
370
|
+
def invoke(method, post={}, code=200)
|
371
|
+
uri = URI.parse("http://127.0.0.1:#{@collector.determine_port}/agent_listener/8/12345/#{method}")
|
372
|
+
request = Net::HTTP::Post.new("#{uri.path}?#{uri.query}")
|
373
|
+
if uri.query && uri.query.include?('marshal_format=json')
|
374
|
+
request.body = JSON.dump(post)
|
375
|
+
else
|
376
|
+
request.body = Marshal.dump(post)
|
377
|
+
end
|
378
|
+
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
379
|
+
http.request(request)
|
380
|
+
end
|
381
|
+
if uri.query && uri.query.include?('marshal_format=json')
|
382
|
+
JSON.load(response.body)
|
383
|
+
else
|
384
|
+
Marshal.load(response.body)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|