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
@@ -67,7 +67,7 @@ class GCRailsInstrumentationTest < ActionController::TestCase
|
|
67
67
|
elapsed = Time.now.to_f - start
|
68
68
|
|
69
69
|
trace = NewRelic::Agent.instance.transaction_sampler.last_sample
|
70
|
-
assert_in_range(elapsed, trace
|
70
|
+
assert_in_range(elapsed, attributes_for(trace, :intrinsic)[:gc_time])
|
71
71
|
end
|
72
72
|
|
73
73
|
def assert_in_range(duration, gc_time)
|
@@ -62,7 +62,7 @@ class IgnoredActionsTest < RailsMultiverseTest
|
|
62
62
|
get '/request_stats/stats_action'
|
63
63
|
|
64
64
|
trace = NewRelic::Agent.instance.transaction_sampler.last_sample
|
65
|
-
assert_equal 1, trace.
|
65
|
+
assert_equal 1, trace.root_node.called_nodes.count
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_should_not_write_cat_response_headers_for_ignored_transactions
|
@@ -10,6 +10,7 @@ class ParameterCaptureController < ApplicationController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
+
raise 'problem' if params[:raise]
|
13
14
|
render :text => 'created'
|
14
15
|
end
|
15
16
|
|
@@ -33,15 +34,14 @@ class ParameterCaptureController < ApplicationController
|
|
33
34
|
end
|
34
35
|
|
35
36
|
class ParameterCaptureTest < RailsMultiverseTest
|
36
|
-
|
37
|
-
|
38
|
-
end
|
37
|
+
include MultiverseHelpers
|
38
|
+
setup_and_teardown_agent
|
39
39
|
|
40
40
|
def test_no_params_captured_on_errors_when_disabled
|
41
41
|
with_config(:capture_params => false) do
|
42
42
|
get '/parameter_capture/error?other=1234&secret=4567'
|
43
|
+
refute_contains_request_params(agent_attributes_for_single_error_posted)
|
43
44
|
end
|
44
|
-
assert_nil last_traced_error_request_params
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_no_params_captured_on_tts_when_disabled
|
@@ -51,49 +51,76 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
51
51
|
assert_equal({}, last_transaction_trace_request_params)
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def test_uri_on_traced_errors_never_contains_query_string_without_capture_params
|
55
55
|
with_config(:capture_params => false) do
|
56
56
|
get '/parameter_capture/error?other=1234&secret=4567'
|
57
|
+
assert_equal('/parameter_capture/error', attributes_for_single_error_posted("request_uri"))
|
57
58
|
end
|
58
|
-
|
59
|
+
end
|
59
60
|
|
61
|
+
def test_uri_on_traced_errors_never_contains_query_string_with_capture_params
|
60
62
|
with_config(:capture_params => true) do
|
61
63
|
get '/parameter_capture/error?other=1234&secret=4567'
|
64
|
+
assert_equal('/parameter_capture/error', attributes_for_single_error_posted("request_uri"))
|
62
65
|
end
|
63
|
-
assert_equal('/parameter_capture/error', last_traced_error.params[:request_uri])
|
64
66
|
end
|
65
67
|
|
66
|
-
def
|
68
|
+
def test_referrer_on_traced_errors_never_contains_query_string_without_capture_params
|
67
69
|
with_config(:capture_params => false) do
|
68
70
|
get '/parameter_capture/error?other=1234&secret=4567', {}, { 'HTTP_REFERER' => '/foo/bar?other=123&secret=456' }
|
71
|
+
attributes = agent_attributes_for_single_error_posted
|
72
|
+
assert_equal('/foo/bar', attributes["request.headers.referer"])
|
69
73
|
end
|
70
|
-
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_referrer_on_traced_errors_never_contains_query_string_even_with_capture_params
|
71
77
|
with_config(:capture_params => true) do
|
72
78
|
get '/parameter_capture/error?other=1234&secret=4567', {}, { 'HTTP_REFERER' => '/foo/bar?other=123&secret=456' }
|
79
|
+
attributes = agent_attributes_for_single_error_posted
|
80
|
+
assert_equal('/foo/bar', attributes["request.headers.referer"])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_controller_and_action_excluded_from_error_parameters
|
85
|
+
with_config(:capture_params => true) do
|
86
|
+
get '/parameter_capture/error'
|
87
|
+
run_harvest
|
88
|
+
|
89
|
+
refute_error_has_agent_attribute('request.parameters.controller')
|
90
|
+
refute_error_has_agent_attribute('request.parameters.action')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_controller_and_action_excluded_from_transaction_trace_parameters
|
95
|
+
with_config(:capture_params => true, :'transaction_tracer.transaction_threshold' => -10) do
|
96
|
+
get '/parameter_capture/transaction'
|
97
|
+
run_harvest
|
98
|
+
|
99
|
+
refute_transaction_trace_has_agent_attribute('request.parameters.controller')
|
100
|
+
refute_transaction_trace_has_agent_attribute('request.parameters.action')
|
73
101
|
end
|
74
|
-
assert_equal('/foo/bar', last_traced_error.params[:request_referer])
|
75
102
|
end
|
76
103
|
|
77
104
|
def test_uri_on_tts_never_contains_query_string
|
78
105
|
with_config(:capture_params => false) do
|
79
106
|
get '/parameter_capture/transaction?other=1234&secret=4567'
|
80
107
|
end
|
81
|
-
assert_equal('/parameter_capture/transaction', last_transaction_trace.
|
108
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.uri)
|
82
109
|
|
83
110
|
with_config(:capture_params => true) do
|
84
111
|
get '/parameter_capture/transaction?other=1234&secret=4567'
|
85
112
|
end
|
86
|
-
assert_equal('/parameter_capture/transaction', last_transaction_trace.
|
113
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.uri)
|
87
114
|
end
|
88
115
|
|
89
116
|
def test_filters_parameters_on_traced_errors
|
90
117
|
with_config(:capture_params => true) do
|
91
118
|
get '/parameter_capture/error?other=1234&secret=4567'
|
92
|
-
end
|
93
119
|
|
94
|
-
|
95
|
-
|
96
|
-
|
120
|
+
captured_params = agent_attributes_for_single_error_posted
|
121
|
+
assert_equal('[FILTERED]', captured_params['request.parameters.secret'])
|
122
|
+
assert_equal('1234', captured_params['request.parameters.other'])
|
123
|
+
end
|
97
124
|
end
|
98
125
|
|
99
126
|
def test_filters_parameters_on_transaction_traces
|
@@ -102,24 +129,30 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
102
129
|
end
|
103
130
|
|
104
131
|
captured_params = last_transaction_trace_request_params
|
105
|
-
assert_equal('[FILTERED]', captured_params['secret'])
|
106
|
-
assert_equal('1234', captured_params['other'])
|
132
|
+
assert_equal('[FILTERED]', captured_params['request.parameters.secret'])
|
133
|
+
assert_equal('1234', captured_params['request.parameters.other'])
|
107
134
|
end
|
108
135
|
|
136
|
+
def test_no_traced_error_params_captured_when_bails_before_rails
|
137
|
+
with_config(:capture_params => false) do
|
138
|
+
get '/middleware_error/before?other=1234&secret=4567'
|
139
|
+
refute_contains_request_params(agent_attributes_for_single_error_posted)
|
140
|
+
end
|
141
|
+
end
|
109
142
|
|
110
|
-
def
|
143
|
+
def test_no_transaction_trace_params_captured_when_bails_before_rails
|
111
144
|
with_config(:capture_params => false) do
|
112
145
|
get '/middleware_error/before?other=1234&secret=4567'
|
113
146
|
end
|
114
|
-
|
147
|
+
|
115
148
|
assert_equal({}, last_transaction_trace_request_params)
|
116
149
|
end
|
117
150
|
|
118
151
|
def test_no_params_captured_on_error_when_bails_before_rails_even_when_enabled
|
119
152
|
with_config(:capture_params => true) do
|
120
153
|
get '/middleware_error/before?other=1234&secret=4567'
|
154
|
+
refute_contains_request_params(agent_attributes_for_single_error_posted)
|
121
155
|
end
|
122
|
-
assert_nil last_traced_error_request_params
|
123
156
|
end
|
124
157
|
|
125
158
|
def test_no_params_captured_on_tt_when_bails_before_rails_even_when_enabled
|
@@ -133,28 +166,28 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
133
166
|
with_config(:capture_params => false) do
|
134
167
|
get '/parameter_capture/transaction?param1=value1¶m2=value2'
|
135
168
|
end
|
136
|
-
assert_equal('/parameter_capture/transaction', last_transaction_trace.
|
169
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.uri)
|
137
170
|
end
|
138
171
|
|
139
172
|
def test_uri_on_tt_should_not_contain_query_string_with_capture_params_on
|
140
173
|
with_config(:capture_params => true) do
|
141
174
|
get '/parameter_capture/transaction?param1=value1¶m2=value2'
|
142
175
|
end
|
143
|
-
assert_equal('/parameter_capture/transaction', last_transaction_trace.
|
176
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.uri)
|
144
177
|
end
|
145
178
|
|
146
179
|
def test_uri_on_traced_error_should_not_contain_query_string_with_capture_params_off
|
147
180
|
with_config(:capture_params => false) do
|
148
181
|
get '/parameter_capture/error?param1=value1¶m2=value2'
|
182
|
+
assert_equal('/parameter_capture/error', attributes_for_single_error_posted("request_uri"))
|
149
183
|
end
|
150
|
-
assert_equal('/parameter_capture/error', last_traced_error.params[:request_uri])
|
151
184
|
end
|
152
185
|
|
153
186
|
def test_uri_on_traced_error_should_not_contain_query_string_with_capture_params_on
|
154
187
|
with_config(:capture_params => true) do
|
155
188
|
get '/parameter_capture/error?param1=value1¶m2=value2'
|
189
|
+
assert_equal('/parameter_capture/error', attributes_for_single_error_posted("request_uri"))
|
156
190
|
end
|
157
|
-
assert_equal('/parameter_capture/error', last_traced_error.params[:request_uri])
|
158
191
|
end
|
159
192
|
|
160
193
|
def test_uri_on_sql_trace_should_not_contain_query_string_with_capture_params_off
|
@@ -171,13 +204,31 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
171
204
|
assert_equal('/parameter_capture/sql', last_sql_trace.url)
|
172
205
|
end
|
173
206
|
|
207
|
+
def test_parameters_attached_to_transaction_events_if_enabled
|
208
|
+
with_config(:'attributes.include' => 'request.parameters.*') do
|
209
|
+
get '/parameter_capture/transaction?param1=value1¶m2=value2'
|
210
|
+
end
|
211
|
+
|
212
|
+
actual = agent_attributes_for_single_event_posted_without_ignored_attributes
|
213
|
+
|
214
|
+
expected = {"request.parameters.param1" => "value1",
|
215
|
+
"request.parameters.param2" => "value2"
|
216
|
+
}
|
217
|
+
|
218
|
+
assert_equal expected, actual
|
219
|
+
end
|
220
|
+
|
174
221
|
if Rails::VERSION::MAJOR > 2
|
175
222
|
def test_params_tts_should_be_filtered_when_serviced_by_rack_app
|
176
223
|
params = {"secret" => "shhhhhhh", "name" => "name"}
|
177
224
|
with_config(:capture_params => true) do
|
178
225
|
post '/filtering_test/', params
|
179
226
|
end
|
180
|
-
|
227
|
+
|
228
|
+
expected = {
|
229
|
+
"request.parameters.secret" => "[FILTERED]",
|
230
|
+
"request.parameters.name" => "name"
|
231
|
+
}
|
181
232
|
assert_equal expected, last_transaction_trace_request_params
|
182
233
|
end
|
183
234
|
|
@@ -185,9 +236,18 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
185
236
|
params = {"secret" => "shhhhhhh", "name" => "name"}
|
186
237
|
with_config(:capture_params => true) do
|
187
238
|
post '/filtering_test?raise=1', params
|
239
|
+
|
240
|
+
expected = {
|
241
|
+
"request.parameters.secret" => "[FILTERED]",
|
242
|
+
"request.parameters.name" => "name",
|
243
|
+
"request.parameters.raise" => "1"
|
244
|
+
}
|
245
|
+
|
246
|
+
attributes = agent_attributes_for_single_error_posted
|
247
|
+
expected.each do |key, value|
|
248
|
+
assert_equal value, attributes[key]
|
249
|
+
end
|
188
250
|
end
|
189
|
-
expected = {"secret" => "[FILTERED]", "name" => "name", "raise" => "1"}
|
190
|
-
assert_equal expected, last_traced_error_request_params
|
191
251
|
end
|
192
252
|
|
193
253
|
def test_parameter_filtering_should_not_mutate_argument
|
@@ -202,30 +262,38 @@ class ParameterCaptureTest < RailsMultiverseTest
|
|
202
262
|
|
203
263
|
if Rails::VERSION::MAJOR > 2 && defined?(Sinatra)
|
204
264
|
def test_params_tts_should_be_filtered_when_serviced_by_sinatra_app
|
205
|
-
params = {"secret" => "shhhhhhh", "name" => "name"}
|
206
265
|
with_config(:capture_params => true) do
|
207
|
-
get '/sinatra_app/',
|
266
|
+
get '/sinatra_app/', "secret" => "shhhhhhh", "name" => "name"
|
208
267
|
end
|
209
|
-
|
268
|
+
|
269
|
+
expected = {
|
270
|
+
"request.parameters.secret" => "[FILTERED]",
|
271
|
+
"request.parameters.name" => "name"
|
272
|
+
}
|
210
273
|
assert_equal expected, last_transaction_trace_request_params
|
211
274
|
end
|
212
275
|
|
213
276
|
def test_params_on_errors_should_be_filtered_when_serviced_by_sinatra_app
|
214
|
-
params = {"secret" => "shhhhhhh", "name" => "name"}
|
215
277
|
with_config(:capture_params => true) do
|
216
|
-
get '/sinatra_app?raise=1',
|
278
|
+
get '/sinatra_app?raise=1', "secret" => "shhhhhhh", "name" => "name"
|
279
|
+
|
280
|
+
attributes = agent_attributes_for_single_error_posted
|
281
|
+
assert_equal "[FILTERED]", attributes["request.parameters.secret"]
|
282
|
+
assert_equal "name", attributes["request.parameters.name"]
|
283
|
+
assert_equal "1", attributes["request.parameters.raise"]
|
217
284
|
end
|
218
|
-
expected = {"secret" => "[FILTERED]", "name" => "name", "raise" => "1"}
|
219
|
-
assert_equal expected, last_traced_error_request_params
|
220
285
|
end
|
221
286
|
|
222
287
|
def test_file_upload_params_are_replaced_with_placeholder
|
223
|
-
with_config(:capture_params => true) do
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
288
|
+
with_config(:capture_params => true, :'transaction_tracer.transaction_threshold' => -10) do
|
289
|
+
post '/parameter_capture', :file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
|
290
|
+
|
291
|
+
run_harvest
|
292
|
+
|
293
|
+
result = single_transaction_trace_posted
|
294
|
+
assert_equal "#<ActionDispatch::Http::UploadedFile>", result.agent_attributes["request.parameters.file"]
|
228
295
|
end
|
229
296
|
end
|
230
297
|
end
|
298
|
+
|
231
299
|
end
|
@@ -18,7 +18,7 @@ class RequestStatsController < ApplicationController
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def stats_action_with_custom_params
|
21
|
-
::NewRelic::Agent.
|
21
|
+
::NewRelic::Agent.add_custom_attributes('color' => 'blue', 1 => :bar, 'bad' => {})
|
22
22
|
render :text => 'some stuff'
|
23
23
|
end
|
24
24
|
end
|
@@ -55,9 +55,13 @@ class RequestStatsTest < RailsMultiverseTest
|
|
55
55
|
assert_kind_of Array, post.events
|
56
56
|
assert_kind_of Array, post.events.first
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
assert_equal 3, post.events.first.length
|
59
|
+
|
60
|
+
post.events.first.each do |event_chunk|
|
61
|
+
assert_kind_of Hash, event_chunk
|
62
|
+
end
|
60
63
|
|
64
|
+
sample = post.events.first.first
|
61
65
|
assert_equal 'Controller/request_stats/stats_action', sample['name']
|
62
66
|
assert_encoding 'utf-8', sample['name']
|
63
67
|
assert_equal 'Transaction', sample['type']
|
@@ -133,14 +137,16 @@ class RequestStatsTest < RailsMultiverseTest
|
|
133
137
|
assert_equal 'Controller/request_stats/stats_action_with_custom_params', sample['name']
|
134
138
|
assert_encoding 'utf-8', sample['name']
|
135
139
|
assert_equal 'Transaction', sample['type']
|
140
|
+
|
136
141
|
['blue', 'bar', 'bad'].each do |key|
|
137
142
|
assert_not_includes(sample, key)
|
138
143
|
end
|
139
144
|
|
140
145
|
custom_params = post.events.first[1]
|
146
|
+
|
141
147
|
assert_equal 'blue', custom_params['color']
|
142
148
|
assert_equal 'bar', custom_params['1']
|
143
|
-
|
149
|
+
assert_equal '{}', custom_params['bad']
|
144
150
|
end
|
145
151
|
end
|
146
152
|
|
@@ -112,27 +112,27 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
112
112
|
assert_equal 500, status
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
115
|
+
def test_should_count_all_the_template_and_partial_nodes
|
116
116
|
get '/views/template_render_with_3_partial_renders'
|
117
117
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
118
|
-
|
119
|
-
|
118
|
+
nodes = find_all_nodes_with_name_matching(sample, ['^Nested/Controller/views', '^View'])
|
119
|
+
nodes_list = "Found these nodes:\n #{nodes.map(&:metric_name).join("\n ")}"
|
120
120
|
|
121
121
|
if Rails::VERSION::MAJOR <= 2
|
122
|
-
assert_equal 8,
|
122
|
+
assert_equal 8, nodes.length, "Should be a node for the controller action, the template, and 3 partials with two nodes each (8). #{nodes_list}"
|
123
123
|
else
|
124
|
-
assert_equal 5,
|
124
|
+
assert_equal 5, nodes.length, "Should be a node for the controller action, the template, and 3 partials (5). #{nodes_list}"
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
def
|
128
|
+
def test_should_have_3_nodes_with_the_correct_metric_name
|
129
129
|
get '/views/template_render_with_3_partial_renders'
|
130
130
|
|
131
131
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
132
|
-
|
132
|
+
partial_nodes = find_all_nodes_with_name_matching(sample, 'View/views/_a_partial.html.erb/Partial')
|
133
133
|
|
134
|
-
assert_equal 3,
|
135
|
-
assert_equal ['View/views/_a_partial.html.erb/Partial'],
|
134
|
+
assert_equal 3, partial_nodes.size, "sanity check"
|
135
|
+
assert_equal ['View/views/_a_partial.html.erb/Partial'], partial_nodes.map(&:metric_name).uniq
|
136
136
|
end
|
137
137
|
|
138
138
|
# We don't capture text or inline template rendering on Rails 2
|
@@ -141,9 +141,9 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
141
141
|
get '/views/inline_render'
|
142
142
|
|
143
143
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
144
|
-
|
144
|
+
text_node = find_node_with_name(sample, 'View/inline template/Rendering')
|
145
145
|
|
146
|
-
assert
|
146
|
+
assert text_node, "Failed to find a node named View/inline template/Rendering"
|
147
147
|
assert_metrics_recorded('View/inline template/Rendering')
|
148
148
|
end
|
149
149
|
|
@@ -152,16 +152,16 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
152
152
|
def test_should_not_instrument_rendering_of_text
|
153
153
|
get '/views/text_render'
|
154
154
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
155
|
-
refute
|
155
|
+
refute find_node_with_name(sample, 'View/text template/Rendering')
|
156
156
|
end
|
157
157
|
else
|
158
158
|
def test_should_create_a_metric_for_the_rendered_text
|
159
159
|
get '/views/text_render'
|
160
160
|
|
161
161
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
162
|
-
|
162
|
+
text_node = find_node_with_name(sample, 'View/text template/Rendering')
|
163
163
|
|
164
|
-
assert
|
164
|
+
assert text_node, "Failed to find a node named View/text template/Rendering"
|
165
165
|
assert_metrics_recorded('View/text template/Rendering')
|
166
166
|
end
|
167
167
|
end
|
@@ -171,9 +171,9 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
171
171
|
get '/views/haml_render'
|
172
172
|
|
173
173
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
174
|
-
|
174
|
+
text_node = find_node_with_name(sample, 'View/views/haml_view.html.haml/Rendering')
|
175
175
|
|
176
|
-
assert
|
176
|
+
assert text_node, "Failed to find a node named View/views/haml_view.html.haml/Rendering"
|
177
177
|
assert_metrics_recorded('View/views/haml_view.html.haml/Rendering')
|
178
178
|
end
|
179
179
|
|
@@ -184,18 +184,18 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
184
184
|
# Different versions have significant difference in handling, but we're
|
185
185
|
# happy enough with what each of them does in the unknown case
|
186
186
|
if Rails::VERSION::MAJOR.to_i < 3 || (Rails::VERSION::MAJOR.to_i == 3 && Rails::VERSION::MINOR.to_i == 0)
|
187
|
-
refute
|
187
|
+
refute find_node_with_name_matching(sample, /^View/)
|
188
188
|
elsif Rails::VERSION::MAJOR.to_i == 3
|
189
|
-
assert
|
189
|
+
assert find_node_with_name(sample, 'View/collection/Partial')
|
190
190
|
else
|
191
|
-
assert
|
191
|
+
assert find_node_with_name(sample, 'View/(unknown)/Partial')
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_should_create_a_proper_metric_when_we_render_a_collection
|
196
196
|
get '/views/collection_render'
|
197
197
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
198
|
-
assert
|
198
|
+
assert find_node_with_name(sample, "View/foos/_foo.html.haml/Partial")
|
199
199
|
end
|
200
200
|
|
201
201
|
[:js_render, :xml_render, :proc_render, :json_render ].each do |action|
|
@@ -203,8 +203,8 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
203
203
|
define_method("test_should_not_instrument_rendering_of_#{action}") do
|
204
204
|
get "/views/#{action}"
|
205
205
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
206
|
-
|
207
|
-
refute
|
206
|
+
view_node = find_node_with_name_matching(sample, /^View\//)
|
207
|
+
refute view_node, "Should not instrument rendering of #{action}, found #{view_node}."
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -214,8 +214,8 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
214
214
|
def test_should_create_a_metric_for_rendered_file_that_does_not_include_the_filename_so_it_doesnt_metric_explode
|
215
215
|
get '/views/file_render'
|
216
216
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
217
|
-
assert
|
218
|
-
refute
|
217
|
+
assert find_node_with_name(sample, 'View/file/Rendering')
|
218
|
+
refute find_node_with_name_matching(sample, 'dummy')
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|