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
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require 'new_relic/transaction_sample'
|
6
|
-
require 'new_relic/transaction_sample/segment'
|
7
|
-
module NewRelic
|
8
|
-
class TransactionSample
|
9
|
-
class SummarySegment < Segment
|
10
|
-
def initialize(segment)
|
11
|
-
super segment.entry_timestamp, segment.metric_name
|
12
|
-
|
13
|
-
add_segments segment.called_segments
|
14
|
-
|
15
|
-
end_trace segment.exit_timestamp
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_segments(segments)
|
19
|
-
segments.collect do |segment|
|
20
|
-
SummarySegment.new(segment)
|
21
|
-
end.each {|segment| add_called_segment(segment)}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/new_relic/url_rule.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
# Represents url mapping rules stored on the server. These rules should be applied
|
6
|
-
# to URLs which are not normalized into controller class/action by Rails routes.
|
7
|
-
# Insantiated strictly by Marshal.
|
8
|
-
class NewRelic::UrlRule
|
9
|
-
attr_reader :match_expression, :replacement, :eval_order, :terminate_chain
|
10
|
-
|
11
|
-
def apply url
|
12
|
-
return nil
|
13
|
-
end
|
14
|
-
|
15
|
-
class RuleSet
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3="othervalue" LIMIT ?
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE foo=? AND baz=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE foo="bar/*" AND baz="whatever */qux"
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = ? AND c3=? LIMIT ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = 'value' AND c3=1234 LIMIT 1
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM foo WHERE bar=? ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM foo WHERE bar='baz' /* Hide Me */
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT foo, bar FROM baz WHERE password=? ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT foo, bar FROM baz WHERE password='hunter2' # Secret
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT "col1", "col2" from "table" WHERE "col3"=E? AND country=e?
|
@@ -1,4 +0,0 @@
|
|
1
|
-
# PostgreSQL supports an alternate string quoting mode where backslash escape
|
2
|
-
# sequences are interpreted.
|
3
|
-
# See: http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
|
4
|
-
SELECT "col1", "col2" from "table" WHERE "col3"=E'foo\'bar\\baz' AND country=e'foo\'bar\\baz'
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo='bar' AND baz="nothing to see here'
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO `X` values(?,?, ? , ?, ?)
|
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO `X` values("test",0, 1 , 2, 'test')
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'
|
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X VALUES(?, ?, ?.?, ?+?)
|
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X VALUES(1, 23456, 123.456, 99+100)
|
@@ -1,4 +0,0 @@
|
|
1
|
-
# Pathological SQL Obfuscation Test Cases
|
2
|
-
|
3
|
-
## Why are these pathological?
|
4
|
-
Because obfuscating dialect-specific SQL is difficult without building a comprehensive lexer, so there are some edge cases where agents are expected to err on the side of over-obfuscation, even though the resulting obfuscation differs from how a perfect lexer might parse and obfuscate it.
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM t WHERE ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM foo WHERE col=? AND ?
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/quote_delimiters_in_comments.sql
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name=? AND value=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name="foo" AND value="don't"
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name=? AND value = ?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name='foo' AND value = 'bar'
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE col=?
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE col1=? AND col2=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE col1='foo"bar' AND col2='what"ever'
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
select * from accounts where accounts.name != ? order by accounts.name
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE col1=? AND col2=?
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE col1="don't" AND col2="won't"
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X values(?, ?,?, ? , ?, ?, ?)
|
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', """jim''s"" hat", "\"jim''s secret\"")
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name=? AND color=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo="this string ends with a backslash\\"
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE foo='this string ends with a backslash\\'
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name=? AND color=?
|
@@ -1 +0,0 @@
|
|
1
|
-
SELECT * FROM table WHERE name='foo\'' AND color='blue'
|
data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X values(?, ?,?, ? , ?)
|
@@ -1 +0,0 @@
|
|
1
|
-
INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')
|
@@ -1,261 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
6
|
-
class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Minitest::Test
|
7
|
-
require 'new_relic/agent/error_collector'
|
8
|
-
include NewRelic::Agent::ErrorCollector::NoticeError
|
9
|
-
|
10
|
-
def test_error_params_from_options_mocked
|
11
|
-
options = {:initial => 'options'}
|
12
|
-
self.expects(:uri_ref_and_root).returns({:hi => 'there', :hello => 'bad'})
|
13
|
-
self.expects(:normalized_request_and_custom_params).with({:initial => 'options'}).returns({:hello => 'world'})
|
14
|
-
assert_equal({:hi => 'there', :hello => 'world'}, error_params_from_options(options))
|
15
|
-
end
|
16
|
-
|
17
|
-
module Winner
|
18
|
-
def winner
|
19
|
-
'yay'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_sense_method
|
24
|
-
object = Object.new
|
25
|
-
object.extend(Winner)
|
26
|
-
assert !sense_method(object, 'blab')
|
27
|
-
assert_equal 'yay', sense_method(object, 'winner')
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_fetch_from_options
|
31
|
-
options = {:hello => 'world'}
|
32
|
-
assert_equal 'world', fetch_from_options(options, :hello, '')
|
33
|
-
assert_equal '', fetch_from_options(options, :none, '')
|
34
|
-
assert_equal({}, options)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_uri_ref_and_root_default
|
38
|
-
fake_control = mocked_control
|
39
|
-
fake_control.expects(:root).returns('rootbeer')
|
40
|
-
options = {}
|
41
|
-
assert_equal({:request_referer => '', :rails_root => 'rootbeer', :request_uri => ''}, uri_ref_and_root(options))
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_uri_ref_and_root_values
|
45
|
-
fake_control = mocked_control
|
46
|
-
fake_control.expects(:root).returns('rootbeer')
|
47
|
-
options = {:uri => 'whee', :referer => 'bang'}
|
48
|
-
assert_equal({:request_referer => 'bang', :rails_root => 'rootbeer', :request_uri => 'whee'}, uri_ref_and_root(options))
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_custom_params_from_opts_base
|
52
|
-
assert_equal({}, custom_params_from_opts({}))
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_custom_params_from_opts_custom_params
|
56
|
-
assert_equal({:foo => 'bar'}, custom_params_from_opts({:custom_params => {:foo => 'bar'}}))
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_custom_params_from_opts_merged_params
|
60
|
-
assert_equal({:foo => 'baz'}, custom_params_from_opts({:custom_params => {:foo => 'bar'}, :foo => 'baz'}))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_request_params_from_opts_positive
|
64
|
-
with_config(:capture_params => true) do
|
65
|
-
val = {:request_params => 'foo'}
|
66
|
-
assert_equal('foo', request_params_from_opts(val))
|
67
|
-
assert_equal({}, val, "should delete request_params key from hash")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_request_params_from_opts_negative
|
72
|
-
with_config(:capture_params => false) do
|
73
|
-
val = {:request_params => 'foo'}
|
74
|
-
assert_equal(nil, request_params_from_opts(val))
|
75
|
-
assert_equal({}, val, "should delete request_params key from hash")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_normalized_request_and_custom_params_base
|
80
|
-
self.expects(:normalize_params).with(nil).returns(nil)
|
81
|
-
self.expects(:normalize_params).with({}).returns({})
|
82
|
-
with_config(:capture_params => true) do
|
83
|
-
assert_equal({:request_params => nil, :custom_params => {}},
|
84
|
-
normalized_request_and_custom_params({}))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_extract_stack_trace
|
89
|
-
exception = mock('exception')
|
90
|
-
self.expects(:sense_method).with(exception, 'original_exception')
|
91
|
-
self.expects(:sense_method).with(exception, 'backtrace')
|
92
|
-
assert_equal('<no stack trace>', extract_stack_trace(exception))
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_extract_stack_trace_positive
|
96
|
-
orig = mock('original')
|
97
|
-
exception = mock('exception')
|
98
|
-
self.expects(:sense_method).with(exception, 'original_exception').returns(orig)
|
99
|
-
self.expects(:sense_method).with(orig, 'backtrace').returns('STACK STACK STACK')
|
100
|
-
assert_equal('STACK STACK STACK', extract_stack_trace(exception))
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_over_queue_limit_negative
|
104
|
-
@errors = []
|
105
|
-
assert !over_queue_limit?(nil)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_over_queue_limit_positive
|
109
|
-
@errors = (1..21).map{|_| NewRelic::NoticedError.new("", {}, nil)}
|
110
|
-
expects_logging(:warn, includes('The error reporting queue has reached 20'))
|
111
|
-
assert over_queue_limit?('hooray')
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_exception_info
|
115
|
-
exception = mock('exception')
|
116
|
-
self.expects(:sense_method).with(exception, 'file_name').returns('file_name')
|
117
|
-
self.expects(:sense_method).with(exception, 'line_number').returns('line_number')
|
118
|
-
self.expects(:extract_stack_trace).with(exception).returns('stack_trace')
|
119
|
-
assert_equal({:file_name => 'file_name', :line_number => 'line_number', :stack_trace => 'stack_trace'},
|
120
|
-
exception_info(exception))
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_add_to_error_queue_positive
|
124
|
-
noticed_error = mock('noticed_error')
|
125
|
-
noticed_error.expects(:message).returns('a message')
|
126
|
-
@lock = Mutex.new
|
127
|
-
@errors = []
|
128
|
-
self.expects(:over_queue_limit?).with('a message').returns(false)
|
129
|
-
add_to_error_queue(noticed_error)
|
130
|
-
assert_equal([noticed_error], @errors)
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_add_to_error_queue_negative
|
134
|
-
noticed_error = mock('noticed_error')
|
135
|
-
noticed_error.expects(:message).returns('a message')
|
136
|
-
@lock = Mutex.new
|
137
|
-
@errors = []
|
138
|
-
self.expects(:over_queue_limit?).with('a message').returns(true)
|
139
|
-
add_to_error_queue(noticed_error)
|
140
|
-
assert_equal([], @errors)
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_skip_notice_error_is_true_if_the_error_collector_is_disabled
|
144
|
-
error = mocked_error
|
145
|
-
with_error_collector_config(:'error_collector.enabled' => false) do |error_collector|
|
146
|
-
assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_skip_notice_error_is_true_if_the_error_is_nil
|
151
|
-
error = nil
|
152
|
-
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
153
|
-
error_collector.expects(:error_is_ignored?).with(error).returns(false)
|
154
|
-
assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_skip_notice_error_is_true_if_the_error_is_ignored
|
159
|
-
error = mocked_error
|
160
|
-
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
161
|
-
error_collector.expects(:error_is_ignored?).with(error).returns(true)
|
162
|
-
assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_skip_notice_error_returns_false_for_non_nil_unignored_errors_with_an_enabled_error_collector
|
167
|
-
error = mocked_error
|
168
|
-
with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
|
169
|
-
error_collector.expects(:error_is_ignored?).with(error).returns(false)
|
170
|
-
assert !error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_filtered_error_positive
|
175
|
-
with_error_collector_config(:'error_collector.ignore_errors' => 'an_error') do |error_collector|
|
176
|
-
error = mocked_error
|
177
|
-
error_class = mock('error class')
|
178
|
-
error.expects(:class).returns(error_class)
|
179
|
-
error_class.expects(:name).returns('an_error')
|
180
|
-
assert error_collector.filtered_error?(error)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_filtered_error_negative
|
185
|
-
error = mocked_error
|
186
|
-
error_class = mock('error class')
|
187
|
-
error.expects(:class).returns(error_class)
|
188
|
-
error_class.expects(:name).returns('an_error')
|
189
|
-
assert !NewRelic::Agent::ErrorCollector.new.filtered_error?(error)
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_filtered_by_error_filter_empty
|
193
|
-
# should return right away when there's no filter
|
194
|
-
assert !filtered_by_error_filter?(nil)
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_filtered_by_error_filter_positive
|
198
|
-
error = mocked_error
|
199
|
-
self.class.class_eval do
|
200
|
-
define_method(:ignore_filter_proc) do |e|
|
201
|
-
assert_equal(error, e)
|
202
|
-
false
|
203
|
-
end
|
204
|
-
end
|
205
|
-
assert filtered_by_error_filter?(error)
|
206
|
-
ensure
|
207
|
-
self.class.class_eval { undef :ignore_filter_proc }
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_filtered_by_error_filter_negative
|
211
|
-
error = mocked_error
|
212
|
-
self.class.class_eval do
|
213
|
-
define_method(:ignore_filter_proc) do |e|
|
214
|
-
assert_equal(error, e)
|
215
|
-
true
|
216
|
-
end
|
217
|
-
end
|
218
|
-
assert !filtered_by_error_filter?(error)
|
219
|
-
ensure
|
220
|
-
self.class.class_eval { undef :ignore_filter_proc }
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_error_is_ignored_positive
|
224
|
-
error = mocked_error
|
225
|
-
self.expects(:filtered_error?).with(error).returns(true)
|
226
|
-
assert error_is_ignored?(error)
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_error_is_ignored_negative
|
230
|
-
error = mocked_error
|
231
|
-
self.expects(:filtered_error?).with(error).returns(false)
|
232
|
-
assert !error_is_ignored?(error)
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_error_is_ignored_no_error
|
236
|
-
assert !error_is_ignored?(nil), 'should not ignore nil'
|
237
|
-
end
|
238
|
-
|
239
|
-
private
|
240
|
-
|
241
|
-
def mocked_error
|
242
|
-
mock('error')
|
243
|
-
end
|
244
|
-
|
245
|
-
def mocked_control
|
246
|
-
fake_control = mock('control')
|
247
|
-
NewRelic::Control.stubs(:instance).returns(fake_control)
|
248
|
-
fake_control
|
249
|
-
end
|
250
|
-
|
251
|
-
def with_error_collector_config(config)
|
252
|
-
with_config(config) do
|
253
|
-
yield NewRelic::Agent::ErrorCollector.new
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
def ignore_error_filter
|
258
|
-
@ignore_filter
|
259
|
-
end
|
260
|
-
|
261
|
-
end
|