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
@@ -4,7 +4,7 @@
|
|
4
4
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
5
5
|
require 'new_relic/agent/instrumentation/active_record_helper'
|
6
6
|
|
7
|
-
class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest <
|
7
|
+
class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest < Minitest::Test
|
8
8
|
include NewRelic::Agent::Instrumentation
|
9
9
|
|
10
10
|
def test_metric_for_name_find
|
@@ -43,14 +43,14 @@ class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest < MiniTest::Unit:
|
|
43
43
|
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
|
44
44
|
base_metric = 'ActiveRecord/Namespace::Model/find'
|
45
45
|
rollup_metrics = ActiveRecordHelper.rollup_metrics_for(base_metric)
|
46
|
-
expected_metrics = ['ActiveRecord/all', 'ActiveRecord/find']
|
46
|
+
expected_metrics = ['Datastore/all', 'ActiveRecord/all', 'ActiveRecord/find']
|
47
47
|
assert_equal(expected_metrics.sort, rollup_metrics.sort)
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_rollup_metrics_for_skips_operation_rollup_given_metric_without_model
|
51
51
|
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
|
52
52
|
rollup_metrics = ActiveRecordHelper.rollup_metrics_for('ActiveRecord/find')
|
53
|
-
expected_metrics = ['ActiveRecord/all']
|
53
|
+
expected_metrics = ['Datastore/all', 'ActiveRecord/all']
|
54
54
|
assert_equal(expected_metrics, rollup_metrics)
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest < MiniTest::Unit:
|
|
58
58
|
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
|
59
59
|
base_metric = 'ActiveRecord/Namespace::Model/find'
|
60
60
|
rollup_metrics = ActiveRecordHelper.rollup_metrics_for(base_metric)
|
61
|
-
assert_equal(['ActiveRecord/find'], rollup_metrics)
|
61
|
+
assert_equal(['Datastore/all', 'Datastore/allOther', 'ActiveRecord/find'], rollup_metrics)
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_remote_service_metric
|
@@ -9,7 +9,7 @@ if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= MIN_RAILS_VERSION && !Ne
|
|
9
9
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
10
10
|
require 'new_relic/agent/instrumentation/active_record_subscriber'
|
11
11
|
|
12
|
-
class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest <
|
12
|
+
class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::Test
|
13
13
|
class Order; end
|
14
14
|
|
15
15
|
def setup
|
@@ -97,7 +97,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < MiniTest::U
|
|
97
97
|
sampler.notice_push_scope('Controller/sandwiches/index')
|
98
98
|
simulate_query(2)
|
99
99
|
sampler.notice_pop_scope('Controller/sandwiches/index')
|
100
|
-
sampler.notice_scope_empty(stub('txn', :name => '/path', :custom_parameters => {}))
|
100
|
+
sampler.notice_scope_empty(stub('txn', :name => '/path', :custom_parameters => {}, :guid => 'a guid'))
|
101
101
|
|
102
102
|
last_segment = nil
|
103
103
|
sampler.last_sample.root_segment.each_segment{|s| last_segment = s }
|
@@ -0,0 +1,385 @@
|
|
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
|
+
if defined?(::Rails)
|
6
|
+
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
8
|
+
require 'active_record_fixtures'
|
9
|
+
|
10
|
+
class NewRelic::Agent::Instrumentation::NewActiveRecordInstrumentationTest < Minitest::Test
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
NewRelic::Agent.manual_start
|
14
|
+
ActiveRecord::Base.establish_connection unless ActiveRecord::Base.connection.active?
|
15
|
+
ActiveRecordFixtures.setup
|
16
|
+
NewRelic::Agent.instance.transaction_sampler.reset!
|
17
|
+
NewRelic::Agent.instance.stats_engine.clear_stats
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
super
|
22
|
+
NewRelic::Agent::TransactionState.reset
|
23
|
+
NewRelic::Agent.shutdown
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_metrics_for_create
|
27
|
+
in_web_transaction do
|
28
|
+
ActiveRecordFixtures::Order.create(:name => 'bob')
|
29
|
+
end
|
30
|
+
|
31
|
+
if active_record_major_version >= 3
|
32
|
+
assert_generic_rollup_metrics('insert')
|
33
|
+
else
|
34
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'create')
|
35
|
+
end
|
36
|
+
assert_remote_service_metrics
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_metrics_for_create_via_association
|
40
|
+
in_web_transaction do
|
41
|
+
order = ActiveRecordFixtures::Order.create(:name => 'bob')
|
42
|
+
order.shipments.create
|
43
|
+
order.shipments.to_a
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_generic_rollup_metrics('insert')
|
47
|
+
assert_remote_service_metrics
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_metrics_for_find
|
51
|
+
in_web_transaction do
|
52
|
+
if active_record_major_version >= 4
|
53
|
+
ActiveRecordFixtures::Order.where(:name => 'foo').load
|
54
|
+
else
|
55
|
+
ActiveRecordFixtures::Order.find_all_by_name('foo')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find')
|
60
|
+
assert_remote_service_metrics
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_metrics_for_find_by_id
|
64
|
+
in_web_transaction do
|
65
|
+
order = ActiveRecordFixtures::Order.create(:name => 'kathy')
|
66
|
+
ActiveRecordFixtures::Order.find(order.id)
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find')
|
70
|
+
assert_remote_service_metrics
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_metrics_for_find_via_association
|
74
|
+
in_web_transaction do
|
75
|
+
order = ActiveRecordFixtures::Order.create(:name => 'bob')
|
76
|
+
order.shipments.create
|
77
|
+
order.shipments.to_a
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Shipment, 'find')
|
81
|
+
assert_remote_service_metrics
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_metrics_for_find_all
|
85
|
+
in_web_transaction do
|
86
|
+
case
|
87
|
+
when active_record_major_version >= 4
|
88
|
+
ActiveRecordFixtures::Order.all.load
|
89
|
+
when active_record_major_version >= 3
|
90
|
+
ActiveRecordFixtures::Order.all
|
91
|
+
else
|
92
|
+
ActiveRecordFixtures::Order.find(:all)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find')
|
97
|
+
assert_remote_service_metrics
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_metrics_for_find_via_named_scope
|
101
|
+
ActiveRecordFixtures::Order.class_eval do
|
102
|
+
if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("4")
|
103
|
+
scope :jeffs, lambda { where(:name => 'Jeff') }
|
104
|
+
elsif NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("3.1")
|
105
|
+
scope :jeffs, :conditions => { :name => 'Jeff' }
|
106
|
+
else
|
107
|
+
named_scope :jeffs, :conditions => { :name => 'Jeff' }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
in_web_transaction do
|
112
|
+
if active_record_major_version >= 4
|
113
|
+
ActiveRecordFixtures::Order.jeffs.load
|
114
|
+
else
|
115
|
+
ActiveRecordFixtures::Order.jeffs.find(:all)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find')
|
120
|
+
assert_remote_service_metrics
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_metrics_for_exists
|
124
|
+
in_web_transaction do
|
125
|
+
ActiveRecordFixtures::Order.exists?(["name=?", "jeff"])
|
126
|
+
end
|
127
|
+
|
128
|
+
if active_record_major_version == 3 && [0,1].include?(active_record_minor_version)
|
129
|
+
# Bugginess in Rails 3.0 and 3.1 doesn't let us get ActiveRecord/find
|
130
|
+
assert_generic_rollup_metrics('select')
|
131
|
+
else
|
132
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find')
|
133
|
+
end
|
134
|
+
assert_remote_service_metrics
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_metrics_for_update
|
138
|
+
in_web_transaction do
|
139
|
+
order = ActiveRecordFixtures::Order.create(:name => "wendy")
|
140
|
+
order.name = 'walter'
|
141
|
+
order.save
|
142
|
+
end
|
143
|
+
|
144
|
+
if active_record_major_version >= 3
|
145
|
+
assert_generic_rollup_metrics('update')
|
146
|
+
else
|
147
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'save')
|
148
|
+
end
|
149
|
+
assert_remote_service_metrics
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_metrics_for_destroy
|
153
|
+
in_web_transaction do
|
154
|
+
order = ActiveRecordFixtures::Order.create("name" => "burt")
|
155
|
+
order.destroy
|
156
|
+
end
|
157
|
+
|
158
|
+
if active_record_major_version >= 3
|
159
|
+
assert_generic_rollup_metrics('delete')
|
160
|
+
else
|
161
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'destroy')
|
162
|
+
end
|
163
|
+
assert_remote_service_metrics
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_metrics_for_direct_sql_select
|
167
|
+
in_web_transaction do
|
168
|
+
conn = ActiveRecordFixtures::Order.connection
|
169
|
+
conn.select_rows("SELECT * FROM #{ActiveRecordFixtures::Order.table_name}")
|
170
|
+
end
|
171
|
+
|
172
|
+
assert_generic_rollup_metrics('select')
|
173
|
+
assert_remote_service_metrics
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_metrics_for_direct_sql_other
|
177
|
+
in_web_transaction do
|
178
|
+
conn = ActiveRecordFixtures::Order.connection
|
179
|
+
conn.execute("begin")
|
180
|
+
conn.execute("commit")
|
181
|
+
end
|
182
|
+
|
183
|
+
assert_generic_rollup_metrics('other')
|
184
|
+
assert_remote_service_metrics
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_metrics_for_direct_sql_show
|
188
|
+
if supports_show_tables?
|
189
|
+
in_web_transaction do
|
190
|
+
conn = ActiveRecordFixtures::Order.connection
|
191
|
+
conn.execute("show tables")
|
192
|
+
end
|
193
|
+
|
194
|
+
assert_generic_rollup_metrics('show')
|
195
|
+
assert_remote_service_metrics
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_still_records_metrics_in_error_cases
|
200
|
+
# have the AR select throw an error
|
201
|
+
ActiveRecordFixtures::Order.connection.stubs(:log_info).with do |sql, *|
|
202
|
+
raise "Error" if sql =~ /select/
|
203
|
+
true
|
204
|
+
end
|
205
|
+
|
206
|
+
in_web_transaction do
|
207
|
+
begin
|
208
|
+
ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
209
|
+
rescue RuntimeError => e
|
210
|
+
# catch only the error we raise above
|
211
|
+
raise unless e.message == 'Error'
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
assert_generic_rollup_metrics('select')
|
216
|
+
assert_remote_service_metrics
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_passes_through_errors
|
220
|
+
begin
|
221
|
+
ActiveRecordFixtures::Order.transaction do
|
222
|
+
raise ActiveRecord::ActiveRecordError.new('preserve-me!')
|
223
|
+
end
|
224
|
+
rescue ActiveRecord::ActiveRecordError => e
|
225
|
+
assert_equal 'preserve-me!', e.message
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_no_metrics_recorded_with_disable_all_tracing
|
230
|
+
NewRelic::Agent.disable_all_tracing do
|
231
|
+
in_web_transaction('bogosity') do
|
232
|
+
ActiveRecordFixtures::Order.first
|
233
|
+
end
|
234
|
+
end
|
235
|
+
assert_nil NewRelic::Agent.instance.transaction_sampler.last_sample
|
236
|
+
assert_metrics_recorded_exclusive([])
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_records_transaction_trace_nodes
|
240
|
+
in_web_transaction do
|
241
|
+
ActiveRecordFixtures::Order.first
|
242
|
+
end
|
243
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
244
|
+
segment = find_segment_by_name(sample, 'ActiveRecord/ActiveRecordFixtures::Order/find')
|
245
|
+
|
246
|
+
assert_equal('ActiveRecord/ActiveRecordFixtures::Order/find', segment.metric_name)
|
247
|
+
|
248
|
+
sql = segment.params[:sql]
|
249
|
+
assert_match(/^SELECT /, sql)
|
250
|
+
|
251
|
+
assert_equal(adapter.to_s, sql.adapter)
|
252
|
+
refute_nil(sql.config)
|
253
|
+
refute_nil(sql.explainer)
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_gathers_explain_plans
|
257
|
+
with_config(:'transaction_tracer.explain_threshold' => -0.1) do
|
258
|
+
in_web_transaction do
|
259
|
+
ActiveRecordFixtures::Order.first
|
260
|
+
end
|
261
|
+
|
262
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
263
|
+
sql_segment = find_segment_by_name(sample, 'ActiveRecord/ActiveRecordFixtures::Order/find')
|
264
|
+
|
265
|
+
assert_match(/^SELECT /, sql_segment.params[:sql])
|
266
|
+
|
267
|
+
sample.prepare_to_send!
|
268
|
+
explanations = sql_segment.params[:explain_plan]
|
269
|
+
if supports_explain_plans?
|
270
|
+
refute_nil explanations, "No explains in segment: #{sql_segment}"
|
271
|
+
assert_equal(2, explanations.size,
|
272
|
+
"No explains in segment: #{sql_segment}")
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_records_metrics_on_background_transaction
|
278
|
+
in_transaction('back it up') do
|
279
|
+
ActiveRecordFixtures::Order.create(:name => 'bob')
|
280
|
+
end
|
281
|
+
|
282
|
+
assert_metrics_recorded(['Datastore/allOther'])
|
283
|
+
assert_metrics_not_recorded(['ActiveRecord/all'])
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_remote_service_metric_respects_dynamic_connection_config
|
287
|
+
if supports_remote_service_metrics?
|
288
|
+
q = "SELECT * FROM #{ActiveRecordFixtures::Shipment.table_name} LIMIT 1"
|
289
|
+
ActiveRecordFixtures::Shipment.connection.execute(q)
|
290
|
+
assert_remote_service_metrics
|
291
|
+
|
292
|
+
config = ActiveRecordFixtures::Shipment.connection.instance_eval { @config }
|
293
|
+
config[:host] = '127.0.0.1'
|
294
|
+
ActiveRecordFixtures::Shipment.establish_connection(config)
|
295
|
+
|
296
|
+
ActiveRecordFixtures::Shipment.connection.execute(q)
|
297
|
+
assert_remote_service_metrics('127.0.0.1')
|
298
|
+
|
299
|
+
config[:host] = 'localhost'
|
300
|
+
ActiveRecordFixtures::Shipment.establish_connection(config)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
# helpers
|
305
|
+
|
306
|
+
def rails_env
|
307
|
+
Rails.env
|
308
|
+
end
|
309
|
+
|
310
|
+
def adapter
|
311
|
+
adapter_string = ActiveRecordFixtures::Order.configurations[rails_env]['adapter']
|
312
|
+
case adapter_string
|
313
|
+
when /postgres/i then :postgres
|
314
|
+
when /mysql/i then :mysql
|
315
|
+
when /sqlite/i then :sqlite3
|
316
|
+
else
|
317
|
+
adapter_string.downcase.to_sym
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def supports_show_tables?
|
322
|
+
[:mysql, :postgres].include?(adapter)
|
323
|
+
end
|
324
|
+
|
325
|
+
def supports_remote_service_metrics?
|
326
|
+
[:mysql, :postgres].include?(adapter)
|
327
|
+
end
|
328
|
+
|
329
|
+
def supports_explain_plans?
|
330
|
+
[:mysql, :postgres].include?(adapter)
|
331
|
+
end
|
332
|
+
|
333
|
+
def active_record_major_version
|
334
|
+
if defined?(::ActiveRecord::VERSION::MAJOR)
|
335
|
+
::ActiveRecord::VERSION::MAJOR.to_i
|
336
|
+
else
|
337
|
+
2
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def active_record_minor_version
|
342
|
+
if defined?(::ActiveRecord::VERSION::MINOR)
|
343
|
+
::ActiveRecord::VERSION::MINOR.to_i
|
344
|
+
else
|
345
|
+
1
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def active_record_version
|
350
|
+
if defined?(::ActiveRecord::VERSION::MINOR)
|
351
|
+
NewRelic::VersionNumber.new(::ActiveRecord::VERSION::STRING)
|
352
|
+
else
|
353
|
+
NewRelic::VersionNumber.new("2.1.0") # Can't tell between 2.1 and 2.2. Meh.
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def assert_activerecord_metrics(model, operation)
|
358
|
+
assert_metrics_recorded([
|
359
|
+
"ActiveRecord/all",
|
360
|
+
"ActiveRecord/#{operation}",
|
361
|
+
"ActiveRecord/#{model}/#{operation}",
|
362
|
+
"Datastore/all"
|
363
|
+
])
|
364
|
+
end
|
365
|
+
|
366
|
+
def assert_generic_rollup_metrics(operation)
|
367
|
+
assert_metrics_recorded([
|
368
|
+
"ActiveRecord/all",
|
369
|
+
"Database/SQL/#{operation}",
|
370
|
+
"Datastore/all"
|
371
|
+
])
|
372
|
+
end
|
373
|
+
|
374
|
+
def assert_remote_service_metrics(host='localhost')
|
375
|
+
if supports_remote_service_metrics?
|
376
|
+
assert_metrics_recorded([
|
377
|
+
"RemoteService/sql/#{adapter}/#{host}"
|
378
|
+
])
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
else
|
384
|
+
puts "Skipping tests in #{__FILE__} because Rails is unavailable"
|
385
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
|
6
|
-
class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest <
|
6
|
+
class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest < Minitest::Test
|
7
7
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
8
8
|
class TestObject
|
9
9
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
|
6
|
-
class NewRelic::Agent::Instrumentation::InstrumentationTest <
|
6
|
+
class NewRelic::Agent::Instrumentation::InstrumentationTest < Minitest::Test
|
7
7
|
def test_load_all_instrumentation_files
|
8
8
|
# just checking for syntax errors and unguarded code
|
9
9
|
Dir.glob('new_relic/agent/instrumentation/**/*.rb') do |f|
|