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,230 @@
|
|
1
|
+
## NewRelic instrumentation for DataMapper
|
2
|
+
#
|
3
|
+
# Instrumenting DM has different key challenges versus AR:
|
4
|
+
#
|
5
|
+
# 1. The hooking of SQL logging in DM is decoupled from any knowledge of the
|
6
|
+
# Model#method that invoked it. But on the positive side, the duration is
|
7
|
+
# already calculated for you (and it happens inside the C-based DO code, so
|
8
|
+
# it's faster than a Ruby equivalent).
|
9
|
+
#
|
10
|
+
# 2. There are a lot more entry points that need to be hooked in order to
|
11
|
+
# understand call flow: DM::Model (model class) vs. DM::Resource (model
|
12
|
+
# instance) vs. DM::Collection (collection of model instances). And
|
13
|
+
# others.
|
14
|
+
#
|
15
|
+
# 3. Strategic Eager Loading (SEL) combined with separately-grouped
|
16
|
+
# lazy-loaded attributes presents a unique problem for tying resulting
|
17
|
+
# SEL-invoked SQL calls to their proper scope.
|
18
|
+
#
|
19
|
+
# NOTE: On using "Database" versus "ActiveRecord" as base metric name
|
20
|
+
#
|
21
|
+
# Using "Database" as the metric name base seems to properly identify methods
|
22
|
+
# as being DB-related in call graphs, but certain New Relic views that show
|
23
|
+
# aggregations of DB CPM, etc still seem to rely solely on "ActiveRecord"
|
24
|
+
# being the base name, thus AFAICT "Database" calls to this are lost. (Though
|
25
|
+
# I haven't yet tested "Database/SQL/{find/save/destroy/all}" yet, as it seems
|
26
|
+
# like an intuitively good name to use.)
|
27
|
+
#
|
28
|
+
# So far I think these are the rules:
|
29
|
+
#
|
30
|
+
# - ActiveRecord/{find/save/destroy} populates "Database Throughput" and
|
31
|
+
# "Database Response Time" in the Database tab. [non-scoped]
|
32
|
+
#
|
33
|
+
# - ActiveRecord/all populates the main Overview tab of DB time. (still
|
34
|
+
# unsure about this one). [non-scoped]
|
35
|
+
#
|
36
|
+
# These metrics are represented as :push_scope => false or included as the
|
37
|
+
# non-first metric in trace_execution_scoped() (docs say only first counts
|
38
|
+
# towards scope) so they don't show up ine normal call graph/trace.
|
39
|
+
|
40
|
+
DependencyDetection.defer do
|
41
|
+
@name = :data_mapper
|
42
|
+
|
43
|
+
depends_on do
|
44
|
+
defined?(::DataMapper)
|
45
|
+
end
|
46
|
+
|
47
|
+
depends_on do
|
48
|
+
defined?(DataMapper::Model)
|
49
|
+
end
|
50
|
+
|
51
|
+
depends_on do
|
52
|
+
defined?(DataMapper::Resource)
|
53
|
+
end
|
54
|
+
|
55
|
+
depends_on do
|
56
|
+
defined?(DataMapper::Collection)
|
57
|
+
end
|
58
|
+
|
59
|
+
executes do
|
60
|
+
::NewRelic::Agent.logger.info 'Installing DataMapper instrumentation'
|
61
|
+
end
|
62
|
+
|
63
|
+
executes do
|
64
|
+
DataMapper::Model.class_eval do
|
65
|
+
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
66
|
+
add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
|
67
|
+
add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
|
68
|
+
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
69
|
+
|
70
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
71
|
+
add_method_tracer :create!, 'ActiveRecord/#{self.name}/create'
|
72
|
+
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
73
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
74
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
75
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
76
|
+
|
77
|
+
# For dm-aggregates and partial dm-ar-finders support:
|
78
|
+
for method in [ :aggregate, :find, :find_by_sql ] do
|
79
|
+
next unless method_defined? method
|
80
|
+
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
executes do
|
87
|
+
DataMapper::Resource.class_eval do
|
88
|
+
add_method_tracer :update, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
|
89
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
|
90
|
+
add_method_tracer :save, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
|
91
|
+
add_method_tracer :save!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
|
92
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
|
93
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
executes do
|
99
|
+
DataMapper::Collection.class_eval do
|
100
|
+
# DM's Collection instance methods
|
101
|
+
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
102
|
+
add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
|
103
|
+
add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
|
104
|
+
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
105
|
+
|
106
|
+
add_method_tracer :lazy_load, 'ActiveRecord/#{self.name}/lazy_load'
|
107
|
+
|
108
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
109
|
+
add_method_tracer :create!, 'ActiveRecord/#{self.name}/create'
|
110
|
+
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
111
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
112
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
113
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
114
|
+
|
115
|
+
# For dm-aggregates support:
|
116
|
+
for method in [ :aggregate ] do
|
117
|
+
next unless method_defined? method
|
118
|
+
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
DependencyDetection.defer do
|
126
|
+
|
127
|
+
depends_on do
|
128
|
+
defined?(DataMapper) && defined?(DataMapper::Adapters) && defined?(DataMapper::Adapters::DataObjectsAdapter)
|
129
|
+
end
|
130
|
+
|
131
|
+
executes do
|
132
|
+
|
133
|
+
# Catch the two entry points into DM::Repository::Adapter that bypass CRUD
|
134
|
+
# (for when SQL is run directly).
|
135
|
+
DataMapper::Adapters::DataObjectsAdapter.class_eval do
|
136
|
+
|
137
|
+
add_method_tracer :select, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/select'
|
138
|
+
add_method_tracer :execute, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/execute'
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
DependencyDetection.defer do
|
145
|
+
|
146
|
+
depends_on do
|
147
|
+
defined?(DataMapper) && defined?(DataMapper::Validations) && defined?(DataMapper::Validations::ClassMethods)
|
148
|
+
end
|
149
|
+
|
150
|
+
# DM::Validations overrides Model#create, but currently in a way that makes it
|
151
|
+
# impossible to instrument from one place. I've got a patch pending inclusion
|
152
|
+
# to make it instrumentable by putting the create method inside ClassMethods.
|
153
|
+
# This will pick it up if/when that patch is accepted.
|
154
|
+
executes do
|
155
|
+
DataMapper::Validations::ClassMethods.class_eval do
|
156
|
+
next unless method_defined? :create
|
157
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
DependencyDetection.defer do
|
163
|
+
|
164
|
+
depends_on do
|
165
|
+
defined?(DataMapper) && defined?(DataMapper::Transaction)
|
166
|
+
end
|
167
|
+
|
168
|
+
# NOTE: DM::Transaction basically calls commit() twice, so as-is it will show
|
169
|
+
# up in traces twice -- second time subordinate to the first's scope. Works
|
170
|
+
# well enough.
|
171
|
+
executes do
|
172
|
+
DataMapper::Transaction.module_eval do
|
173
|
+
add_method_tracer :commit, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/commit'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
module NewRelic
|
180
|
+
module Agent
|
181
|
+
module Instrumentation
|
182
|
+
module DataMapperInstrumentation
|
183
|
+
# Unlike in AR, log is called in DM after the query actually ran,
|
184
|
+
# complete with metrics. Since DO has already calculated the
|
185
|
+
# duration, there's nothing more to measure, so just record and log.
|
186
|
+
#
|
187
|
+
# We rely on the assumption that all possible entry points have been
|
188
|
+
# hooked with tracers, ensuring that notice_sql attaches this SQL to
|
189
|
+
# the proper call scope.
|
190
|
+
def log(msg)
|
191
|
+
return unless NewRelic::Agent.is_execution_traced?
|
192
|
+
return unless operation = case NewRelic::Helper.correctly_encoded(msg.query)
|
193
|
+
when /^\s*select/i then 'find'
|
194
|
+
when /^\s*(update|insert)/i then 'save'
|
195
|
+
when /^\s*delete/i then 'destroy'
|
196
|
+
else nil
|
197
|
+
end
|
198
|
+
|
199
|
+
# FYI: self.to_s will yield connection URI string.
|
200
|
+
duration = msg.duration / 1000000.0
|
201
|
+
|
202
|
+
# Attach SQL to current segment/scope.
|
203
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(msg.query, nil, duration)
|
204
|
+
|
205
|
+
# Record query duration associated with each of the desired metrics.
|
206
|
+
metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
|
207
|
+
metrics.each do |metric|
|
208
|
+
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
|
209
|
+
end
|
210
|
+
ensure
|
211
|
+
super
|
212
|
+
end
|
213
|
+
|
214
|
+
end # DataMapperInstrumentation
|
215
|
+
end # Instrumentation
|
216
|
+
end # Agent
|
217
|
+
end # NewRelic
|
218
|
+
|
219
|
+
DependencyDetection.defer do
|
220
|
+
|
221
|
+
depends_on do
|
222
|
+
defined?(DataObjects) && defined?(DataObjects::Connection)
|
223
|
+
end
|
224
|
+
|
225
|
+
executes do
|
226
|
+
DataObjects::Connection.class_eval do
|
227
|
+
include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
2
|
+
|
3
|
+
DependencyDetection.defer do
|
4
|
+
@name = :delayed_job
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
!NewRelic::Agent.config[:disable_dj]
|
8
|
+
end
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
# double check because of old JRuby bug
|
12
|
+
defined?(::Delayed) && defined?(::Delayed::Job) &&
|
13
|
+
Delayed::Job.method_defined?(:invoke_job)
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation'
|
18
|
+
end
|
19
|
+
|
20
|
+
executes do
|
21
|
+
Delayed::Job.class_eval do
|
22
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
23
|
+
if self.instance_methods.include?('name') || self.instance_methods.include?(:name)
|
24
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}'
|
25
|
+
else
|
26
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
executes do
|
32
|
+
Delayed::Job.instance_eval do
|
33
|
+
if self.respond_to?('after_fork')
|
34
|
+
if method_defined?(:after_fork)
|
35
|
+
def after_fork_with_newrelic
|
36
|
+
NewRelic::Agent.after_fork(:force_reconnect => true)
|
37
|
+
after_fork_without_newrelic
|
38
|
+
end
|
39
|
+
|
40
|
+
alias_method :after_fork_without_newrelic, :after_fork
|
41
|
+
alias_method :after_fork, :after_fork_with_newrelic
|
42
|
+
else
|
43
|
+
def after_fork
|
44
|
+
NewRelic::Agent.after_fork(:force_reconnect => true)
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# NOTE there are multiple implementations of the MemCache client in Ruby,
|
2
|
+
# each with slightly different API's and semantics.
|
3
|
+
# See:
|
4
|
+
# http://www.deveiate.org/code/Ruby-MemCache/ (Gem: Ruby-MemCache)
|
5
|
+
# http://seattlerb.rubyforge.org/memcache-client/ (Gem: memcache-client)
|
6
|
+
# http://github.com/mperham/dalli (Gem: dalli)
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Instrumentation
|
11
|
+
module Memcache
|
12
|
+
module_function
|
13
|
+
def instrument_methods(the_class, method_names)
|
14
|
+
method_names.each do |method_name|
|
15
|
+
next unless the_class.method_defined? method_name.to_sym
|
16
|
+
the_class.class_eval <<-EOD
|
17
|
+
def #{method_name}_with_newrelic_trace(*args, &block)
|
18
|
+
metrics = ["Memcache/#{method_name}",
|
19
|
+
(NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Memcache/allWeb' : 'Memcache/allOther')]
|
20
|
+
self.class.trace_execution_scoped(metrics) do
|
21
|
+
t0 = Time.now
|
22
|
+
begin
|
23
|
+
#{method_name}_without_newrelic_trace(*args, &block)
|
24
|
+
ensure
|
25
|
+
#{memcache_key_snippet(method_name)}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
alias #{method_name}_without_newrelic_trace #{method_name}
|
30
|
+
alias #{method_name} #{method_name}_with_newrelic_trace
|
31
|
+
EOD
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def memcache_key_snippet(method_name)
|
35
|
+
return "" unless NewRelic::Agent.config[:capture_memcache_keys]
|
36
|
+
"NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
DependencyDetection.defer do
|
44
|
+
@name = :memcache
|
45
|
+
|
46
|
+
depends_on do
|
47
|
+
!NewRelic::Agent.config[:disable_memcache_instrumentation]
|
48
|
+
end
|
49
|
+
|
50
|
+
depends_on do
|
51
|
+
defined?(::MemCache) || defined?(::Memcached) ||
|
52
|
+
defined?(::Dalli::Client) || defined?(::Spymemcached)
|
53
|
+
end
|
54
|
+
|
55
|
+
executes do
|
56
|
+
commands = %w[get get_multi set add incr decr delete replace append prepend]
|
57
|
+
if defined? ::MemCache
|
58
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::MemCache,
|
59
|
+
commands)
|
60
|
+
::NewRelic::Agent.logger.info 'Installing MemCache instrumentation'
|
61
|
+
end
|
62
|
+
if defined? ::Memcached
|
63
|
+
commands << 'cas'
|
64
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Memcached,
|
65
|
+
commands)
|
66
|
+
::NewRelic::Agent.logger.info 'Installing Memcached instrumentation'
|
67
|
+
end
|
68
|
+
if defined? ::Dalli::Client
|
69
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Dalli::Client,
|
70
|
+
commands)
|
71
|
+
::NewRelic::Agent.logger.info 'Installing Dalli Memcache instrumentation'
|
72
|
+
end
|
73
|
+
if defined? ::Spymemcached
|
74
|
+
commands << 'multiget'
|
75
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Spymemcached,
|
76
|
+
commands)
|
77
|
+
::NewRelic::Agent.logger.info 'Installing Spymemcached instrumentation'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
DependencyDetection.defer do
|
4
|
+
@name = :merb_controller
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(Merb) && defined?(Merb::Controller)
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
::NewRelic::Agent.logger.info 'Installing Merb Controller instrumentation'
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
require 'merb-core/controller/merb_controller'
|
16
|
+
|
17
|
+
Merb::Controller.class_eval do
|
18
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
19
|
+
|
20
|
+
class_inheritable_accessor :do_not_trace
|
21
|
+
class_inheritable_accessor :ignore_apdex
|
22
|
+
|
23
|
+
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
24
|
+
self.send "#{attr_name}=", attr_name, value
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.newrelic_read_attr(attr_name) # :nodoc:
|
28
|
+
self.send attr_name
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
# determine the path that is used in the metric name for
|
33
|
+
# the called controller action
|
34
|
+
def newrelic_metric_path
|
35
|
+
"#{controller_name}/#{action_name}"
|
36
|
+
end
|
37
|
+
alias_method :perform_action_without_newrelic_trace, :_dispatch
|
38
|
+
alias_method :_dispatch, :perform_action_with_newrelic_trace
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
DependencyDetection.defer do
|
2
|
+
@name = :merb_error
|
3
|
+
|
4
|
+
depends_on do
|
5
|
+
defined?(Merb) && defined?(Merb::Dispatcher) && defined?(Merb::Dispatcher::DefaultException)
|
6
|
+
end
|
7
|
+
|
8
|
+
depends_on do
|
9
|
+
Merb::Dispatcher::DefaultException.respond_to?(:before)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
::NewRelic::Agent.logger.info 'Installing Merb Errors instrumentation'
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
|
18
|
+
# Hook in the notification to merb
|
19
|
+
error_notifier = Proc.new {
|
20
|
+
if request.exceptions #check that there's actually an exception
|
21
|
+
# Note, this assumes we have already captured the other information such as uri and params in the MetricFrame.
|
22
|
+
NewRelic::Agent::Instrumentation::MetricFrame.notice_error(request.exceptions.first)
|
23
|
+
end
|
24
|
+
}
|
25
|
+
Merb::Dispatcher::DefaultException.before error_notifier
|
26
|
+
Exceptions.before error_notifier
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,356 @@
|
|
1
|
+
require 'new_relic/agent/instrumentation/metric_frame/pop'
|
2
|
+
|
3
|
+
# A struct holding the information required to measure a controller
|
4
|
+
# action. This is put on the thread local. Handles the issue of
|
5
|
+
# re-entrancy, or nested action calls.
|
6
|
+
#
|
7
|
+
# This class is not part of the public API. Avoid making calls on it directly.
|
8
|
+
#
|
9
|
+
module NewRelic
|
10
|
+
module Agent
|
11
|
+
module Instrumentation
|
12
|
+
class MetricFrame
|
13
|
+
# helper module refactored out of the `pop` method
|
14
|
+
include Pop
|
15
|
+
|
16
|
+
attr_accessor :start # A Time instance for the start time, never nil
|
17
|
+
attr_accessor :apdex_start # A Time instance used for calculating the apdex score, which
|
18
|
+
# might end up being @start, or it might be further upstream if
|
19
|
+
# we can find a request header for the queue entry time
|
20
|
+
attr_accessor :exception,
|
21
|
+
:filtered_params, :force_flag,
|
22
|
+
:jruby_cpu_start, :process_cpu_start, :database_metric_name
|
23
|
+
|
24
|
+
# Give the current metric frame a request context. Use this to
|
25
|
+
# get the URI and referer. The request is interpreted loosely
|
26
|
+
# as a Rack::Request or an ActionController::AbstractRequest.
|
27
|
+
attr_accessor :request
|
28
|
+
|
29
|
+
|
30
|
+
# Return the currently active metric frame, or nil. Call with +true+
|
31
|
+
# to create a new metric frame if one is not already on the thread.
|
32
|
+
def self.current(create_if_empty=nil)
|
33
|
+
f = Thread.current[:newrelic_metric_frame]
|
34
|
+
return f if f || !create_if_empty
|
35
|
+
Thread.current[:newrelic_metric_frame] = new
|
36
|
+
end
|
37
|
+
|
38
|
+
# This is the name of the model currently assigned to database
|
39
|
+
# measurements, overriding the default.
|
40
|
+
def self.database_metric_name
|
41
|
+
current && current.database_metric_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.referer
|
45
|
+
current && current.referer
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.agent
|
49
|
+
NewRelic::Agent.instance
|
50
|
+
end
|
51
|
+
|
52
|
+
@@java_classes_loaded = false
|
53
|
+
|
54
|
+
if defined? JRuby
|
55
|
+
begin
|
56
|
+
require 'java'
|
57
|
+
java_import 'java.lang.management.ManagementFactory'
|
58
|
+
java_import 'com.sun.management.OperatingSystemMXBean'
|
59
|
+
@@java_classes_loaded = true
|
60
|
+
rescue => e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
attr_reader :depth
|
65
|
+
|
66
|
+
def initialize
|
67
|
+
@start = Time.now
|
68
|
+
@path_stack = [] # stack of [controller, path] elements
|
69
|
+
@jruby_cpu_start = jruby_cpu_time
|
70
|
+
@process_cpu_start = process_cpu
|
71
|
+
Thread.current[:last_metric_frame] = self
|
72
|
+
end
|
73
|
+
|
74
|
+
def agent
|
75
|
+
NewRelic::Agent.instance
|
76
|
+
end
|
77
|
+
|
78
|
+
def transaction_sampler
|
79
|
+
agent.transaction_sampler
|
80
|
+
end
|
81
|
+
|
82
|
+
def sql_sampler
|
83
|
+
agent.sql_sampler
|
84
|
+
end
|
85
|
+
|
86
|
+
private :agent
|
87
|
+
private :transaction_sampler
|
88
|
+
private :sql_sampler
|
89
|
+
|
90
|
+
# Indicate that we are entering a measured controller action or task.
|
91
|
+
# Make sure you unwind every push with a pop call.
|
92
|
+
def push(m)
|
93
|
+
transaction_sampler.notice_first_scope_push(start)
|
94
|
+
sql_sampler.notice_first_scope_push(start)
|
95
|
+
@path_stack.push NewRelic::MetricParser::MetricParser.for_metric_named(m)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Indicate that you don't want to keep the currently saved transaction
|
99
|
+
# information
|
100
|
+
def self.abort_transaction!
|
101
|
+
current.abort_transaction! if current
|
102
|
+
end
|
103
|
+
|
104
|
+
# For the current web transaction, return the path of the URI minus the host part and query string, or nil.
|
105
|
+
def uri
|
106
|
+
@uri ||= self.class.uri_from_request(@request) unless @request.nil?
|
107
|
+
end
|
108
|
+
|
109
|
+
# For the current web transaction, return the full referer, minus the host string, or nil.
|
110
|
+
def referer
|
111
|
+
@referer ||= self.class.referer_from_request(@request)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Call this to ensure that the current transaction is not saved
|
115
|
+
def abort_transaction!
|
116
|
+
transaction_sampler.ignore_transaction
|
117
|
+
end
|
118
|
+
# This needs to be called after entering the call to trace the
|
119
|
+
# controller action, otherwise the controller action blames
|
120
|
+
# itself. It gets reset in the normal #pop call.
|
121
|
+
def start_transaction
|
122
|
+
agent.stats_engine.start_transaction metric_name
|
123
|
+
# Only push the transaction context info once, on entry:
|
124
|
+
if @path_stack.size == 1
|
125
|
+
transaction_sampler.notice_transaction(metric_name, uri, filtered_params)
|
126
|
+
sql_sampler.notice_transaction(metric_name, uri, filtered_params)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def current_metric
|
131
|
+
@path_stack.last
|
132
|
+
end
|
133
|
+
|
134
|
+
# Return the path, the part of the metric after the category
|
135
|
+
def path
|
136
|
+
@path_stack.last.last
|
137
|
+
end
|
138
|
+
|
139
|
+
# Unwind one stack level. It knows if it's back at the outermost caller and
|
140
|
+
# does the appropriate wrapup of the context.
|
141
|
+
def pop
|
142
|
+
metric = @path_stack.pop
|
143
|
+
log_underflow if metric.nil?
|
144
|
+
if @path_stack.empty?
|
145
|
+
handle_empty_path_stack(metric)
|
146
|
+
else
|
147
|
+
set_new_scope!(current_stack_metric)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# If we have an active metric frame, notice the error and increment the error metric.
|
152
|
+
# Options:
|
153
|
+
# * <tt>:request</tt> => Request object to get the uri and referer
|
154
|
+
# * <tt>:uri</tt> => The request path, minus any request params or query string.
|
155
|
+
# * <tt>:referer</tt> => The URI of the referer
|
156
|
+
# * <tt>:metric</tt> => The metric name associated with the transaction
|
157
|
+
# * <tt>:request_params</tt> => Request parameters, already filtered if necessary
|
158
|
+
# * <tt>:custom_params</tt> => Custom parameters
|
159
|
+
# Anything left over is treated as custom params
|
160
|
+
|
161
|
+
def self.notice_error(e, options={})
|
162
|
+
request = options.delete(:request)
|
163
|
+
if request
|
164
|
+
options[:referer] = referer_from_request(request)
|
165
|
+
options[:uri] = uri_from_request(request)
|
166
|
+
end
|
167
|
+
if current
|
168
|
+
current.notice_error(e, options)
|
169
|
+
else
|
170
|
+
agent.error_collector.notice_error(e, options)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Do not call this. Invoke the class method instead.
|
175
|
+
def notice_error(e, options={}) # :nodoc:
|
176
|
+
params = custom_parameters
|
177
|
+
options[:referer] = referer if referer
|
178
|
+
options[:request_params] = filtered_params if filtered_params
|
179
|
+
options[:uri] = uri if uri
|
180
|
+
options[:metric] = metric_name
|
181
|
+
options.merge!(custom_parameters)
|
182
|
+
if exception != e
|
183
|
+
result = agent.error_collector.notice_error(e, options)
|
184
|
+
self.exception = result if result
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Add context parameters to the metric frame. This information will be passed in to errors
|
189
|
+
# and transaction traces. Keys and Values should be strings, numbers or date/times.
|
190
|
+
def self.add_custom_parameters(p)
|
191
|
+
current.add_custom_parameters(p) if current
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.custom_parameters
|
195
|
+
(current && current.custom_parameters) ? current.custom_parameters : {}
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.set_user_attributes(attributes)
|
199
|
+
current.set_user_attributes(attributes) if current
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.user_attributes
|
203
|
+
(current) ? current.user_attributes : {}
|
204
|
+
end
|
205
|
+
|
206
|
+
def record_apdex()
|
207
|
+
return unless recording_web_transaction? && NewRelic::Agent.is_execution_traced?
|
208
|
+
t = Time.now
|
209
|
+
self.class.record_apdex(current_metric, t - start, t - apdex_start, !exception.nil?)
|
210
|
+
end
|
211
|
+
|
212
|
+
def metric_name
|
213
|
+
return nil if @path_stack.empty?
|
214
|
+
current_metric.name
|
215
|
+
end
|
216
|
+
|
217
|
+
# Return the array of metrics to record for the current metric frame.
|
218
|
+
def recorded_metrics
|
219
|
+
metrics = [ metric_name ]
|
220
|
+
metrics += current_metric.summary_metrics if @path_stack.size == 1
|
221
|
+
metrics
|
222
|
+
end
|
223
|
+
|
224
|
+
# Yield to a block that is run with a database metric name context. This means
|
225
|
+
# the Database instrumentation will use this for the metric name if it does not
|
226
|
+
# otherwise know about a model. This is re-entrant.
|
227
|
+
#
|
228
|
+
# * <tt>model</tt> is the DB model class
|
229
|
+
# * <tt>method</tt> is the name of the finder method or other method to identify the operation with.
|
230
|
+
#
|
231
|
+
def with_database_metric_name(model, method)
|
232
|
+
previous = @database_metric_name
|
233
|
+
model_name = case model
|
234
|
+
when Class
|
235
|
+
model.name
|
236
|
+
when String
|
237
|
+
model
|
238
|
+
else
|
239
|
+
model.to_s
|
240
|
+
end
|
241
|
+
@database_metric_name = "ActiveRecord/#{model_name}/#{method}"
|
242
|
+
yield
|
243
|
+
ensure
|
244
|
+
@database_metric_name=previous
|
245
|
+
end
|
246
|
+
|
247
|
+
def custom_parameters
|
248
|
+
@custom_parameters ||= {}
|
249
|
+
end
|
250
|
+
|
251
|
+
def user_attributes
|
252
|
+
@user_atrributes ||= {}
|
253
|
+
end
|
254
|
+
|
255
|
+
def queue_time
|
256
|
+
start - apdex_start
|
257
|
+
end
|
258
|
+
|
259
|
+
def add_custom_parameters(p)
|
260
|
+
custom_parameters.merge!(p)
|
261
|
+
end
|
262
|
+
|
263
|
+
def set_user_attributes(attributes)
|
264
|
+
user_attributes.merge!(attributes)
|
265
|
+
end
|
266
|
+
|
267
|
+
def self.recording_web_transaction?
|
268
|
+
c = Thread.current[:newrelic_metric_frame]
|
269
|
+
if c
|
270
|
+
c.recording_web_transaction?
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def recording_web_transaction?
|
275
|
+
current_metric && current_metric.is_web_transaction?
|
276
|
+
end
|
277
|
+
|
278
|
+
def is_web_transaction?(metric)
|
279
|
+
0 == metric.index("Controller")
|
280
|
+
end
|
281
|
+
|
282
|
+
# Make a safe attempt to get the referer from a request object, generally successful when
|
283
|
+
# it's a Rack request.
|
284
|
+
def self.referer_from_request(request)
|
285
|
+
if request && request.respond_to?(:referer)
|
286
|
+
request.referer.to_s.split('?').first
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
# Make a safe attempt to get the URI, without the host and query string.
|
291
|
+
def self.uri_from_request(request)
|
292
|
+
approximate_uri = case
|
293
|
+
when request.respond_to?(:fullpath) then request.fullpath
|
294
|
+
when request.respond_to?(:path) then request.path
|
295
|
+
when request.respond_to?(:request_uri) then request.request_uri
|
296
|
+
when request.respond_to?(:uri) then request.uri
|
297
|
+
when request.respond_to?(:url) then request.url
|
298
|
+
end
|
299
|
+
return approximate_uri[%r{^(https?://.*?)?(/[^?]*)}, 2] || '/' if approximate_uri # '
|
300
|
+
end
|
301
|
+
|
302
|
+
def self.record_apdex(current_metric, action_duration, total_duration, is_error)
|
303
|
+
summary_stat = agent.stats_engine.lookup_stats("Apdex") ||
|
304
|
+
initialize_apdex("Apdex")
|
305
|
+
update_apdex(summary_stat, total_duration, is_error)
|
306
|
+
|
307
|
+
controller_stat = agent.stats_engine.lookup_stats(current_metric.apdex_metric_path) ||
|
308
|
+
initialize_apdex(current_metric.apdex_metric_path)
|
309
|
+
update_apdex(controller_stat, action_duration, is_error)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Apdex min and max values should be initialized to the
|
313
|
+
# current apdex_t
|
314
|
+
def self.initialize_apdex(metric_name)
|
315
|
+
stats = agent.stats_engine.get_stats_no_scope(metric_name)
|
316
|
+
apdex_t = TransactionInfo.get.apdex_t
|
317
|
+
stats.min_call_time = apdex_t
|
318
|
+
stats.max_call_time = apdex_t
|
319
|
+
return stats
|
320
|
+
end
|
321
|
+
|
322
|
+
# Record an apdex value for the given stat. when `failed`
|
323
|
+
# the apdex should be recorded as a failure regardless of duration.
|
324
|
+
def self.update_apdex(stat, duration, failed)
|
325
|
+
duration = duration.to_f
|
326
|
+
apdex_t = TransactionInfo.get.apdex_t
|
327
|
+
case
|
328
|
+
when failed
|
329
|
+
stat.record_apdex_f
|
330
|
+
when duration <= apdex_t
|
331
|
+
stat.record_apdex_s
|
332
|
+
when duration <= 4 * apdex_t
|
333
|
+
stat.record_apdex_t
|
334
|
+
else
|
335
|
+
stat.record_apdex_f
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
private
|
340
|
+
|
341
|
+
def process_cpu
|
342
|
+
return nil if defined? JRuby
|
343
|
+
p = Process.times
|
344
|
+
p.stime + p.utime
|
345
|
+
end
|
346
|
+
|
347
|
+
def jruby_cpu_time # :nodoc:
|
348
|
+
return nil unless @@java_classes_loaded
|
349
|
+
threadMBean = ManagementFactory.getThreadMXBean()
|
350
|
+
java_utime = threadMBean.getCurrentThreadUserTime() # ns
|
351
|
+
-1 == java_utime ? 0.0 : java_utime/1e9
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|