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
@@ -49,7 +49,7 @@ class ResqueTest < Minitest::Test
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
run_harvest
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_all_jobs_ran
|
@@ -70,14 +70,17 @@ class ResqueTest < Minitest::Test
|
|
70
70
|
|
71
71
|
def test_doesnt_capture_args_by_default
|
72
72
|
run_jobs
|
73
|
-
|
73
|
+
refute_attributes_on_transaction_traces
|
74
|
+
refute_attributes_on_events
|
74
75
|
end
|
75
76
|
|
76
77
|
def test_isnt_influenced_by_global_capture_params
|
77
78
|
with_config(:capture_params => true) do
|
78
79
|
run_jobs
|
79
80
|
end
|
80
|
-
|
81
|
+
|
82
|
+
refute_attributes_on_transaction_traces
|
83
|
+
refute_attributes_on_events
|
81
84
|
end
|
82
85
|
|
83
86
|
def test_agent_posts_captured_args_to_job
|
@@ -85,15 +88,16 @@ class ResqueTest < Minitest::Test
|
|
85
88
|
run_jobs
|
86
89
|
end
|
87
90
|
|
88
|
-
|
89
|
-
|
91
|
+
assert_attributes_on_transaction_traces
|
92
|
+
refute_attributes_on_events
|
93
|
+
end
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
assert_equal sample.tree.custom_params["job_arguments"], ["testing"]
|
95
|
-
end
|
95
|
+
def test_arguments_are_captured_on_transaction_events_when_enabled
|
96
|
+
with_config(:'attributes.include' => 'job.resque.args.*') do
|
97
|
+
run_jobs
|
96
98
|
end
|
99
|
+
|
100
|
+
assert_attributes_on_events
|
97
101
|
end
|
98
102
|
|
99
103
|
def assert_metric_and_call_count(name, expected_call_count)
|
@@ -107,14 +111,44 @@ class ResqueTest < Minitest::Test
|
|
107
111
|
assert_equal(expected_call_count, call_count)
|
108
112
|
end
|
109
113
|
|
110
|
-
def
|
114
|
+
def assert_attributes_on_transaction_traces
|
115
|
+
transaction_samples = $collector.calls_for('transaction_sample_data')
|
116
|
+
assert_false transaction_samples.empty?
|
117
|
+
|
118
|
+
transaction_samples.each do |post|
|
119
|
+
post.samples.each do |sample|
|
120
|
+
assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
|
121
|
+
assert_equal 'testing', sample.agent_attributes["job.resque.args.0"]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def refute_attributes_on_transaction_traces
|
111
127
|
transaction_samples = $collector.calls_for('transaction_sample_data')
|
112
128
|
assert_false transaction_samples.empty?
|
113
129
|
|
114
130
|
transaction_samples.each do |post|
|
115
131
|
post.samples.each do |sample|
|
116
132
|
assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
|
117
|
-
|
133
|
+
assert sample.agent_attributes.keys.none? { |k| k =~ /^job.resque.args.*/ }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def assert_attributes_on_events
|
139
|
+
event_posts = $collector.calls_for('analytic_event_data')
|
140
|
+
event_posts.each do |post|
|
141
|
+
post.events.each do |event|
|
142
|
+
assert_equal ["job.resque.args.0"], event[2].keys
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def refute_attributes_on_events
|
148
|
+
event_posts = $collector.calls_for('analytic_event_data')
|
149
|
+
event_posts.each do |post|
|
150
|
+
post.events.each do |event|
|
151
|
+
assert event[2].keys.none? { |k| k.start_with?("job.resque.args") }, "Found unexpected resque arguments"
|
118
152
|
end
|
119
153
|
end
|
120
154
|
end
|
@@ -92,20 +92,20 @@ class SequelExtensionTest < Minitest::Test
|
|
92
92
|
def test_slow_queries_get_an_explain_plan
|
93
93
|
with_config( :'transaction_tracer.explain_threshold' => -0.01,
|
94
94
|
:'transaction_tracer.record_sql' => 'raw' ) do
|
95
|
-
|
95
|
+
node = last_node_for do
|
96
96
|
@posts[:id => 11]
|
97
97
|
end
|
98
|
-
assert_match %r{select \* from `posts` where \(?`id` = 11\)?( limit 1)?}i,
|
99
|
-
|
98
|
+
assert_match %r{select \* from `posts` where \(?`id` = 11\)?( limit 1)?}i, node.params[:sql]
|
99
|
+
assert_node_has_explain_plan( node )
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_sql_is_recorded_in_tt_for_non_select
|
104
104
|
with_config(:'transaction_tracer.record_sql' => 'raw') do
|
105
|
-
|
105
|
+
node = last_node_for do
|
106
106
|
@posts.insert(:title => 'title', :content => 'content')
|
107
107
|
end
|
108
|
-
assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i,
|
108
|
+
assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, node.params[:sql]
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -115,11 +115,11 @@ class SequelExtensionTest < Minitest::Test
|
|
115
115
|
:'transaction_tracer.record_sql' => 'obfuscated'
|
116
116
|
}
|
117
117
|
with_config(config) do
|
118
|
-
|
118
|
+
node = last_node_for(:record_sql => :obfuscated) do
|
119
119
|
@posts[:id => 11]
|
120
120
|
end
|
121
|
-
assert_match %r{select \* from `posts` where \(?`id` = \?\)?}i,
|
122
|
-
|
121
|
+
assert_match %r{select \* from `posts` where \(?`id` = \?\)?}i, node.params[:sql]
|
122
|
+
assert_node_has_explain_plan( node )
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -26,26 +26,26 @@ module SequelHelpers
|
|
26
26
|
|
27
27
|
# This is particular to sqlite plans currently. To abstract it up, we'd need to
|
28
28
|
# be able to specify a flavor (e.g., :sqlite, :postgres, :mysql, etc.)
|
29
|
-
def
|
30
|
-
msg = "Expected #{
|
31
|
-
assert_block( msg ) {
|
29
|
+
def assert_node_has_explain_plan( node, msg=nil )
|
30
|
+
msg = "Expected #{node.inspect} to have an explain plan"
|
31
|
+
assert_block( msg ) { node.params[:explain_plan].join =~ SQLITE_EXPLAIN_PLAN_COLUMNS_RE }
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def last_node_for(options={})
|
35
35
|
in_transaction('sandwiches/index') do
|
36
36
|
yield
|
37
37
|
end
|
38
38
|
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
39
39
|
sample.prepare_to_send!
|
40
|
-
|
40
|
+
last_node(sample)
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
txn_sample.
|
46
|
-
|
43
|
+
def last_node(txn_sample)
|
44
|
+
l_node = nil
|
45
|
+
txn_sample.root_node.each_node do |node|
|
46
|
+
l_node = node
|
47
47
|
end
|
48
|
-
|
48
|
+
l_node
|
49
49
|
end
|
50
50
|
|
51
51
|
def product_name
|
@@ -59,4 +59,4 @@ module SequelHelpers
|
|
59
59
|
def assert_datastore_metrics_recorded_exclusive(metrics, options = {})
|
60
60
|
assert_metrics_recorded_exclusive(metrics, {:filter => /^Datastores/}.update(options))
|
61
61
|
end
|
62
|
-
end
|
62
|
+
end
|
@@ -164,20 +164,20 @@ class SequelPluginTest < Minitest::Test
|
|
164
164
|
def test_slow_queries_get_an_explain_plan
|
165
165
|
with_config( :'transaction_tracer.explain_threshold' => -0.01,
|
166
166
|
:'transaction_tracer.record_sql' => 'raw' ) do
|
167
|
-
|
167
|
+
node = last_node_for do
|
168
168
|
Post[11]
|
169
169
|
end
|
170
|
-
assert_match %r{select \* from `posts` where `id` = 11}i,
|
171
|
-
|
170
|
+
assert_match %r{select \* from `posts` where `id` = 11}i, node.params[:sql]
|
171
|
+
assert_node_has_explain_plan( node )
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
175
|
def test_sql_is_recorded_in_tt_for_non_select
|
176
176
|
with_config(:'transaction_tracer.record_sql' => 'raw') do
|
177
|
-
|
177
|
+
node = last_node_for do
|
178
178
|
Post.create(:title => 'title', :content => 'content')
|
179
179
|
end
|
180
|
-
assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i,
|
180
|
+
assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, node.params[:sql]
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
@@ -189,11 +189,11 @@ class SequelPluginTest < Minitest::Test
|
|
189
189
|
|
190
190
|
with_config(:'transaction_tracer.explain_threshold' => -0.01,
|
191
191
|
:'transaction_tracer.record_sql' => 'raw') do
|
192
|
-
|
192
|
+
node = last_node_for do
|
193
193
|
model_class[11]
|
194
194
|
end
|
195
|
-
assert_match %r{select \* from `posts` where `id` = 11}i,
|
196
|
-
assert_equal([],
|
195
|
+
assert_match %r{select \* from `posts` where `id` = 11}i, node.params[:sql]
|
196
|
+
assert_equal([], node.params[:explain_plan], "Should not capture explain plan with single-threaded connection pool")
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -203,11 +203,11 @@ class SequelPluginTest < Minitest::Test
|
|
203
203
|
:'transaction_tracer.record_sql' => 'obfuscated'
|
204
204
|
}
|
205
205
|
with_config(config) do
|
206
|
-
|
206
|
+
node = last_node_for(:record_sql => :obfuscated) do
|
207
207
|
Post[11]
|
208
208
|
end
|
209
|
-
assert_match %r{select \* from `posts` where `id` = \?}i,
|
210
|
-
|
209
|
+
assert_match %r{select \* from `posts` where `id` = \?}i, node.params[:sql]
|
210
|
+
assert_node_has_explain_plan( node )
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
@@ -6,12 +6,9 @@ end
|
|
6
6
|
if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
|
7
7
|
gemfile <<-RB
|
8
8
|
gem 'json'
|
9
|
-
gem 'sidekiq', '~> 3.
|
9
|
+
gem 'sidekiq', '~> 3.3.4'
|
10
10
|
gem 'rack'
|
11
11
|
|
12
|
-
# Work around for https://github.com/celluloid/celluloid/issues/457
|
13
|
-
gem 'celluloid', '0.15.2'
|
14
|
-
|
15
12
|
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
16
13
|
RB
|
17
14
|
end
|
@@ -2,6 +2,15 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
module Sidekiq
|
6
|
+
class CLI
|
7
|
+
def exit(*args)
|
8
|
+
# No-op Sidekiq's exit since we don't want it shutting us down and eating
|
9
|
+
# our exit code
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
if defined?(SidekiqServer)
|
6
15
|
SidekiqServer.instance.stop
|
7
16
|
end
|
@@ -51,7 +51,7 @@ class SidekiqTest < Minitest::Test
|
|
51
51
|
|
52
52
|
def run_delayed
|
53
53
|
run_and_transmit do |i|
|
54
|
-
TestWorker.delay(:queue => SidekiqServer.instance.queue_name).record('jobs_completed', i + 1)
|
54
|
+
TestWorker.delay(:queue => SidekiqServer.instance.queue_name, :retry => false).record('jobs_completed', i + 1)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -62,7 +62,7 @@ class SidekiqTest < Minitest::Test
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
run_harvest
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_delayed
|
@@ -93,14 +93,16 @@ class SidekiqTest < Minitest::Test
|
|
93
93
|
|
94
94
|
def test_doesnt_capture_args_by_default
|
95
95
|
run_jobs
|
96
|
-
|
96
|
+
refute_attributes_on_transaction_trace
|
97
|
+
refute_attributes_on_events
|
97
98
|
end
|
98
99
|
|
99
100
|
def test_isnt_influenced_by_global_capture_params
|
100
101
|
with_config(:capture_params => true) do
|
101
102
|
run_jobs
|
102
103
|
end
|
103
|
-
|
104
|
+
refute_attributes_on_transaction_trace
|
105
|
+
refute_attributes_on_events
|
104
106
|
end
|
105
107
|
|
106
108
|
def test_agent_posts_captured_args_to_job
|
@@ -108,18 +110,16 @@ class SidekiqTest < Minitest::Test
|
|
108
110
|
run_jobs
|
109
111
|
end
|
110
112
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
transaction_samples.each do |post|
|
115
|
-
post.samples.each do |sample|
|
116
|
-
assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
|
113
|
+
assert_attributes_on_transaction_trace
|
114
|
+
refute_attributes_on_events
|
115
|
+
end
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
117
|
+
def test_arguments_are_captured_on_transaction_events_when_enabled
|
118
|
+
with_config(:'attributes.include' => 'job.sidekiq.args.*') do
|
119
|
+
run_jobs
|
122
120
|
end
|
121
|
+
|
122
|
+
assert_attributes_on_events
|
123
123
|
end
|
124
124
|
|
125
125
|
def assert_metric_and_call_count(name, expected_call_count)
|
@@ -134,14 +134,47 @@ class SidekiqTest < Minitest::Test
|
|
134
134
|
assert_equal(expected_call_count, call_count)
|
135
135
|
end
|
136
136
|
|
137
|
-
def
|
137
|
+
def assert_attributes_on_transaction_trace
|
138
|
+
transaction_samples = $collector.calls_for('transaction_sample_data')
|
139
|
+
refute transaction_samples.empty?, "Expected a transaction trace"
|
140
|
+
|
141
|
+
transaction_samples.each do |post|
|
142
|
+
post.samples.each do |sample|
|
143
|
+
assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
|
144
|
+
|
145
|
+
actual = sample.agent_attributes.keys.to_set
|
146
|
+
expected = Set.new ["job.sidekiq.args.0", "job.sidekiq.args.1"]
|
147
|
+
assert_equal expected, actual
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def refute_attributes_on_transaction_trace
|
138
153
|
transaction_samples = $collector.calls_for('transaction_sample_data')
|
139
154
|
refute transaction_samples.empty?, "Didn't find any transaction samples!"
|
140
155
|
|
141
156
|
transaction_samples.each do |post|
|
142
157
|
post.samples.each do |sample|
|
143
158
|
assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
|
144
|
-
|
159
|
+
assert sample.agent_attributes.keys.none? { |k| k =~ /^job.sidekiq.args.*/ }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def assert_attributes_on_events
|
165
|
+
event_posts = $collector.calls_for('analytic_event_data')
|
166
|
+
event_posts.each do |post|
|
167
|
+
post.events.each do |event|
|
168
|
+
assert_equal Set.new(["job.sidekiq.args.0", "job.sidekiq.args.1"]), event[2].keys.to_set
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def refute_attributes_on_events
|
174
|
+
event_posts = $collector.calls_for('analytic_event_data')
|
175
|
+
event_posts.each do |post|
|
176
|
+
post.events.each do |event|
|
177
|
+
assert event[2].keys.none? { |k| k.start_with?("job.sidekiq.args") }, "Found unexpected sidekiq arguments"
|
145
178
|
end
|
146
179
|
end
|
147
180
|
end
|
@@ -0,0 +1,65 @@
|
|
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
|
+
class SinatraParameterCaptureTestApp < Sinatra::Base
|
6
|
+
post "/capture_test" do
|
7
|
+
"capture test"
|
8
|
+
end
|
9
|
+
|
10
|
+
post '/files' do
|
11
|
+
"file uploaded"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class SinatraParameterCaptureTest < Minitest::Test
|
17
|
+
include Rack::Test::Methods
|
18
|
+
include MultiverseHelpers
|
19
|
+
|
20
|
+
setup_and_teardown_agent
|
21
|
+
|
22
|
+
def app
|
23
|
+
SinatraParameterCaptureTestApp
|
24
|
+
end
|
25
|
+
|
26
|
+
def app_name
|
27
|
+
app.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_request_params_are_captured_for_transaction_events
|
31
|
+
with_config(:'attributes.include' => 'request.parameters.*') do
|
32
|
+
params = {
|
33
|
+
:foo => "bar",
|
34
|
+
:bar => "baz"
|
35
|
+
}
|
36
|
+
post '/capture_test', params
|
37
|
+
end
|
38
|
+
|
39
|
+
expected = {
|
40
|
+
"request.parameters.foo" => "bar",
|
41
|
+
"request.parameters.bar" => "baz"
|
42
|
+
}
|
43
|
+
|
44
|
+
actual = agent_attributes_for_single_event_posted_without_ignored_attributes
|
45
|
+
|
46
|
+
assert_equal(expected, actual)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_file_upload_params_are_filtered
|
50
|
+
with_config(:capture_params => true) do
|
51
|
+
params = {
|
52
|
+
:title => "blah",
|
53
|
+
:file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
|
54
|
+
}
|
55
|
+
post '/files', params
|
56
|
+
|
57
|
+
expected = {
|
58
|
+
"request.parameters.title" => "blah",
|
59
|
+
"request.parameters.file" => "[FILE]"
|
60
|
+
}
|
61
|
+
|
62
|
+
assert_equal(expected, last_transaction_trace_request_params)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|