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
@@ -9,7 +9,8 @@ module NewRelic
|
|
9
9
|
|
10
10
|
def initialize(event_listener)
|
11
11
|
@samplers = []
|
12
|
-
event_listener
|
12
|
+
@event_listener = event_listener
|
13
|
+
@event_listener.subscribe(:before_harvest) { poll_samplers }
|
13
14
|
end
|
14
15
|
|
15
16
|
def each(&blk)
|
@@ -39,7 +40,9 @@ module NewRelic
|
|
39
40
|
def add_sampler(sampler_class)
|
40
41
|
if sampler_class.supported_on_this_platform?
|
41
42
|
if !sampler_class_registered?(sampler_class)
|
42
|
-
|
43
|
+
sampler = sampler_class.new
|
44
|
+
sampler.setup_events(@event_listener) if sampler.respond_to?(:setup_events)
|
45
|
+
@samplers << sampler
|
43
46
|
::NewRelic::Agent.logger.debug("Registered #{sampler_class.name} for harvest time sampling.")
|
44
47
|
else
|
45
48
|
::NewRelic::Agent.logger.warn("Ignoring addition of #{sampler_class.name} because it is already registered.")
|
@@ -22,7 +22,7 @@ module NewRelic
|
|
22
22
|
def after_fork *args; end
|
23
23
|
def start *args; end
|
24
24
|
def shutdown *args; end
|
25
|
-
def
|
25
|
+
def merge_data_for_endpoint *args; end
|
26
26
|
def push_trace_execution_flag *args; end
|
27
27
|
def pop_trace_execution_flag *args; end
|
28
28
|
def browser_timing_header; "" end
|
@@ -21,9 +21,14 @@ module NewRelic
|
|
21
21
|
# we can find a request header for the queue entry time
|
22
22
|
attr_accessor(:type, :exceptions, :filtered_params, :force_flag,
|
23
23
|
:jruby_cpu_start, :process_cpu_start, :database_metric_name)
|
24
|
+
|
24
25
|
attr_reader :name
|
26
|
+
attr_reader :guid
|
25
27
|
attr_reader :stats_hash
|
26
28
|
|
29
|
+
# Populated with the trace sample once this transaction is completed.
|
30
|
+
attr_reader :transaction_trace
|
31
|
+
|
27
32
|
# Give the current transaction a request context. Use this to
|
28
33
|
# get the URI and referer. The request is interpreted loosely
|
29
34
|
# as a Rack::Request or an ActionController::AbstractRequest.
|
@@ -102,6 +107,7 @@ module NewRelic
|
|
102
107
|
@request = options[:request]
|
103
108
|
@exceptions = {}
|
104
109
|
@stats_hash = StatsHash.new
|
110
|
+
@guid = generate_guid
|
105
111
|
TransactionState.get.transaction = self
|
106
112
|
end
|
107
113
|
|
@@ -196,7 +202,6 @@ module NewRelic
|
|
196
202
|
end
|
197
203
|
@transaction_trace = transaction_sampler.notice_scope_empty(self, Time.now, gc_time)
|
198
204
|
sql_sampler.notice_scope_empty(@name)
|
199
|
-
overview_metrics = transaction_overview_metrics
|
200
205
|
end
|
201
206
|
|
202
207
|
record_exceptions
|
@@ -204,23 +209,42 @@ module NewRelic
|
|
204
209
|
|
205
210
|
# these tear everything down so need to be done after merging stats
|
206
211
|
if self.root?
|
207
|
-
send_transaction_finished_event(start_time, end_time
|
212
|
+
send_transaction_finished_event(start_time, end_time)
|
208
213
|
agent.stats_engine.end_transaction
|
209
214
|
end
|
210
215
|
end
|
211
216
|
|
212
|
-
|
217
|
+
# This event is fired when the transaction is fully completed. The metric
|
218
|
+
# values and sampler can't be successfully modified from this event.
|
219
|
+
def send_transaction_finished_event(start_time, end_time)
|
213
220
|
payload = {
|
214
221
|
:name => @name,
|
215
222
|
:type => @type,
|
216
223
|
:start_timestamp => start_time.to_f,
|
217
224
|
:duration => end_time.to_f - start_time.to_f,
|
218
|
-
:
|
225
|
+
:metrics => @stats_hash,
|
219
226
|
:custom_params => custom_parameters
|
220
227
|
}
|
228
|
+
append_guid_to(payload)
|
229
|
+
append_referring_transaction_guid_to(payload)
|
230
|
+
|
221
231
|
agent.events.notify(:transaction_finished, payload)
|
222
232
|
end
|
223
233
|
|
234
|
+
def append_guid_to(payload)
|
235
|
+
guid = NewRelic::Agent::TransactionState.get.request_guid_for_event
|
236
|
+
if guid
|
237
|
+
payload[:guid] = guid
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def append_referring_transaction_guid_to(payload)
|
242
|
+
referring_guid = NewRelic::Agent.instance.cross_app_monitor.client_referring_transaction_guid
|
243
|
+
if referring_guid
|
244
|
+
payload[:referring_transaction_guid] = referring_guid
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
224
248
|
def merge_stats_hash
|
225
249
|
stats_hash.resolve_scopes!(@name)
|
226
250
|
NewRelic::Agent.instance.stats_engine.merge!(stats_hash)
|
@@ -233,24 +257,6 @@ module NewRelic
|
|
233
257
|
end
|
234
258
|
end
|
235
259
|
|
236
|
-
OVERVIEW_SPECS = [
|
237
|
-
[:webDuration, MetricSpec.new('HttpDispatcher')],
|
238
|
-
[:queueDuration, MetricSpec.new('WebFrontend/QueueTime')],
|
239
|
-
[:externalDuration, MetricSpec.new('External/allWeb')],
|
240
|
-
[:databaseDuration, MetricSpec.new('ActiveRecord/all')],
|
241
|
-
[:gcCumulative, MetricSpec.new("GC/cumulative")],
|
242
|
-
[:memcacheDuration, MetricSpec.new('Memcache/allWeb')]
|
243
|
-
]
|
244
|
-
|
245
|
-
def transaction_overview_metrics
|
246
|
-
metrics = {}
|
247
|
-
stats = @stats_hash
|
248
|
-
OVERVIEW_SPECS.each do |(dest_key, spec)|
|
249
|
-
metrics[dest_key] = stats[spec].total_call_time if stats.key?(spec)
|
250
|
-
end
|
251
|
-
metrics
|
252
|
-
end
|
253
|
-
|
254
260
|
# If we have an active transaction, notice the error and increment the error metric.
|
255
261
|
# Options:
|
256
262
|
# * <tt>:request</tt> => Request object to get the uri and referer
|
@@ -466,6 +472,19 @@ module NewRelic
|
|
466
472
|
def sql_sampler
|
467
473
|
agent.sql_sampler
|
468
474
|
end
|
475
|
+
|
476
|
+
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
477
|
+
GUID_LENGTH = 16
|
478
|
+
|
479
|
+
# generate a random 64 bit uuid
|
480
|
+
def generate_guid
|
481
|
+
guid = ''
|
482
|
+
GUID_LENGTH.times do |a|
|
483
|
+
guid << HEX_DIGITS[rand(16)]
|
484
|
+
end
|
485
|
+
guid
|
486
|
+
end
|
487
|
+
|
469
488
|
end
|
470
489
|
end
|
471
490
|
end
|
@@ -119,8 +119,10 @@ module NewRelic
|
|
119
119
|
|
120
120
|
@samples_lock.synchronize do
|
121
121
|
@last_sample = last_builder.sample
|
122
|
+
@last_sample.guid = txn.guid
|
122
123
|
@last_sample.set_custom_param(:gc_time, gc_time) if gc_time
|
123
124
|
store_sample(@last_sample)
|
125
|
+
@last_sample
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
@@ -144,11 +146,6 @@ module NewRelic
|
|
144
146
|
builder.ignore_transaction if builder
|
145
147
|
end
|
146
148
|
|
147
|
-
# For developer mode profiling support - delegates to the builder
|
148
|
-
def notice_profile(profile)
|
149
|
-
builder.set_profile(profile) if builder
|
150
|
-
end
|
151
|
-
|
152
149
|
# Sets the CPU time used by a transaction, delegates to the builder
|
153
150
|
def notice_transaction_cpu_time(cpu_time)
|
154
151
|
builder.set_transaction_cpu_time(cpu_time) if builder
|
@@ -29,27 +29,40 @@ module NewRelic
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# This starts the timer for the transaction.
|
32
|
-
def self.reset
|
33
|
-
self.get.reset
|
32
|
+
def self.reset
|
33
|
+
self.get.reset
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.request=(request)
|
37
|
+
self.get.request = request
|
34
38
|
end
|
35
39
|
|
36
40
|
def initialize
|
37
41
|
@stats_scope_stack = []
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
44
|
+
def request=(request)
|
45
|
+
reset unless reset?
|
46
|
+
@request = request
|
47
|
+
@request_token = BrowserToken.get_token(request)
|
48
|
+
end
|
49
|
+
|
50
|
+
def reset
|
41
51
|
# We almost always want to use the transaction time, but in case it's
|
42
52
|
# not available, we track the last reset. No accessor, as only the
|
43
53
|
# TransactionState class should use it.
|
44
54
|
@last_reset_time = Time.now
|
45
|
-
|
46
|
-
@transaction = Transaction.current
|
55
|
+
@transaction = nil
|
47
56
|
@timings = nil
|
48
|
-
|
49
|
-
@
|
50
|
-
@request_token = BrowserToken.get_token(request)
|
51
|
-
@request_guid = ""
|
57
|
+
@request = nil
|
58
|
+
@request_token = nil
|
52
59
|
@request_ignore_enduser = false
|
60
|
+
@is_cross_app_caller = false
|
61
|
+
@referring_transaction_info = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
def reset?
|
65
|
+
@transaction.nil?
|
53
66
|
end
|
54
67
|
|
55
68
|
def timings
|
@@ -58,10 +71,29 @@ module NewRelic
|
|
58
71
|
|
59
72
|
# Cross app tracing
|
60
73
|
# Because we need values from headers before the transaction actually starts
|
61
|
-
attr_accessor :client_cross_app_id, :referring_transaction_info
|
74
|
+
attr_accessor :client_cross_app_id, :referring_transaction_info, :is_cross_app_caller
|
75
|
+
|
76
|
+
def is_cross_app_caller?
|
77
|
+
@is_cross_app_caller
|
78
|
+
end
|
79
|
+
|
80
|
+
def is_cross_app_callee?
|
81
|
+
referring_transaction_info != nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def request_guid_for_event
|
85
|
+
return nil unless is_cross_app_callee? || is_cross_app_caller? || include_guid?
|
86
|
+
request_guid
|
87
|
+
end
|
62
88
|
|
63
89
|
# Request data
|
64
|
-
|
90
|
+
attr_reader :request
|
91
|
+
attr_accessor :request_token, :request_ignore_enduser
|
92
|
+
|
93
|
+
def request_guid
|
94
|
+
return nil unless transaction
|
95
|
+
transaction.guid
|
96
|
+
end
|
65
97
|
|
66
98
|
def request_guid_to_include
|
67
99
|
return "" unless include_guid?
|
@@ -0,0 +1,32 @@
|
|
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/language_support'
|
6
|
+
require 'new_relic/agent/vm/mri_vm'
|
7
|
+
require 'new_relic/agent/vm/jruby_vm'
|
8
|
+
require 'new_relic/agent/vm/rubinius_vm'
|
9
|
+
|
10
|
+
module NewRelic
|
11
|
+
module Agent
|
12
|
+
module VM
|
13
|
+
def self.snapshot
|
14
|
+
vm.snapshot
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.vm
|
18
|
+
@vm ||= create_vm
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.create_vm
|
22
|
+
if NewRelic::LanguageSupport.using_engine?('jruby')
|
23
|
+
JRubyVM.new
|
24
|
+
elsif NewRelic::LanguageSupport.using_engine?('rbx')
|
25
|
+
RubiniusVM.new
|
26
|
+
else
|
27
|
+
MriVM.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 'thread'
|
6
|
+
require 'new_relic/agent/vm/snapshot'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module VM
|
11
|
+
class JRubyVM
|
12
|
+
def snapshot
|
13
|
+
snap = Snapshot.new
|
14
|
+
gather_stats(snap)
|
15
|
+
snap
|
16
|
+
end
|
17
|
+
|
18
|
+
def gather_stats(snap)
|
19
|
+
if supports?(:gc_runs)
|
20
|
+
gc_stats = GC.stat
|
21
|
+
snap.gc_runs = gc_stats[:count]
|
22
|
+
end
|
23
|
+
|
24
|
+
snap.thread_count = Thread.list.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def supports?(key)
|
28
|
+
case key
|
29
|
+
when :gc_runs
|
30
|
+
RUBY_VERSION >= "1.9.2"
|
31
|
+
when :thread_count
|
32
|
+
true
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
# The GC::Profiler class available on MRI has to be reset periodically to avoid
|
6
|
+
# memory "leaking" in the underlying implementation. However, it's a major
|
7
|
+
# bummer for how we want to gather those statistics.
|
8
|
+
#
|
9
|
+
# This class comes to the rescue. It relies on being the only party to reset
|
10
|
+
# the underlying GC::Profiler, but otherwise gives us a steadily increasing
|
11
|
+
# total time.
|
12
|
+
module NewRelic
|
13
|
+
module Agent
|
14
|
+
module VM
|
15
|
+
class MonotonicGCProfiler
|
16
|
+
def initialize
|
17
|
+
@total_time = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
class ProfilerNotEnabledError < StandardError
|
21
|
+
def initialize
|
22
|
+
super("total_time is not available if GC::Profiler isn't enabled")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def total_time
|
27
|
+
raise ProfilerNotEnabledError.new unless NewRelic::LanguageSupport.gc_profiler_enabled?
|
28
|
+
|
29
|
+
@total_time += ::GC::Profiler.total_time
|
30
|
+
::GC::Profiler.clear
|
31
|
+
@total_time
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,86 @@
|
|
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 'thread'
|
6
|
+
require 'new_relic/agent/vm/snapshot'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module VM
|
11
|
+
class MriVM
|
12
|
+
def snapshot
|
13
|
+
snap = Snapshot.new
|
14
|
+
gather_stats(snap)
|
15
|
+
snap
|
16
|
+
end
|
17
|
+
|
18
|
+
def gather_stats(snap)
|
19
|
+
gather_gc_stats(snap)
|
20
|
+
gather_ruby_vm_stats(snap)
|
21
|
+
gather_thread_stats(snap)
|
22
|
+
end
|
23
|
+
|
24
|
+
def gather_gc_stats(snap)
|
25
|
+
if supports?(:gc_runs)
|
26
|
+
snap.gc_runs = GC.count
|
27
|
+
end
|
28
|
+
|
29
|
+
if GC.respond_to?(:stat)
|
30
|
+
gc_stats = GC.stat
|
31
|
+
snap.total_allocated_object = gc_stats[:total_allocated_object]
|
32
|
+
snap.major_gc_count = gc_stats[:major_gc_count]
|
33
|
+
snap.minor_gc_count = gc_stats[:minor_gc_count]
|
34
|
+
snap.heap_live = gc_stats[:heap_live_slot] || gc_stats[:heap_live_num]
|
35
|
+
snap.heap_free = gc_stats[:heap_free_slot] || gc_stats[:heap_free_num]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def gather_gc_time(snap)
|
40
|
+
if supports?(:gc_total_time)
|
41
|
+
snap.gc_total_time = NewRelic::Agent.instance.monotonic_gc_profiler.total_time
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def gather_ruby_vm_stats(snap)
|
46
|
+
if supports?(:method_cache_invalidations)
|
47
|
+
vm_stats = RubyVM.stat
|
48
|
+
snap.method_cache_invalidations = vm_stats[:global_method_state]
|
49
|
+
snap.constant_cache_invalidations = vm_stats[:global_constant_state]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def gather_thread_stats(snap)
|
54
|
+
snap.thread_count = Thread.list.size
|
55
|
+
end
|
56
|
+
|
57
|
+
def supports?(key)
|
58
|
+
case key
|
59
|
+
when :gc_runs
|
60
|
+
RUBY_VERSION >= '1.9.2'
|
61
|
+
when :gc_total_time
|
62
|
+
NewRelic::LanguageSupport.gc_profiler_enabled?
|
63
|
+
when :total_allocated_object
|
64
|
+
RUBY_VERSION >= '2.0.0'
|
65
|
+
when :major_gc_count
|
66
|
+
RUBY_VERSION >= '2.1.0'
|
67
|
+
when :minor_gc_count
|
68
|
+
RUBY_VERSION >= '2.1.0'
|
69
|
+
when :heap_live
|
70
|
+
RUBY_VERSION >= '1.9.3'
|
71
|
+
when :heap_free
|
72
|
+
RUBY_VERSION >= '1.9.3'
|
73
|
+
when :method_cache_invalidations
|
74
|
+
RUBY_VERSION >= '2.1.0'
|
75
|
+
when :constant_cache_invalidations
|
76
|
+
RUBY_VERSION >= '2.1.0'
|
77
|
+
when :thread_count
|
78
|
+
true
|
79
|
+
else
|
80
|
+
false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|