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,67 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
+
|
3
|
+
class EventListenerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@events = NewRelic::Agent::EventListener.new
|
7
|
+
|
8
|
+
@called = false
|
9
|
+
@called_with = nil
|
10
|
+
|
11
|
+
@check_method = Proc.new do |*args|
|
12
|
+
@called = true
|
13
|
+
@called_with = args
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#
|
19
|
+
# Helpers
|
20
|
+
#
|
21
|
+
|
22
|
+
def assert_was_called
|
23
|
+
assert @called, "Event wasn't called"
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_was_not_called
|
27
|
+
assert !@called, "Event was called"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
#
|
32
|
+
# Tests
|
33
|
+
#
|
34
|
+
|
35
|
+
def test_notifies
|
36
|
+
@events.subscribe(:before_call, &@check_method)
|
37
|
+
@events.notify(:before_call, :env => "env")
|
38
|
+
|
39
|
+
assert_was_called
|
40
|
+
assert_equal([{:env => "env"}], @called_with)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_failure_during_notify_doesnt_block_other_hooks
|
44
|
+
@events.subscribe(:after_call) { raise "Boo!" }
|
45
|
+
@events.subscribe(:after_call, &@check_method)
|
46
|
+
|
47
|
+
@events.notify(:after_call)
|
48
|
+
|
49
|
+
assert_was_called
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_runaway_events
|
53
|
+
@events.runaway_threshold = 0
|
54
|
+
expects_logging(:debug, includes("my_event"))
|
55
|
+
@events.subscribe(:my_event) {}
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_clear
|
59
|
+
@events.subscribe(:after_call, &@check_method)
|
60
|
+
@events.clear
|
61
|
+
@events.notify(:after_call)
|
62
|
+
|
63
|
+
assert_was_not_called
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,606 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
|
+
|
3
|
+
class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::Unit::TestCase
|
4
|
+
require 'active_record_fixtures'
|
5
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
6
|
+
|
7
|
+
# the db adapter library the tests are running under (e.g. sqlite3)
|
8
|
+
def adapter
|
9
|
+
if ActiveRecord::Base.respond_to?(:connection_config)
|
10
|
+
ActiveRecord::Base.connection_config[:adapter]
|
11
|
+
else
|
12
|
+
# old versions of rails are usually tested against mysql
|
13
|
+
'mysql'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
super
|
19
|
+
NewRelic::Agent.manual_start
|
20
|
+
ActiveRecordFixtures.setup
|
21
|
+
NewRelic::Agent.instance.transaction_sampler.reset!
|
22
|
+
NewRelic::Agent.instance.stats_engine.clear_stats
|
23
|
+
rescue => e
|
24
|
+
puts e
|
25
|
+
puts e.backtrace.join("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
super
|
30
|
+
NewRelic::Agent.shutdown
|
31
|
+
end
|
32
|
+
|
33
|
+
#####################################################################
|
34
|
+
# Note: If these tests are failing, most likely the problem is that #
|
35
|
+
# the active record instrumentation is not loading for whichever #
|
36
|
+
# version of rails you're testing at the moment. #
|
37
|
+
#####################################################################
|
38
|
+
|
39
|
+
def test_agent_setup
|
40
|
+
assert NewRelic::Agent.instance.class == NewRelic::Agent::Agent
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_finder
|
44
|
+
ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
45
|
+
find_metric = "ActiveRecord/ActiveRecordFixtures::Order/find"
|
46
|
+
|
47
|
+
assert_calls_metrics(find_metric) do
|
48
|
+
all_finder(ActiveRecordFixtures::Order)
|
49
|
+
check_metric_count(find_metric, 1)
|
50
|
+
if NewRelic::Control.instance.rails_version >= "4"
|
51
|
+
ActiveRecordFixtures::Order.where(:name => "jeff").load
|
52
|
+
else
|
53
|
+
ActiveRecordFixtures::Order.find_all_by_name "jeff"
|
54
|
+
end
|
55
|
+
check_metric_count(find_metric, 2)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_exists
|
60
|
+
return if NewRelic::Control.instance.rails_version < "2.3.4" ||
|
61
|
+
NewRelic::Control.instance.rails_version >= "3.0.7"
|
62
|
+
|
63
|
+
ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
64
|
+
|
65
|
+
find_metric = "ActiveRecord/ActiveRecordFixtures::Order/find"
|
66
|
+
|
67
|
+
assert_calls_metrics(find_metric) do
|
68
|
+
ActiveRecordFixtures::Order.exists?(["name=?", 'jeff'])
|
69
|
+
check_metric_count(find_metric, 1)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# multiple duplicate find calls should only cause metric trigger on the first
|
74
|
+
# call. the others are ignored.
|
75
|
+
def test_query_cache
|
76
|
+
# Not sure why we get a transaction error with sqlite
|
77
|
+
return if isSqlite?
|
78
|
+
|
79
|
+
find_metric = "ActiveRecord/ActiveRecordFixtures::Order/find"
|
80
|
+
ActiveRecordFixtures::Order.cache do
|
81
|
+
m = ActiveRecordFixtures::Order.create :id => 1, :name => 'jeff'
|
82
|
+
assert_calls_metrics(find_metric) do
|
83
|
+
all_finder(ActiveRecordFixtures::Order)
|
84
|
+
end
|
85
|
+
|
86
|
+
check_metric_count(find_metric, 1)
|
87
|
+
|
88
|
+
assert_calls_metrics(find_metric) do
|
89
|
+
10.times { ActiveRecordFixtures::Order.find m.id }
|
90
|
+
end
|
91
|
+
check_metric_count(find_metric, 2)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_metric_names_jruby
|
96
|
+
# fails due to a bug in rails 3 - log does not provide the correct
|
97
|
+
# transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
98
|
+
return if rails3? || !defined?(JRuby)
|
99
|
+
expected = %W[
|
100
|
+
ActiveRecord/all
|
101
|
+
ActiveRecord/find
|
102
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
103
|
+
Database/SQL/insert
|
104
|
+
RemoteService/sql/#{adapter}/localhost
|
105
|
+
]
|
106
|
+
|
107
|
+
if NewRelic::Control.instance.rails_version < '2.1.0'
|
108
|
+
expected += %W[ActiveRecord/save ActiveRecord/ActiveRecordFixtures::Order/save]
|
109
|
+
end
|
110
|
+
|
111
|
+
assert_calls_metrics(*expected) do
|
112
|
+
m = ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
113
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
114
|
+
m.id = 999
|
115
|
+
m.save!
|
116
|
+
end
|
117
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
118
|
+
|
119
|
+
compare_metrics expected, metrics
|
120
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
121
|
+
# zero because jruby uses a different mysql adapter
|
122
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 0)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_metric_names_sqlite
|
126
|
+
# fails due to a bug in rails 3 - log does not provide the correct
|
127
|
+
# transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
128
|
+
return if rails3? || !isSqlite? || defined?(JRuby)
|
129
|
+
|
130
|
+
expected = %W[
|
131
|
+
ActiveRecord/all
|
132
|
+
ActiveRecord/find
|
133
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
134
|
+
ActiveRecord/create
|
135
|
+
ActiveRecord/ActiveRecordFixtures::Order/create]
|
136
|
+
|
137
|
+
if NewRelic::Control.instance.rails_version < '2.1.0'
|
138
|
+
expected += %W[ActiveRecord/save ActiveRecord/ActiveRecordFixtures::Order/save]
|
139
|
+
end
|
140
|
+
|
141
|
+
assert_calls_metrics(*expected) do
|
142
|
+
m = ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
143
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
144
|
+
m.id = 999
|
145
|
+
m.save!
|
146
|
+
end
|
147
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
148
|
+
|
149
|
+
compare_metrics expected, metrics
|
150
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
151
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_metric_names_standard
|
155
|
+
# fails due to a bug in rails 3 - log does not provide the correct
|
156
|
+
# transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
157
|
+
return if defined?(JRuby) || isSqlite?
|
158
|
+
|
159
|
+
expected = %W[
|
160
|
+
ActiveRecord/all
|
161
|
+
ActiveRecord/find
|
162
|
+
ActiveRecord/create
|
163
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
164
|
+
ActiveRecord/ActiveRecordFixtures::Order/create
|
165
|
+
Database/SQL/other
|
166
|
+
RemoteService/sql/#{adapter}/localhost]
|
167
|
+
|
168
|
+
if NewRelic::Control.instance.rails_version < '2.1.0'
|
169
|
+
expected += ['ActiveRecord/save',
|
170
|
+
'ActiveRecord/ActiveRecordFixtures::Order/save']
|
171
|
+
elsif NewRelic::Control.instance.rails_version >= '3.0.0'
|
172
|
+
expected << 'Database/SQL/insert'
|
173
|
+
end
|
174
|
+
|
175
|
+
assert_calls_metrics(*expected) do
|
176
|
+
m = ActiveRecordFixtures::Order.create :id => 1, :name => 'donkey'
|
177
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
178
|
+
m.id = 999
|
179
|
+
m.save!
|
180
|
+
end
|
181
|
+
|
182
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
183
|
+
|
184
|
+
compare_metrics expected, metrics
|
185
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
186
|
+
if NewRelic::Control.instance.rails_version < '3.0.0'
|
187
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
|
188
|
+
else
|
189
|
+
check_metric_count("Database/SQL/insert", 1)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_join_metrics_jruby
|
194
|
+
return unless defined?(JRuby)
|
195
|
+
return if rails3?
|
196
|
+
|
197
|
+
expected_metrics = %W[
|
198
|
+
ActiveRecord/all
|
199
|
+
ActiveRecord/destroy
|
200
|
+
ActiveRecord/ActiveRecordFixtures::Order/destroy
|
201
|
+
Database/SQL/insert
|
202
|
+
Database/SQL/delete
|
203
|
+
Database/SQL/show
|
204
|
+
ActiveRecord/find
|
205
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
206
|
+
ActiveRecord/ActiveRecordFixtures::Shipment/find
|
207
|
+
RemoteService/sql/#{adapter}/localhost
|
208
|
+
]
|
209
|
+
|
210
|
+
assert_calls_metrics(*expected_metrics) do
|
211
|
+
m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
212
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
213
|
+
s = m.shipments.create
|
214
|
+
m.shipments.to_a
|
215
|
+
m.destroy
|
216
|
+
end
|
217
|
+
|
218
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
219
|
+
|
220
|
+
compare_metrics expected_metrics, metrics
|
221
|
+
|
222
|
+
check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
223
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
224
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
225
|
+
check_metric_count("Database/SQL/insert", 3)
|
226
|
+
check_metric_count("Database/SQL/delete", 1)
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_join_metrics_sqlite
|
230
|
+
return if (defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_i == 3)
|
231
|
+
return if defined?(JRuby)
|
232
|
+
return unless isSqlite?
|
233
|
+
|
234
|
+
expected_metrics = %W[
|
235
|
+
ActiveRecord/all
|
236
|
+
ActiveRecord/destroy
|
237
|
+
ActiveRecord/ActiveRecordFixtures::Order/destroy
|
238
|
+
Database/SQL/insert
|
239
|
+
Database/SQL/delete
|
240
|
+
ActiveRecord/find
|
241
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
242
|
+
ActiveRecord/ActiveRecordFixtures::Shipment/find
|
243
|
+
ActiveRecord/create
|
244
|
+
ActiveRecord/ActiveRecordFixtures::Shipment/create
|
245
|
+
ActiveRecord/ActiveRecordFixtures::Order/create
|
246
|
+
]
|
247
|
+
|
248
|
+
assert_calls_metrics(*expected_metrics) do
|
249
|
+
m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
250
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
251
|
+
s = m.shipments.create
|
252
|
+
m.shipments.to_a
|
253
|
+
m.destroy
|
254
|
+
end
|
255
|
+
|
256
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
257
|
+
compare_metrics expected_metrics, metrics
|
258
|
+
if !(defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Enterprise Edition/)
|
259
|
+
check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
260
|
+
end
|
261
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
262
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
263
|
+
check_metric_count("Database/SQL/insert", 3)
|
264
|
+
check_metric_count("Database/SQL/delete", 1)
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_join_metrics_standard
|
268
|
+
return if (defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_i >= 3)
|
269
|
+
return if defined?(JRuby) || isSqlite?
|
270
|
+
|
271
|
+
expected_metrics = %W[
|
272
|
+
ActiveRecord/all
|
273
|
+
RemoteService/sql/#{adapter}/localhost
|
274
|
+
ActiveRecord/destroy
|
275
|
+
ActiveRecord/ActiveRecordFixtures::Order/destroy
|
276
|
+
Database/SQL/insert
|
277
|
+
Database/SQL/delete
|
278
|
+
ActiveRecord/find
|
279
|
+
ActiveRecord/ActiveRecordFixtures::Order/find
|
280
|
+
ActiveRecord/ActiveRecordFixtures::Shipment/find
|
281
|
+
Database/SQL/other
|
282
|
+
Database/SQL/show
|
283
|
+
ActiveRecord/create
|
284
|
+
ActiveRecord/ActiveRecordFixtures::Shipment/create
|
285
|
+
ActiveRecord/ActiveRecordFixtures::Order/create
|
286
|
+
]
|
287
|
+
|
288
|
+
assert_calls_metrics(*expected_metrics) do
|
289
|
+
m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
290
|
+
m = ActiveRecordFixtures::Order.find(m.id)
|
291
|
+
s = m.shipments.create
|
292
|
+
m.shipments.to_a
|
293
|
+
m.destroy
|
294
|
+
end
|
295
|
+
|
296
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
297
|
+
|
298
|
+
compare_metrics expected_metrics, metrics
|
299
|
+
if !(defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Enterprise Edition/)
|
300
|
+
check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
301
|
+
end
|
302
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
303
|
+
check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
304
|
+
check_metric_count("Database/SQL/insert", 1)
|
305
|
+
check_metric_count("Database/SQL/delete", 1)
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_direct_sql
|
309
|
+
assert_nil NewRelic::Agent::Instrumentation::MetricFrame.current
|
310
|
+
assert_nil NewRelic::Agent.instance.stats_engine.scope_name
|
311
|
+
assert_equal 0, NewRelic::Agent.instance.stats_engine.metrics.size, NewRelic::Agent.instance.stats_engine.metrics.inspect
|
312
|
+
|
313
|
+
expected_metrics = %W[
|
314
|
+
ActiveRecord/all
|
315
|
+
Database/SQL/select
|
316
|
+
RemoteService/sql/#{adapter}/localhost
|
317
|
+
]
|
318
|
+
|
319
|
+
assert_calls_unscoped_metrics(*expected_metrics) do
|
320
|
+
ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
321
|
+
end
|
322
|
+
|
323
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
324
|
+
compare_metrics(expected_metrics, metrics)
|
325
|
+
|
326
|
+
check_unscoped_metric_count('Database/SQL/select', 1)
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_other_sql
|
331
|
+
expected_metrics = %W[
|
332
|
+
ActiveRecord/all
|
333
|
+
Database/SQL/other
|
334
|
+
RemoteService/sql/#{adapter}/localhost
|
335
|
+
]
|
336
|
+
assert_calls_unscoped_metrics(*expected_metrics) do
|
337
|
+
ActiveRecordFixtures::Order.connection.execute "begin"
|
338
|
+
end
|
339
|
+
|
340
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
341
|
+
|
342
|
+
compare_metrics expected_metrics, metrics
|
343
|
+
check_unscoped_metric_count('Database/SQL/other', 1)
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_show_sql
|
347
|
+
return if isSqlite?
|
348
|
+
return if isPostgres?
|
349
|
+
|
350
|
+
expected_metrics = %W[ActiveRecord/all Database/SQL/show RemoteService/sql/#{adapter}/localhost]
|
351
|
+
|
352
|
+
assert_calls_metrics(*expected_metrics) do
|
353
|
+
ActiveRecordFixtures::Order.connection.execute "show tables"
|
354
|
+
end
|
355
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
356
|
+
compare_metrics expected_metrics, metrics
|
357
|
+
check_unscoped_metric_count('Database/SQL/show', 1)
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_blocked_instrumentation
|
361
|
+
ActiveRecordFixtures::Order.add_delay
|
362
|
+
NewRelic::Agent.disable_all_tracing do
|
363
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
364
|
+
all_finder(ActiveRecordFixtures::Order)
|
365
|
+
end
|
366
|
+
end
|
367
|
+
assert_nil NewRelic::Agent.instance.transaction_sampler.last_sample
|
368
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
369
|
+
compare_metrics [], metrics
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_run_explains
|
373
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
374
|
+
ActiveRecordFixtures::Order.add_delay
|
375
|
+
all_finder(ActiveRecordFixtures::Order)
|
376
|
+
end
|
377
|
+
|
378
|
+
# that's a mouthful. perhaps we should ponder our API.
|
379
|
+
segment = NewRelic::Agent.instance.transaction_sampler.last_sample \
|
380
|
+
.root_segment.called_segments[0].called_segments[0].called_segments[0]
|
381
|
+
regex = /^SELECT (["`]?#{ActiveRecordFixtures::Order.table_name}["`]?.)?\* FROM ["`]?#{ActiveRecordFixtures::Order.table_name}["`]?$/
|
382
|
+
assert_match regex, segment.params[:sql].strip
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_prepare_to_send
|
386
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
387
|
+
ActiveRecordFixtures::Order.add_delay
|
388
|
+
all_finder(ActiveRecordFixtures::Order)
|
389
|
+
end
|
390
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
391
|
+
assert_not_nil sample
|
392
|
+
|
393
|
+
includes_gc = false
|
394
|
+
sample.each_segment {|s| includes_gc ||= s.metric_name =~ /GC/ }
|
395
|
+
|
396
|
+
assert_equal (includes_gc ? 4 : 3), sample.count_segments, sample.to_s
|
397
|
+
|
398
|
+
sql_segment = sample.root_segment.called_segments.first.called_segments.first.called_segments.first
|
399
|
+
assert_not_nil sql_segment, sample.to_s
|
400
|
+
assert_match /^SELECT /, sql_segment.params[:sql]
|
401
|
+
assert sql_segment.duration > 0.0, "Segment duration must be greater than zero."
|
402
|
+
sample = sample.prepare_to_send(:record_sql => :raw, :explain_sql => 0.0)
|
403
|
+
sql_segment = sample.root_segment.called_segments.first.called_segments.first.called_segments.first
|
404
|
+
assert_match /^SELECT /, sql_segment.params[:sql]
|
405
|
+
explanations = sql_segment.params[:explain_plan]
|
406
|
+
if isMysql? || isPostgres?
|
407
|
+
assert_not_nil explanations, "No explains in segment: #{sql_segment}"
|
408
|
+
assert_equal(2, explanations.size,
|
409
|
+
"No explains in segment: #{sql_segment}")
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
def test_transaction_mysql
|
414
|
+
return unless isMysql? && !defined?(JRuby)
|
415
|
+
ActiveRecordFixtures.setup
|
416
|
+
sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
417
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
418
|
+
ActiveRecordFixtures::Order.add_delay
|
419
|
+
all_finder(ActiveRecordFixtures::Order)
|
420
|
+
end
|
421
|
+
|
422
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
423
|
+
|
424
|
+
sample = sample.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.0)
|
425
|
+
segment = sample.root_segment.called_segments.first.called_segments.first.called_segments.first
|
426
|
+
explanation = segment.params[:explain_plan]
|
427
|
+
assert_not_nil explanation, "No explains in segment: #{segment}"
|
428
|
+
assert_equal 2, explanation.size,"No explains in segment: #{segment}"
|
429
|
+
|
430
|
+
assert_equal 10, explanation[0].size
|
431
|
+
['id', 'select_type', 'table'].each do |c|
|
432
|
+
assert explanation[0].include?(c)
|
433
|
+
end
|
434
|
+
['1', 'SIMPLE', ActiveRecordFixtures::Order.table_name].each do |c|
|
435
|
+
assert explanation[1][0].include?(c)
|
436
|
+
end
|
437
|
+
|
438
|
+
s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
439
|
+
assert_equal 1, s.call_count
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_transaction_postgres
|
443
|
+
return unless isPostgres?
|
444
|
+
# note that our current test builds do not use postgres, this is
|
445
|
+
# here strictly for troubleshooting, not CI builds
|
446
|
+
sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
447
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
448
|
+
ActiveRecordFixtures::Order.add_delay
|
449
|
+
all_finder(ActiveRecordFixtures::Order)
|
450
|
+
end
|
451
|
+
|
452
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
453
|
+
|
454
|
+
sample = sample.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.0)
|
455
|
+
segment = sample.root_segment.called_segments.first.called_segments.first.called_segments.first
|
456
|
+
explanations = segment.params[:explain_plan]
|
457
|
+
|
458
|
+
assert_not_nil explanations, "No explains in segment: #{segment}"
|
459
|
+
assert_equal 1, explanations.size,"No explains in segment: #{segment}"
|
460
|
+
assert_equal 1, explanations.first.size
|
461
|
+
|
462
|
+
assert_equal("Explain Plan", explanations[0][0])
|
463
|
+
assert_match /Seq Scan on test_data/, explanations[0][1].join(";")
|
464
|
+
|
465
|
+
s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
466
|
+
assert_equal 1, s.call_count
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_transaction_other
|
470
|
+
return if isMysql? || isPostgres?
|
471
|
+
sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
472
|
+
perform_action_with_newrelic_trace :name => 'bogosity' do
|
473
|
+
ActiveRecordFixtures::Order.add_delay
|
474
|
+
all_finder(ActiveRecordFixtures::Order)
|
475
|
+
end
|
476
|
+
|
477
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
478
|
+
|
479
|
+
sample = sample.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.0)
|
480
|
+
segment = sample.root_segment.called_segments.first.called_segments.first.called_segments.first
|
481
|
+
|
482
|
+
s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
483
|
+
assert_equal 1, s.call_count
|
484
|
+
end
|
485
|
+
|
486
|
+
# These are only valid for rails 2.1 and later
|
487
|
+
if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("2.1.0")
|
488
|
+
ActiveRecordFixtures::Order.class_eval do
|
489
|
+
if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("4")
|
490
|
+
scope :jeffs, lambda { where(:name => 'Jeff') }
|
491
|
+
elsif NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("3.1")
|
492
|
+
scope :jeffs, :conditions => { :name => 'Jeff' }
|
493
|
+
else
|
494
|
+
named_scope :jeffs, :conditions => { :name => 'Jeff' }
|
495
|
+
end
|
496
|
+
end
|
497
|
+
def test_named_scope
|
498
|
+
ActiveRecordFixtures::Order.create :name => 'Jeff'
|
499
|
+
|
500
|
+
find_metric = "ActiveRecord/ActiveRecordFixtures::Order/find"
|
501
|
+
|
502
|
+
check_metric_count(find_metric, 0)
|
503
|
+
assert_calls_metrics(find_metric) do
|
504
|
+
if NewRelic::Control.instance.rails_version >= "4"
|
505
|
+
x = ActiveRecordFixtures::Order.jeffs.load
|
506
|
+
else
|
507
|
+
x = ActiveRecordFixtures::Order.jeffs.find(:all)
|
508
|
+
end
|
509
|
+
end
|
510
|
+
check_metric_count(find_metric, 1)
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
# This is to make sure the all metric is recorded for exceptional cases
|
515
|
+
def test_error_handling
|
516
|
+
# have the AR select throw an error
|
517
|
+
ActiveRecordFixtures::Order.connection.stubs(:log_info).with do | sql, x, y |
|
518
|
+
raise "Error" if sql =~ /select/
|
519
|
+
true
|
520
|
+
end
|
521
|
+
|
522
|
+
expected_metrics = %W[ActiveRecord/all Database/SQL/select RemoteService/sql/#{adapter}/localhost]
|
523
|
+
|
524
|
+
assert_calls_metrics(*expected_metrics) do
|
525
|
+
begin
|
526
|
+
ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
527
|
+
rescue RuntimeError => e
|
528
|
+
# catch only the error we raise above
|
529
|
+
raise unless e.message == 'Error'
|
530
|
+
end
|
531
|
+
end
|
532
|
+
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
533
|
+
compare_metrics expected_metrics, metrics
|
534
|
+
check_metric_count('Database/SQL/select', 1)
|
535
|
+
check_metric_count('ActiveRecord/all', 1)
|
536
|
+
check_metric_count("RemoteService/sql/#{adapter}/localhost", 1)
|
537
|
+
end
|
538
|
+
|
539
|
+
def test_rescue_handling
|
540
|
+
# Not sure why we get a transaction error with sqlite
|
541
|
+
return if isSqlite?
|
542
|
+
|
543
|
+
begin
|
544
|
+
ActiveRecordFixtures::Order.transaction do
|
545
|
+
raise ActiveRecord::ActiveRecordError.new('preserve-me!')
|
546
|
+
end
|
547
|
+
rescue ActiveRecord::ActiveRecordError => e
|
548
|
+
assert_equal 'preserve-me!', e.message
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
def test_remote_service_metric_respects_dynamic_connection_config
|
553
|
+
return unless isMysql?
|
554
|
+
|
555
|
+
# puts NewRelic::Agent::Database.config.inspect
|
556
|
+
|
557
|
+
ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
|
558
|
+
assert(NewRelic::Agent.get_stats("RemoteService/sql/#{adapter}/localhost").call_count != 0)
|
559
|
+
|
560
|
+
config = ActiveRecordFixtures::Shipment.connection.instance_eval { @config }
|
561
|
+
config[:host] = '127.0.0.1'
|
562
|
+
connection = ActiveRecordFixtures::Shipment.establish_connection(config)
|
563
|
+
|
564
|
+
# puts ActiveRecord::Base.connection.instance_eval { @config }.inspect
|
565
|
+
# puts NewRelic::Agent::Database.config.inspect
|
566
|
+
|
567
|
+
ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
|
568
|
+
assert(NewRelic::Agent.get_stats("RemoteService/sql/#{adapter}/127.0.0.1").call_count != 0)
|
569
|
+
|
570
|
+
config[:host] = 'localhost'
|
571
|
+
ActiveRecordFixtures::Shipment.establish_connection(config)
|
572
|
+
|
573
|
+
# raise NewRelic::Agent.instance.stats_engine.inspect
|
574
|
+
end
|
575
|
+
|
576
|
+
private
|
577
|
+
|
578
|
+
def rails3?
|
579
|
+
(defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_i >= 3)
|
580
|
+
end
|
581
|
+
|
582
|
+
def rails_env
|
583
|
+
rails3? ? ::Rails.env : RAILS_ENV
|
584
|
+
end
|
585
|
+
|
586
|
+
def isPostgres?
|
587
|
+
ActiveRecordFixtures::Order.configurations[rails_env]['adapter'] =~ /postgres/i
|
588
|
+
end
|
589
|
+
def isMysql?
|
590
|
+
ActiveRecordFixtures::Order.connection.class.name =~ /mysql/i
|
591
|
+
end
|
592
|
+
|
593
|
+
def isSqlite?
|
594
|
+
ActiveRecord::Base.configurations[rails_env]['adapter'] =~ /sqlite/i
|
595
|
+
end
|
596
|
+
|
597
|
+
def all_finder(relation)
|
598
|
+
if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("4.0")
|
599
|
+
relation.all.load
|
600
|
+
elsif NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("3.0")
|
601
|
+
relation.all
|
602
|
+
else
|
603
|
+
relation.find(:all)
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|