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,11 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Configuration
|
4
|
+
MASK_DEFAULTS = {
|
5
|
+
:'thread_profiler' => Proc.new { !NewRelic::Agent::ThreadProfiler.is_supported? },
|
6
|
+
:'thread_profiler.enabled' => Proc.new { !NewRelic::Agent::ThreadProfiler.is_supported? },
|
7
|
+
:verify_certificate => Proc.new{ true }
|
8
|
+
}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Configuration
|
4
|
+
class ServerSource < DottedHash
|
5
|
+
def initialize(hash)
|
6
|
+
if hash['agent_config']
|
7
|
+
if hash['agent_config']['transaction_tracer.transaction_threshold'] =~ /apdex_f/i
|
8
|
+
# when value is "apdex_f" remove the config and defer to default
|
9
|
+
hash['agent_config'].delete('transaction_tracer.transaction_threshold')
|
10
|
+
end
|
11
|
+
super(hash.delete('agent_config'))
|
12
|
+
end
|
13
|
+
|
14
|
+
string_map = [
|
15
|
+
['collect_traces', 'transaction_tracer.enabled'],
|
16
|
+
['collect_traces', 'slow_sql.enabled'],
|
17
|
+
['collect_errors', 'error_collector.enabled']
|
18
|
+
].each do |pair|
|
19
|
+
hash[pair[1]] = hash[pair[0]] if hash[pair[0]] != nil
|
20
|
+
end
|
21
|
+
|
22
|
+
if hash['web_transactions_apdex']
|
23
|
+
self[:web_transactions_apdex] = hash.delete('web_transactions_apdex')
|
24
|
+
end
|
25
|
+
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'new_relic/agent/configuration'
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
module Agent
|
5
|
+
module Configuration
|
6
|
+
class YamlSource < DottedHash
|
7
|
+
attr_accessor :file_path
|
8
|
+
|
9
|
+
def initialize(path, env)
|
10
|
+
::NewRelic::Agent.logger.debug("Reading configuration from #{path}")
|
11
|
+
|
12
|
+
config = {}
|
13
|
+
begin
|
14
|
+
@file_path = File.expand_path(path)
|
15
|
+
if !File.exists?(@file_path)
|
16
|
+
::NewRelic::Agent.logger.error("Unable to load configuration from #{path}")
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
file = File.read(@file_path)
|
21
|
+
|
22
|
+
# Next two are for populating the newrelic.yml via erb binding, necessary
|
23
|
+
# when using the default newrelic.yml file
|
24
|
+
generated_for_user = ''
|
25
|
+
license_key = ''
|
26
|
+
|
27
|
+
erb = ERB.new(file).result(binding)
|
28
|
+
confighash = YAML.load(erb)
|
29
|
+
::NewRelic::Agent.logger.error("Config (#{path}) doesn't include a '#{env}' environment!") unless
|
30
|
+
confighash.key?(env)
|
31
|
+
|
32
|
+
config = merge!(confighash[env] || {})
|
33
|
+
rescue ScriptError, StandardError => e
|
34
|
+
::NewRelic::Agent.logger.error("Unable to read configuration file #{path}: #{e}")
|
35
|
+
end
|
36
|
+
|
37
|
+
if config['transaction_tracer'] &&
|
38
|
+
config['transaction_tracer']['transaction_threshold'] =~ /apdex_f/i
|
39
|
+
# when value is "apdex_f" remove the config and defer to default
|
40
|
+
config['transaction_tracer'].delete('transaction_threshold')
|
41
|
+
end
|
42
|
+
|
43
|
+
booleanify_values(config, 'agent_enabled', 'enabled', 'monitor_daemons')
|
44
|
+
|
45
|
+
super(config)
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def booleanify_values(config, *keys)
|
51
|
+
# auto means defer ro default
|
52
|
+
keys.each do |option|
|
53
|
+
if config[option] == 'auto'
|
54
|
+
config.delete(option)
|
55
|
+
elsif !config[option].nil? && !is_boolean?(config[option])
|
56
|
+
config[option] = !!(config[option] =~ /yes|on|true/i)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def is_boolean?(value)
|
62
|
+
value == !!value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'new_relic/rack/agent_hooks'
|
2
|
+
require 'new_relic/agent/thread'
|
3
|
+
|
4
|
+
module NewRelic
|
5
|
+
module Agent
|
6
|
+
|
7
|
+
class CrossAppMonitor
|
8
|
+
|
9
|
+
NEWRELIC_ID_HEADER = 'X-NewRelic-ID'
|
10
|
+
NEWRELIC_APPDATA_HEADER = 'X-NewRelic-App-Data'
|
11
|
+
NEWRELIC_TXN_HEADER = 'X-NewRelic-Transaction'
|
12
|
+
NEWRELIC_TXN_HEADER_KEYS = %W{
|
13
|
+
#{NEWRELIC_TXN_HEADER} HTTP_X_NEWRELIC_TRANSACTION X_NEWRELIC_TRANSACTION
|
14
|
+
}
|
15
|
+
NEWRELIC_ID_HEADER_KEYS = %W{
|
16
|
+
#{NEWRELIC_ID_HEADER} HTTP_X_NEWRELIC_ID X_NEWRELIC_ID
|
17
|
+
}
|
18
|
+
CONTENT_LENGTH_HEADER_KEYS = %w{Content-Length HTTP_CONTENT_LENGTH CONTENT_LENGTH}
|
19
|
+
|
20
|
+
# Because we aren't in the right spot when our transaction actually
|
21
|
+
# starts, hold client_cross_app_id we get thread local until then.
|
22
|
+
THREAD_ID_KEY = :newrelic_client_cross_app_id
|
23
|
+
|
24
|
+
# Same for the referring transaction guid
|
25
|
+
THREAD_TXN_KEY = :newrelic_cross_app_referring_txn_info
|
26
|
+
|
27
|
+
|
28
|
+
# Functions for obfuscating and unobfuscating header values
|
29
|
+
module EncodingFunctions
|
30
|
+
|
31
|
+
module_function
|
32
|
+
|
33
|
+
def obfuscate_with_key(key, text)
|
34
|
+
[ encode_with_key(key, text) ].pack('m').chomp.gsub(/\n/, '')
|
35
|
+
end
|
36
|
+
|
37
|
+
def decode_with_key(key, text)
|
38
|
+
encode_with_key( key, text.unpack('m').first )
|
39
|
+
end
|
40
|
+
|
41
|
+
def encode_with_key(key, text)
|
42
|
+
return text unless key
|
43
|
+
key = key.bytes.to_a if key.respond_to?( :bytes )
|
44
|
+
|
45
|
+
encoded = ""
|
46
|
+
index = 0
|
47
|
+
text.each_byte do |byte|
|
48
|
+
encoded.concat((byte ^ key[index % key.length].to_i))
|
49
|
+
index+=1
|
50
|
+
end
|
51
|
+
encoded
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
include EncodingFunctions
|
56
|
+
|
57
|
+
|
58
|
+
def initialize(events = nil)
|
59
|
+
# When we're starting up for real in the agent, we get passed the events
|
60
|
+
# Other spots can pull from the agent, during startup the agent doesn't exist yet!
|
61
|
+
events ||= Agent.instance.events
|
62
|
+
|
63
|
+
events.subscribe(:finished_configuring) do
|
64
|
+
register_event_listeners
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
# Expected sequence of events:
|
70
|
+
# :before_call will save our cross application request id to the thread
|
71
|
+
# :start_transaction will get called when a transaction starts up
|
72
|
+
# :after_call will write our response headers/metrics and clean up the thread
|
73
|
+
def register_event_listeners
|
74
|
+
NewRelic::Agent.logger.
|
75
|
+
debug("Wiring up Cross Application Tracing to events after finished configuring")
|
76
|
+
|
77
|
+
events = Agent.instance.events
|
78
|
+
events.subscribe(:before_call) do |env|
|
79
|
+
if should_process_request(env)
|
80
|
+
save_client_cross_app_id(env)
|
81
|
+
save_referring_transaction_info(env)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
events.subscribe(:start_transaction) do |name|
|
86
|
+
set_transaction_custom_parameters
|
87
|
+
end
|
88
|
+
|
89
|
+
events.subscribe(:after_call) do |env, (status_code, headers, body)|
|
90
|
+
insert_response_header(env, headers)
|
91
|
+
end
|
92
|
+
|
93
|
+
events.subscribe(:notice_error) do |_, options|
|
94
|
+
set_error_custom_parameters(options)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def save_client_cross_app_id(request_headers)
|
99
|
+
NewRelic::Agent::AgentThread.current[THREAD_ID_KEY] = decoded_id(request_headers)
|
100
|
+
end
|
101
|
+
|
102
|
+
def clear_client_cross_app_id
|
103
|
+
NewRelic::Agent::AgentThread.current[THREAD_ID_KEY] = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
def client_cross_app_id
|
107
|
+
NewRelic::Agent::AgentThread.current[THREAD_ID_KEY]
|
108
|
+
end
|
109
|
+
|
110
|
+
def save_referring_transaction_info(request_headers)
|
111
|
+
key = NewRelic::Agent.config[:encoding_key]
|
112
|
+
txn_header = from_headers( request_headers, NEWRELIC_TXN_HEADER_KEYS ) or return
|
113
|
+
txn_header = decode_with_key( key, txn_header )
|
114
|
+
txn_info = NewRelic.json_load( txn_header )
|
115
|
+
NewRelic::Agent.logger.debug "Referring txn_info: %p" % [ txn_info ]
|
116
|
+
|
117
|
+
NewRelic::Agent::AgentThread.current[THREAD_TXN_KEY] = txn_info
|
118
|
+
end
|
119
|
+
|
120
|
+
def clear_referring_transaction_info
|
121
|
+
NewRelic::Agent::AgentThread.current[THREAD_TXN_KEY] = nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def client_referring_transaction_guid
|
125
|
+
info = NewRelic::Agent::AgentThread.current[THREAD_TXN_KEY] or return nil
|
126
|
+
return info[0]
|
127
|
+
end
|
128
|
+
|
129
|
+
def client_referring_transaction_record_flag
|
130
|
+
info = NewRelic::Agent::AgentThread.current[THREAD_TXN_KEY] or return nil
|
131
|
+
return info[1]
|
132
|
+
end
|
133
|
+
|
134
|
+
def insert_response_header(request_headers, response_headers)
|
135
|
+
unless client_cross_app_id.nil?
|
136
|
+
timings = NewRelic::Agent::BrowserMonitoring.timings
|
137
|
+
content_length = content_length_from_request(request_headers)
|
138
|
+
|
139
|
+
set_response_headers(response_headers, timings, content_length)
|
140
|
+
set_metrics(client_cross_app_id, timings)
|
141
|
+
|
142
|
+
clear_client_cross_app_id
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def should_process_request(request_headers)
|
147
|
+
return cross_app_enabled? && trusts?(request_headers)
|
148
|
+
end
|
149
|
+
|
150
|
+
def cross_app_enabled?
|
151
|
+
NewRelic::Agent.config[:cross_process_id] &&
|
152
|
+
(NewRelic::Agent.config[:"cross_application_tracer.enabled"] ||
|
153
|
+
NewRelic::Agent.config[:cross_application_tracing])
|
154
|
+
end
|
155
|
+
|
156
|
+
# Expects an ID of format "12#345", and will only accept that!
|
157
|
+
def trusts?(request)
|
158
|
+
id = decoded_id(request)
|
159
|
+
split_id = id.match(/(\d+)#\d+/)
|
160
|
+
return false if split_id.nil?
|
161
|
+
|
162
|
+
NewRelic::Agent.config[:trusted_account_ids].include?(split_id.captures.first.to_i)
|
163
|
+
end
|
164
|
+
|
165
|
+
def set_response_headers(response_headers, timings, content_length)
|
166
|
+
response_headers[NEWRELIC_APPDATA_HEADER] = build_payload(timings, content_length)
|
167
|
+
end
|
168
|
+
|
169
|
+
def build_payload(timings, content_length)
|
170
|
+
|
171
|
+
# FIXME The transaction name might not be properly encoded. use a json generator
|
172
|
+
# For now we just handle quote characters by dropping them
|
173
|
+
transaction_name = timings.transaction_name.gsub(/["']/, "")
|
174
|
+
|
175
|
+
payload = [
|
176
|
+
NewRelic::Agent.config[:cross_process_id],
|
177
|
+
transaction_name,
|
178
|
+
timings.queue_time_in_seconds.to_f,
|
179
|
+
timings.app_time_in_seconds.to_f,
|
180
|
+
content_length,
|
181
|
+
transaction_guid()
|
182
|
+
]
|
183
|
+
key = NewRelic::Agent.config[:encoding_key]
|
184
|
+
payload = obfuscate_with_key( key, NewRelic.json_dump(payload) )
|
185
|
+
end
|
186
|
+
|
187
|
+
def set_transaction_custom_parameters
|
188
|
+
# We expect to get the before call to set the id (if we have it) before
|
189
|
+
# this, and then write our custom parameter when the transaction starts
|
190
|
+
NewRelic::Agent.add_custom_parameters(:client_cross_process_id => client_cross_app_id()) if client_cross_app_id()
|
191
|
+
NewRelic::Agent.add_custom_parameters(:referring_transaction_guid => client_referring_transaction_guid()) if
|
192
|
+
client_referring_transaction_guid()
|
193
|
+
|
194
|
+
NewRelic::Agent.logger.debug "Referring transaction guid: %p" % [client_referring_transaction_guid()]
|
195
|
+
end
|
196
|
+
|
197
|
+
def set_error_custom_parameters(options)
|
198
|
+
options[:client_cross_process_id] = client_cross_app_id() if client_cross_app_id()
|
199
|
+
# [MG] TODO: Should the CAT metrics be set here too?
|
200
|
+
end
|
201
|
+
|
202
|
+
def set_metrics(id, timings)
|
203
|
+
metric = NewRelic::Agent.instance.stats_engine.get_stats_no_scope("ClientApplication/#{id}/all")
|
204
|
+
metric.record_data_point(timings.app_time_in_seconds)
|
205
|
+
end
|
206
|
+
|
207
|
+
def decoded_id(request)
|
208
|
+
encoded_id = from_headers(request, NEWRELIC_ID_HEADER_KEYS)
|
209
|
+
return "" if encoded_id.nil?
|
210
|
+
|
211
|
+
key = NewRelic::Agent.config[:encoding_key]
|
212
|
+
decode_with_key( key, encoded_id )
|
213
|
+
end
|
214
|
+
|
215
|
+
def content_length_from_request(request)
|
216
|
+
from_headers(request, CONTENT_LENGTH_HEADER_KEYS) || -1
|
217
|
+
end
|
218
|
+
|
219
|
+
def transaction_guid
|
220
|
+
NewRelic::Agent::TransactionInfo.get.guid
|
221
|
+
end
|
222
|
+
|
223
|
+
private
|
224
|
+
|
225
|
+
def from_headers(request, try_keys)
|
226
|
+
# For lookups, upcase all our keys on both sides just to be safe
|
227
|
+
upcased_keys = try_keys.map{|k| k.upcase}
|
228
|
+
upcased_keys.each do |header|
|
229
|
+
found_key = request.keys.find { |k| k.upcase == header }
|
230
|
+
return request[found_key] unless found_key.nil?
|
231
|
+
end
|
232
|
+
nil
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
@@ -0,0 +1,281 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
3
|
+
|
4
|
+
module NewRelic
|
5
|
+
module Agent
|
6
|
+
module CrossAppTracing
|
7
|
+
extend NewRelic::Agent::CrossAppMonitor::EncodingFunctions
|
8
|
+
|
9
|
+
# Exception raised if there is a problem with cross app transactions.
|
10
|
+
class Error < RuntimeError; end
|
11
|
+
|
12
|
+
|
13
|
+
# The cross app response header for "outgoing" calls
|
14
|
+
NR_APPDATA_HEADER = 'X-NewRelic-App-Data'
|
15
|
+
|
16
|
+
# The cross app id header for "outgoing" calls
|
17
|
+
NR_ID_HEADER = 'X-NewRelic-ID'
|
18
|
+
|
19
|
+
# The cross app transaction header for "outgoing" calls
|
20
|
+
NR_TXN_HEADER = 'X-NewRelic-Transaction'
|
21
|
+
|
22
|
+
# The index of the transaction GUID in the appdata header of responses
|
23
|
+
APPDATA_TXN_GUID_INDEX = 5
|
24
|
+
|
25
|
+
|
26
|
+
###############
|
27
|
+
module_function
|
28
|
+
###############
|
29
|
+
|
30
|
+
# Send the given +request+, adding metrics appropriate to the
|
31
|
+
# response when it comes back.
|
32
|
+
def trace_http_request( http, request )
|
33
|
+
return yield unless NewRelic::Agent.is_execution_traced?
|
34
|
+
|
35
|
+
t0, segment = start_trace( http, request )
|
36
|
+
begin
|
37
|
+
response = yield
|
38
|
+
ensure
|
39
|
+
finish_trace( t0, segment, request, response, http ) if t0
|
40
|
+
end
|
41
|
+
|
42
|
+
return response
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# Set up the necessary state for cross-application tracing before the
|
47
|
+
# given +request+ goes out on the specified +http+ connection.
|
48
|
+
def start_trace( http, request )
|
49
|
+
inject_request_headers( request ) if cross_app_enabled?
|
50
|
+
|
51
|
+
# Create a segment and time the call
|
52
|
+
t0 = Time.now
|
53
|
+
segment = stats_engine.push_scope( "External/#{http.address}/all", t0 )
|
54
|
+
|
55
|
+
return t0, segment
|
56
|
+
rescue => err
|
57
|
+
NewRelic::Agent.logger.error "Uncaught exception while tracing HTTP request", err
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Finish tracing the HTTP +request+ that started at +t0+ with the information in
|
63
|
+
# +response+ and the given +http+ connection.
|
64
|
+
def finish_trace( t0, segment, request, response, http )
|
65
|
+
t1 = Time.now
|
66
|
+
duration = t1.to_f - t0.to_f
|
67
|
+
|
68
|
+
begin
|
69
|
+
if request && response && http
|
70
|
+
# Figure out which metrics we need to report based on the request and response
|
71
|
+
# The last (most-specific) one is scoped.
|
72
|
+
metrics = metrics_for( http, request, response )
|
73
|
+
scoped_metric = metrics.pop
|
74
|
+
|
75
|
+
# Report the metrics
|
76
|
+
metrics.each { |metric| get_metric(metric).trace_call(duration) }
|
77
|
+
get_scoped_metric( scoped_metric ).trace_call( duration )
|
78
|
+
|
79
|
+
# Add TT custom parameters
|
80
|
+
stats_engine.rename_scope_segment( scoped_metric )
|
81
|
+
extract_custom_parameters( response ) if response_is_crossapp?( response )
|
82
|
+
end
|
83
|
+
ensure
|
84
|
+
# We always need to pop the scope stack to avoid an inconsistent
|
85
|
+
# state, which will prevent tracing of the whole transaction.
|
86
|
+
stats_engine.pop_scope( segment, duration, t1 )
|
87
|
+
end
|
88
|
+
rescue NewRelic::Agent::CrossAppTracing::Error => err
|
89
|
+
NewRelic::Agent.logger.debug "while cross app tracing", err
|
90
|
+
rescue => err
|
91
|
+
NewRelic::Agent.logger.error "Uncaught exception while finishing an HTTP request trace", err
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
# Return +true+ if cross app tracing is enabled in the config.
|
96
|
+
def cross_app_enabled?
|
97
|
+
NewRelic::Agent.config[:cross_process_id] &&
|
98
|
+
(NewRelic::Agent.config[:"cross_application_tracer.enabled"] ||
|
99
|
+
NewRelic::Agent.config[:cross_application_tracing])
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
# Memoized fetcher for the cross app encoding key. Raises a
|
104
|
+
# NewRelic::Agent::CrossAppTracing::Error if the key isn't configured.
|
105
|
+
def cross_app_encoding_key
|
106
|
+
NewRelic::Agent.config[:encoding_key] or
|
107
|
+
raise NewRelic::Agent::CrossAppTracing::Error, "No encoding_key set."
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# Inject the X-Process header into the outgoing +request+.
|
112
|
+
def inject_request_headers( request )
|
113
|
+
key = cross_app_encoding_key()
|
114
|
+
cross_app_id = NewRelic::Agent.config[:cross_process_id] or
|
115
|
+
raise NewRelic::Agent::CrossAppTracing::Error, "no cross app ID configured"
|
116
|
+
txn_guid = NewRelic::Agent::TransactionInfo.get.guid
|
117
|
+
txn_data = NewRelic.json_dump([ txn_guid, false ])
|
118
|
+
|
119
|
+
request[ NR_ID_HEADER ] = obfuscate_with_key( key, cross_app_id )
|
120
|
+
request[ NR_TXN_HEADER ] = obfuscate_with_key( key, txn_data )
|
121
|
+
|
122
|
+
rescue NewRelic::Agent::CrossAppTracing::Error => err
|
123
|
+
NewRelic::Agent.logger.debug "Not injecting x-process header", err
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# Extract any custom parameters from +response+ if it's cross-application and
|
128
|
+
# add them to the current TT node.
|
129
|
+
def extract_custom_parameters( response )
|
130
|
+
|
131
|
+
appdata = extract_appdata( response )
|
132
|
+
sampler = NewRelic::Agent.instance.transaction_sampler
|
133
|
+
sampler.add_segment_parameters( :transaction_guid => appdata[APPDATA_TXN_GUID_INDEX] )
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# Return the set of metrics (NewRelic::MethodTraceStats objects) that correspond to
|
139
|
+
# the given +request+ and +response+.
|
140
|
+
def metrics_for( http, request, response )
|
141
|
+
metrics = common_metrics( http )
|
142
|
+
|
143
|
+
if response_is_crossapp?( response )
|
144
|
+
begin
|
145
|
+
metrics.concat metrics_for_crossapp_response( http, response )
|
146
|
+
rescue => err
|
147
|
+
# Fall back to regular metrics if there's a problem with x-process metrics
|
148
|
+
NewRelic::Agent.logger.debug "%p while fetching x-process metrics: %s" %
|
149
|
+
[ err.class, err.message ]
|
150
|
+
metrics.concat metrics_for_regular_response( http, request, response )
|
151
|
+
end
|
152
|
+
else
|
153
|
+
NewRelic::Agent.logger.debug "Response doesn't have CAT headers."
|
154
|
+
metrics.concat metrics_for_regular_response( http, request, response )
|
155
|
+
end
|
156
|
+
|
157
|
+
return metrics
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
# Return an Array of metrics used for every response.
|
162
|
+
def common_metrics( http )
|
163
|
+
metrics = [ "External/all" ]
|
164
|
+
metrics << "External/#{http.address}/all"
|
165
|
+
|
166
|
+
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
|
167
|
+
metrics << "External/allWeb"
|
168
|
+
else
|
169
|
+
metrics << "External/allOther"
|
170
|
+
end
|
171
|
+
|
172
|
+
return metrics
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# Returns +true+ if Cross Application Tracing is enabled, and the given +response+
|
177
|
+
# has the appropriate headers.
|
178
|
+
def response_is_crossapp?( response )
|
179
|
+
return false unless cross_app_enabled?
|
180
|
+
unless response[NR_APPDATA_HEADER]
|
181
|
+
NewRelic::Agent.logger.debug "Response doesn't have the %p header: %p" %
|
182
|
+
[ NR_APPDATA_HEADER, response.to_hash ]
|
183
|
+
return false
|
184
|
+
end
|
185
|
+
|
186
|
+
return true
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
# Return the set of metric objects appropriate for the given cross app
|
191
|
+
# +response+.
|
192
|
+
def metrics_for_crossapp_response( http, response )
|
193
|
+
xp_id, txn_name, q_time, r_time, req_len, _ = extract_appdata( response )
|
194
|
+
|
195
|
+
check_crossapp_id( xp_id )
|
196
|
+
check_transaction_name( txn_name )
|
197
|
+
|
198
|
+
NewRelic::Agent.logger.debug "CAT xp_id: %p, txn_name: %p." % [ xp_id, txn_name ]
|
199
|
+
|
200
|
+
metrics = []
|
201
|
+
metrics << "ExternalApp/#{http.address}/#{xp_id}/all"
|
202
|
+
metrics << "ExternalTransaction/#{http.address}/#{xp_id}/#{txn_name}"
|
203
|
+
|
204
|
+
return metrics
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
# Extract x-process application data from the specified +response+ and return
|
209
|
+
# it as an array of the form:
|
210
|
+
#
|
211
|
+
# [
|
212
|
+
# <cross app ID>,
|
213
|
+
# <transaction name>,
|
214
|
+
# <queue time in seconds>,
|
215
|
+
# <response time in seconds>,
|
216
|
+
# <request content length in bytes>,
|
217
|
+
# <transaction GUID>
|
218
|
+
# ]
|
219
|
+
def extract_appdata( response )
|
220
|
+
appdata = response[NR_APPDATA_HEADER] or
|
221
|
+
raise NewRelic::Agent::CrossAppTracing::Error,
|
222
|
+
"Can't derive metrics for response: no #{NR_APPDATA_HEADER} header!"
|
223
|
+
|
224
|
+
key = cross_app_encoding_key()
|
225
|
+
decoded_appdata = decode_with_key( key, appdata )
|
226
|
+
decoded_appdata.set_encoding( ::Encoding::UTF_8 ) if
|
227
|
+
decoded_appdata.respond_to?( :set_encoding )
|
228
|
+
|
229
|
+
return NewRelic.json_load( decoded_appdata )
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# Return the set of metric objects appropriate for the given (non-cross app)
|
234
|
+
# +response+.
|
235
|
+
def metrics_for_regular_response( http, request, response )
|
236
|
+
metrics = []
|
237
|
+
metrics << "External/#{http.address}/Net::HTTP/#{request.method}"
|
238
|
+
|
239
|
+
return metrics
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
# Convenience function for fetching the metric associated with +metric_name+.
|
244
|
+
def get_metric( metric_name )
|
245
|
+
stats_engine.get_stats_no_scope( metric_name )
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
# Convenience function for fetching the scoped metric associated with +metric_name+.
|
250
|
+
def get_scoped_metric( metric_name )
|
251
|
+
# Default is to use the metric_name itself as the scope, which is what we want
|
252
|
+
stats_engine.get_stats( metric_name )
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
# Fetch a reference to the stats engine.
|
257
|
+
def stats_engine
|
258
|
+
NewRelic::Agent.instance.stats_engine
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
# Check the given +id+ to ensure it conforms to the format of a cross-application
|
263
|
+
# ID. Raises an NewRelic::Agent::CrossAppTracing::Error if it doesn't.
|
264
|
+
def check_crossapp_id( id )
|
265
|
+
id =~ /\A\d+#\d+\z/ or
|
266
|
+
raise NewRelic::Agent::CrossAppTracing::Error,
|
267
|
+
"malformed cross application ID %p" % [ id ]
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
# Check the given +name+ to ensure it conforms to the format of a valid transaction
|
272
|
+
# name.
|
273
|
+
def check_transaction_name( name )
|
274
|
+
# No-op -- apparently absolutely anything is a valid transaction name?
|
275
|
+
# This is here for when that inevitably comes back to haunt us.
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|