newrelic_rpm 3.7.2.195 → 3.7.3.199
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +25 -1
- data/Rakefile +7 -0
- data/lib/new_relic/agent/agent.rb +19 -13
- data/lib/new_relic/agent/configuration/default_source.rb +23 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +2 -0
- data/lib/new_relic/agent/database.rb +123 -94
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +37 -0
- data/lib/new_relic/agent/database/obfuscator.rb +65 -0
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +49 -0
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +2 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +9 -8
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -38
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +26 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +3 -2
- data/lib/new_relic/agent/pipe_channel_manager.rb +45 -12
- data/lib/new_relic/agent/pipe_service.rb +14 -8
- data/lib/new_relic/agent/request_sampler.rb +63 -6
- data/lib/new_relic/agent/sampler_collection.rb +5 -2
- data/lib/new_relic/agent/shim_agent.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +41 -22
- data/lib/new_relic/agent/transaction_sample_builder.rb +0 -4
- data/lib/new_relic/agent/transaction_sampler.rb +2 -5
- data/lib/new_relic/agent/transaction_state.rb +43 -11
- data/lib/new_relic/agent/vm.rb +32 -0
- data/lib/new_relic/agent/vm/jruby_vm.rb +40 -0
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +36 -0
- data/lib/new_relic/agent/vm/mri_vm.rb +86 -0
- data/lib/new_relic/agent/vm/rubinius_vm.rb +40 -0
- data/lib/new_relic/agent/vm/snapshot.rb +16 -0
- data/lib/new_relic/control.rb +0 -6
- data/lib/new_relic/language_support.rb +20 -0
- data/lib/new_relic/latest_changes.rb +41 -12
- data/lib/new_relic/rack/developer_mode.rb +8 -1
- data/lib/new_relic/rack/transaction_reset.rb +1 -1
- data/lib/new_relic/transaction_sample.rb +0 -13
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +5 -0
- data/newrelic_rpm.gemspec +2 -1
- data/test/active_record_fixtures.rb +7 -9
- data/test/agent_helper.rb +11 -50
- data/test/environments/lib/environments/runner.rb +3 -5
- data/test/environments/rails40/Gemfile +12 -3
- data/test/environments/rails41/Gemfile +34 -0
- data/test/environments/rails41/Rakefile +11 -0
- data/test/environments/rails41/config/application.rb +18 -0
- data/test/environments/rails41/config/boot.rb +10 -0
- data/test/environments/rails41/config/database.yml +26 -0
- data/test/environments/rails41/config/environment.rb +6 -0
- data/test/environments/rails41/db/schema.rb +5 -0
- data/test/fixtures/cross_agent_tests/README.md +12 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/basic_where.colon_obfuscated.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/basic_where.explain.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/basic_where.obfuscated.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/basic_where.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/current_date.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/current_date.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/current_date.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/current_date.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/date.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/date.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/date.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/date.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_newline.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_newline.explain.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_newline.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_newline.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_quote.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_quote.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_quote.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/embedded_quote.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/floating_point.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/floating_point.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/floating_point.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/floating_point.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/function_with_strings.colon_obfuscated.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/function_with_strings.explain.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/function_with_strings.obfuscated.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/function_with_strings.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/quote_in_table_name.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/quote_in_table_name.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/quote_in_table_name.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/quote_in_table_name.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/subplan.colon_obfuscated.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/subplan.explain.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/subplan.obfuscated.txt +5 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/subplan.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_integer.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_integer.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_integer.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_integer.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_regex_chars.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_regex_chars.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_regex_chars.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_regex_chars.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_substring.colon_obfuscated.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_substring.explain.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_substring.obfuscated.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/where_with_substring.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case1.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case1.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case1.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case1.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case2.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case2.explain.txt +3 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case2.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case2.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case3.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case3.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case3.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case3.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case4.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case4.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case4.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case4.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case5.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case5.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case5.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case5.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case6.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case6.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case6.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case6.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case7.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case7.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case7.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case7.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case8.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case8.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case8.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case8.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case9.colon_obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case9.explain.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case9.obfuscated.txt +2 -0
- data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/with_escape_case9.query.txt +1 -0
- data/test/fixtures/cross_agent_tests/rules.json +165 -0
- data/test/fixtures/cross_agent_tests/rum_client_config.json +142 -0
- data/test/fixtures/cross_agent_tests/rum_cookie.json +17 -0
- data/test/fixtures/cross_agent_tests/rum_footer_insertion_location/close-body-in-comment.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_footer_insertion_location/dynamic-iframe.html +19 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/basic.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/body_with_attributes.html +3 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/charset_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/charset_tag_after_x_ua_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/charset_tag_before_x_ua_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/charset_tag_with_spaces.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/comments1.html +24 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/comments2.html +24 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/content_type_charset_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/content_type_charset_tag_after_x_ua_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/content_type_charset_tag_before_x_ua_tag.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/gt_in_quotes1.html +27 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/gt_in_quotes2.html +24 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/gt_in_quotes_mismatch.html +24 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/gt_in_single_quotes1.html +25 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/gt_in_single_quotes_mismatch.html +25 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/head_with_attributes.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/incomplete_non_meta_tags.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/no_header.html +7 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/no_html_and_no_header.html +3 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/no_start_header.html +9 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/script1.html +19 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/script2.html +17 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag_multiline.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag_spaces_around_equals.html +10 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag_with_others.html +11 -0
- data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag_with_spaces.html +10 -0
- data/test/fixtures/cross_agent_tests/sql_parsing.json +55 -0
- data/test/fixtures/cross_agent_tests/url_clean.json +15 -0
- data/test/fixtures/cross_agent_tests/url_domain_extraction.json +35 -0
- data/test/flaky_proxy/README.md +91 -33
- data/test/flaky_proxy/lib/flaky_proxy.rb +1 -0
- data/test/flaky_proxy/lib/flaky_proxy/http_message.rb +2 -0
- data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +19 -4
- data/test/flaky_proxy/lib/flaky_proxy/rule.rb +13 -16
- data/test/flaky_proxy/lib/flaky_proxy/rule_set.rb +10 -2
- data/test/flaky_proxy/lib/flaky_proxy/sequence.rb +14 -0
- data/test/helpers/file_searching.rb +1 -1
- data/test/intentional_fail.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +26 -3
- data/test/multiverse/suites/active_record/Envfile +1 -1
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +1 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -1
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -1
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +1 -1
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +1 -1
- data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +1 -1
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +1 -1
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +1 -1
- data/test/multiverse/suites/agent_only/ssl_test.rb +1 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +1 -1
- data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +1 -1
- data/test/multiverse/suites/curb/curb_test.rb +1 -1
- data/test/multiverse/suites/datamapper/datamapper_test.rb +1 -1
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/httpclient/httpclient_test.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +7 -3
- data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +2 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +1 -1
- data/test/multiverse/suites/padrino/Envfile +1 -1
- data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
- data/test/multiverse/suites/rails/Envfile +10 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +59 -6
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +1 -0
- data/test/multiverse/suites/resque/instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +5 -18
- data/test/multiverse/suites/sequel/sequel_safety_test.rb +1 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sinatra/ignoring_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +1 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +36 -2
- data/test/new_relic/FAKECHANGELOG +21 -0
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
- data/test/new_relic/agent/agent_logger_test.rb +1 -1
- data/test/new_relic/agent/agent_test.rb +14 -8
- data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
- data/test/new_relic/agent/audit_logger_test.rb +1 -1
- data/test/new_relic/agent/autostart_test.rb +1 -1
- data/test/new_relic/agent/browser_token_test.rb +1 -1
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/commands/agent_command_router_test.rb +1 -1
- data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +2 -2
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
- data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
- data/test/new_relic/agent/configuration/default_source_test.rb +1 -1
- data/test/new_relic/agent/configuration/environment_source_test.rb +1 -1
- data/test/new_relic/agent/configuration/manager_test.rb +1 -1
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +1 -1
- data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
- data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
- data/test/new_relic/agent/cross_app_tracing_test.rb +1 -1
- data/test/new_relic/agent/database/postgres_explain_obfuscator_test.rb +34 -0
- data/test/new_relic/agent/database_test.rb +192 -5
- data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +11 -1
- data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +1 -1
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +1 -1
- data/test/new_relic/agent/event_listener_test.rb +1 -1
- data/test/new_relic/agent/harvester_test.rb +1 -1
- data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -4
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/active_record_test.rb +385 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/javascript_instrumentor_test.rb +3 -3
- data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/memory_logger_test.rb +1 -1
- data/test/new_relic/agent/method_interrobang_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_visibility_test.rb +1 -1
- data/test/new_relic/agent/new_relic_service_test.rb +2 -2
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +216 -143
- data/test/new_relic/agent/pipe_service_test.rb +26 -15
- data/test/new_relic/agent/request_sampler_test.rb +65 -18
- data/test/new_relic/agent/rpm_agent_test.rb +1 -1
- data/test/new_relic/agent/rules_engine_test.rb +1 -1
- data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
- data/test/new_relic/agent/sampler_collection_test.rb +8 -1
- data/test/new_relic/agent/sampler_test.rb +1 -1
- data/test/new_relic/agent/shim_agent_test.rb +3 -3
- data/test/new_relic/agent/sql_sampler_test.rb +7 -6
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/samplers_test.rb +1 -1
- data/test/new_relic/agent/stats_engine_test.rb +1 -1
- data/test/new_relic/agent/stats_hash_test.rb +1 -1
- data/test/new_relic/agent/stats_test.rb +1 -1
- data/test/new_relic/agent/threading/agent_thread_test.rb +1 -1
- data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
- data/test/new_relic/agent/threading/backtrace_service_test.rb +3 -3
- data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/pop_test.rb +1 -1
- data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -1
- data/test/new_relic/agent/transaction_sampler_test.rb +17 -17
- data/test/new_relic/agent/transaction_state_test.rb +61 -6
- data/test/new_relic/agent/transaction_test.rb +60 -3
- data/test/new_relic/agent/transaction_timings_test.rb +1 -1
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +42 -0
- data/test/new_relic/agent/vm/mri_vm_test.rb +35 -0
- data/test/new_relic/agent/vm/snapshot_test.rb +8 -0
- data/test/new_relic/agent/vm_test.rb +48 -0
- data/test/new_relic/agent/worker_loop_test.rb +1 -1
- data/test/new_relic/agent_test.rb +1 -1
- data/test/new_relic/cli/deployments_test.rb +1 -1
- data/test/new_relic/coerce_test.rb +1 -1
- data/test/new_relic/collection_helper_test.rb +1 -1
- data/test/new_relic/control/class_methods_test.rb +1 -1
- data/test/new_relic/control/frameworks/rails_test.rb +1 -1
- data/test/new_relic/control_test.rb +1 -1
- data/test/new_relic/dependency_detection_test.rb +1 -1
- data/test/new_relic/dispatcher_test.rb +1 -1
- data/test/new_relic/environment_report_test.rb +1 -1
- data/test/new_relic/framework_test.rb +1 -1
- data/test/new_relic/http_client_test_cases.rb +1 -1
- data/test/new_relic/json_wrapper_test.rb +1 -1
- data/test/new_relic/language_support_test.rb +42 -1
- data/test/new_relic/latest_changes_test.rb +45 -0
- data/test/new_relic/license_test.rb +2 -2
- data/test/new_relic/load_test.rb +1 -1
- data/test/new_relic/local_environment_test.rb +1 -1
- data/test/new_relic/metric_data_test.rb +1 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
- data/test/new_relic/metric_spec_test.rb +1 -1
- data/test/new_relic/multiverse_helpers.rb +0 -27
- data/test/new_relic/noticed_error_test.rb +1 -1
- data/test/new_relic/rack/agent_hooks_test.rb +1 -1
- data/test/new_relic/rack/all_test.rb +1 -1
- data/test/new_relic/rack/browser_monitoring_test.rb +2 -2
- data/test/new_relic/rack/deferred_instrumentation_test.rb +1 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
- data/test/new_relic/rack/developer_mode_test.rb +2 -19
- data/test/new_relic/rack/error_collector_test.rb +1 -1
- data/test/new_relic/rack/transaction_reset_test.rb +1 -1
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +1 -1
- data/test/new_relic/transaction_analysis_test.rb +1 -1
- data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample/segment_test.rb +2 -2
- data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
- data/test/new_relic/transaction_sample_test.rb +3 -3
- data/test/new_relic/version_number_test.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +33 -0
- data/test/performance/lib/performance/platform.rb +1 -0
- data/test/performance/suites/marshalling.rb +2 -1
- data/test/test_helper.rb +33 -3
- data/ui/views/newrelic/index.rhtml +2 -2
- metadata +169 -31
- metadata.gz.sig +0 -0
- data/lib/new_relic/control/profiling.rb +0 -29
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +0 -648
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'new_relic/agent/database/obfuscation_helpers'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
module Database
|
10
|
+
class Obfuscator
|
11
|
+
include Singleton
|
12
|
+
include ObfuscationHelpers
|
13
|
+
|
14
|
+
attr_reader :obfuscator
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
reset
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset
|
21
|
+
@obfuscator = method(:default_sql_obfuscator)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Sets the sql obfuscator used to clean up sql when sending it
|
25
|
+
# to the server. Possible types are:
|
26
|
+
#
|
27
|
+
# :before => sets the block to run before the existing
|
28
|
+
# obfuscators
|
29
|
+
#
|
30
|
+
# :after => sets the block to run after the existing
|
31
|
+
# obfuscator(s)
|
32
|
+
#
|
33
|
+
# :replace => removes the current obfuscator and replaces it
|
34
|
+
# with the provided block
|
35
|
+
def set_sql_obfuscator(type, &block)
|
36
|
+
if type == :before
|
37
|
+
@obfuscator = NewRelic::ChainedCall.new(block, @obfuscator)
|
38
|
+
elsif type == :after
|
39
|
+
@obfuscator = NewRelic::ChainedCall.new(@obfuscator, block)
|
40
|
+
elsif type == :replace
|
41
|
+
@obfuscator = block
|
42
|
+
else
|
43
|
+
fail "unknown sql_obfuscator type #{type}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_sql_obfuscator(sql)
|
48
|
+
if sql[-3,3] == '...'
|
49
|
+
return "Query too large (over 16k characters) to safely obfuscate"
|
50
|
+
end
|
51
|
+
|
52
|
+
stmt = sql.kind_of?(Statement) ? sql : Statement.new(sql)
|
53
|
+
adapter = stmt.adapter
|
54
|
+
obfuscated = remove_escaped_quotes(stmt)
|
55
|
+
obfuscated = obfuscate_single_quote_literals(obfuscated)
|
56
|
+
if !(adapter.to_s =~ /postgres/ || adapter.to_s =~ /sqlite/)
|
57
|
+
obfuscated = obfuscate_double_quote_literals(obfuscated)
|
58
|
+
end
|
59
|
+
obfuscated = obfuscate_numeric_literals(obfuscated)
|
60
|
+
obfuscated.to_s # return back to a regular String
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'new_relic/agent/database'
|
6
|
+
require 'new_relic/agent/database/obfuscation_helpers'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Database
|
11
|
+
module PostgresExplainObfuscator
|
12
|
+
extend self
|
13
|
+
|
14
|
+
extend ObfuscationHelpers
|
15
|
+
|
16
|
+
SINGLE_OR_DOUBLE_QUOTES = Regexp.new([
|
17
|
+
ObfuscationHelpers::SINGLE_QUOTES.source,
|
18
|
+
ObfuscationHelpers::DOUBLE_QUOTES.source
|
19
|
+
].join('|')).freeze
|
20
|
+
LABEL_LINE_REGEX = /^([^:\n]*:\s+).*$/.freeze
|
21
|
+
|
22
|
+
def obfuscate(explain)
|
23
|
+
# First, we replace all single-quoted strings.
|
24
|
+
# This is necessary in order to deal with multi-line string constants
|
25
|
+
# embedded in the explain output.
|
26
|
+
#
|
27
|
+
# Note that we look for both single or double quotes but do not
|
28
|
+
# replace double quotes in order to avoid accidentally latching onto a
|
29
|
+
# single quote character embedded within a quoted identifier (such as
|
30
|
+
# a table name).
|
31
|
+
#
|
32
|
+
# Note also that we make no special provisions for backslash-escaped
|
33
|
+
# single quotes (\') because these are canonicalized to two single
|
34
|
+
# quotes ('') in the explain output.
|
35
|
+
explain.gsub!(SINGLE_OR_DOUBLE_QUOTES) do |match|
|
36
|
+
match.start_with?('"') ? match : '?'
|
37
|
+
end
|
38
|
+
|
39
|
+
# Now, mask anything after the first colon (:).
|
40
|
+
# All parts of the query that can appear in the explain output are
|
41
|
+
# prefixed with "<label>: ", so we want to preserve the label, but
|
42
|
+
# remove the rest of the line.
|
43
|
+
explain.gsub!(LABEL_LINE_REGEX, '\1?')
|
44
|
+
explain
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -52,7 +52,8 @@ module NewRelic
|
|
52
52
|
def self.build_metrics(name, collection, request_type = :web)
|
53
53
|
default_metrics = [
|
54
54
|
"Datastore/statement/MongoDB/#{collection}/#{name}",
|
55
|
-
"Datastore/operation/MongoDB/#{name}"
|
55
|
+
"Datastore/operation/MongoDB/#{name}",
|
56
|
+
"Datastore/all"
|
56
57
|
]
|
57
58
|
|
58
59
|
if request_type == :web
|
@@ -34,11 +34,10 @@ module NewRelic
|
|
34
34
|
def metric_for_sql(sql)
|
35
35
|
metric = NewRelic::Agent::Transaction.database_metric_name
|
36
36
|
if metric.nil?
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
metric = "Database/SQL/#{$1.downcase}"
|
37
|
+
operation = NewRelic::Agent::Database.parse_operation_from_query(sql)
|
38
|
+
if operation
|
39
|
+
# Could not determine the model/operation so use a fallback metric
|
40
|
+
metric = "Database/SQL/#{operation}"
|
42
41
|
else
|
43
42
|
metric = "Database/SQL/other"
|
44
43
|
end
|
@@ -48,17 +47,19 @@ module NewRelic
|
|
48
47
|
|
49
48
|
# Given a metric name such as "ActiveRecord/model/action" this
|
50
49
|
# returns an array of rollup metrics:
|
51
|
-
# [ "ActiveRecord/all", "ActiveRecord/action" ]
|
50
|
+
# [ "Datastore/all", "ActiveRecord/all", "ActiveRecord/action" ]
|
52
51
|
# If the metric name is in the form of "ActiveRecord/action"
|
53
|
-
# this returns merely: [ "ActiveRecord/all" ]
|
52
|
+
# this returns merely: [ "Datastore/all", "ActiveRecord/all" ]
|
54
53
|
def rollup_metrics_for(metric)
|
55
|
-
metrics = []
|
54
|
+
metrics = ["Datastore/all"]
|
56
55
|
|
57
56
|
# If we're outside of a web transaction, don't record any rollup
|
58
57
|
# database metrics. This is to prevent metrics from background tasks
|
59
58
|
# from polluting the metrics used to drive overview graphs.
|
60
59
|
if NewRelic::Agent::Transaction.recording_web_transaction?
|
61
60
|
metrics << "ActiveRecord/all"
|
61
|
+
else
|
62
|
+
metrics << "Datastore/allOther"
|
62
63
|
end
|
63
64
|
metrics << "ActiveRecord/#{$1}" if metric =~ /ActiveRecord\/[\w|\:]+\/(\w+)/
|
64
65
|
|
@@ -310,8 +310,7 @@ module NewRelic
|
|
310
310
|
# @api public
|
311
311
|
#
|
312
312
|
def perform_action_with_newrelic_trace(*args, &block)
|
313
|
-
request = newrelic_request(args)
|
314
|
-
NewRelic::Agent::TransactionState.reset(request)
|
313
|
+
NewRelic::Agent::TransactionState.request = newrelic_request(args)
|
315
314
|
|
316
315
|
# Skip instrumentation based on the value of 'do_not_trace' and if
|
317
316
|
# we aren't calling directly with a block.
|
@@ -322,9 +321,6 @@ module NewRelic
|
|
322
321
|
end
|
323
322
|
end
|
324
323
|
|
325
|
-
control = NewRelic::Control.instance
|
326
|
-
return perform_action_with_newrelic_profile(args, &block) if control.profiling?
|
327
|
-
|
328
324
|
txn = _start_transaction(block_given? ? args : [])
|
329
325
|
begin
|
330
326
|
options = { :force => txn.force_flag, :transaction => true }
|
@@ -413,39 +409,6 @@ module NewRelic
|
|
413
409
|
|
414
410
|
private
|
415
411
|
|
416
|
-
# Profile the instrumented call. Dev mode only. Experimental
|
417
|
-
# - should definitely not be used on production applications
|
418
|
-
def perform_action_with_newrelic_profile(args)
|
419
|
-
txn = _start_transaction(block_given? ? args : [])
|
420
|
-
val = nil
|
421
|
-
options = { :metric => true }
|
422
|
-
|
423
|
-
_, expected_scope = NewRelic::Agent::MethodTracer::TraceExecutionScoped.trace_execution_scoped_header(options, txn.start_time.to_f)
|
424
|
-
|
425
|
-
NewRelic::Agent.disable_all_tracing do
|
426
|
-
# turn on profiling
|
427
|
-
profile = RubyProf.profile do
|
428
|
-
if block_given?
|
429
|
-
val = yield
|
430
|
-
else
|
431
|
-
val = perform_action_without_newrelic_trace(*args)
|
432
|
-
end
|
433
|
-
end
|
434
|
-
NewRelic::Agent.instance.transaction_sampler.notice_profile profile
|
435
|
-
end
|
436
|
-
|
437
|
-
return val
|
438
|
-
ensure
|
439
|
-
end_time = Time.now
|
440
|
-
txn.freeze_name
|
441
|
-
metric_names = Array(recorded_metrics(txn))
|
442
|
-
txn_name = metric_names.shift
|
443
|
-
|
444
|
-
NewRelic::Agent::MethodTracer::TraceExecutionScoped.trace_execution_scoped_footer(txn.start_time.to_f, txn_name, metric_names, expected_scope, options, end_time.to_f)
|
445
|
-
|
446
|
-
txn = Transaction.stop(txn_name, end_time)
|
447
|
-
end
|
448
|
-
|
449
412
|
# Write a transaction onto a thread local if there isn't already one there.
|
450
413
|
# If there is one, just update it.
|
451
414
|
def _start_transaction(args) # :nodoc:
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
DependencyDetection.defer do
|
6
|
+
named :rubyprof
|
7
|
+
|
8
|
+
depends_on do
|
9
|
+
defined?(::RubyProf)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
NewRelic::Agent.instance.events.subscribe(:start_transaction) do
|
14
|
+
if NewRelic::Agent.config[:'profiling.enabled']
|
15
|
+
::RubyProf.start
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
NewRelic::Agent.instance.events.subscribe(:transaction_finished) do
|
20
|
+
if NewRelic::Agent.config[:'profiling.enabled']
|
21
|
+
trace = NewRelic::Agent::TransactionState.get.transaction.transaction_trace
|
22
|
+
trace.profile = ::RubyProf.stop
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -64,10 +64,11 @@ module NewRelic::Agent::Instrumentation::TyphoeusTracing
|
|
64
64
|
if NewRelic::Agent.is_execution_traced? && !request_is_hydra_enabled?(request)
|
65
65
|
wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
|
66
66
|
t0, segment = ::NewRelic::Agent::CrossAppTracing.start_trace(wrapped_request)
|
67
|
-
|
67
|
+
callback = Proc.new do
|
68
68
|
wrapped_response = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(request.response)
|
69
69
|
::NewRelic::Agent::CrossAppTracing.finish_trace(t0, segment, wrapped_request, wrapped_response)
|
70
|
-
end
|
70
|
+
end
|
71
|
+
request.on_complete.unshift(callback)
|
71
72
|
end
|
72
73
|
end
|
73
74
|
end
|
@@ -42,8 +42,22 @@ module NewRelic
|
|
42
42
|
# pipe in the parent and child processes is essential in order for the EOF
|
43
43
|
# to be correctly triggered. The ready marker mechanism is used because
|
44
44
|
# there's no easy hook for after_fork in the parent process.
|
45
|
+
#
|
46
|
+
# This class provides message framing (separation of individual messages),
|
47
|
+
# but not serialization. Serialization / deserialization is the
|
48
|
+
# responsibility of clients.
|
49
|
+
#
|
50
|
+
# Message framing works like this:
|
51
|
+
#
|
52
|
+
# Each message sent across the pipe is preceded by a length tag that
|
53
|
+
# specifies the length of the message that immediately follows, in bytes.
|
54
|
+
# The length tags are serialized as unsigned big-endian long values, (4
|
55
|
+
# bytes each). This means that the maximum theoretical message size is
|
56
|
+
# 4 GB - much larger than we'd ever need or want for this application.
|
57
|
+
#
|
45
58
|
class Pipe
|
46
59
|
READY_MARKER = "READY"
|
60
|
+
NUM_LENGTH_BYTES = 4
|
47
61
|
|
48
62
|
attr_accessor :in, :out
|
49
63
|
attr_reader :last_read, :parent_pid
|
@@ -62,18 +76,37 @@ module NewRelic
|
|
62
76
|
@in.close unless @in.closed?
|
63
77
|
end
|
64
78
|
|
79
|
+
def serialize_message_length(data)
|
80
|
+
[data.bytesize].pack("L>")
|
81
|
+
end
|
82
|
+
|
83
|
+
def deserialize_message_length(data)
|
84
|
+
data.unpack("L>").first
|
85
|
+
end
|
86
|
+
|
65
87
|
def write(data)
|
66
88
|
@out.close unless @out.closed?
|
67
|
-
@in <<
|
68
|
-
|
69
|
-
end
|
70
|
-
@in << "\n\n"
|
89
|
+
@in << serialize_message_length(data)
|
90
|
+
@in << data
|
71
91
|
end
|
72
92
|
|
73
93
|
def read
|
74
94
|
@in.close unless @in.closed?
|
75
95
|
@last_read = Time.now
|
76
|
-
@out.
|
96
|
+
length_bytes = @out.read(NUM_LENGTH_BYTES)
|
97
|
+
if length_bytes
|
98
|
+
message_length = deserialize_message_length(length_bytes)
|
99
|
+
if message_length
|
100
|
+
@out.read(message_length)
|
101
|
+
else
|
102
|
+
length_hex = length_bytes.bytes.map { |b| b.to_s(16) }.join(' ')
|
103
|
+
NewRelic::Agent.logger.error("Failed to deserialize message length from pipe. Bytes: [#{length_hex}]")
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
else
|
107
|
+
NewRelic::Agent.logger.error("Failed to read bytes for length from pipe.")
|
108
|
+
nil
|
109
|
+
end
|
77
110
|
end
|
78
111
|
|
79
112
|
def eof?
|
@@ -176,15 +209,15 @@ module NewRelic
|
|
176
209
|
def merge_data_from_pipe(pipe_handle)
|
177
210
|
pipe = find_pipe_for_handle(pipe_handle)
|
178
211
|
raw_payload = pipe.read
|
179
|
-
|
180
212
|
if raw_payload && !raw_payload.empty?
|
181
|
-
|
182
|
-
if payload == Pipe::READY_MARKER
|
213
|
+
if raw_payload == Pipe::READY_MARKER
|
183
214
|
pipe.after_fork_in_parent
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
215
|
+
else
|
216
|
+
payload = unmarshal(raw_payload)
|
217
|
+
if payload
|
218
|
+
endpoint, items = payload
|
219
|
+
NewRelic::Agent.agent.merge_data_for_endpoint(endpoint, items)
|
220
|
+
end
|
188
221
|
end
|
189
222
|
end
|
190
223
|
|
@@ -28,25 +28,25 @@ module NewRelic
|
|
28
28
|
[]
|
29
29
|
end
|
30
30
|
|
31
|
-
def analytic_event_data(
|
32
|
-
|
31
|
+
def analytic_event_data(events)
|
32
|
+
write_to_pipe(:analytic_event_data, events) if events
|
33
33
|
end
|
34
34
|
|
35
35
|
def metric_data(unsent_timeslice_data)
|
36
|
-
write_to_pipe(:
|
36
|
+
write_to_pipe(:metric_data, unsent_timeslice_data)
|
37
37
|
{}
|
38
38
|
end
|
39
39
|
|
40
40
|
def transaction_sample_data(transactions)
|
41
|
-
write_to_pipe(:
|
41
|
+
write_to_pipe(:transaction_sample_data, transactions) if transactions
|
42
42
|
end
|
43
43
|
|
44
44
|
def error_data(errors)
|
45
|
-
write_to_pipe(:
|
45
|
+
write_to_pipe(:error_data, errors) if errors
|
46
46
|
end
|
47
47
|
|
48
48
|
def sql_trace_data(sql)
|
49
|
-
write_to_pipe(:
|
49
|
+
write_to_pipe(:sql_trace_data, sql) if sql
|
50
50
|
end
|
51
51
|
|
52
52
|
def shutdown(time)
|
@@ -66,8 +66,14 @@ module NewRelic
|
|
66
66
|
|
67
67
|
private
|
68
68
|
|
69
|
-
def
|
70
|
-
|
69
|
+
def marshal_payload(data)
|
70
|
+
NewRelic::LanguageSupport.with_cautious_gc do
|
71
|
+
Marshal.dump(data)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def write_to_pipe(endpoint, data)
|
76
|
+
@pipe.write(marshal_payload([endpoint, data])) if @pipe
|
71
77
|
end
|
72
78
|
end
|
73
79
|
end
|
@@ -16,10 +16,12 @@ class NewRelic::Agent::RequestSampler
|
|
16
16
|
SAMPLE_TYPE = 'Transaction'
|
17
17
|
|
18
18
|
# Strings for static keys of the sample structure
|
19
|
-
TYPE_KEY
|
20
|
-
TIMESTAMP_KEY
|
21
|
-
NAME_KEY
|
22
|
-
DURATION_KEY
|
19
|
+
TYPE_KEY = 'type'
|
20
|
+
TIMESTAMP_KEY = 'timestamp'
|
21
|
+
NAME_KEY = 'name'
|
22
|
+
DURATION_KEY = 'duration'
|
23
|
+
GUID_KEY = 'nr.guid'
|
24
|
+
REFERRING_TRANSACTION_GUID_KEY = 'nr.referringTransactionGuid'
|
23
25
|
|
24
26
|
def initialize( event_listener )
|
25
27
|
super()
|
@@ -113,7 +115,6 @@ class NewRelic::Agent::RequestSampler
|
|
113
115
|
# Event handler for the :transaction_finished event.
|
114
116
|
def on_transaction_finished(payload)
|
115
117
|
return unless @enabled
|
116
|
-
return unless NewRelic::Agent::Transaction.transaction_type_is_web?(payload[:type])
|
117
118
|
|
118
119
|
main_event = create_main_event(payload)
|
119
120
|
custom_params = create_custom_parameters(payload)
|
@@ -122,14 +123,70 @@ class NewRelic::Agent::RequestSampler
|
|
122
123
|
notify_full if is_full && !@notified_full
|
123
124
|
end
|
124
125
|
|
126
|
+
def self.map_metric(metric_name, to_add={})
|
127
|
+
to_add.values.each(&:freeze)
|
128
|
+
|
129
|
+
spec = ::NewRelic::MetricSpec.new(metric_name)
|
130
|
+
mappings = OVERVIEW_SPECS.fetch(spec, {})
|
131
|
+
mappings.merge!(to_add)
|
132
|
+
|
133
|
+
OVERVIEW_SPECS[spec] = mappings
|
134
|
+
end
|
135
|
+
|
136
|
+
OVERVIEW_SPECS = {}
|
137
|
+
|
138
|
+
# All Transactions
|
139
|
+
# Don't need to use the transaction-type specific metrics since this is
|
140
|
+
# scoped to just one transaction, so Datastore/all has what we want.
|
141
|
+
map_metric('Datastore/all', :total_call_time => "databaseDuration")
|
142
|
+
map_metric('Datastore/all', :call_count => "databaseCallCount")
|
143
|
+
|
144
|
+
# Web Metrics
|
145
|
+
map_metric('WebFrontend/QueueTime', :total_call_time => "queueDuration")
|
146
|
+
map_metric("GC/cumulative", :total_call_time => "gcCumulative")
|
147
|
+
map_metric('Memcache/allWeb', :total_call_time => "memcacheDuration")
|
148
|
+
|
149
|
+
map_metric('External/allWeb', :total_call_time => "externalDuration")
|
150
|
+
map_metric('External/allWeb', :call_count => "externalCallCount")
|
151
|
+
|
152
|
+
# Background Metrics
|
153
|
+
map_metric('Memcache/allOther', :total_call_time => "memcacheDuration")
|
154
|
+
|
155
|
+
map_metric('External/allOther', :total_call_time => "externalDuration")
|
156
|
+
map_metric('External/allOther', :call_count => "externalCallCount")
|
157
|
+
|
158
|
+
def extract_metrics(stats_hash)
|
159
|
+
result = {}
|
160
|
+
if stats_hash
|
161
|
+
OVERVIEW_SPECS.each do |(metric_spec, extracted_values)|
|
162
|
+
if stats_hash.has_key?(metric_spec)
|
163
|
+
stat = stats_hash[metric_spec]
|
164
|
+
extracted_values.each do |value_name, key_name|
|
165
|
+
result[key_name] = stat.send(value_name)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
result
|
171
|
+
end
|
172
|
+
|
125
173
|
def create_main_event(payload)
|
126
|
-
sample = payload[:
|
174
|
+
sample = extract_metrics(payload[:metrics])
|
127
175
|
sample.merge!({
|
128
176
|
TIMESTAMP_KEY => float(payload[:start_timestamp]),
|
129
177
|
NAME_KEY => string(payload[:name]),
|
130
178
|
DURATION_KEY => float(payload[:duration]),
|
131
179
|
TYPE_KEY => SAMPLE_TYPE,
|
132
180
|
})
|
181
|
+
optionally_append(GUID_KEY, :guid, sample, payload)
|
182
|
+
optionally_append(REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
|
183
|
+
sample
|
184
|
+
end
|
185
|
+
|
186
|
+
def optionally_append(sample_key, payload_key, sample, payload)
|
187
|
+
if payload.include?(payload_key)
|
188
|
+
sample[sample_key] = string(payload[payload_key])
|
189
|
+
end
|
133
190
|
end
|
134
191
|
|
135
192
|
def create_custom_parameters(payload)
|