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,254 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
# columns for a mysql explain plan
|
5
|
+
MYSQL_EXPLAIN_COLUMNS = [
|
6
|
+
"Id",
|
7
|
+
"Select Type",
|
8
|
+
"Table",
|
9
|
+
"Type",
|
10
|
+
"Possible Keys",
|
11
|
+
"Key",
|
12
|
+
"Key Length",
|
13
|
+
"Ref",
|
14
|
+
"Rows",
|
15
|
+
"Extra"
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
module Agent
|
19
|
+
module Database
|
20
|
+
extend self
|
21
|
+
|
22
|
+
def obfuscate_sql(sql)
|
23
|
+
Obfuscator.instance.obfuscator.call(sql)
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_sql_obfuscator(type, &block)
|
27
|
+
Obfuscator.instance.set_sql_obfuscator(type, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def record_sql_method
|
31
|
+
case Agent.config[:'transaction_tracer.record_sql'].to_s
|
32
|
+
when 'off'
|
33
|
+
:off
|
34
|
+
when 'none'
|
35
|
+
:off
|
36
|
+
when 'false'
|
37
|
+
:off
|
38
|
+
when 'raw'
|
39
|
+
:raw
|
40
|
+
else
|
41
|
+
:obfuscated
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_connection(config)
|
46
|
+
ConnectionManager.instance.get_connection(config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def close_connections
|
50
|
+
ConnectionManager.instance.close_connections
|
51
|
+
end
|
52
|
+
|
53
|
+
# Perform this in the runtime environment of a managed
|
54
|
+
# application, to explain the sql statement executed within a
|
55
|
+
# segment of a transaction sample. Returns an array of
|
56
|
+
# explanations (which is an array rows consisting of an array of
|
57
|
+
# strings for each column returned by the the explain query)
|
58
|
+
# Note this happens only for statements whose execution time
|
59
|
+
# exceeds a threshold (e.g. 500ms) and only within the slowest
|
60
|
+
# transaction in a report period, selected for shipment to New
|
61
|
+
# Relic
|
62
|
+
def explain_sql(sql, connection_config)
|
63
|
+
return nil unless sql && connection_config
|
64
|
+
statement = sql.split(";\n")[0] # only explain the first
|
65
|
+
explain_plan = explain_statement(statement, connection_config)
|
66
|
+
return explain_plan || []
|
67
|
+
end
|
68
|
+
|
69
|
+
def explain_statement(statement, config)
|
70
|
+
return unless is_select?(statement)
|
71
|
+
|
72
|
+
if statement[-3,3] == '...'
|
73
|
+
NewRelic::Agent.logger.debug('Unable to collect explain plan for truncated query.')
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
if parameterized?(statement)
|
78
|
+
NewRelic::Agent.logger.debug('Unable to collect explain plan for parameterized query.')
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
handle_exception_in_explain do
|
83
|
+
connection = get_connection(config)
|
84
|
+
plan = nil
|
85
|
+
if connection
|
86
|
+
plan = process_resultset(connection.execute("EXPLAIN #{statement}"))
|
87
|
+
end
|
88
|
+
return plan
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def process_resultset(items)
|
93
|
+
# The resultset type varies for different drivers. Only thing you can count on is
|
94
|
+
# that it implements each. Also: can't use select_rows because the native postgres
|
95
|
+
# driver doesn't know that method.
|
96
|
+
|
97
|
+
headers = []
|
98
|
+
values = []
|
99
|
+
if items.respond_to?(:each_hash)
|
100
|
+
items.each_hash do |row|
|
101
|
+
headers = row.keys
|
102
|
+
values << headers.map{|h| row[h] }
|
103
|
+
end
|
104
|
+
elsif items.respond_to?(:each)
|
105
|
+
items.each do |row|
|
106
|
+
if row.kind_of?(Hash)
|
107
|
+
headers = row.keys
|
108
|
+
values << headers.map{|h| row[h] }
|
109
|
+
else
|
110
|
+
values << row
|
111
|
+
end
|
112
|
+
end
|
113
|
+
else
|
114
|
+
values = [items]
|
115
|
+
end
|
116
|
+
|
117
|
+
headers = nil if headers.empty?
|
118
|
+
[headers, values]
|
119
|
+
end
|
120
|
+
|
121
|
+
def handle_exception_in_explain
|
122
|
+
yield
|
123
|
+
rescue => e
|
124
|
+
begin
|
125
|
+
# guarantees no throw from explain_sql
|
126
|
+
::NewRelic::Agent.logger.error("Error getting query plan:", e)
|
127
|
+
rescue
|
128
|
+
# double exception. throw up your hands
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def is_select?(statement)
|
133
|
+
# split the string into at most two segments on the
|
134
|
+
# system-defined field separator character
|
135
|
+
first_word, rest_of_statement = statement.split($;, 2)
|
136
|
+
(first_word.upcase == 'SELECT')
|
137
|
+
end
|
138
|
+
|
139
|
+
def parameterized?(statement)
|
140
|
+
Obfuscator.instance.obfuscate_single_quote_literals(statement) =~ /\$\d+/
|
141
|
+
end
|
142
|
+
|
143
|
+
class ConnectionManager
|
144
|
+
include Singleton
|
145
|
+
|
146
|
+
# Returns a cached connection for a given ActiveRecord
|
147
|
+
# configuration - these are stored or reopened as needed, and if
|
148
|
+
# we cannot get one, we ignore it and move on without explaining
|
149
|
+
# the sql
|
150
|
+
def get_connection(config)
|
151
|
+
@connections ||= {}
|
152
|
+
|
153
|
+
connection = @connections[config]
|
154
|
+
|
155
|
+
return connection if connection
|
156
|
+
|
157
|
+
begin
|
158
|
+
connection = ActiveRecord::Base.send("#{config[:adapter]}_connection", config)
|
159
|
+
@connections[config] = connection
|
160
|
+
rescue => e
|
161
|
+
::NewRelic::Agent.logger.error("Caught exception trying to get connection to DB for explain. Control: #{config}", e)
|
162
|
+
nil
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Closes all the connections in the internal connection cache
|
167
|
+
def close_connections
|
168
|
+
@connections ||= {}
|
169
|
+
@connections.values.each do |connection|
|
170
|
+
begin
|
171
|
+
connection.disconnect!
|
172
|
+
rescue
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
@connections = {}
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class Obfuscator
|
181
|
+
include Singleton
|
182
|
+
|
183
|
+
attr_reader :obfuscator
|
184
|
+
|
185
|
+
def initialize
|
186
|
+
reset
|
187
|
+
end
|
188
|
+
|
189
|
+
def reset
|
190
|
+
@obfuscator = method(:default_sql_obfuscator)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Sets the sql obfuscator used to clean up sql when sending it
|
194
|
+
# to the server. Possible types are:
|
195
|
+
#
|
196
|
+
# :before => sets the block to run before the existing
|
197
|
+
# obfuscators
|
198
|
+
#
|
199
|
+
# :after => sets the block to run after the existing
|
200
|
+
# obfuscator(s)
|
201
|
+
#
|
202
|
+
# :replace => removes the current obfuscator and replaces it
|
203
|
+
# with the provided block
|
204
|
+
def set_sql_obfuscator(type, &block)
|
205
|
+
if type == :before
|
206
|
+
@obfuscator = NewRelic::ChainedCall.new(block, @obfuscator)
|
207
|
+
elsif type == :after
|
208
|
+
@obfuscator = NewRelic::ChainedCall.new(@obfuscator, block)
|
209
|
+
elsif type == :replace
|
210
|
+
@obfuscator = block
|
211
|
+
else
|
212
|
+
fail "unknown sql_obfuscator type #{type}"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def default_sql_obfuscator(sql)
|
217
|
+
if sql[-3,3] == '...'
|
218
|
+
return "Query too large (over 16k characters) to safely obfuscate"
|
219
|
+
end
|
220
|
+
|
221
|
+
stmt = sql.kind_of?(Statement) ? sql : Statement.new(sql)
|
222
|
+
adapter = stmt.adapter
|
223
|
+
obfuscated = remove_escaped_quotes(stmt)
|
224
|
+
obfuscated = obfuscate_single_quote_literals(obfuscated)
|
225
|
+
if !(adapter.to_s =~ /postgres/ || adapter.to_s =~ /sqlite/)
|
226
|
+
obfuscated = obfuscate_double_quote_literals(obfuscated)
|
227
|
+
end
|
228
|
+
obfuscated = obfuscate_numeric_literals(obfuscated)
|
229
|
+
obfuscated.to_s # return back to a regular String
|
230
|
+
end
|
231
|
+
|
232
|
+
def remove_escaped_quotes(sql)
|
233
|
+
sql.gsub(/\\"/, '').gsub(/\\'/, '')
|
234
|
+
end
|
235
|
+
|
236
|
+
def obfuscate_single_quote_literals(sql)
|
237
|
+
sql.gsub(/'(?:[^']|'')*'/, '?')
|
238
|
+
end
|
239
|
+
|
240
|
+
def obfuscate_double_quote_literals(sql)
|
241
|
+
sql.gsub(/"(?:[^"]|"")*"/, '?')
|
242
|
+
end
|
243
|
+
|
244
|
+
def obfuscate_numeric_literals(sql)
|
245
|
+
sql.gsub(/\b\d+\b/, "?")
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
class Statement < String
|
250
|
+
attr_accessor :adapter
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
@@ -0,0 +1,266 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
# This class collects errors from the parent application, storing
|
4
|
+
# them until they are harvested and transmitted to the server
|
5
|
+
class ErrorCollector
|
6
|
+
include NewRelic::CollectionHelper
|
7
|
+
|
8
|
+
# Defined the methods that need to be stubbed out when the
|
9
|
+
# agent is disabled
|
10
|
+
module Shim #:nodoc:
|
11
|
+
def notice_error(*args); end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Maximum possible length of the queue - defaults to 20, may be
|
15
|
+
# made configurable in the future. This is a tradeoff between
|
16
|
+
# memory and data retention
|
17
|
+
MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
|
18
|
+
|
19
|
+
attr_accessor :errors
|
20
|
+
|
21
|
+
# Returns a new error collector
|
22
|
+
def initialize
|
23
|
+
@errors = []
|
24
|
+
@seen_error_ids = []
|
25
|
+
|
26
|
+
# lookup of exception class names to ignore. Hash for fast access
|
27
|
+
@ignore = {}
|
28
|
+
@capture_source = Agent.config[:'error_collector.capture_source']
|
29
|
+
|
30
|
+
initialize_ignored_errors(Agent.config[:'error_collector.ignore_errors'])
|
31
|
+
@lock = Mutex.new
|
32
|
+
|
33
|
+
Agent.config.register_callback(:'error_collector.enabled') do |config_enabled|
|
34
|
+
::NewRelic::Agent.logger.debug "Errors will #{config_enabled ? '' : 'not '}be sent to the New Relic service."
|
35
|
+
end
|
36
|
+
Agent.config.register_callback(:'error_collector.ignore_errors') do |ignore_errors|
|
37
|
+
initialize_ignored_errors(ignore_errors)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize_ignored_errors(ignore_errors)
|
42
|
+
@ignore.clear
|
43
|
+
ignore_errors = ignore_errors.split(",") if ignore_errors.is_a? String
|
44
|
+
ignore_errors.each { |error| error.strip! }
|
45
|
+
ignore(ignore_errors)
|
46
|
+
end
|
47
|
+
|
48
|
+
def enabled?
|
49
|
+
Agent.config[:'error_collector.enabled']
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the error filter proc that is used to check if an
|
53
|
+
# error should be reported. When given a block, resets the
|
54
|
+
# filter to the provided block. The define_method() is used to
|
55
|
+
# wrap the block in a lambda so return statements don't result in a
|
56
|
+
# LocalJump exception.
|
57
|
+
def ignore_error_filter(&block)
|
58
|
+
if block
|
59
|
+
self.class.class_eval { define_method(:ignore_filter_proc, &block) }
|
60
|
+
@ignore_filter = method(:ignore_filter_proc)
|
61
|
+
else
|
62
|
+
@ignore_filter
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# errors is an array of Exception Class Names
|
67
|
+
#
|
68
|
+
def ignore(errors)
|
69
|
+
errors.each do |error|
|
70
|
+
@ignore[error] = true
|
71
|
+
::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}'")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# This module was extracted from the notice_error method - it is
|
76
|
+
# internally tested and can be refactored without major issues.
|
77
|
+
module NoticeError
|
78
|
+
# Checks the provided error against the error filter, if there
|
79
|
+
# is an error filter
|
80
|
+
def filtered_by_error_filter?(error)
|
81
|
+
return unless @ignore_filter
|
82
|
+
!@ignore_filter.call(error)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Checks the array of error names and the error filter against
|
86
|
+
# the provided error
|
87
|
+
def filtered_error?(error)
|
88
|
+
@ignore[error.class.name] || filtered_by_error_filter?(error)
|
89
|
+
end
|
90
|
+
|
91
|
+
# an error is ignored if it is nil or if it is filtered
|
92
|
+
def error_is_ignored?(error)
|
93
|
+
error && filtered_error?(error)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Increments a statistic that tracks total error rate
|
97
|
+
# Be sure not to double-count same exception. This clears per harvest.
|
98
|
+
def increment_error_count!(exception)
|
99
|
+
return if @seen_error_ids.include?(exception.object_id)
|
100
|
+
@seen_error_ids << exception.object_id
|
101
|
+
|
102
|
+
NewRelic::Agent.get_stats("Errors/all").increment_count
|
103
|
+
|
104
|
+
txn_info = NewRelic::Agent::TransactionInfo.get
|
105
|
+
if (txn_info.transaction_name_set?)
|
106
|
+
NewRelic::Agent.get_stats("Errors/#{txn_info.transaction_name}").increment_count
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# whether we should return early from the notice_error process
|
111
|
+
# - based on whether the error is ignored or the error
|
112
|
+
# collector is disabled
|
113
|
+
def should_exit_notice_error?(exception)
|
114
|
+
if enabled?
|
115
|
+
if !error_is_ignored?(exception)
|
116
|
+
increment_error_count!(exception)
|
117
|
+
return exception.nil? # exit early if the exception is nil
|
118
|
+
end
|
119
|
+
end
|
120
|
+
# disabled or an ignored error, per above
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
# acts just like Hash#fetch, but deletes the key from the hash
|
125
|
+
def fetch_from_options(options, key, default=nil)
|
126
|
+
options.delete(key) || default
|
127
|
+
end
|
128
|
+
|
129
|
+
# returns some basic option defaults pulled from the provided
|
130
|
+
# options hash
|
131
|
+
def uri_ref_and_root(options)
|
132
|
+
{
|
133
|
+
:request_uri => fetch_from_options(options, :uri, ''),
|
134
|
+
:request_referer => fetch_from_options(options, :referer, ''),
|
135
|
+
:rails_root => NewRelic::Control.instance.root
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
# If anything else is left over, we treat it like a custom param
|
140
|
+
def custom_params_from_opts(options)
|
141
|
+
# If anything else is left over, treat it like a custom param:
|
142
|
+
fetch_from_options(options, :custom_params, {}).merge(options)
|
143
|
+
end
|
144
|
+
|
145
|
+
# takes the request parameters out of the options hash, and
|
146
|
+
# returns them if we are capturing parameters, otherwise
|
147
|
+
# returns nil
|
148
|
+
def request_params_from_opts(options)
|
149
|
+
value = options.delete(:request_params)
|
150
|
+
if Agent.config[:capture_params]
|
151
|
+
value
|
152
|
+
else
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# normalizes the request and custom parameters before attaching
|
158
|
+
# them to the error. See NewRelic::CollectionHelper#normalize_params
|
159
|
+
def normalized_request_and_custom_params(options)
|
160
|
+
{
|
161
|
+
:request_params => normalize_params(request_params_from_opts(options)),
|
162
|
+
:custom_params => normalize_params(custom_params_from_opts(options))
|
163
|
+
}
|
164
|
+
end
|
165
|
+
|
166
|
+
# Merges together many of the options into something that can
|
167
|
+
# actually be attached to the error
|
168
|
+
def error_params_from_options(options)
|
169
|
+
uri_ref_and_root(options).merge(normalized_request_and_custom_params(options))
|
170
|
+
end
|
171
|
+
|
172
|
+
# calls a method on an object, if it responds to it - used for
|
173
|
+
# detection and soft fail-safe. Returns nil if the method does
|
174
|
+
# not exist
|
175
|
+
def sense_method(object, method)
|
176
|
+
object.send(method) if object.respond_to?(method)
|
177
|
+
end
|
178
|
+
|
179
|
+
# extracts source from the exception, if the exception supports
|
180
|
+
# that method
|
181
|
+
def extract_source(exception)
|
182
|
+
sense_method(exception, 'source_extract') if @capture_source
|
183
|
+
end
|
184
|
+
|
185
|
+
# extracts a stack trace from the exception for debugging purposes
|
186
|
+
def extract_stack_trace(exception)
|
187
|
+
actual_exception = sense_method(exception, 'original_exception') || exception
|
188
|
+
sense_method(actual_exception, 'backtrace') || '<no stack trace>'
|
189
|
+
end
|
190
|
+
|
191
|
+
# extracts a bunch of information from the exception to include
|
192
|
+
# in the noticed error - some may or may not be available, but
|
193
|
+
# we try to include all of it
|
194
|
+
def exception_info(exception)
|
195
|
+
{
|
196
|
+
:file_name => sense_method(exception, 'file_name'),
|
197
|
+
:line_number => sense_method(exception, 'line_number'),
|
198
|
+
:source => extract_source(exception),
|
199
|
+
:stack_trace => extract_stack_trace(exception)
|
200
|
+
}
|
201
|
+
end
|
202
|
+
|
203
|
+
# checks the size of the error queue to make sure we are under
|
204
|
+
# the maximum limit, and logs a warning if we are over the limit.
|
205
|
+
def over_queue_limit?(message)
|
206
|
+
over_limit = (@errors.length >= MAX_ERROR_QUEUE_LENGTH)
|
207
|
+
::NewRelic::Agent.logger.warn("The error reporting queue has reached #{MAX_ERROR_QUEUE_LENGTH}. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: #{message}") if over_limit
|
208
|
+
over_limit
|
209
|
+
end
|
210
|
+
|
211
|
+
# Synchronizes adding an error to the error queue, and checks if
|
212
|
+
# the error queue is too long - if so, we drop the error on the
|
213
|
+
# floor after logging a warning.
|
214
|
+
def add_to_error_queue(noticed_error)
|
215
|
+
@lock.synchronize do
|
216
|
+
if !over_queue_limit?(noticed_error.message) && !@errors.include?(noticed_error)
|
217
|
+
@errors << noticed_error
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
include NoticeError
|
224
|
+
|
225
|
+
|
226
|
+
# Notice the error with the given available options:
|
227
|
+
#
|
228
|
+
# * <tt>:uri</tt> => The request path, minus any request params or query string.
|
229
|
+
# * <tt>:referer</tt> => The URI of the referer
|
230
|
+
# * <tt>:metric</tt> => The metric name associated with the transaction
|
231
|
+
# * <tt>:request_params</tt> => Request parameters, already filtered if necessary
|
232
|
+
# * <tt>:custom_params</tt> => Custom parameters
|
233
|
+
#
|
234
|
+
# If anything is left over, it's added to custom params
|
235
|
+
# If exception is nil, the error count is bumped and no traced error is recorded
|
236
|
+
def notice_error(exception, options={})
|
237
|
+
return if should_exit_notice_error?(exception)
|
238
|
+
NewRelic::Agent.instance.events.notify(:notice_error, exception, options)
|
239
|
+
action_path = fetch_from_options(options, :metric, (NewRelic::Agent.instance.stats_engine.scope_name || ''))
|
240
|
+
exception_options = error_params_from_options(options).merge(exception_info(exception))
|
241
|
+
add_to_error_queue(NewRelic::NoticedError.new(action_path, exception_options, exception))
|
242
|
+
exception
|
243
|
+
rescue => e
|
244
|
+
::NewRelic::Agent.logger.warn("Failure when capturing error '#{exception}':", e)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Get the errors currently queued up. Unsent errors are left
|
248
|
+
# over from a previous unsuccessful attempt to send them to the server.
|
249
|
+
def harvest_errors(unsent_errors)
|
250
|
+
@lock.synchronize do
|
251
|
+
errors = @errors
|
252
|
+
@errors = []
|
253
|
+
|
254
|
+
# Only expect to re-see errors on same request, so clear on harvest
|
255
|
+
@seen_error_ids = []
|
256
|
+
|
257
|
+
if unsent_errors && !unsent_errors.empty?
|
258
|
+
errors = unsent_errors + errors
|
259
|
+
end
|
260
|
+
|
261
|
+
errors
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|