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
@@ -4,42 +4,34 @@
|
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
6
|
|
7
|
-
class NewRelic::Agent::
|
7
|
+
class NewRelic::Agent::TransactionSampleBuilderTest < Minitest::Test
|
8
8
|
|
9
9
|
def setup
|
10
10
|
freeze_time
|
11
11
|
@builder = NewRelic::Agent::TransactionSampleBuilder.new
|
12
12
|
end
|
13
13
|
|
14
|
-
# if it doesn't the core app tests will break. Not strictly necessary but
|
15
|
-
# we'll enforce it with this test for now.
|
16
|
-
def test_trace_entry_returns_segment
|
17
|
-
segment = @builder.trace_entry(Time.now)
|
18
|
-
assert segment, "Segment should not be nil"
|
19
|
-
assert segment.is_a?(NewRelic::TransactionSample::Segment), "Segment should not be a #{segment.class.name}"
|
20
|
-
end
|
21
|
-
|
22
14
|
def test_build_sample
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
build_node("a") do
|
16
|
+
build_node("aa") do
|
17
|
+
build_node("aaa")
|
26
18
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
build_node("ab") do
|
20
|
+
build_node("aba") do
|
21
|
+
build_node("abaa")
|
30
22
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
build_node("aba")
|
24
|
+
build_node("abc") do
|
25
|
+
build_node("abca")
|
26
|
+
build_node("abcd")
|
35
27
|
end
|
36
28
|
end
|
37
29
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
30
|
+
build_node "b"
|
31
|
+
build_node "c" do
|
32
|
+
build_node "ca"
|
33
|
+
build_node "cb" do
|
34
|
+
build_node "cba"
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
@@ -48,101 +40,101 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
|
|
48
40
|
end
|
49
41
|
|
50
42
|
def test_freeze
|
51
|
-
|
52
|
-
|
43
|
+
build_node "a" do
|
44
|
+
build_node "aa"
|
53
45
|
end
|
54
46
|
|
55
47
|
@builder.finish_trace(Time.now.to_f)
|
56
48
|
|
57
49
|
validate_builder
|
58
50
|
|
59
|
-
assert_raises(
|
60
|
-
|
51
|
+
assert_raises(NewRelic::Agent::Transaction::Trace::FinishedTraceError) do
|
52
|
+
build_node "b"
|
61
53
|
end
|
62
54
|
end
|
63
55
|
|
64
56
|
def test_marshal
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
57
|
+
build_node "a" do
|
58
|
+
build_node "ab"
|
59
|
+
end
|
60
|
+
build_node "b" do
|
61
|
+
build_node "ba"
|
62
|
+
build_node "bb"
|
63
|
+
build_node "bc" do
|
64
|
+
build_node "bca"
|
73
65
|
end
|
74
66
|
end
|
75
|
-
|
67
|
+
build_node "c"
|
76
68
|
|
77
69
|
@builder.finish_trace(Time.now.to_f)
|
78
70
|
validate_builder
|
79
71
|
|
80
72
|
dump = Marshal.dump @builder.sample
|
81
73
|
sample = Marshal.restore(dump)
|
82
|
-
|
74
|
+
validate_node(sample.root_node)
|
83
75
|
end
|
84
76
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
77
|
+
def test_parallel_first_level_nodes
|
78
|
+
build_node "a" do
|
79
|
+
build_node "ab"
|
88
80
|
end
|
89
|
-
|
90
|
-
|
81
|
+
build_node "b"
|
82
|
+
build_node "c"
|
91
83
|
|
92
84
|
@builder.finish_trace(Time.now.to_f)
|
93
85
|
validate_builder
|
94
86
|
end
|
95
87
|
|
96
|
-
def
|
88
|
+
def test_trace_should_not_record_more_than_node_limit
|
97
89
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
98
|
-
8.times {|i|
|
99
|
-
assert_equal 3, @builder.sample.
|
90
|
+
8.times {|i| build_node i.to_s }
|
91
|
+
assert_equal 3, @builder.sample.count_nodes
|
100
92
|
end
|
101
93
|
end
|
102
94
|
|
103
|
-
def
|
95
|
+
def test_trace_has_valid_durations_when_nodes_limited
|
104
96
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
105
|
-
|
97
|
+
build_node "parent" do
|
106
98
|
advance_time 1
|
107
|
-
|
99
|
+
build_node "child-0.0" do
|
108
100
|
advance_time 1
|
109
|
-
|
101
|
+
build_node "child-0.1" do
|
110
102
|
advance_time 1
|
111
103
|
end
|
112
104
|
end
|
113
105
|
advance_time 1
|
114
|
-
|
106
|
+
build_node "child-1.0" do
|
115
107
|
advance_time 1
|
116
|
-
|
108
|
+
build_node "child-1.1" do
|
117
109
|
advance_time 1
|
118
110
|
end
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
122
114
|
sample = @builder.sample
|
123
|
-
assert_equal(3, sample.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
sample.
|
128
|
-
if s != sample.
|
129
|
-
|
130
|
-
|
115
|
+
assert_equal(3, sample.count_nodes)
|
116
|
+
|
117
|
+
node_names = []
|
118
|
+
node_durations = []
|
119
|
+
sample.each_node do |s|
|
120
|
+
if s != sample.root_node
|
121
|
+
node_names << s.metric_name
|
122
|
+
node_durations << s.duration
|
131
123
|
end
|
132
124
|
end
|
133
125
|
|
134
|
-
assert_equal(["parent", "child-0.0", "child-0.1"],
|
135
|
-
assert_equal([6.0, 2.0, 1.0],
|
126
|
+
assert_equal(["parent", "child-0.0", "child-0.1"], node_names)
|
127
|
+
assert_equal([6.0, 2.0, 1.0], node_durations)
|
136
128
|
end
|
137
129
|
end
|
138
130
|
|
139
|
-
def
|
131
|
+
def test_attaching_params_doesnt_raise_when_nodes_are_limited
|
140
132
|
with_config(:'transaction_tracer.limit_segments' => 5) do
|
141
|
-
6.times { |i|
|
142
|
-
# now we should have a placeholder
|
143
|
-
|
144
|
-
@builder.
|
145
|
-
@builder.
|
133
|
+
6.times { |i| build_node "s#{i}" }
|
134
|
+
# now we should have a placeholder node
|
135
|
+
build_node "this-should-be-truncated" do
|
136
|
+
@builder.current_node['eggs'] = 'ham'
|
137
|
+
@builder.current_node.params.merge!('foo' => 'bar')
|
146
138
|
end
|
147
139
|
end
|
148
140
|
end
|
@@ -155,10 +147,10 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
|
|
155
147
|
end
|
156
148
|
|
157
149
|
# regression
|
158
|
-
def
|
150
|
+
def test_trace_should_log_node_reached_once
|
159
151
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
160
|
-
expects_logging(:debug, includes("
|
161
|
-
8.times {|i|
|
152
|
+
expects_logging(:debug, includes("Node limit"))
|
153
|
+
8.times {|i| build_node i.to_s }
|
162
154
|
end
|
163
155
|
end
|
164
156
|
|
@@ -186,14 +178,14 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
|
|
186
178
|
end
|
187
179
|
|
188
180
|
def validate_builder(check_names = true)
|
189
|
-
|
181
|
+
validate_node @builder.sample.root_node, check_names
|
190
182
|
end
|
191
183
|
|
192
|
-
def
|
193
|
-
p = s.
|
184
|
+
def validate_node(s, check_names = true)
|
185
|
+
p = s.parent_node
|
194
186
|
|
195
187
|
unless p.nil? || p.metric_name == 'ROOT'
|
196
|
-
assert p.
|
188
|
+
assert p.called_nodes.include?(s)
|
197
189
|
assert_equal p.metric_name.length, s.metric_name.length - 1, "p: #{p.metric_name}, s: #{s.metric_name}" if check_names
|
198
190
|
assert p.metric_name < s.metric_name if check_names
|
199
191
|
assert p.entry_timestamp <= s.entry_timestamp
|
@@ -201,7 +193,7 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
|
|
201
193
|
|
202
194
|
assert s.exit_timestamp >= s.entry_timestamp
|
203
195
|
|
204
|
-
children = s.
|
196
|
+
children = s.called_nodes
|
205
197
|
parent = s
|
206
198
|
children.each do |child|
|
207
199
|
if check_names
|
@@ -211,11 +203,11 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
|
|
211
203
|
assert(child.entry_timestamp >= parent.entry_timestamp,
|
212
204
|
"#{child.entry_timestamp} !>= #{parent.entry_timestamp}")
|
213
205
|
|
214
|
-
|
206
|
+
validate_node(child, check_names)
|
215
207
|
end
|
216
208
|
end
|
217
209
|
|
218
|
-
def
|
210
|
+
def build_node(metric, time = 0, &proc)
|
219
211
|
@builder.trace_entry(Time.now.to_f)
|
220
212
|
proc.call if proc
|
221
213
|
@builder.trace_exit(metric, Time.now.to_f)
|
@@ -36,14 +36,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
36
36
|
NewRelic::Agent.instance.instance_variable_set(:@transaction_sampler, @sampler)
|
37
37
|
@test_config = { :'transaction_tracer.enabled' => true }
|
38
38
|
NewRelic::Agent.config.add_config_for_testing(@test_config)
|
39
|
+
|
40
|
+
attributes = NewRelic::Agent::Transaction::Attributes.new(NewRelic::Agent.instance.attribute_filter)
|
39
41
|
@txn = stub('txn',
|
40
42
|
:best_name => '/path',
|
43
|
+
:request_path => '/request_path',
|
41
44
|
:guid => 'a guid',
|
42
|
-
:
|
45
|
+
:ignore_trace? => false,
|
43
46
|
:cat_trip_id => '',
|
44
47
|
:cat_path_hash => '',
|
45
48
|
:is_synthetics_request? => false,
|
46
|
-
:filtered_params => {}
|
49
|
+
:filtered_params => {},
|
50
|
+
:attributes => attributes
|
51
|
+
)
|
47
52
|
end
|
48
53
|
|
49
54
|
def teardown
|
@@ -61,7 +66,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
61
66
|
|
62
67
|
def populate_container(sampler, n)
|
63
68
|
n.times do |i|
|
64
|
-
sample = sample_with(:duration => 1, :transaction_name => "t#{i}", :
|
69
|
+
sample = sample_with(:duration => 1, :transaction_name => "t#{i}", :synthetics_resource_id => 1)
|
65
70
|
@sampler.store_sample(sample)
|
66
71
|
end
|
67
72
|
end
|
@@ -125,30 +130,12 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
125
130
|
assert_equal('a guid', @sampler.last_sample.guid)
|
126
131
|
end
|
127
132
|
|
128
|
-
def test_ignore_transaction_no_builder
|
129
|
-
ret = @sampler.ignore_transaction(@state)
|
130
|
-
assert_nil ret
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_ignore_transaction_with_builder
|
134
|
-
in_transaction do
|
135
|
-
@sampler.ignore_transaction(@state)
|
136
|
-
end
|
137
|
-
|
138
|
-
assert_nil(@sampler.last_sample)
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_notice_transaction_cpu_time_no_builder_does_not_crash
|
142
|
-
@state.transaction_sample_builder = nil
|
143
|
-
@sampler.notice_transaction_cpu_time(@state, 0.0)
|
144
|
-
end
|
145
|
-
|
146
133
|
def test_records_cpu_time_on_transaction_samples
|
147
134
|
in_transaction do |txn|
|
148
135
|
txn.stubs(:cpu_burn).returns(42)
|
149
136
|
end
|
150
137
|
|
151
|
-
assert_equal(42, @sampler.last_sample
|
138
|
+
assert_equal(42, attributes_for(@sampler.last_sample, :intrinsic)[:cpu_time])
|
152
139
|
end
|
153
140
|
|
154
141
|
def test_notice_extra_data_no_builder
|
@@ -156,43 +143,43 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
156
143
|
assert_nil ret
|
157
144
|
end
|
158
145
|
|
159
|
-
def
|
146
|
+
def test_notice_extra_data_no_node
|
160
147
|
mock_builder = mock('builder')
|
161
148
|
@sampler.expects(:tl_builder).returns(mock_builder).once
|
162
|
-
mock_builder.expects(:
|
149
|
+
mock_builder.expects(:current_node).returns(nil)
|
163
150
|
builder = @sampler.tl_builder
|
164
151
|
@sampler.send(:notice_extra_data, builder, nil, nil, nil)
|
165
152
|
end
|
166
153
|
|
167
|
-
def
|
154
|
+
def test_notice_extra_data_with_node_no_old_message_no_config_key
|
168
155
|
key = :a_key
|
169
156
|
mock_builder = mock('builder')
|
170
|
-
|
157
|
+
node = mock('node')
|
171
158
|
@sampler.expects(:tl_builder).returns(mock_builder).once
|
172
|
-
mock_builder.expects(:
|
159
|
+
mock_builder.expects(:current_node).returns(node)
|
173
160
|
NewRelic::Agent::TransactionSampler.expects(:truncate_message) \
|
174
161
|
.with('a message').returns('truncated_message')
|
175
|
-
|
176
|
-
@sampler.expects(:append_backtrace).with(
|
162
|
+
node.expects(:[]=).with(key, 'truncated_message')
|
163
|
+
@sampler.expects(:append_backtrace).with(node, 1.0)
|
177
164
|
builder = @sampler.tl_builder
|
178
165
|
@sampler.send(:notice_extra_data, builder, 'a message', 1.0, key)
|
179
166
|
end
|
180
167
|
|
181
168
|
def test_append_backtrace_under_duration
|
182
169
|
with_config(:'transaction_tracer.stack_trace_threshold' => 2.0) do
|
183
|
-
|
184
|
-
|
185
|
-
@sampler.append_backtrace(mock('
|
170
|
+
node = mock('node')
|
171
|
+
node.expects(:[]=).with(:backtrace, any_parameters).never
|
172
|
+
@sampler.append_backtrace(mock('node'), 1.0)
|
186
173
|
end
|
187
174
|
end
|
188
175
|
|
189
176
|
def test_append_backtrace_over_duration
|
190
177
|
with_config(:'transaction_tracer.stack_trace_threshold' => 2.0) do
|
191
|
-
|
178
|
+
node = mock('node')
|
192
179
|
# note the mocha expectation matcher - you can't hardcode a
|
193
180
|
# backtrace so we match on any string, which should be okay.
|
194
|
-
|
195
|
-
@sampler.append_backtrace(
|
181
|
+
node.expects(:[]=).with(:backtrace, instance_of(String))
|
182
|
+
@sampler.append_backtrace(node, 2.5)
|
196
183
|
end
|
197
184
|
end
|
198
185
|
|
@@ -258,21 +245,15 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
258
245
|
end
|
259
246
|
|
260
247
|
def test_harvest_avoids_dups_from_harvested_samples
|
261
|
-
sample = sample_with(:duration => 2.5
|
248
|
+
sample = sample_with(:duration => 2.5)
|
262
249
|
@sampler.store_sample(sample)
|
263
250
|
@sampler.store_sample(sample)
|
264
251
|
|
265
252
|
assert_equal([sample], @sampler.harvest!)
|
266
253
|
end
|
267
254
|
|
268
|
-
def test_merge_avoids_dups_from_forced
|
269
|
-
sample = sample_with(:duration => 1, :force_persist => true)
|
270
|
-
@sampler.merge!([sample, sample])
|
271
|
-
assert_equal([sample], @sampler.harvest!)
|
272
|
-
end
|
273
|
-
|
274
255
|
def test_harvest_adding_slowest
|
275
|
-
sample = sample_with(:duration => 2.5
|
256
|
+
sample = sample_with(:duration => 2.5)
|
276
257
|
@sampler.store_sample(sample)
|
277
258
|
|
278
259
|
assert_equal([sample], @sampler.harvest!)
|
@@ -298,44 +279,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
298
279
|
assert_equal([slower_sample], @sampler.harvest!)
|
299
280
|
end
|
300
281
|
|
301
|
-
def test_harvest_keep_force_persist_in_previous_results
|
302
|
-
unforced_sample = sample_with(:duration => 10, :force_persist => false)
|
303
|
-
forced_sample = sample_with(:duration => 1, :force_persist => true)
|
304
|
-
|
305
|
-
@sampler.merge!([unforced_sample, forced_sample])
|
306
|
-
result = @sampler.harvest!
|
307
|
-
|
308
|
-
assert_includes(result, unforced_sample)
|
309
|
-
assert_includes(result, forced_sample)
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_harvest_keeps_force_persist_in_new_results
|
313
|
-
forced_sample = sample_with(:duration => 1, :force_persist => true)
|
314
|
-
@sampler.store_sample(forced_sample)
|
315
|
-
|
316
|
-
unforced_sample = sample_with(:duration => 10, :force_persist => false)
|
317
|
-
@sampler.store_sample(unforced_sample)
|
318
|
-
|
319
|
-
result = @sampler.harvest!
|
320
|
-
|
321
|
-
assert_includes(result, unforced_sample)
|
322
|
-
assert_includes(result, forced_sample)
|
323
|
-
end
|
324
|
-
|
325
|
-
def test_harvest_keeps_forced_from_new_and_previous_results
|
326
|
-
new_forced = sample_with(:duration => 1, :force_persist => true)
|
327
|
-
@sampler.store_sample(new_forced)
|
328
|
-
|
329
|
-
old_forced = sample_with(:duration => 1, :force_persist => true)
|
330
|
-
|
331
|
-
@sampler.merge!([old_forced])
|
332
|
-
result = @sampler.harvest!
|
333
|
-
|
334
|
-
assert_includes(result, new_forced)
|
335
|
-
assert_includes(result, old_forced)
|
336
|
-
end
|
337
|
-
|
338
|
-
FORCE_PERSIST_MAX = NewRelic::Agent::Transaction::ForcePersistSampleBuffer::CAPACITY
|
339
282
|
SLOWEST_SAMPLE_MAX = NewRelic::Agent::Transaction::SlowestSampleBuffer::CAPACITY
|
340
283
|
XRAY_SAMPLE_MAX = NewRelic::Agent.config[:'xray_session.max_samples']
|
341
284
|
|
@@ -343,9 +286,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
343
286
|
slowest = sample_with(:duration => 10.0)
|
344
287
|
previous = [slowest]
|
345
288
|
|
346
|
-
forced_samples = generate_samples(100, :force_persist => true)
|
347
|
-
previous.concat(forced_samples)
|
348
|
-
|
349
289
|
xray_samples = generate_samples(100, :transaction_name => "Active/xray")
|
350
290
|
previous.concat(xray_samples)
|
351
291
|
|
@@ -356,7 +296,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
356
296
|
end
|
357
297
|
|
358
298
|
expected = [slowest]
|
359
|
-
expected = expected.concat(forced_samples.last(FORCE_PERSIST_MAX))
|
360
299
|
expected = expected.concat(xray_samples.first(XRAY_SAMPLE_MAX))
|
361
300
|
|
362
301
|
assert_equal_unordered(expected, result)
|
@@ -366,11 +305,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
366
305
|
slowest = sample_with(:duration => 10.0)
|
367
306
|
@sampler.store_sample(slowest)
|
368
307
|
|
369
|
-
forced_samples = generate_samples(100, :force_persist => true)
|
370
|
-
forced_samples.each do |forced|
|
371
|
-
@sampler.store_sample(forced)
|
372
|
-
end
|
373
|
-
|
374
308
|
xray_samples = generate_samples(100, :transaction_name => "Active/xray")
|
375
309
|
with_active_xray_session("Active/xray") do
|
376
310
|
xray_samples.each do |xrayed|
|
@@ -381,7 +315,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
381
315
|
result = @sampler.harvest!
|
382
316
|
|
383
317
|
expected = [slowest]
|
384
|
-
expected = expected.concat(forced_samples.last(FORCE_PERSIST_MAX))
|
385
318
|
expected = expected.concat(xray_samples.first(XRAY_SAMPLE_MAX))
|
386
319
|
assert_equal_unordered(expected, result)
|
387
320
|
end
|
@@ -447,7 +380,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
447
380
|
|
448
381
|
def test_sample_tree
|
449
382
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
450
|
-
@sampler.on_start_transaction(@state, Time.now
|
383
|
+
@sampler.on_start_transaction(@state, Time.now)
|
451
384
|
@sampler.notice_push_frame(@state)
|
452
385
|
|
453
386
|
@sampler.notice_push_frame(@state)
|
@@ -472,7 +405,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
472
405
|
MockGCStats.mock_values = [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0]
|
473
406
|
|
474
407
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
475
|
-
@sampler.on_start_transaction(@state, Time.now
|
408
|
+
@sampler.on_start_transaction(@state, Time.now)
|
476
409
|
@sampler.notice_push_frame(@state)
|
477
410
|
|
478
411
|
@sampler.notice_push_frame(@state)
|
@@ -556,7 +489,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
556
489
|
|
557
490
|
def test_sample_with_parallel_paths
|
558
491
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
559
|
-
@sampler.on_start_transaction(@state, Time.now
|
492
|
+
@sampler.on_start_transaction(@state, Time.now)
|
560
493
|
@sampler.notice_push_frame(@state)
|
561
494
|
|
562
495
|
assert_equal 1, @sampler.tl_builder.scope_depth
|
@@ -566,7 +499,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
566
499
|
|
567
500
|
assert_nil @sampler.tl_builder
|
568
501
|
|
569
|
-
@sampler.on_start_transaction(@state, Time.now
|
502
|
+
@sampler.on_start_transaction(@state, Time.now)
|
570
503
|
@sampler.notice_push_frame(@state)
|
571
504
|
@sampler.notice_pop_frame(@state, "a")
|
572
505
|
@sampler.on_finishing_transaction(@state, @txn)
|
@@ -579,7 +512,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
579
512
|
|
580
513
|
def test_double_traced_method_stack_empty
|
581
514
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
582
|
-
@sampler.on_start_transaction(@state, Time.now
|
515
|
+
@sampler.on_start_transaction(@state, Time.now)
|
583
516
|
@sampler.notice_push_frame(@state)
|
584
517
|
@sampler.notice_pop_frame(@state, "a")
|
585
518
|
@sampler.on_finishing_transaction(@state, @txn)
|
@@ -599,19 +532,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
599
532
|
|
600
533
|
@sampler.notice_sql("test", {}, 0, @state)
|
601
534
|
|
602
|
-
|
535
|
+
node = @sampler.send(:tl_builder).current_node
|
603
536
|
|
604
|
-
assert_nil
|
537
|
+
assert_nil node[:sql]
|
605
538
|
end
|
606
539
|
|
607
540
|
def test_stack_trace_sql
|
608
541
|
with_config(:'transaction_tracer.stack_trace_threshold' => 0) do
|
609
542
|
@sampler.on_start_transaction(@state, Time.now.to_f)
|
610
543
|
@sampler.notice_sql("test", {}, 1, @state)
|
611
|
-
|
544
|
+
node = @sampler.send(:tl_builder).current_node
|
612
545
|
|
613
|
-
assert
|
614
|
-
assert
|
546
|
+
assert node[:sql]
|
547
|
+
assert node[:backtrace]
|
615
548
|
end
|
616
549
|
end
|
617
550
|
|
@@ -619,10 +552,10 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
619
552
|
with_config(:'transaction_tracer.stack_trace_threshold' => 2) do
|
620
553
|
@sampler.on_start_transaction(@state, Time.now.to_f)
|
621
554
|
@sampler.notice_sql("test", {}, 1, @state)
|
622
|
-
|
555
|
+
node = @sampler.send(:tl_builder).current_node
|
623
556
|
|
624
|
-
assert
|
625
|
-
assert_nil
|
557
|
+
assert node[:sql]
|
558
|
+
assert_nil node[:backtrace]
|
626
559
|
end
|
627
560
|
end
|
628
561
|
|
@@ -637,14 +570,14 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
637
570
|
len += sql.length
|
638
571
|
end
|
639
572
|
|
640
|
-
|
573
|
+
node = @sampler.send(:tl_builder).current_node
|
641
574
|
|
642
|
-
sql =
|
575
|
+
sql = node[:sql]
|
643
576
|
|
644
577
|
assert sql.length <= 16384
|
645
578
|
end
|
646
579
|
|
647
|
-
def
|
580
|
+
def test_node_obfuscated
|
648
581
|
@sampler.on_start_transaction(@state, Time.now.to_f)
|
649
582
|
@sampler.notice_push_frame(@state)
|
650
583
|
|
@@ -652,29 +585,14 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
652
585
|
|
653
586
|
@sampler.notice_sql(orig_sql, {}, 0, @state)
|
654
587
|
|
655
|
-
|
588
|
+
node = @sampler.send(:tl_builder).current_node
|
656
589
|
|
657
|
-
assert_equal orig_sql,
|
658
|
-
assert_equal "SELECT * from Jim where id=?",
|
590
|
+
assert_equal orig_sql, node[:sql]
|
591
|
+
assert_equal "SELECT * from Jim where id=?", node.obfuscated_sql
|
659
592
|
@sampler.notice_pop_frame(@state, "foo")
|
660
593
|
end
|
661
594
|
|
662
|
-
def
|
663
|
-
[true, false].each do |capture|
|
664
|
-
with_config(:capture_params => capture) do
|
665
|
-
tt = with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
666
|
-
@sampler.on_start_transaction(@state, Time.now, nil)
|
667
|
-
@txn.filtered_params[:param] = 'hi'
|
668
|
-
@sampler.on_finishing_transaction(@state, @txn)
|
669
|
-
@sampler.harvest![0]
|
670
|
-
end
|
671
|
-
|
672
|
-
assert_equal (capture ? 1 : 0), tt.params[:request_params].length
|
673
|
-
end
|
674
|
-
end
|
675
|
-
end
|
676
|
-
|
677
|
-
def test_should_not_collect_segments_beyond_limit
|
595
|
+
def test_should_not_collect_nodes_beyond_limit
|
678
596
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
679
597
|
run_sample_trace do
|
680
598
|
@sampler.notice_push_frame(@state)
|
@@ -684,27 +602,27 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
684
602
|
@sampler.notice_pop_frame(@state, "a11")
|
685
603
|
@sampler.notice_pop_frame(@state, "a1")
|
686
604
|
end
|
687
|
-
assert_equal 3, @sampler.last_sample.
|
605
|
+
assert_equal 3, @sampler.last_sample.count_nodes
|
688
606
|
|
689
607
|
expected_sql = "SELECT * FROM sandwiches WHERE bread = 'challah'"
|
690
|
-
|
691
|
-
assert_equal([],
|
692
|
-
assert_equal(expected_sql,
|
608
|
+
deepest_node = find_last_transaction_node(@sampler.last_sample)
|
609
|
+
assert_equal([], deepest_node.called_nodes)
|
610
|
+
assert_equal(expected_sql, deepest_node[:sql])
|
693
611
|
end
|
694
612
|
end
|
695
613
|
|
696
|
-
def
|
614
|
+
def test_renaming_current_node_midflight
|
697
615
|
@sampler.start_builder(@state)
|
698
|
-
|
699
|
-
|
616
|
+
node = @sampler.notice_push_frame(@state)
|
617
|
+
node.metric_name = 'External/www.google.com/Net::HTTP/GET'
|
700
618
|
@sampler.notice_pop_frame(@state, 'External/www.google.com/Net::HTTP/GET')
|
701
619
|
end
|
702
620
|
|
703
|
-
def
|
621
|
+
def test_adding_node_parameters
|
704
622
|
@sampler.start_builder(@state)
|
705
623
|
@sampler.notice_push_frame(@state)
|
706
|
-
@sampler.
|
707
|
-
assert_equal '97612F92E6194080', @sampler.tl_builder.
|
624
|
+
@sampler.add_node_parameters(:transaction_guid => '97612F92E6194080')
|
625
|
+
assert_equal '97612F92E6194080', @sampler.tl_builder.current_node[:transaction_guid]
|
708
626
|
end
|
709
627
|
|
710
628
|
def test_large_transaction_trace_harvest
|
@@ -720,7 +638,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
720
638
|
assert_equal(1, samples.size)
|
721
639
|
|
722
640
|
# Verify that the TT stopped recording after 100 nodes
|
723
|
-
assert_equal(100, samples.first.
|
641
|
+
assert_equal(100, samples.first.count_nodes)
|
724
642
|
end
|
725
643
|
end
|
726
644
|
|
@@ -749,35 +667,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
749
667
|
assert_equal([samples[1]], prepared)
|
750
668
|
end
|
751
669
|
|
752
|
-
def test_custom_params_omitted_if_config_says_so
|
753
|
-
config = {
|
754
|
-
:'transaction_tracer.transaction_threshold' => 0.0,
|
755
|
-
:'transaction_tracer.capture_attributes' => false
|
756
|
-
}
|
757
|
-
with_config(config) do
|
758
|
-
in_transaction do
|
759
|
-
NewRelic::Agent.add_custom_parameters(:foo => 'bar')
|
760
|
-
end
|
761
|
-
end
|
762
|
-
sample = NewRelic::Agent.agent.transaction_sampler.harvest![0]
|
763
|
-
custom_params = sample.params[:custom_params]
|
764
|
-
assert_false(custom_params.keys.include?(:foo))
|
765
|
-
end
|
766
|
-
|
767
|
-
def test_custom_params_included_if_config_says_so
|
768
|
-
config = {
|
769
|
-
:'transaction_tracer.transaction_threshold' => 0.0,
|
770
|
-
:'transaction_tracer.capture_attributes' => true
|
771
|
-
}
|
772
|
-
with_config(config) do
|
773
|
-
in_transaction do
|
774
|
-
NewRelic::Agent.add_custom_parameters(:foo => 'bar')
|
775
|
-
end
|
776
|
-
end
|
777
|
-
custom_params = custom_params_from_last_sample
|
778
|
-
assert_includes custom_params.keys, :foo
|
779
|
-
end
|
780
|
-
|
781
670
|
def test_custom_params_include_gc_time
|
782
671
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
783
672
|
in_transaction do
|
@@ -785,7 +674,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
785
674
|
end
|
786
675
|
end
|
787
676
|
|
788
|
-
assert_equal 10.0,
|
677
|
+
assert_equal 10.0, intrinsic_attributes_from_last_sample[:gc_time]
|
789
678
|
end
|
790
679
|
|
791
680
|
def test_custom_params_include_tripid
|
@@ -800,7 +689,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
800
689
|
end
|
801
690
|
end
|
802
691
|
|
803
|
-
assert_equal 'PDX-NRT',
|
692
|
+
assert_equal 'PDX-NRT', intrinsic_attributes_from_last_sample[:trip_id]
|
804
693
|
end
|
805
694
|
|
806
695
|
def test_custom_params_dont_include_tripid_if_not_cross_app_transaction
|
@@ -812,7 +701,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
812
701
|
end
|
813
702
|
end
|
814
703
|
|
815
|
-
assert_nil
|
704
|
+
assert_nil intrinsic_attributes_from_last_sample[:trip_id]
|
816
705
|
end
|
817
706
|
|
818
707
|
def test_custom_params_include_path_hash
|
@@ -826,7 +715,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
826
715
|
end
|
827
716
|
end
|
828
717
|
|
829
|
-
assert_equal path_hash,
|
718
|
+
assert_equal path_hash, intrinsic_attributes_from_last_sample[:path_hash]
|
830
719
|
end
|
831
720
|
|
832
721
|
def test_synthetics_parameters_not_included_if_not_valid_synthetics_request
|
@@ -839,11 +728,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
839
728
|
|
840
729
|
sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
|
841
730
|
|
842
|
-
|
731
|
+
intrinsic_attributes = attributes_for(sample, :intrinsic)
|
843
732
|
assert_nil sample.synthetics_resource_id
|
844
|
-
assert_nil
|
845
|
-
assert_nil
|
846
|
-
assert_nil
|
733
|
+
assert_nil intrinsic_attributes[:synthetics_resource_id]
|
734
|
+
assert_nil intrinsic_attributes[:synthetics_job_id]
|
735
|
+
assert_nil intrinsic_attributes[:synthetics_monitor_id]
|
847
736
|
end
|
848
737
|
|
849
738
|
def test_synthetics_parameters_included
|
@@ -854,11 +743,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
854
743
|
|
855
744
|
sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
|
856
745
|
|
857
|
-
|
746
|
+
intrinsic_attributes = attributes_for(sample, :intrinsic)
|
858
747
|
assert_equal 100, sample.synthetics_resource_id
|
859
|
-
assert_equal 100,
|
860
|
-
assert_equal 200,
|
861
|
-
assert_equal 300,
|
748
|
+
assert_equal 100, intrinsic_attributes[:synthetics_resource_id]
|
749
|
+
assert_equal 200, intrinsic_attributes[:synthetics_job_id]
|
750
|
+
assert_equal 300, intrinsic_attributes[:synthetics_monitor_id]
|
862
751
|
end
|
863
752
|
|
864
753
|
class Dummy
|
@@ -887,7 +776,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
887
776
|
|
888
777
|
SAMPLE_DEFAULTS = {
|
889
778
|
:threshold => 1.0,
|
890
|
-
:force_persist => false,
|
891
779
|
:transaction_name => nil
|
892
780
|
}
|
893
781
|
|
@@ -895,9 +783,12 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
895
783
|
opts = SAMPLE_DEFAULTS.dup
|
896
784
|
opts.merge!(incoming_opts)
|
897
785
|
|
898
|
-
|
786
|
+
attributes = NewRelic::Agent::Transaction::Attributes.new(NewRelic::Agent.instance.attribute_filter)
|
787
|
+
attributes.add_intrinsic_attribute(:synthetics_resource_id, opts[:synthetics_resource_id])
|
788
|
+
|
789
|
+
sample = NewRelic::Agent::Transaction::Trace.new(Time.now)
|
790
|
+
sample.attributes = attributes
|
899
791
|
sample.threshold = opts[:threshold]
|
900
|
-
sample.force_persist = opts[:force_persist]
|
901
792
|
sample.transaction_name = opts[:transaction_name]
|
902
793
|
sample.stubs(:duration).returns(opts[:duration])
|
903
794
|
sample
|
@@ -927,7 +818,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
927
818
|
end
|
928
819
|
|
929
820
|
def run_long_sample_trace(n)
|
930
|
-
@sampler.on_start_transaction(@state, Time.now
|
821
|
+
@sampler.on_start_transaction(@state, Time.now)
|
931
822
|
n.times do |i|
|
932
823
|
@sampler.notice_push_frame(@state)
|
933
824
|
yield if block_given?
|
@@ -937,7 +828,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
937
828
|
end
|
938
829
|
|
939
830
|
def run_sample_trace(start = Time.now.to_f, stop = nil, state = @state)
|
940
|
-
@sampler.on_start_transaction(state, start
|
831
|
+
@sampler.on_start_transaction(state, start)
|
941
832
|
@sampler.notice_push_frame(state)
|
942
833
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0, state)
|
943
834
|
@sampler.notice_push_frame(state)
|
@@ -951,8 +842,8 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
951
842
|
@sampler.on_finishing_transaction(state, @txn, (stop || Time.now.to_f))
|
952
843
|
end
|
953
844
|
|
954
|
-
def
|
845
|
+
def intrinsic_attributes_from_last_sample
|
955
846
|
sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
|
956
|
-
sample
|
847
|
+
attributes_for(sample, :intrinsic)
|
957
848
|
end
|
958
849
|
end
|