newrelic_rpm 3.11.2.286 → 3.12.0.288
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/.yardopts +2 -0
- data/CHANGELOG +39 -4
- data/README.md +4 -2
- data/lib/new_relic/agent.rb +229 -214
- data/lib/new_relic/agent/agent.rb +23 -12
- data/lib/new_relic/agent/attribute_filter.rb +242 -0
- data/lib/new_relic/agent/attribute_processing.rb +62 -0
- data/lib/new_relic/agent/commands/xray_session_collection.rb +4 -1
- data/lib/new_relic/agent/configuration/default_source.rb +284 -30
- data/lib/new_relic/agent/configuration/high_security_source.rb +0 -8
- data/lib/new_relic/agent/configuration/manager.rb +1 -1
- data/lib/new_relic/agent/configuration/server_source.rb +86 -31
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -1
- data/lib/new_relic/agent/cross_app_monitor.rb +8 -13
- data/lib/new_relic/agent/cross_app_tracing.rb +15 -15
- data/lib/new_relic/agent/custom_event_aggregator.rb +6 -2
- data/lib/new_relic/agent/database.rb +15 -2
- data/lib/new_relic/agent/datastores.rb +52 -38
- data/lib/new_relic/agent/datastores/metric_helper.rb +2 -1
- data/lib/new_relic/agent/encoding_normalizer.rb +82 -0
- data/lib/new_relic/agent/error_collector.rb +125 -169
- data/lib/new_relic/agent/hash_extensions.rb +26 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +13 -11
- data/lib/new_relic/agent/http_clients/uri_util.rb +9 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +12 -5
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +6 -7
- data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +4 -3
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +6 -3
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +9 -3
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -1
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +9 -7
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +8 -6
- data/lib/new_relic/agent/instrumentation/resque.rb +2 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +24 -16
- data/lib/new_relic/agent/parameter_filtering.rb +8 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +1 -0
- data/lib/new_relic/agent/stats.rb +0 -4
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +5 -3
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -0
- data/lib/new_relic/agent/supported_versions.rb +2 -2
- data/lib/new_relic/agent/traced_method_stack.rb +3 -3
- data/lib/new_relic/agent/transaction.rb +141 -118
- data/lib/new_relic/agent/transaction/attributes.rb +161 -0
- data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +4 -4
- data/lib/new_relic/agent/transaction/trace.rb +150 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +190 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +2 -2
- data/lib/new_relic/agent/transaction_event_aggregator.rb +23 -7
- data/lib/new_relic/agent/transaction_sample_builder.rb +37 -62
- data/lib/new_relic/agent/transaction_sampler.rb +29 -66
- data/lib/new_relic/cli/commands/install.rb +2 -2
- data/lib/new_relic/coerce.rb +15 -28
- data/lib/new_relic/json_wrapper.rb +14 -73
- data/lib/new_relic/noticed_error.rb +81 -5
- data/lib/new_relic/rack/browser_monitoring.rb +14 -19
- data/lib/new_relic/rack/developer_mode.rb +68 -14
- data/lib/new_relic/rack/developer_mode/segment_summary.rb +56 -0
- data/lib/new_relic/version.rb +2 -2
- data/newrelic.yml +19 -196
- data/test/agent_helper.rb +42 -36
- data/test/config/newrelic.yml +0 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/environments/rails42/Gemfile +1 -1
- data/test/fixtures/cross_agent_tests/attribute_configuration.json +35 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +19 -12
- data/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json +365 -0
- data/test/multiverse/lib/multiverse/suite.rb +5 -1
- data/test/multiverse/suites/active_record/active_record_test.rb +8 -8
- data/test/multiverse/suites/agent_only/agent_attributes_test.rb +145 -0
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +8 -0
- data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +5 -1
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +6 -6
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +2 -3
- data/test/multiverse/suites/agent_only/synthetics_test.rb +3 -3
- data/test/multiverse/suites/agent_only/testing_app.rb +4 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +9 -7
- data/test/multiverse/suites/curb/Envfile +5 -6
- data/test/multiverse/suites/curb/curb_test.rb +4 -5
- data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
- data/test/multiverse/suites/excon/Envfile +11 -4
- data/test/multiverse/suites/excon/excon_test.rb +5 -5
- data/test/multiverse/suites/grape/config/newrelic.yml +1 -0
- data/test/multiverse/suites/grape/grape_test.rb +76 -12
- data/test/multiverse/suites/grape/grape_test_api.rb +16 -0
- data/test/multiverse/suites/high_security/config/newrelic.yml +43 -3
- data/test/multiverse/suites/high_security/high_security_test.rb +165 -9
- data/test/multiverse/suites/httpclient/Envfile +5 -1
- data/test/multiverse/suites/httpclient/httpclient_test.rb +2 -2
- data/test/multiverse/suites/memcached/Envfile +1 -1
- data/test/multiverse/suites/mongo/Envfile +8 -1
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +29 -29
- data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +43 -8
- data/test/multiverse/suites/rack/rack_parameter_filtering_test.rb +13 -3
- data/test/multiverse/suites/rails/Envfile +3 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +52 -31
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/rails/ignore_test.rb +1 -1
- data/test/multiverse/suites/rails/parameter_capture_test.rb +108 -40
- data/test/multiverse/suites/rails/request_statistics_test.rb +10 -4
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +24 -24
- data/test/multiverse/suites/resque/instrumentation_test.rb +46 -12
- data/test/multiverse/suites/sequel/sequel_extension_test.rb +8 -8
- data/test/multiverse/suites/sequel/sequel_helpers.rb +11 -11
- data/test/multiverse/suites/sequel/sequel_plugin_test.rb +11 -11
- data/test/multiverse/suites/sidekiq/Envfile +1 -4
- data/test/multiverse/suites/sidekiq/after_suite.rb +9 -0
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +49 -16
- data/test/multiverse/suites/sidekiq/test_worker.rb +1 -2
- data/test/multiverse/suites/sinatra/Envfile +1 -1
- data/test/multiverse/suites/sinatra/config/newrelic.yml +1 -0
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +0 -4
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +0 -4
- data/test/multiverse/suites/sinatra/sinatra_parameter_capture_test.rb +65 -0
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +0 -11
- data/test/multiverse/suites/typhoeus/Envfile +8 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +4 -4
- data/test/new_relic/agent/agent/connect_test.rb +13 -9
- data/test/new_relic/agent/agent_test.rb +34 -24
- data/test/new_relic/agent/attribute_filter_test.rb +218 -0
- data/test/new_relic/agent/attribute_processing_test.rb +160 -0
- data/test/new_relic/agent/configuration/default_source_test.rb +88 -0
- data/test/new_relic/agent/configuration/manager_test.rb +3 -4
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +3 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +39 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +6 -30
- data/test/new_relic/agent/cross_app_tracing_test.rb +12 -12
- data/test/new_relic/agent/database/sql_obfuscation_test.rb +39 -65
- data/test/new_relic/agent/datastores/metric_helper_test.rb +36 -0
- data/test/new_relic/agent/encoding_normalizer_test.rb +66 -0
- data/test/new_relic/agent/error_collector_test.rb +181 -34
- data/test/new_relic/agent/hash_extensions_test.rb +34 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +20 -23
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +12 -12
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +5 -5
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +4 -4
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +21 -11
- data/test/new_relic/agent/javascript_instrumentor_test.rb +69 -45
- data/test/new_relic/agent/pipe_service_test.rb +2 -2
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +8 -7
- data/test/new_relic/agent/stats_engine/stats_hash_test.rb +2 -2
- data/test/new_relic/agent/threading/backtrace_node_test.rb +2 -2
- data/test/new_relic/agent/transaction/attributes_test.rb +276 -0
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +10 -10
- data/test/new_relic/agent/transaction/trace_node_test.rb +361 -0
- data/test/new_relic/agent/transaction/trace_test.rb +394 -0
- data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_event_aggregator_test.rb +127 -57
- data/test/new_relic/agent/transaction_sample_builder_test.rb +70 -78
- data/test/new_relic/agent/transaction_sampler_test.rb +76 -185
- data/test/new_relic/agent/transaction_test.rb +283 -135
- data/test/new_relic/agent_test.rb +27 -12
- data/test/new_relic/cli/commands/install_test.rb +27 -0
- data/test/new_relic/coerce_test.rb +0 -59
- data/test/new_relic/data_container_tests.rb +5 -5
- data/test/new_relic/fake_collector.rb +27 -9
- data/test/new_relic/filtering_test_app.rb +2 -1
- data/test/new_relic/http_client_test_cases.rb +16 -16
- data/test/new_relic/json_wrapper_test.rb +0 -54
- data/test/new_relic/marshalling_test_cases.rb +1 -0
- data/test/new_relic/multiverse_helpers.rb +144 -0
- data/test/new_relic/noticed_error_test.rb +112 -9
- data/test/new_relic/rack/browser_monitoring_test.rb +12 -7
- data/test/new_relic/{transaction_analysis → rack/developer_mode}/segment_summary_test.rb +5 -4
- data/test/new_relic/rack/developer_mode_test.rb +17 -3
- data/test/new_relic/rack/error_collector_test.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
- data/test/performance/script/runner +2 -2
- data/test/performance/suites/active_record.rb +3 -3
- data/test/performance/suites/agent_attributes.rb +62 -0
- data/test/performance/suites/rack_middleware.rb +78 -28
- data/test/performance/suites/transaction_tracing.rb +35 -0
- data/test/test_helper.rb +9 -1
- data/ui/helpers/developer_mode_helper.rb +16 -23
- data/ui/views/newrelic/_sample.rhtml +3 -3
- data/ui/views/newrelic/_segment.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_summary.rhtml +1 -1
- data/ui/views/newrelic/show_sample.rhtml +5 -4
- metadata +23 -80
- data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +0 -25
- data/lib/new_relic/transaction_analysis.rb +0 -80
- data/lib/new_relic/transaction_analysis/segment_summary.rb +0 -53
- data/lib/new_relic/transaction_sample.rb +0 -207
- data/lib/new_relic/transaction_sample/composite_segment.rb +0 -31
- data/lib/new_relic/transaction_sample/fake_segment.rb +0 -13
- data/lib/new_relic/transaction_sample/segment.rb +0 -197
- data/lib/new_relic/transaction_sample/summary_segment.rb +0 -25
- data/lib/new_relic/url_rule.rb +0 -18
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +0 -4
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/README.md +0 -4
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/end_of_line_comments_with_quotes.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/end_of_line_comments_with_quotes.sql +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_comments_and_quotes.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_comments_and_quotes.sql +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_comments_and_newlines.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_comments_and_newlines.sql +0 -4
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_end_of_line_comments.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_end_of_line_comments.sql +0 -3
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/quote_delimiters_in_comments.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/quote_delimiters_in_comments.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +0 -4
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +0 -2
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +0 -4
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +0 -1
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +0 -1
- data/test/new_relic/agent/error_collector/notice_error_test.rb +0 -261
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +0 -52
- data/test/new_relic/transaction_analysis_test.rb +0 -125
- data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -38
- data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -18
- data/test/new_relic/transaction_sample/segment_test.rb +0 -361
- data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -34
- data/test/new_relic/transaction_sample_subtest_test.rb +0 -41
- data/test/new_relic/transaction_sample_test.rb +0 -361
@@ -68,8 +68,8 @@ class HTTPClientTest < Minitest::Test
|
|
68
68
|
raise e unless e == test_exception
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
assert_equal("External/localhost/HTTPClient/GET",
|
71
|
+
last_node = find_last_transaction_node()
|
72
|
+
assert_equal("External/localhost/HTTPClient/GET", last_node.metric_name)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -14,7 +14,7 @@ memcache_client_versions.each do |version|
|
|
14
14
|
gem 'memcache-client', '~> #{version}', :require => 'memcache'
|
15
15
|
# version lockdown for ZenTest that cooperates with all Rubies
|
16
16
|
# and the build VMs
|
17
|
-
gem 'ZenTest', '3.4.2'
|
17
|
+
gem 'ZenTest', '3.4.2' unless RUBY_VERSION >= '2.2.0'
|
18
18
|
RB
|
19
19
|
end
|
20
20
|
|
@@ -1,3 +1,10 @@
|
|
1
|
+
if RUBY_VERSION >= '1.9.3'
|
2
|
+
gemfile <<-RB
|
3
|
+
gem 'mongo', '~>2.0.1'
|
4
|
+
gem 'bson_ext', :platforms => :ruby
|
5
|
+
RB
|
6
|
+
end
|
7
|
+
|
1
8
|
gemfile <<-RB
|
2
9
|
gem 'mongo', '1.10.0'
|
3
10
|
gem 'bson_ext', :platforms => :ruby
|
@@ -34,7 +41,7 @@ class PreExistingMongo
|
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
37
|
-
$mongo = PreExistingMongo.new("
|
44
|
+
$mongo = PreExistingMongo.new("127.0.0.1", 27017)
|
38
45
|
|
39
46
|
def mongo_running?
|
40
47
|
Timeout::timeout(1) do
|
@@ -305,12 +305,12 @@ module MongoOperationTests
|
|
305
305
|
end
|
306
306
|
|
307
307
|
def test_notices_nosql
|
308
|
-
|
308
|
+
node = nil
|
309
309
|
|
310
310
|
in_transaction do
|
311
311
|
@collection.insert(@tribble)
|
312
312
|
|
313
|
-
|
313
|
+
node = find_last_transaction_node
|
314
314
|
end
|
315
315
|
|
316
316
|
expected = {
|
@@ -319,114 +319,114 @@ module MongoOperationTests
|
|
319
319
|
:operation => :insert
|
320
320
|
}
|
321
321
|
|
322
|
-
result =
|
322
|
+
result = node.params[:statement]
|
323
323
|
assert_equal expected, result
|
324
324
|
end
|
325
325
|
|
326
326
|
def test_noticed_nosql_includes_operation
|
327
|
-
|
327
|
+
node = nil
|
328
328
|
|
329
329
|
in_transaction do
|
330
330
|
@collection.insert(@tribble)
|
331
|
-
|
331
|
+
node = find_last_transaction_node
|
332
332
|
end
|
333
333
|
|
334
|
-
query =
|
334
|
+
query = node.params[:statement]
|
335
335
|
|
336
336
|
assert_equal :insert, query[:operation]
|
337
337
|
end
|
338
338
|
|
339
339
|
def test_noticed_nosql_includes_update_operation
|
340
|
-
|
340
|
+
node = nil
|
341
341
|
|
342
342
|
in_transaction do
|
343
343
|
updated = @tribble.dup
|
344
344
|
updated['name'] = 't-rex'
|
345
345
|
@collection.update(@tribble, updated)
|
346
346
|
|
347
|
-
|
347
|
+
node = find_last_transaction_node
|
348
348
|
end
|
349
349
|
|
350
|
-
query =
|
350
|
+
query = node.params[:statement]
|
351
351
|
|
352
352
|
assert_equal :update, query[:operation]
|
353
353
|
end
|
354
354
|
|
355
355
|
def test_noticed_nosql_includes_save_operation
|
356
|
-
|
356
|
+
node = nil
|
357
357
|
|
358
358
|
in_transaction do
|
359
359
|
@collection.save(@tribble)
|
360
|
-
|
360
|
+
node = find_last_transaction_node
|
361
361
|
end
|
362
362
|
|
363
|
-
query =
|
363
|
+
query = node.params[:statement]
|
364
364
|
assert_equal :save, query[:operation]
|
365
365
|
end
|
366
366
|
|
367
367
|
def test_noticed_nosql_includes_ensure_index_operation
|
368
|
-
|
368
|
+
node = nil
|
369
369
|
|
370
370
|
in_transaction do
|
371
371
|
@collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
|
372
|
-
|
372
|
+
node = find_last_transaction_node
|
373
373
|
end
|
374
374
|
|
375
|
-
|
375
|
+
assert_ensure_index_in_transaction_node(node)
|
376
376
|
end
|
377
377
|
|
378
378
|
def test_noticed_nosql_includes_ensure_index_operation_with_symbol
|
379
|
-
|
379
|
+
node = nil
|
380
380
|
|
381
381
|
in_transaction do
|
382
382
|
@collection.ensure_index(unique_field_name.to_sym)
|
383
|
-
|
383
|
+
node = find_last_transaction_node
|
384
384
|
end
|
385
385
|
|
386
|
-
|
386
|
+
assert_ensure_index_in_transaction_node(node)
|
387
387
|
end
|
388
388
|
|
389
389
|
def test_noticed_nosql_includes_ensure_index_operation_with_string
|
390
|
-
|
390
|
+
node = nil
|
391
391
|
|
392
392
|
in_transaction do
|
393
393
|
@collection.ensure_index(unique_field_name)
|
394
|
-
|
394
|
+
node = find_last_transaction_node
|
395
395
|
end
|
396
396
|
|
397
|
-
|
397
|
+
assert_ensure_index_in_transaction_node(node)
|
398
398
|
end
|
399
399
|
|
400
|
-
def
|
401
|
-
query =
|
400
|
+
def assert_ensure_index_in_transaction_node(node)
|
401
|
+
query = node.params[:statement]
|
402
402
|
result = query[:operation]
|
403
403
|
|
404
404
|
assert_equal :ensureIndex, result
|
405
405
|
end
|
406
406
|
|
407
407
|
def test_noticed_nosql_does_not_contain_documents
|
408
|
-
|
408
|
+
node = nil
|
409
409
|
|
410
410
|
in_transaction do
|
411
411
|
@collection.insert({'name' => 'soterios johnson'})
|
412
|
-
|
412
|
+
node = find_last_transaction_node
|
413
413
|
end
|
414
414
|
|
415
|
-
statement =
|
415
|
+
statement = node.params[:statement]
|
416
416
|
|
417
417
|
refute statement.keys.include?(:documents), "Noticed NoSQL should not include documents: #{statement}"
|
418
418
|
end
|
419
419
|
|
420
420
|
def test_noticed_nosql_does_not_contain_selector_values
|
421
421
|
@collection.insert({'password' => '$ecret'})
|
422
|
-
|
422
|
+
node = nil
|
423
423
|
|
424
424
|
in_transaction do
|
425
425
|
@collection.remove({'password' => '$ecret'})
|
426
|
-
|
426
|
+
node = find_last_transaction_node
|
427
427
|
end
|
428
428
|
|
429
|
-
statement =
|
429
|
+
statement = node.params[:statement]
|
430
430
|
|
431
431
|
refute statement.inspect.include?('$secret')
|
432
432
|
|
@@ -7,31 +7,66 @@ require 'newrelic_rpm'
|
|
7
7
|
require 'new_relic/agent/datastores/mongo'
|
8
8
|
|
9
9
|
if !NewRelic::Agent::Datastores::Mongo.is_supported_version?
|
10
|
-
require File.join(File.dirname(__FILE__), 'helpers', 'mongo_server')
|
11
|
-
|
12
10
|
class NewRelic::Agent::Instrumentation::MongoInstrumentationTest < Minitest::Test
|
13
11
|
include Mongo
|
14
12
|
|
15
13
|
def setup
|
16
|
-
@client = Mongo::Connection.new($mongo.host, $mongo.port)
|
17
14
|
@database_name = "multiverse"
|
18
|
-
@database = @client.db(@database_name)
|
19
15
|
@collection_name = "tribbles-#{SecureRandom.hex(16)}"
|
20
|
-
@collection = @database.collection(@collection_name)
|
21
|
-
|
22
16
|
@tribble = {'name' => 'soterios johnson'}
|
23
17
|
|
18
|
+
setup_collection
|
19
|
+
|
24
20
|
NewRelic::Agent.drop_buffered_data
|
25
21
|
end
|
26
22
|
|
27
23
|
def teardown
|
28
24
|
NewRelic::Agent.drop_buffered_data
|
29
|
-
|
25
|
+
drop_collection
|
30
26
|
end
|
31
27
|
|
32
28
|
def test_records_metrics_for_insert
|
33
|
-
|
29
|
+
insert_to_collection
|
34
30
|
assert_metrics_not_recorded(["Datastore/all", "Datastore/allWeb", "Datastore/allOther"])
|
35
31
|
end
|
32
|
+
|
33
|
+
# API changes between 1.x and 2.x that we need to work around to make
|
34
|
+
# sure that we're testing unsupported versions properly
|
35
|
+
module Mongo1xUnsupported
|
36
|
+
def setup_collection
|
37
|
+
client = Mongo::Connection.new($mongo.host, $mongo.port)
|
38
|
+
@database = client.db(@database_name)
|
39
|
+
@collection = @database.collection(@collection_name)
|
40
|
+
end
|
41
|
+
|
42
|
+
def drop_collection
|
43
|
+
@database.drop_collection(@collection_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def insert_to_collection
|
47
|
+
@collection.insert(@tribble)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
module Mongo2xUnsupported
|
52
|
+
def setup_collection
|
53
|
+
client = Mongo::Client.new(["#{$mongo.host}:#{$mongo.port}"], :database => @database_name, :connect => :direct)
|
54
|
+
@collection = client[@collection_name]
|
55
|
+
end
|
56
|
+
|
57
|
+
def drop_collection
|
58
|
+
@collection.drop
|
59
|
+
end
|
60
|
+
|
61
|
+
def insert_to_collection
|
62
|
+
@collection.insert_one(@tribble)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if NewRelic::Agent::Datastores::Mongo.is_version2?
|
67
|
+
include Mongo2xUnsupported
|
68
|
+
else
|
69
|
+
include Mongo1xUnsupported
|
70
|
+
end
|
36
71
|
end
|
37
72
|
end
|
@@ -24,7 +24,12 @@ if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
|
24
24
|
:file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
|
25
25
|
}
|
26
26
|
post '/', params
|
27
|
-
|
27
|
+
|
28
|
+
expected = {
|
29
|
+
"request.parameters.title" => "blah",
|
30
|
+
"request.parameters.file" => "[FILE]"
|
31
|
+
}
|
32
|
+
assert_equal expected, last_transaction_trace_request_params
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
@@ -32,8 +37,13 @@ if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
|
32
37
|
with_config(:capture_params => true) do
|
33
38
|
params = {"name" => "name", "password" => "mypass"}
|
34
39
|
post '/', params
|
35
|
-
|
40
|
+
|
41
|
+
expected = {
|
42
|
+
"request.parameters.name" => "name",
|
43
|
+
"request.parameters.password" => "mypass"
|
44
|
+
}
|
45
|
+
assert_equal expected, last_transaction_trace_request_params
|
36
46
|
end
|
37
47
|
end
|
38
48
|
end
|
39
|
-
end
|
49
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
if RUBY_VERSION >= '1.9.3'
|
2
2
|
gemfile <<-RB
|
3
|
-
gem 'rails', '~>4.2.
|
3
|
+
gem 'rails', '~>4.2.1'
|
4
4
|
gem 'haml', :require => false
|
5
5
|
gem 'minitest', '5.2.3'
|
6
6
|
RB
|
7
7
|
|
8
8
|
gemfile <<-RB
|
9
|
-
gem 'rails', '~>4.1.
|
9
|
+
gem 'rails', '~>4.1.10'
|
10
10
|
# Multiverse has an incompatibility with Minitest 5.3.0, so lock here for
|
11
11
|
# now
|
12
12
|
gem 'minitest', '5.2.3'
|
@@ -16,7 +16,7 @@ if RUBY_VERSION >= '1.9.3'
|
|
16
16
|
RB
|
17
17
|
|
18
18
|
gemfile <<-RB
|
19
|
-
gem 'rails', '~>4.0.
|
19
|
+
gem 'rails', '~>4.0.13'
|
20
20
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
21
21
|
RB
|
22
22
|
end
|
@@ -61,7 +61,7 @@ class ErrorController < ApplicationController
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def error_with_custom_params
|
64
|
-
NewRelic::Agent.
|
64
|
+
NewRelic::Agent.add_custom_attributes(:texture => 'chunky')
|
65
65
|
raise 'bad things'
|
66
66
|
end
|
67
67
|
|
@@ -113,16 +113,17 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
|
|
113
113
|
|
114
114
|
def test_should_capture_request_uri_and_params
|
115
115
|
get '/error/controller_error?eat=static'
|
116
|
-
assert_equal('/error/controller_error',
|
116
|
+
assert_equal('/error/controller_error', attributes_for_single_error_posted("request_uri"))
|
117
117
|
|
118
|
-
expected_params = {
|
118
|
+
expected_params = {
|
119
|
+
'request.parameters.eat' => 'static',
|
120
|
+
'httpResponseCode' => 500
|
121
|
+
}
|
119
122
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
+
attributes = agent_attributes_for_single_error_posted
|
124
|
+
expected_params.each do |key, value|
|
125
|
+
assert_equal value, attributes[key]
|
123
126
|
end
|
124
|
-
|
125
|
-
assert_equal(expected_params, last_error.params[:request_params])
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -181,16 +182,16 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
|
|
181
182
|
|
182
183
|
def test_should_apply_parameter_filtering
|
183
184
|
get '/error/controller_error?secret=shouldnotbecaptured&other=whatever'
|
184
|
-
|
185
|
-
assert_equal('[FILTERED]',
|
186
|
-
assert_equal('whatever',
|
185
|
+
attributes = agent_attributes_for_single_error_posted
|
186
|
+
assert_equal('[FILTERED]', attributes['request.parameters.secret'])
|
187
|
+
assert_equal('whatever', attributes['request.parameters.other'])
|
187
188
|
end
|
188
189
|
|
189
190
|
def test_should_apply_parameter_filtering_for_non_standard_errors
|
190
191
|
get '/error/exception_error?secret=shouldnotbecaptured&other=whatever'
|
191
|
-
|
192
|
-
assert_equal('[FILTERED]',
|
193
|
-
assert_equal('whatever',
|
192
|
+
attributes = agent_attributes_for_single_error_posted
|
193
|
+
assert_equal('[FILTERED]', attributes['request.parameters.secret'])
|
194
|
+
assert_equal('whatever', attributes['request.parameters.other'])
|
194
195
|
end
|
195
196
|
|
196
197
|
def test_should_not_notice_errors_from_ignored_action
|
@@ -231,28 +232,47 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
|
|
231
232
|
assert_error_reported_once('this is a server ignored error')
|
232
233
|
end
|
233
234
|
|
234
|
-
|
235
|
-
|
236
|
-
def test_captured_errors_should_include_custom_params
|
235
|
+
def test_captured_errors_should_include_custom_params
|
236
|
+
with_config(:'error_collector.attributes.enabled' => true) do
|
237
237
|
get '/error/error_with_custom_params'
|
238
238
|
assert_error_reported_once('bad things')
|
239
|
-
|
240
|
-
|
241
|
-
assert_equal({
|
239
|
+
|
240
|
+
attributes = user_attributes_for_single_error_posted
|
241
|
+
assert_equal({'texture' => 'chunky'}, attributes)
|
242
242
|
end
|
243
|
+
end
|
243
244
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
245
|
+
def test_captured_errors_should_include_custom_params_with_legacy_setting
|
246
|
+
with_config(:'error_collector.capture_attributes' => true) do
|
247
|
+
get '/error/error_with_custom_params'
|
248
|
+
assert_error_reported_once('bad things')
|
249
|
+
|
250
|
+
attributes = user_attributes_for_single_error_posted
|
251
|
+
assert_equal({'texture' => 'chunky'}, attributes)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_captured_errors_should_not_include_custom_params_if_config_says_no
|
256
|
+
with_config(:'error_collector.attributes.enabled' => false) do
|
257
|
+
get '/error/error_with_custom_params'
|
248
258
|
assert_error_reported_once('bad things')
|
249
|
-
|
250
|
-
|
251
|
-
|
259
|
+
|
260
|
+
attributes = user_attributes_for_single_error_posted
|
261
|
+
assert_empty attributes
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_captured_errors_should_not_include_custom_params_if_legacy_setting_says_no
|
266
|
+
with_config(:'error_collector.capture_attributes' => false) do
|
267
|
+
get '/error/error_with_custom_params'
|
268
|
+
assert_error_reported_once('bad things')
|
269
|
+
|
270
|
+
attributes = user_attributes_for_single_error_posted
|
271
|
+
assert_empty attributes
|
252
272
|
end
|
253
273
|
end
|
254
274
|
|
255
|
-
|
275
|
+
protected
|
256
276
|
|
257
277
|
def errors_with_message(message)
|
258
278
|
@error_collector.errors.select{|error| error.message == message}
|
@@ -280,10 +300,11 @@ end
|
|
280
300
|
class ErrorsWithSSCTest < ErrorsWithoutSSCTest
|
281
301
|
def setup_collector_mocks
|
282
302
|
$collector.stub('connect', {
|
283
|
-
"listen_to_server_config" => true,
|
284
303
|
"agent_run_id" => 1,
|
285
|
-
"
|
286
|
-
|
304
|
+
"agent_config" => {
|
305
|
+
"error_collector.ignore_errors" => 'NewRelic::TestHelpers::Exceptions::IgnoredError,NewRelic::TestHelpers::Exceptions::ServerIgnoredError',
|
306
|
+
"error_collector.enabled" => true,
|
307
|
+
},
|
287
308
|
"collect_errors" => true
|
288
309
|
}, 200)
|
289
310
|
end
|