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
@@ -125,6 +125,94 @@ module NewRelic::Agent::Configuration
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
def test_transaction_tracer_attributes_enabled_default
|
129
|
+
with_config(:'transaction_tracer.capture_attributes' => :foo) do
|
130
|
+
assert_equal :foo, NewRelic::Agent.config['transaction_tracer.attributes.enabled']
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_transaction_events_attributes_enabled_default
|
135
|
+
with_config(:'analytics_events.capture_attributes' => :foo) do
|
136
|
+
assert_equal :foo, NewRelic::Agent.config['transaction_events.attributes.enabled']
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_error_collector_attributes_enabled_default
|
141
|
+
with_config(:'error_collector.capture_attributes' => :foo) do
|
142
|
+
assert_equal :foo, NewRelic::Agent.config['error_collector.attributes.enabled']
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_browser_monitoring_attributes_enabled_default
|
147
|
+
with_config(:'browser_monitoring.capture_attributes' => :foo) do
|
148
|
+
assert_equal :foo, NewRelic::Agent.config['browser_monitoring.attributes.enabled']
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_agent_attribute_settings_convert_comma_delimited_strings_into_an_arrays
|
153
|
+
types = %w(transaction_tracer. transaction_events. error_collector. browser_monitoring.)
|
154
|
+
types << ''
|
155
|
+
|
156
|
+
types.each do |type|
|
157
|
+
key = "#{type}attributes.exclude".to_sym
|
158
|
+
|
159
|
+
with_config(key => 'foo,bar,baz') do
|
160
|
+
expected = ["foo", "bar", "baz"]
|
161
|
+
result = NewRelic::Agent.config[key]
|
162
|
+
|
163
|
+
message = "Expected #{key} to convert comma delimited string into array.\nExpected: #{expected.inspect}, Result: #{result.inspect}\n"
|
164
|
+
assert expected == result, message
|
165
|
+
end
|
166
|
+
|
167
|
+
key = "#{type}attributes.include".to_sym
|
168
|
+
|
169
|
+
with_config(key => 'foo,bar,baz') do
|
170
|
+
assert_equal ["foo", "bar", "baz"], NewRelic::Agent.config[key]
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_agent_attributes_settings_with_yaml_array
|
176
|
+
types = %w(transaction_tracer. transaction_events. error_collector. browser_monitoring.)
|
177
|
+
types << ''
|
178
|
+
|
179
|
+
types.each do |type|
|
180
|
+
key = "#{type}attributes.exclude".to_sym
|
181
|
+
|
182
|
+
with_config(key => ['foo','bar','baz']) do
|
183
|
+
expected = ["foo", "bar", "baz"]
|
184
|
+
result = NewRelic::Agent.config[key]
|
185
|
+
|
186
|
+
message = "Expected #{key} not to modify settings from YAML array.\nExpected: #{expected.inspect}, Result: #{result.inspect}\n"
|
187
|
+
assert expected == result, message
|
188
|
+
end
|
189
|
+
|
190
|
+
key = "#{type}attributes.include".to_sym
|
191
|
+
|
192
|
+
with_config(key => 'foo,bar,baz') do
|
193
|
+
assert_equal ["foo", "bar", "baz"], NewRelic::Agent.config[key]
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_all_settings_specify_whether_they_are_allowed_from_server
|
199
|
+
unspecified_keys = []
|
200
|
+
bad_value_keys = []
|
201
|
+
|
202
|
+
@defaults.each do |key, spec|
|
203
|
+
if !spec.has_key?(:allowed_from_server)
|
204
|
+
unspecified_keys << key
|
205
|
+
end
|
206
|
+
|
207
|
+
if ![true, false].include?(spec[:allowed_from_server])
|
208
|
+
bad_value_keys << key
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
assert unspecified_keys.empty?, "The following keys did not specify a value for :allowed_from_server: #{unspecified_keys.join(', ')}"
|
213
|
+
assert bad_value_keys.empty?, "The following keys had incorrect :allowed_from_server values (only true or false are allowed): #{bad_value_keys.join(', ')}"
|
214
|
+
end
|
215
|
+
|
128
216
|
def get_config_value_class(value)
|
129
217
|
type = value.class
|
130
218
|
|
@@ -46,9 +46,8 @@ module NewRelic::Agent::Configuration
|
|
46
46
|
def test_sources_applied_in_correct_order
|
47
47
|
# in order of precedence
|
48
48
|
high_security = HighSecuritySource.new({})
|
49
|
-
server_source = ServerSource.new(
|
50
|
-
manual_source = ManualSource.new(:
|
51
|
-
:capture_params => true)
|
49
|
+
server_source = ServerSource.new('data_report_period' => 3, 'capture_params' => true)
|
50
|
+
manual_source = ManualSource.new(:data_report_period => 2, :bar => 'bar', :capture_params => true)
|
52
51
|
|
53
52
|
# load them out of order, just to prove that load order
|
54
53
|
# doesn't determine precedence
|
@@ -56,7 +55,7 @@ module NewRelic::Agent::Configuration
|
|
56
55
|
@manager.replace_or_add_config(server_source)
|
57
56
|
@manager.replace_or_add_config(high_security)
|
58
57
|
|
59
|
-
assert_equal
|
58
|
+
assert_equal 3, @manager['data_report_period']
|
60
59
|
assert_equal 'bar', @manager['bar']
|
61
60
|
assert_equal false, @manager['capture_params']
|
62
61
|
end
|
@@ -29,7 +29,9 @@ class OrphanedConfigTest < Minitest::Test
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
# This is a bit loose (allows any config[] with the right key) so we can pass
|
33
|
+
# NewRelic::Agent.config into classes as long as we call the variable config
|
34
|
+
AGENT_CONFIG_PATTERN = /config\[:['"]?([a-z\._]+)['"]?\s*\]/
|
33
35
|
DEFAULT_VALUE_OF_PATTERN = /:default\s*=>\s*value_of\(:['"]?([a-z\._]+)['"]?\)\s*/
|
34
36
|
REGISTER_CALLBACK_PATTERN = /register_callback\(:['"]?([a-z\._]+)['"]?\)/
|
35
37
|
NAMED_DEPENDENCY_PATTERN = /^\s*named[ (]+\:?([a-z0-9\._]+).*$/
|
@@ -159,5 +159,44 @@ module NewRelic::Agent::Configuration
|
|
159
159
|
assert @source[:'analytics_events.enabled']
|
160
160
|
assert @source[:'custom_insights_events.enabled']
|
161
161
|
end
|
162
|
+
|
163
|
+
def test_should_strip_non_ssc_keys
|
164
|
+
rsp = {
|
165
|
+
'agent_config' => {
|
166
|
+
'attributes.include' => 'foo,bar',
|
167
|
+
'slow_sql.explain_threshold' => 42
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
source = ServerSource.new(rsp, {})
|
172
|
+
refute_includes source.keys, :'attributes.include'
|
173
|
+
assert_includes source.keys, :'slow_sql.explain_threshold'
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_should_strip_unrecognized_keys_in_agent_config_hash
|
177
|
+
rsp = {
|
178
|
+
'agent_config' => {
|
179
|
+
'platypus' => 'mammal'
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
source = ServerSource.new(rsp, {})
|
184
|
+
refute_includes source.keys, :platypus
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_should_not_merge_in_keys_that_are_not_allowed_at_top_level
|
188
|
+
rsp = {
|
189
|
+
'slow_sql.explain_threshold' => 42
|
190
|
+
}
|
191
|
+
source = ServerSource.new(rsp, {})
|
192
|
+
refute_includes source.keys, :'slow_sql.explain_threshold'
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_all_top_level_keys_should_be_allowed_from_server
|
196
|
+
ServerSource::TOP_LEVEL_KEYS.each do |key|
|
197
|
+
assert DEFAULTS[key.to_sym], "Did not find entry in config DEFAULTS hash for to-level server config key #{key}"
|
198
|
+
assert DEFAULTS[key.to_sym][:allowed_from_server], "Expected top-level server config key #{key} to be allowed from server"
|
199
|
+
end
|
200
|
+
end
|
162
201
|
end
|
163
202
|
end
|
@@ -135,29 +135,13 @@ module NewRelic::Agent
|
|
135
135
|
assert_equal(42, @monitor.content_length_from_request(request))
|
136
136
|
end
|
137
137
|
|
138
|
-
def
|
138
|
+
def test_writes_attributes
|
139
139
|
with_default_timings
|
140
140
|
|
141
|
-
|
142
|
-
NewRelic::Agent.expects(:add_custom_parameters).with(:referring_transaction_guid => REF_TRANSACTION_GUID)
|
141
|
+
txn = when_request_runs
|
143
142
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
def test_error_writes_custom_parameters
|
148
|
-
with_default_timings
|
149
|
-
|
150
|
-
options = when_request_has_error
|
151
|
-
|
152
|
-
assert_equal REQUEST_CROSS_APP_ID, options[:client_cross_process_id]
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_error_doesnt_write_custom_parameters_if_no_id
|
156
|
-
with_default_timings
|
157
|
-
|
158
|
-
options = when_request_has_error(for_id(''))
|
159
|
-
|
160
|
-
assert_equal false, options.key?(:client_cross_process_id)
|
143
|
+
assert_equal REQUEST_CROSS_APP_ID, attributes_for(txn, :intrinsic)[:client_cross_process_id]
|
144
|
+
assert_equal REF_TRANSACTION_GUID, attributes_for(txn, :intrinsic)[:referring_transaction_guid]
|
161
145
|
end
|
162
146
|
|
163
147
|
def test_writes_metric
|
@@ -225,23 +209,15 @@ module NewRelic::Agent
|
|
225
209
|
#
|
226
210
|
|
227
211
|
def when_request_runs(request=for_id(REQUEST_CROSS_APP_ID))
|
228
|
-
in_transaction('transaction') do
|
212
|
+
in_transaction('transaction') do |txn|
|
229
213
|
@events.notify(:before_call, request)
|
230
214
|
# Fake out our GUID for easier comparison in tests
|
231
215
|
NewRelic::Agent::Transaction.tl_current.stubs(:guid).returns(TRANSACTION_GUID)
|
232
216
|
@events.notify(:after_call, request, [200, @response, ''])
|
217
|
+
txn
|
233
218
|
end
|
234
219
|
end
|
235
220
|
|
236
|
-
def when_request_has_error(request=for_id(REQUEST_CROSS_APP_ID))
|
237
|
-
options = {}
|
238
|
-
@events.notify(:before_call, request)
|
239
|
-
@events.notify(:notice_error, nil, options)
|
240
|
-
@events.notify(:after_call, request, [500, @response, ''])
|
241
|
-
|
242
|
-
options
|
243
|
-
end
|
244
|
-
|
245
221
|
def with_default_timings
|
246
222
|
NewRelic::Agent::TransactionState.any_instance.stubs(:timings).returns(stub(
|
247
223
|
:transaction_name => TRANSACTION_NAME,
|
@@ -9,10 +9,10 @@ module NewRelic
|
|
9
9
|
module Agent
|
10
10
|
class CrossAppTracingTest < Minitest::Test
|
11
11
|
|
12
|
-
attr_reader :
|
12
|
+
attr_reader :node, :request, :response
|
13
13
|
|
14
14
|
def setup
|
15
|
-
@
|
15
|
+
@node = stub_everything
|
16
16
|
@request = stub_everything(:uri => URI.parse("http://newrelic.com"),
|
17
17
|
:type => "Fake",
|
18
18
|
:method => "GET")
|
@@ -21,28 +21,28 @@ module NewRelic
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_start_trace
|
24
|
-
t0
|
25
|
-
|
26
|
-
refute_nil
|
24
|
+
t0 = Time.now
|
25
|
+
node = CrossAppTracing.start_trace(@state, t0, request)
|
26
|
+
refute_nil node
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def test_start_trace_has_nil_node_on_agent_failure
|
30
30
|
@state.traced_method_stack.stubs(:push_frame).raises("Boom!")
|
31
31
|
t0 = Time.now
|
32
|
-
|
33
|
-
assert_nil
|
32
|
+
node = CrossAppTracing.start_trace(@state, t0, request)
|
33
|
+
assert_nil node
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_finish_trace_treats_nil_start_time_as_agent_error
|
37
37
|
expects_logging(:error, any_parameters)
|
38
38
|
expects_no_pop_frame
|
39
|
-
CrossAppTracing.finish_trace(@state, nil,
|
39
|
+
CrossAppTracing.finish_trace(@state, nil, node, request, response)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Since we log and swallow errors, assert on the logging to ensure these
|
43
43
|
# paths are cleanly accepting nils, not just smothering the exceptions.
|
44
44
|
|
45
|
-
def
|
45
|
+
def test_finish_trace_allows_nil_node
|
46
46
|
expects_no_logging(:error)
|
47
47
|
CrossAppTracing.finish_trace(@state, Time.now, nil, request, response)
|
48
48
|
end
|
@@ -50,13 +50,13 @@ module NewRelic
|
|
50
50
|
def test_finish_trace_allows_nil_request
|
51
51
|
expects_no_logging(:error)
|
52
52
|
expects_pop_frame
|
53
|
-
CrossAppTracing.finish_trace(@state, Time.now,
|
53
|
+
CrossAppTracing.finish_trace(@state, Time.now, node, nil, response)
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_finish_trace_allows_nil_response
|
57
57
|
expects_no_logging(:error)
|
58
58
|
expects_pop_frame
|
59
|
-
CrossAppTracing.finish_trace(@state, Time.now,
|
59
|
+
CrossAppTracing.finish_trace(@state, Time.now, node, request, nil)
|
60
60
|
end
|
61
61
|
|
62
62
|
def expects_pop_frame
|
@@ -6,79 +6,53 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'te
|
|
6
6
|
|
7
7
|
module NewRelic::Agent::Database
|
8
8
|
class SqlObfuscationTest < Minitest::Test
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
when /\.postgres\.sql$/ then :postgresql
|
20
|
-
when /\.mysql\.sql$/ then :mysql
|
21
|
-
else nil
|
9
|
+
DIALECT_MAP = {
|
10
|
+
'postgres' => :postgresql,
|
11
|
+
'mysql' => :mysql
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.create_input_statements(raw_query, dialects)
|
15
|
+
dialects.map do |dialect|
|
16
|
+
NewRelic::Agent::Database::Statement.new(raw_query).tap do |s|
|
17
|
+
s.adapter = DIALECT_MAP[dialect]
|
18
|
+
end
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def strip_comments(text)
|
38
|
-
text.gsub(/^\s*#.*/, '').strip
|
39
|
-
end
|
40
|
-
|
41
|
-
def read_query(input_file)
|
42
|
-
adapter = self.class.adapter_from_input_file(input_file)
|
43
|
-
query = strip_comments(File.read(input_file))
|
44
|
-
|
45
|
-
if adapter
|
46
|
-
query = NewRelic::Agent::Database::Statement.new(query)
|
47
|
-
query.adapter = adapter.to_sym
|
48
|
-
end
|
49
|
-
|
50
|
-
query
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.create_regular_obfuscation_test(filename, type = "normal")
|
54
|
-
name = name_for_input_file(filename)
|
55
|
-
|
56
|
-
define_method("test_sql_obfuscation_#{type}_#{name}") do
|
57
|
-
query = read_query(filename)
|
58
|
-
expected_obfuscated = File.read(obfuscated_filename(filename))
|
59
|
-
actual_obfuscated = NewRelic::Agent::Database.obfuscate_sql(query)
|
60
|
-
assert_equal(expected_obfuscated, actual_obfuscated, "Failed to obfuscate #{type} query from #{filename}\nQuery: #{query}")
|
22
|
+
def build_failure_message(statement, acceptable_outputs, actual_output)
|
23
|
+
msg = "Failed to obfuscate #{statement.adapter} query correctly.\n"
|
24
|
+
msg << "Input: #{statement.to_s}\n"
|
25
|
+
if acceptable_outputs.size == 1
|
26
|
+
msg << "Expected: #{acceptable_outputs.first}\n"
|
27
|
+
else
|
28
|
+
msg << "Acceptable outputs:\n"
|
29
|
+
acceptable_outputs.each do |output|
|
30
|
+
msg << " #{output}\n"
|
31
|
+
end
|
61
32
|
end
|
33
|
+
msg << "Actual: #{actual_output}\n"
|
62
34
|
end
|
63
35
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
input_files('pathological').each do |input_file|
|
71
|
-
create_regular_obfuscation_test(input_file, "pathological")
|
72
|
-
end
|
36
|
+
test_cases = load_cross_agent_test('sql_obfuscation/sql_obfuscation')
|
37
|
+
test_cases.each do |test_case|
|
38
|
+
name = test_case['name']
|
39
|
+
query = test_case['sql']
|
40
|
+
acceptable_outputs = test_case['obfuscated']
|
41
|
+
dialects = test_case['dialects']
|
73
42
|
|
74
|
-
|
75
|
-
|
76
|
-
|
43
|
+
# If the entire query is obfuscated because it's malformed, we use a
|
44
|
+
# placeholder message instead of just '?', so add that to the acceptable
|
45
|
+
# outputs.
|
46
|
+
if test_case['malformed']
|
47
|
+
acceptable_outputs << NewRelic::Agent::Database::Obfuscator::FAILED_TO_OBFUSCATE_MESSAGE
|
48
|
+
end
|
77
49
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
50
|
+
create_input_statements(query, dialects).each do |statement|
|
51
|
+
define_method("test_sql_obfuscation_#{name}_#{statement.adapter}") do
|
52
|
+
actual_obfuscated = NewRelic::Agent::Database.obfuscate_sql(statement)
|
53
|
+
message = build_failure_message(statement, acceptable_outputs, actual_obfuscated)
|
54
|
+
assert_includes(acceptable_outputs, actual_obfuscated, message)
|
55
|
+
end
|
82
56
|
end
|
83
57
|
end
|
84
58
|
end
|
@@ -56,6 +56,42 @@ module NewRelic
|
|
56
56
|
assert_equal expected, result
|
57
57
|
end
|
58
58
|
|
59
|
+
def test_metrics_for_obeys_collection_and_operation_overrides
|
60
|
+
in_transaction do
|
61
|
+
NewRelic::Agent.with_database_metric_name("Model", "new_method") do
|
62
|
+
expected = [
|
63
|
+
"Datastore/statement/JonanDB/Model/new_method",
|
64
|
+
"Datastore/operation/JonanDB/new_method",
|
65
|
+
"Datastore/JonanDB/allOther",
|
66
|
+
"Datastore/JonanDB/all",
|
67
|
+
"Datastore/allOther",
|
68
|
+
"Datastore/all"
|
69
|
+
]
|
70
|
+
|
71
|
+
result = Datastores::MetricHelper.metrics_for(@product, "original_method")
|
72
|
+
assert_equal expected, result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_metrics_for_obeys_collection_override
|
78
|
+
in_transaction do
|
79
|
+
NewRelic::Agent.with_database_metric_name("Model", nil) do
|
80
|
+
expected = [
|
81
|
+
"Datastore/statement/JonanDB/Model/original_method",
|
82
|
+
"Datastore/operation/JonanDB/original_method",
|
83
|
+
"Datastore/JonanDB/allOther",
|
84
|
+
"Datastore/JonanDB/all",
|
85
|
+
"Datastore/allOther",
|
86
|
+
"Datastore/all"
|
87
|
+
]
|
88
|
+
|
89
|
+
result = Datastores::MetricHelper.metrics_for(@product, "original_method")
|
90
|
+
assert_equal expected, result
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
59
95
|
end
|
60
96
|
end
|
61
97
|
end
|