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/agent/transaction/transaction_sample_buffer'
|
6
|
-
|
7
|
-
module NewRelic
|
8
|
-
module Agent
|
9
|
-
class Transaction
|
10
|
-
class ForcePersistSampleBuffer < TransactionSampleBuffer
|
11
|
-
|
12
|
-
CAPACITY = 10
|
13
|
-
|
14
|
-
def capacity
|
15
|
-
CAPACITY
|
16
|
-
end
|
17
|
-
|
18
|
-
def allow_sample?(sample)
|
19
|
-
sample.force_persist
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,80 +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_analysis/segment_summary'
|
6
|
-
# Add these methods to TransactionSample that enable performance analysis in the user interface.
|
7
|
-
module NewRelic
|
8
|
-
module TransactionAnalysis
|
9
|
-
def database_time
|
10
|
-
time_percentage(/^Database\/.*/)
|
11
|
-
end
|
12
|
-
|
13
|
-
def render_time
|
14
|
-
time_percentage(/^View\/.*/)
|
15
|
-
end
|
16
|
-
|
17
|
-
# return the data that breaks down the performance of the transaction
|
18
|
-
# as an array of SegmentSummary objects. If a limit is specified, then
|
19
|
-
# limit the data set to the top n
|
20
|
-
def breakdown_data(limit = nil)
|
21
|
-
metric_hash = {}
|
22
|
-
each_segment_with_nest_tracking do |segment|
|
23
|
-
unless segment == root_segment
|
24
|
-
metric_name = segment.metric_name
|
25
|
-
metric_hash[metric_name] ||= SegmentSummary.new(metric_name, self)
|
26
|
-
metric_hash[metric_name] << segment
|
27
|
-
metric_hash[metric_name]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
data = metric_hash.values
|
32
|
-
|
33
|
-
data.sort! do |x,y|
|
34
|
-
y.exclusive_time <=> x.exclusive_time
|
35
|
-
end
|
36
|
-
|
37
|
-
if limit && data.length > limit
|
38
|
-
data = data[0..limit - 1]
|
39
|
-
end
|
40
|
-
|
41
|
-
# add one last segment for the remaining time if any
|
42
|
-
remainder = duration
|
43
|
-
data.each do |segment|
|
44
|
-
remainder -= segment.exclusive_time
|
45
|
-
end
|
46
|
-
|
47
|
-
if (remainder*1000).round > 0
|
48
|
-
remainder_summary = SegmentSummary.new('Remainder', self)
|
49
|
-
remainder_summary.total_time = remainder_summary.exclusive_time = remainder
|
50
|
-
remainder_summary.call_count = 1
|
51
|
-
data << remainder_summary
|
52
|
-
end
|
53
|
-
|
54
|
-
data
|
55
|
-
end
|
56
|
-
|
57
|
-
# return an array of sql statements executed by this transaction
|
58
|
-
# each element in the array contains [sql, parent_segment_metric_name, duration]
|
59
|
-
def sql_segments(show_non_sql_segments = true)
|
60
|
-
segments = []
|
61
|
-
each_segment do |segment|
|
62
|
-
segments << segment if segment[:sql] || segment[:sql_obfuscated] || (show_non_sql_segments && segment[:key])
|
63
|
-
end
|
64
|
-
segments
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
def time_percentage(regex)
|
69
|
-
total = 0
|
70
|
-
each_segment do |segment|
|
71
|
-
if regex =~ segment.metric_name
|
72
|
-
total += segment.duration
|
73
|
-
end
|
74
|
-
end
|
75
|
-
fraction = 100.0 * total / duration
|
76
|
-
# percent value rounded to two digits:
|
77
|
-
return (100 * fraction).round / 100.0
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,53 +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
|
-
module NewRelic
|
6
|
-
module TransactionAnalysis
|
7
|
-
# summarizes performance data for all calls to segments
|
8
|
-
# with the same metric_name
|
9
|
-
class SegmentSummary
|
10
|
-
attr_accessor :metric_name, :total_time, :exclusive_time, :call_count, :current_nest_count
|
11
|
-
def initialize(metric_name, sample)
|
12
|
-
@metric_name = metric_name
|
13
|
-
@total_time, @exclusive_time, @call_count = 0,0,0
|
14
|
-
@sample = sample
|
15
|
-
@current_nest_count = 0
|
16
|
-
end
|
17
|
-
|
18
|
-
def <<(segment)
|
19
|
-
if metric_name != segment.metric_name
|
20
|
-
raise ArgumentError, "Metric Name Mismatch: #{segment.metric_name} != #{metric_name}"
|
21
|
-
end
|
22
|
-
|
23
|
-
# a nested segment should use the sum of the top level totals
|
24
|
-
@total_time += segment.duration if current_nest_count == 0
|
25
|
-
@exclusive_time += segment.exclusive_duration
|
26
|
-
@call_count += 1
|
27
|
-
end
|
28
|
-
|
29
|
-
def average_time
|
30
|
-
@total_time / @call_count
|
31
|
-
end
|
32
|
-
|
33
|
-
def average_exclusive_time
|
34
|
-
@exclusive_time / @call_count
|
35
|
-
end
|
36
|
-
|
37
|
-
def exclusive_time_percentage
|
38
|
-
return 0 unless @exclusive_time && @sample.duration && @sample.duration > 0
|
39
|
-
@exclusive_time / @sample.duration
|
40
|
-
end
|
41
|
-
|
42
|
-
def total_time_percentage
|
43
|
-
return 0 unless @total_time && @sample.duration && @sample.duration > 0
|
44
|
-
@total_time / @sample.duration
|
45
|
-
end
|
46
|
-
|
47
|
-
def ui_name
|
48
|
-
return @metric_name if @metric_name == 'Remainder'
|
49
|
-
NewRelic::MetricParser::MetricParser.parse(@metric_name).developer_name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,207 +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 'base64'
|
6
|
-
|
7
|
-
require 'new_relic/transaction_sample/segment'
|
8
|
-
require 'new_relic/transaction_sample/summary_segment'
|
9
|
-
require 'new_relic/transaction_sample/fake_segment'
|
10
|
-
require 'new_relic/transaction_sample/composite_segment'
|
11
|
-
module NewRelic
|
12
|
-
# the number of segments that need to exist before we roll them up
|
13
|
-
# into one segment with multiple executions
|
14
|
-
COLLAPSE_SEGMENTS_THRESHOLD = 2
|
15
|
-
|
16
|
-
class TransactionSample
|
17
|
-
|
18
|
-
attr_accessor :params, :root_segment, :profile, :force_persist, :guid,
|
19
|
-
:threshold, :finished, :xray_session_id, :start_time,
|
20
|
-
:synthetics_resource_id
|
21
|
-
attr_reader :root_segment, :params, :sample_id
|
22
|
-
attr_writer :prepared
|
23
|
-
|
24
|
-
@@start_time = Time.now
|
25
|
-
|
26
|
-
def initialize(time = Time.now.to_f, sample_id = nil)
|
27
|
-
@sample_id = sample_id || object_id
|
28
|
-
@start_time = time
|
29
|
-
@params = { :segment_count => -1, :request_params => {} }
|
30
|
-
@segment_count = -1
|
31
|
-
@root_segment = create_segment 0.0, "ROOT"
|
32
|
-
@prepared = false
|
33
|
-
end
|
34
|
-
|
35
|
-
def prepared?
|
36
|
-
@prepared
|
37
|
-
end
|
38
|
-
|
39
|
-
def count_segments
|
40
|
-
@segment_count
|
41
|
-
end
|
42
|
-
|
43
|
-
# makes sure that the parameter cache for segment count is set to
|
44
|
-
# the correct value
|
45
|
-
def ensure_segment_count_set(count)
|
46
|
-
params[:segment_count] ||= count
|
47
|
-
end
|
48
|
-
|
49
|
-
# offset from start of app
|
50
|
-
def timestamp
|
51
|
-
@start_time - @@start_time.to_f
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_custom_param(name, value)
|
55
|
-
@params[:custom_params] ||= {}
|
56
|
-
@params[:custom_params][name] = value
|
57
|
-
end
|
58
|
-
|
59
|
-
include NewRelic::Coerce
|
60
|
-
|
61
|
-
def to_array
|
62
|
-
[ float(@start_time),
|
63
|
-
@params[:request_params],
|
64
|
-
@params[:custom_params],
|
65
|
-
@root_segment.to_array ]
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_collector_array(encoder)
|
69
|
-
trace_tree = encoder.encode(self.to_array)
|
70
|
-
[ Helper.time_to_millis(@start_time),
|
71
|
-
Helper.time_to_millis(duration),
|
72
|
-
string(transaction_name),
|
73
|
-
string(@params[:uri]),
|
74
|
-
trace_tree,
|
75
|
-
string(@guid),
|
76
|
-
nil,
|
77
|
-
forced?,
|
78
|
-
int_or_nil(xray_session_id),
|
79
|
-
string(synthetics_resource_id)
|
80
|
-
]
|
81
|
-
end
|
82
|
-
|
83
|
-
def path_string
|
84
|
-
@root_segment.path_string
|
85
|
-
end
|
86
|
-
|
87
|
-
def transaction_name
|
88
|
-
@params[:path]
|
89
|
-
end
|
90
|
-
|
91
|
-
def transaction_name=(new_name)
|
92
|
-
@params[:path] = new_name
|
93
|
-
end
|
94
|
-
|
95
|
-
def forced?
|
96
|
-
!!@force_persist || !int_or_nil(xray_session_id).nil?
|
97
|
-
end
|
98
|
-
|
99
|
-
# relative_timestamp is seconds since the start of the transaction
|
100
|
-
def create_segment(relative_timestamp, metric_name=nil)
|
101
|
-
raise TypeError.new("Frozen Transaction Sample") if finished
|
102
|
-
@params[:segment_count] += 1
|
103
|
-
@segment_count += 1
|
104
|
-
NewRelic::TransactionSample::Segment.new(relative_timestamp, metric_name)
|
105
|
-
end
|
106
|
-
|
107
|
-
def duration
|
108
|
-
root_segment.duration
|
109
|
-
end
|
110
|
-
|
111
|
-
# Iterates recursively over each segment in the entire transaction
|
112
|
-
# sample tree
|
113
|
-
def each_segment(&block)
|
114
|
-
@root_segment.each_segment(&block)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Iterates recursively over each segment in the entire transaction
|
118
|
-
# sample tree while keeping track of nested segments
|
119
|
-
def each_segment_with_nest_tracking(&block)
|
120
|
-
@root_segment.each_segment_with_nest_tracking(&block)
|
121
|
-
end
|
122
|
-
|
123
|
-
def to_s_compact
|
124
|
-
@root_segment.to_s_compact
|
125
|
-
end
|
126
|
-
|
127
|
-
# Searches the tree recursively for the segment with the given
|
128
|
-
# id. note that this is an internal id, not an ActiveRecord id
|
129
|
-
def find_segment(id)
|
130
|
-
@root_segment.find_segment(id)
|
131
|
-
end
|
132
|
-
|
133
|
-
def to_s
|
134
|
-
s = "Transaction Sample collected at #{Time.at(start_time)}\n"
|
135
|
-
s << " {\n"
|
136
|
-
s << " Path: #{params[:path]} \n"
|
137
|
-
|
138
|
-
params.each do |k,v|
|
139
|
-
next if k == :path
|
140
|
-
s << " #{k}: " <<
|
141
|
-
case v
|
142
|
-
when Enumerable then v.map(&:to_s).sort.join("; ")
|
143
|
-
when String then v
|
144
|
-
when Float then '%6.3s' % v
|
145
|
-
when Fixnum then v.to_s
|
146
|
-
when nil then ''
|
147
|
-
else
|
148
|
-
raise "unexpected value type for #{k}: '#{v}' (#{v.class})"
|
149
|
-
end << "\n"
|
150
|
-
end
|
151
|
-
s << " }\n\n"
|
152
|
-
s << @root_segment.to_debug_str(0)
|
153
|
-
end
|
154
|
-
|
155
|
-
# Return a new transaction sample that can be sent to the New
|
156
|
-
# Relic service.
|
157
|
-
def prepare_to_send!
|
158
|
-
return self if @prepared
|
159
|
-
|
160
|
-
if Agent::Database.should_record_sql?
|
161
|
-
collect_explain_plans!
|
162
|
-
prepare_sql_for_transmission!
|
163
|
-
else
|
164
|
-
strip_sql!
|
165
|
-
end
|
166
|
-
|
167
|
-
@prepared = true
|
168
|
-
self
|
169
|
-
end
|
170
|
-
|
171
|
-
def params=(params)
|
172
|
-
@params = params
|
173
|
-
end
|
174
|
-
|
175
|
-
private
|
176
|
-
|
177
|
-
def strip_sql!
|
178
|
-
each_segment do |segment|
|
179
|
-
segment.params.delete(:sql)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def collect_explain_plans!
|
184
|
-
return unless Agent::Database.should_collect_explain_plans?
|
185
|
-
threshold = Agent.config[:'transaction_tracer.explain_threshold']
|
186
|
-
each_segment do |segment|
|
187
|
-
if segment[:sql] && segment.duration > threshold
|
188
|
-
segment[:explain_plan] = segment.explain_sql
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def prepare_sql_for_transmission!
|
194
|
-
strategy = Agent::Database.record_sql_method
|
195
|
-
each_segment do |segment|
|
196
|
-
if segment[:sql]
|
197
|
-
segment[:sql] = case strategy
|
198
|
-
when :raw
|
199
|
-
segment[:sql].to_s
|
200
|
-
when :obfuscated
|
201
|
-
Agent::Database.obfuscate_sql(segment[:sql]).to_s
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
@@ -1,31 +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
|
-
require 'new_relic/transaction_sample/summary_segment'
|
8
|
-
module NewRelic
|
9
|
-
class TransactionSample
|
10
|
-
class CompositeSegment < Segment
|
11
|
-
attr_reader :detail_segments
|
12
|
-
|
13
|
-
def initialize(segments)
|
14
|
-
summary = SummarySegment.new(segments.first)
|
15
|
-
super summary.entry_timestamp, "Repeating pattern (#{segments.length} repeats)"
|
16
|
-
|
17
|
-
summary.end_trace(segments.last.exit_timestamp)
|
18
|
-
|
19
|
-
@detail_segments = segments.clone
|
20
|
-
|
21
|
-
add_called_segment(summary)
|
22
|
-
end_trace summary.exit_timestamp
|
23
|
-
end
|
24
|
-
|
25
|
-
def detail_segments=(segments)
|
26
|
-
@detail_segments = segments
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,13 +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 FakeSegment < Segment
|
10
|
-
public :parent_segment=
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,197 +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
|
-
|
7
|
-
module NewRelic
|
8
|
-
class TransactionSample
|
9
|
-
class Segment
|
10
|
-
attr_reader :entry_timestamp
|
11
|
-
# The exit timestamp will be relative except for the outermost sample which will
|
12
|
-
# have a timestamp.
|
13
|
-
attr_reader :exit_timestamp
|
14
|
-
attr_reader :parent_segment
|
15
|
-
|
16
|
-
# This is only used from developer mode and rpm_site.
|
17
|
-
# No new clients should be added.
|
18
|
-
attr_reader :segment_id
|
19
|
-
|
20
|
-
attr_accessor :metric_name
|
21
|
-
|
22
|
-
UNKNOWN_SEGMENT_NAME = '<unknown>'.freeze
|
23
|
-
|
24
|
-
def initialize(timestamp, metric_name, segment_id=nil)
|
25
|
-
@entry_timestamp = timestamp
|
26
|
-
@metric_name = metric_name || UNKNOWN_SEGMENT_NAME
|
27
|
-
@segment_id = segment_id || object_id
|
28
|
-
end
|
29
|
-
|
30
|
-
# sets the final timestamp on a segment to indicate the exit
|
31
|
-
# point of the segment
|
32
|
-
def end_trace(timestamp)
|
33
|
-
@exit_timestamp = timestamp
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_called_segment(s)
|
37
|
-
@called_segments ||= []
|
38
|
-
@called_segments << s
|
39
|
-
s.parent_segment = self
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_s
|
43
|
-
to_debug_str(0)
|
44
|
-
end
|
45
|
-
|
46
|
-
include NewRelic::Coerce
|
47
|
-
|
48
|
-
def to_array
|
49
|
-
[ NewRelic::Helper.time_to_millis(@entry_timestamp),
|
50
|
-
NewRelic::Helper.time_to_millis(@exit_timestamp),
|
51
|
-
string(@metric_name),
|
52
|
-
(@params || {}) ] +
|
53
|
-
[ (@called_segments ? @called_segments.map{|s| s.to_array} : []) ]
|
54
|
-
end
|
55
|
-
|
56
|
-
def path_string
|
57
|
-
"#{metric_name}[#{called_segments.collect {|segment| segment.path_string }.join('')}]"
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_s_compact
|
61
|
-
str = ""
|
62
|
-
str << metric_name
|
63
|
-
if called_segments.any?
|
64
|
-
str << "{#{called_segments.map { | cs | cs.to_s_compact }.join(",")}}"
|
65
|
-
end
|
66
|
-
str
|
67
|
-
end
|
68
|
-
|
69
|
-
def to_debug_str(depth)
|
70
|
-
tab = " " * depth
|
71
|
-
s = tab.clone
|
72
|
-
s << ">> #{'%3i ms' % (@entry_timestamp*1000)} [#{self.class.name.split("::").last}] #{metric_name} \n"
|
73
|
-
unless params.empty?
|
74
|
-
params.each do |k,v|
|
75
|
-
s << "#{tab} -#{'%-16s' % k}: #{v.to_s[0..80]}\n"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
called_segments.each do |cs|
|
79
|
-
s << cs.to_debug_str(depth + 1)
|
80
|
-
end
|
81
|
-
s << tab + "<< "
|
82
|
-
s << case @exit_timestamp
|
83
|
-
when nil then ' n/a'
|
84
|
-
when Numeric then '%3i ms' % (@exit_timestamp*1000)
|
85
|
-
else @exit_timestamp.to_s
|
86
|
-
end
|
87
|
-
s << " #{metric_name}\n"
|
88
|
-
end
|
89
|
-
|
90
|
-
def called_segments
|
91
|
-
@called_segments || []
|
92
|
-
end
|
93
|
-
|
94
|
-
# return the total duration of this segment
|
95
|
-
def duration
|
96
|
-
(@exit_timestamp - @entry_timestamp).to_f
|
97
|
-
end
|
98
|
-
|
99
|
-
# return the duration of this segment without
|
100
|
-
# including the time in the called segments
|
101
|
-
def exclusive_duration
|
102
|
-
d = duration
|
103
|
-
|
104
|
-
called_segments.each do |segment|
|
105
|
-
d -= segment.duration
|
106
|
-
end
|
107
|
-
d
|
108
|
-
end
|
109
|
-
|
110
|
-
def count_segments
|
111
|
-
count = 1
|
112
|
-
called_segments.each { | seg | count += seg.count_segments }
|
113
|
-
count
|
114
|
-
end
|
115
|
-
|
116
|
-
def []=(key, value)
|
117
|
-
# only create a parameters field if a parameter is set; this will save
|
118
|
-
# bandwidth etc as most segments have no parameters
|
119
|
-
params[key] = value
|
120
|
-
end
|
121
|
-
|
122
|
-
def [](key)
|
123
|
-
params[key]
|
124
|
-
end
|
125
|
-
|
126
|
-
def params
|
127
|
-
@params ||= {}
|
128
|
-
end
|
129
|
-
|
130
|
-
def params=(p)
|
131
|
-
@params = p
|
132
|
-
end
|
133
|
-
|
134
|
-
# call the provided block for this segment and each
|
135
|
-
# of the called segments
|
136
|
-
def each_segment(&block)
|
137
|
-
block.call self
|
138
|
-
|
139
|
-
if @called_segments
|
140
|
-
@called_segments.each do |segment|
|
141
|
-
segment.each_segment(&block)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# call the provided block for this segment and each
|
147
|
-
# of the called segments while keeping track of nested segments
|
148
|
-
def each_segment_with_nest_tracking(&block)
|
149
|
-
summary = block.call self
|
150
|
-
summary.current_nest_count += 1 if summary
|
151
|
-
|
152
|
-
if @called_segments
|
153
|
-
@called_segments.each do |segment|
|
154
|
-
segment.each_segment_with_nest_tracking(&block)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
summary.current_nest_count -= 1 if summary
|
159
|
-
end
|
160
|
-
|
161
|
-
# This is only for use by developer mode
|
162
|
-
def find_segment(id)
|
163
|
-
return self if segment_id == id
|
164
|
-
called_segments.each do |segment|
|
165
|
-
found = segment.find_segment(id)
|
166
|
-
return found if found
|
167
|
-
end
|
168
|
-
nil
|
169
|
-
end
|
170
|
-
|
171
|
-
def explain_sql
|
172
|
-
return params[:explain_plan] if params.key?(:explain_plan)
|
173
|
-
|
174
|
-
statement = params[:sql]
|
175
|
-
return nil unless statement.respond_to?(:config) &&
|
176
|
-
statement.respond_to?(:explainer)
|
177
|
-
|
178
|
-
NewRelic::Agent::Database.explain_sql(statement,
|
179
|
-
statement.config,
|
180
|
-
&statement.explainer)
|
181
|
-
end
|
182
|
-
|
183
|
-
def obfuscated_sql
|
184
|
-
NewRelic::Agent::Database.obfuscate_sql(params[:sql])
|
185
|
-
end
|
186
|
-
|
187
|
-
def called_segments=(segments)
|
188
|
-
@called_segments = segments
|
189
|
-
end
|
190
|
-
|
191
|
-
protected
|
192
|
-
def parent_segment=(s)
|
193
|
-
@parent_segment = s
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|