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,97 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
class StatsEngine
|
4
|
+
module Shim # :nodoc:
|
5
|
+
def add_sampler(*args); end
|
6
|
+
def add_harvest_sampler(*args); end
|
7
|
+
def start_sampler_thread(*args); end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Contains statistics engine extensions to support the concept of samplers
|
11
|
+
module Samplers
|
12
|
+
|
13
|
+
# By default a sampler polls on harvest time, once a minute. However you can
|
14
|
+
# override #use_harvest_sampler? to return false and it will sample
|
15
|
+
# every POLL_PERIOD seconds on a background thread.
|
16
|
+
POLL_PERIOD = 20
|
17
|
+
|
18
|
+
# starts the sampler thread which runs periodically, rather than
|
19
|
+
# at harvest time. This is deprecated, and should not actually
|
20
|
+
# be used - mo threads mo problems
|
21
|
+
#
|
22
|
+
# returns unless there are actually periodic samplers to run
|
23
|
+
def start_sampler_thread
|
24
|
+
|
25
|
+
return if @sampler_thread && @sampler_thread.alive?
|
26
|
+
|
27
|
+
# start up a thread that will periodically poll for metric samples
|
28
|
+
return if periodic_samplers.empty?
|
29
|
+
|
30
|
+
@sampler_thread = NewRelic::Agent::AgentThread.new('Sampler Tasks') do
|
31
|
+
loop do
|
32
|
+
now = Time.now
|
33
|
+
begin
|
34
|
+
sleep POLL_PERIOD
|
35
|
+
poll periodic_samplers
|
36
|
+
ensure
|
37
|
+
NewRelic::Agent.instance.stats_engine \
|
38
|
+
.get_stats_no_scope('Supportability/Samplers') \
|
39
|
+
.record_data_point((Time.now - now).to_f)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def add_sampler_to(sampler_array, sampler)
|
48
|
+
raise "Sampler #{sampler.inspect} is already registered. Don't call add_sampler directly anymore." if sampler_array.include?(sampler)
|
49
|
+
sampler_array << sampler
|
50
|
+
sampler.stats_engine = self
|
51
|
+
end
|
52
|
+
|
53
|
+
def log_added_sampler(type, sampler)
|
54
|
+
::NewRelic::Agent.logger.debug "Adding #{type} sampler: #{sampler.id}"
|
55
|
+
end
|
56
|
+
|
57
|
+
public
|
58
|
+
|
59
|
+
# Add an instance of Sampler to be invoked about every 10 seconds on a background
|
60
|
+
# thread.
|
61
|
+
def add_sampler(sampler)
|
62
|
+
add_sampler_to(periodic_samplers, sampler)
|
63
|
+
log_added_sampler('periodic', sampler)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Add a sampler to be invoked just before each harvest.
|
67
|
+
def add_harvest_sampler(sampler)
|
68
|
+
add_sampler_to(harvest_samplers, sampler)
|
69
|
+
log_added_sampler('harvest-time', sampler)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
# Call poll on each of the samplers. Remove
|
75
|
+
# the sampler if it raises.
|
76
|
+
def poll(samplers)
|
77
|
+
samplers.delete_if do |sampled_item|
|
78
|
+
begin
|
79
|
+
sampled_item.poll
|
80
|
+
false # it's okay. don't delete it.
|
81
|
+
rescue => e
|
82
|
+
::NewRelic::Agent.logger.warn "Removing #{sampled_item} from list", e
|
83
|
+
true # remove the sampler
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def harvest_samplers
|
89
|
+
@harvest_samplers ||= []
|
90
|
+
end
|
91
|
+
def periodic_samplers
|
92
|
+
@periodic_samplers ||= []
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# A Hash-descended class for storing metric data in the NewRelic Agent.
|
2
|
+
#
|
3
|
+
# Keys are NewRelic::MetricSpec objects.
|
4
|
+
# Values are NewRelic::Agent::Stats objects.
|
5
|
+
#
|
6
|
+
# Missing keys will be automatically created as empty NewRelic::Agent::Stats
|
7
|
+
# instances, so use has_key? explicitly to check for key existence.
|
8
|
+
#
|
9
|
+
# This class makes no provisions for safe usage from multiple threads, such
|
10
|
+
# measures should be externally provided.
|
11
|
+
module NewRelic
|
12
|
+
module Agent
|
13
|
+
class StatsHash < ::Hash
|
14
|
+
def initialize
|
15
|
+
super { |hash, key| hash[key] = NewRelic::Agent::Stats.new }
|
16
|
+
end
|
17
|
+
|
18
|
+
def marshal_dump
|
19
|
+
Hash[self]
|
20
|
+
end
|
21
|
+
|
22
|
+
def marshal_load(hash)
|
23
|
+
self.merge!(hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
def ==(other)
|
27
|
+
Hash[self] == Hash[other]
|
28
|
+
end
|
29
|
+
|
30
|
+
def record(metric_specs, value=nil)
|
31
|
+
Array(metric_specs).each do |metric_spec|
|
32
|
+
stats = self[metric_spec]
|
33
|
+
if block_given?
|
34
|
+
yield stats
|
35
|
+
else
|
36
|
+
case value
|
37
|
+
when Numeric
|
38
|
+
stats.record_data_point(value)
|
39
|
+
when NewRelic::Agent::Stats
|
40
|
+
stats.merge!(value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def merge!(other)
|
47
|
+
other.each do |key,val|
|
48
|
+
if self.has_key?(key)
|
49
|
+
self[key].merge!(val)
|
50
|
+
else
|
51
|
+
self[key] = val
|
52
|
+
end
|
53
|
+
end
|
54
|
+
self
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module NewRelic
|
3
|
+
module Agent
|
4
|
+
class StatsEngine
|
5
|
+
# A simple stack element that tracks the current name and length
|
6
|
+
# of the executing stack
|
7
|
+
class ScopeStackElement
|
8
|
+
attr_reader :deduct_call_time_from_parent
|
9
|
+
attr_accessor :name, :children_time
|
10
|
+
def initialize(name, deduct_call_time)
|
11
|
+
@name = name
|
12
|
+
@deduct_call_time_from_parent = deduct_call_time
|
13
|
+
@children_time = 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Handles pushing and popping elements onto an internal stack that
|
18
|
+
# tracks where time should be allocated in Transaction Traces
|
19
|
+
module Transactions
|
20
|
+
|
21
|
+
# Defines methods that stub out the stats engine methods
|
22
|
+
# when the agent is disabled
|
23
|
+
module Shim # :nodoc:
|
24
|
+
def start_transaction(*args); end
|
25
|
+
def end_transaction; end
|
26
|
+
def push_scope(*args); end
|
27
|
+
def transaction_sampler=(*args); end
|
28
|
+
def scope_name=(*args); end
|
29
|
+
def scope_name; end
|
30
|
+
def pop_scope(*args); end
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :transaction_sampler
|
34
|
+
|
35
|
+
# add a new transaction sampler, unless we're currently in a
|
36
|
+
# transaction (then we fail)
|
37
|
+
def transaction_sampler= sampler
|
38
|
+
fail "Can't add a scope listener midflight in a transaction" if scope_stack.any?
|
39
|
+
@transaction_sampler = sampler
|
40
|
+
end
|
41
|
+
|
42
|
+
# removes a transaction sampler
|
43
|
+
def remove_transaction_sampler(l)
|
44
|
+
@transaction_sampler = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Pushes a scope onto the transaction stack - this generates a
|
48
|
+
# TransactionSample::Segment at the end of transaction execution
|
49
|
+
def push_scope(metric, time = Time.now.to_f, deduct_call_time_from_parent = true)
|
50
|
+
stack = scope_stack
|
51
|
+
@transaction_sampler.notice_push_scope metric, time if sampler_enabled?
|
52
|
+
scope = ScopeStackElement.new(metric, deduct_call_time_from_parent)
|
53
|
+
stack.push scope
|
54
|
+
scope
|
55
|
+
end
|
56
|
+
|
57
|
+
# Pops a scope off the transaction stack - this updates the
|
58
|
+
# transaction sampler that we've finished execution of a traced method
|
59
|
+
def pop_scope(expected_scope, duration, time=Time.now.to_f)
|
60
|
+
stack = scope_stack
|
61
|
+
scope = stack.pop
|
62
|
+
|
63
|
+
if scope != expected_scope
|
64
|
+
scope = expected_scope
|
65
|
+
end
|
66
|
+
|
67
|
+
if !stack.empty?
|
68
|
+
if scope.deduct_call_time_from_parent
|
69
|
+
stack.last.children_time += duration
|
70
|
+
else
|
71
|
+
stack.last.children_time += scope.children_time
|
72
|
+
end
|
73
|
+
end
|
74
|
+
@transaction_sampler.notice_pop_scope(scope.name, time) if sampler_enabled?
|
75
|
+
scope
|
76
|
+
end
|
77
|
+
|
78
|
+
def sampler_enabled?
|
79
|
+
@transaction_sampler && Agent.config[:'transaction_tracer.enabled']
|
80
|
+
end
|
81
|
+
|
82
|
+
# Rename the segment associated with the last pushed scope to +new_name+.
|
83
|
+
def rename_scope_segment( new_name )
|
84
|
+
self.peek_scope.name = new_name
|
85
|
+
@transaction_sampler.rename_scope_segment( new_name )
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns the latest ScopeStackElement
|
89
|
+
def peek_scope
|
90
|
+
scope_stack.last
|
91
|
+
end
|
92
|
+
|
93
|
+
# set the name of the transaction for the current thread, which will be used
|
94
|
+
# to define the scope of all traced methods called on this thread until the
|
95
|
+
# scope stack is empty.
|
96
|
+
#
|
97
|
+
# currently the transaction name is the name of the controller action that
|
98
|
+
# is invoked via the dispatcher, but conceivably we could use other transaction
|
99
|
+
# names in the future if the traced application does more than service http request
|
100
|
+
# via controller actions
|
101
|
+
def scope_name=(transaction)
|
102
|
+
Thread::current[:newrelic_scope_name] = transaction
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns the current scope name from the thread local
|
106
|
+
def scope_name
|
107
|
+
Thread::current[:newrelic_scope_name]
|
108
|
+
end
|
109
|
+
|
110
|
+
# Start a new transaction, unless one is already in progress
|
111
|
+
def start_transaction(name = nil)
|
112
|
+
Thread::current[:newrelic_scope_stack] ||= []
|
113
|
+
self.scope_name = name if name
|
114
|
+
NewRelic::Agent.instance.events.notify(:start_transaction, name)
|
115
|
+
GCProfiler.init
|
116
|
+
end
|
117
|
+
|
118
|
+
# Try to clean up gracefully, otherwise we leave things hanging around on thread locals.
|
119
|
+
# If it looks like a transaction is still in progress, then maybe this is an inner transaction
|
120
|
+
# and is ignored.
|
121
|
+
#
|
122
|
+
def end_transaction
|
123
|
+
elapsed = GCProfiler.capture
|
124
|
+
if @transaction_sampler && @transaction_sampler.last_sample
|
125
|
+
@transaction_sampler.last_sample.params[:custom_params] ||= {}
|
126
|
+
@transaction_sampler.last_sample.params[:custom_params][:gc_time] = elapsed
|
127
|
+
end
|
128
|
+
stack = scope_stack
|
129
|
+
|
130
|
+
if stack && stack.empty?
|
131
|
+
Thread::current[:newrelic_scope_stack] = nil
|
132
|
+
Thread::current[:newrelic_scope_name] = nil
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
# Returns the current scope stack, memoized to a thread local variable
|
139
|
+
def scope_stack
|
140
|
+
Thread::current[:newrelic_scope_stack] ||= []
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
|
4
|
+
class AgentThread < ::Thread
|
5
|
+
def initialize(label)
|
6
|
+
::NewRelic::Agent.logger.debug("Creating New Relic thread: #{label}")
|
7
|
+
self[:newrelic_label] = label
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.bucket_thread(thread, profile_agent_code)
|
12
|
+
if thread.key?(:newrelic_label)
|
13
|
+
return profile_agent_code ? :agent : :ignore
|
14
|
+
elsif !thread[:newrelic_metric_frame].nil?
|
15
|
+
thread[:newrelic_metric_frame].request.nil? ? :background : :request
|
16
|
+
else
|
17
|
+
:other
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.scrub_backtrace(thread, profile_agent_code)
|
22
|
+
begin
|
23
|
+
bt = thread.backtrace
|
24
|
+
rescue Exception => e
|
25
|
+
::NewRelic::Agent.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}")
|
26
|
+
end
|
27
|
+
return nil unless bt
|
28
|
+
profile_agent_code ? bt : bt.select { |t| t !~ /\/newrelic_rpm-\d/ }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,319 @@
|
|
1
|
+
require 'new_relic/agent/thread'
|
2
|
+
require 'new_relic/agent/worker_loop'
|
3
|
+
|
4
|
+
module NewRelic
|
5
|
+
module Agent
|
6
|
+
|
7
|
+
class ThreadProfiler
|
8
|
+
|
9
|
+
attr_reader :profile
|
10
|
+
|
11
|
+
def self.is_supported?
|
12
|
+
RUBY_VERSION >= "1.9.2"
|
13
|
+
end
|
14
|
+
|
15
|
+
def start(profile_id, duration, interval, profile_agent_code)
|
16
|
+
if !ThreadProfiler.is_supported?
|
17
|
+
::NewRelic::Agent.logger.debug("Not starting thread profile as it isn't supported on this environment")
|
18
|
+
@profile = nil
|
19
|
+
else
|
20
|
+
::NewRelic::Agent.logger.debug("Starting thread profile. profile_id=#{profile_id}, duration=#{duration}")
|
21
|
+
@profile = ThreadProfile.new(profile_id, duration, interval, profile_agent_code)
|
22
|
+
@profile.run
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def stop(report_data)
|
27
|
+
@profile.stop unless @profile.nil?
|
28
|
+
@profile = nil if !report_data
|
29
|
+
end
|
30
|
+
|
31
|
+
def harvest
|
32
|
+
profile = @profile
|
33
|
+
@profile = nil
|
34
|
+
profile
|
35
|
+
end
|
36
|
+
|
37
|
+
def respond_to_commands(commands, ¬ify_results)
|
38
|
+
return if commands.empty? || commands.first.size < 2
|
39
|
+
|
40
|
+
# Doesn't deal with multiple commands in the return set as
|
41
|
+
# we currently only have start/stop of thread profiling
|
42
|
+
command_id = commands.first[0]
|
43
|
+
command = commands.first[1]
|
44
|
+
|
45
|
+
name = command["name"]
|
46
|
+
arguments = command["arguments"]
|
47
|
+
|
48
|
+
if (ThreadProfiler.is_supported?)
|
49
|
+
case name
|
50
|
+
when "start_profiler"
|
51
|
+
start_unless_running_and_notify(command_id, arguments, ¬ify_results)
|
52
|
+
|
53
|
+
when "stop_profiler"
|
54
|
+
stop_and_notify(command_id, arguments, ¬ify_results)
|
55
|
+
end
|
56
|
+
else
|
57
|
+
msg = <<-EOF
|
58
|
+
Thread profiling is only supported on 1.9.2 and greater versions of Ruby.
|
59
|
+
We detected running agents capable of profiling, but the profile started with
|
60
|
+
an agent running Ruby #{RUBY_VERSION}.
|
61
|
+
|
62
|
+
Profiling again might select an appropriate agent, but we recommend running a
|
63
|
+
consistent version of Ruby across your application for better results.
|
64
|
+
EOF
|
65
|
+
::NewRelic::Agent.logger.debug(msg)
|
66
|
+
notify_results.call(command_id, msg) if !notify_results.nil?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def running?
|
71
|
+
!@profile.nil?
|
72
|
+
end
|
73
|
+
|
74
|
+
def finished?
|
75
|
+
@profile && @profile.finished?
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def start_unless_running_and_notify(command_id, arguments)
|
81
|
+
profile_id = arguments.fetch("profile_id", -1)
|
82
|
+
duration = arguments.fetch("duration", 120)
|
83
|
+
interval = arguments.fetch("sample_period", 0.1)
|
84
|
+
profile_agent_code = arguments.fetch("profile_agent_code", true)
|
85
|
+
|
86
|
+
if running?
|
87
|
+
msg = "Profile already in progress. Ignoring agent command to start another."
|
88
|
+
::NewRelic::Agent.logger.debug(msg)
|
89
|
+
yield(command_id, msg) if block_given?
|
90
|
+
else
|
91
|
+
start(profile_id, duration, interval, profile_agent_code)
|
92
|
+
yield(command_id) if block_given?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def stop_and_notify(command_id, arguments)
|
97
|
+
report_data = arguments.fetch("report_data", true)
|
98
|
+
stop(report_data)
|
99
|
+
yield(command_id) if block_given?
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
class ThreadProfile
|
105
|
+
|
106
|
+
attr_reader :profile_id,
|
107
|
+
:traces,
|
108
|
+
:profile_agent_code, :interval,
|
109
|
+
:poll_count, :sample_count,
|
110
|
+
:start_time, :stop_time
|
111
|
+
|
112
|
+
def initialize(profile_id, duration, interval, profile_agent_code)
|
113
|
+
@profile_id = profile_id
|
114
|
+
@profile_agent_code = profile_agent_code
|
115
|
+
|
116
|
+
@worker_loop = NewRelic::Agent::WorkerLoop.new(:duration => duration)
|
117
|
+
@interval = interval
|
118
|
+
@finished = false
|
119
|
+
|
120
|
+
@traces = {
|
121
|
+
:agent => [],
|
122
|
+
:background => [],
|
123
|
+
:other => [],
|
124
|
+
:request => []
|
125
|
+
}
|
126
|
+
@flattened_nodes = []
|
127
|
+
|
128
|
+
@poll_count = 0
|
129
|
+
@sample_count = 0
|
130
|
+
@failure_count = 0
|
131
|
+
end
|
132
|
+
|
133
|
+
def run
|
134
|
+
AgentThread.new('Thread Profiler') do
|
135
|
+
@start_time = now_in_millis
|
136
|
+
|
137
|
+
@worker_loop.run(@interval) do
|
138
|
+
NewRelic::Agent.instance.stats_engine.
|
139
|
+
record_supportability_metrics_timed("ThreadProfiler/PollingTime") do
|
140
|
+
|
141
|
+
@poll_count += 1
|
142
|
+
AgentThread.list.each do |t|
|
143
|
+
bucket = AgentThread.bucket_thread(t, @profile_agent_code)
|
144
|
+
if bucket != :ignore
|
145
|
+
backtrace = AgentThread.scrub_backtrace(t, @profile_agent_code)
|
146
|
+
if backtrace.nil?
|
147
|
+
@failure_count += 1
|
148
|
+
else
|
149
|
+
@sample_count += 1
|
150
|
+
aggregate(backtrace, @traces[bucket])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
mark_done
|
158
|
+
::NewRelic::Agent.logger.debug("Finished thread profile. #{@sample_count} backtraces, #{@failure_count} failures. Will send with next harvest.")
|
159
|
+
NewRelic::Agent.instance.stats_engine.
|
160
|
+
record_supportability_metrics_count(@failure_count, "ThreadProfiler/BacktraceFailures")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def stop
|
165
|
+
@worker_loop.stop
|
166
|
+
mark_done
|
167
|
+
::NewRelic::Agent.logger.debug("Stopping thread profile.")
|
168
|
+
end
|
169
|
+
|
170
|
+
def aggregate(trace, trees=@traces[:request], parent=nil)
|
171
|
+
return nil if trace.nil? || trace.empty?
|
172
|
+
node = Node.new(trace.last)
|
173
|
+
existing = trees.find {|n| n == node}
|
174
|
+
|
175
|
+
if existing.nil?
|
176
|
+
existing = node
|
177
|
+
@flattened_nodes << node
|
178
|
+
end
|
179
|
+
|
180
|
+
if parent
|
181
|
+
parent.add_child(node)
|
182
|
+
else
|
183
|
+
trees << node unless trees.include? node
|
184
|
+
end
|
185
|
+
|
186
|
+
existing.runnable_count += 1
|
187
|
+
aggregate(trace[0..-2], existing.children, existing)
|
188
|
+
|
189
|
+
existing
|
190
|
+
end
|
191
|
+
|
192
|
+
def prune!(count_to_keep)
|
193
|
+
@flattened_nodes.sort!(&:order_for_pruning)
|
194
|
+
|
195
|
+
NewRelic::Agent.instance.stats_engine.
|
196
|
+
record_supportability_metrics_count(@flattened_nodes.size, "ThreadProfiler/NodeCount")
|
197
|
+
|
198
|
+
mark_for_pruning(@flattened_nodes, count_to_keep)
|
199
|
+
|
200
|
+
traces.each { |_, nodes| Node.prune!(nodes) }
|
201
|
+
end
|
202
|
+
|
203
|
+
THREAD_PROFILER_NODES = 20_000
|
204
|
+
|
205
|
+
include NewRelic::Coerce
|
206
|
+
|
207
|
+
def to_collector_array(encoder)
|
208
|
+
prune!(THREAD_PROFILER_NODES)
|
209
|
+
|
210
|
+
traces = {
|
211
|
+
"OTHER" => @traces[:other].map{|t| t.to_array },
|
212
|
+
"REQUEST" => @traces[:request].map{|t| t.to_array },
|
213
|
+
"AGENT" => @traces[:agent].map{|t| t.to_array },
|
214
|
+
"BACKGROUND" => @traces[:background].map{|t| t.to_array }
|
215
|
+
}
|
216
|
+
|
217
|
+
[[
|
218
|
+
int(@profile_id),
|
219
|
+
float(@start_time),
|
220
|
+
float(@stop_time),
|
221
|
+
int(@poll_count),
|
222
|
+
string(encoder.encode(traces)),
|
223
|
+
int(@sample_count),
|
224
|
+
0
|
225
|
+
]]
|
226
|
+
end
|
227
|
+
|
228
|
+
def now_in_millis
|
229
|
+
Time.now.to_f * 1_000
|
230
|
+
end
|
231
|
+
|
232
|
+
def finished?
|
233
|
+
@finished
|
234
|
+
end
|
235
|
+
|
236
|
+
def mark_done
|
237
|
+
@finished = true
|
238
|
+
@stop_time = now_in_millis
|
239
|
+
end
|
240
|
+
|
241
|
+
def mark_for_pruning(nodes, count_to_keep)
|
242
|
+
to_prune = nodes[count_to_keep..-1] || []
|
243
|
+
to_prune.each { |n| n.to_prune = true }
|
244
|
+
end
|
245
|
+
|
246
|
+
def self.flattened_nodes(nodes)
|
247
|
+
nodes.map { |n| [n, flattened_nodes(n.children)] }.flatten
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.parse_backtrace(trace)
|
251
|
+
trace.map do |line|
|
252
|
+
line =~ /(.*)\:(\d+)\:in `(.*)'/
|
253
|
+
{ :method => $3, :line_no => $2.to_i, :file => $1 }
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
class Node
|
258
|
+
attr_reader :file, :method, :line_no, :children
|
259
|
+
attr_accessor :runnable_count, :to_prune, :depth
|
260
|
+
|
261
|
+
def initialize(line, parent=nil)
|
262
|
+
line =~ /(.*)\:(\d+)\:in `(.*)'/
|
263
|
+
@file = $1
|
264
|
+
@method = $3
|
265
|
+
@line_no = $2.to_i
|
266
|
+
@children = []
|
267
|
+
@runnable_count = 0
|
268
|
+
@to_prune = false
|
269
|
+
@depth = 0
|
270
|
+
|
271
|
+
parent.add_child(self) if parent
|
272
|
+
end
|
273
|
+
|
274
|
+
def ==(other)
|
275
|
+
@file == other.file &&
|
276
|
+
@method == other.method &&
|
277
|
+
@line_no == other.line_no
|
278
|
+
end
|
279
|
+
|
280
|
+
def total_count
|
281
|
+
@runnable_count
|
282
|
+
end
|
283
|
+
|
284
|
+
# Descending order on count, ascending on depth of nodes
|
285
|
+
def order_for_pruning(y)
|
286
|
+
[-runnable_count, depth] <=> [-y.runnable_count, y.depth]
|
287
|
+
end
|
288
|
+
|
289
|
+
include NewRelic::Coerce
|
290
|
+
|
291
|
+
def to_array
|
292
|
+
[[
|
293
|
+
string(@file),
|
294
|
+
string(@method),
|
295
|
+
int(@line_no)
|
296
|
+
],
|
297
|
+
int(@runnable_count),
|
298
|
+
0,
|
299
|
+
@children.map {|c| c.to_array}]
|
300
|
+
end
|
301
|
+
|
302
|
+
def add_child(child)
|
303
|
+
child.depth = @depth + 1
|
304
|
+
@children << child unless @children.include? child
|
305
|
+
end
|
306
|
+
|
307
|
+
def prune!
|
308
|
+
Node.prune!(@children)
|
309
|
+
end
|
310
|
+
|
311
|
+
def self.prune!(kids)
|
312
|
+
kids.delete_if { |child| child.to_prune }
|
313
|
+
kids.each { |child| child.prune! }
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|