newrelic_rpm 3.8.1.221 → 3.9.0.229
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG +95 -0
- data/README.md +9 -3
- data/Rakefile +6 -0
- data/lib/new_relic/agent.rb +37 -52
- data/lib/new_relic/agent/agent.rb +32 -64
- data/lib/new_relic/agent/agent_logger.rb +3 -2
- data/lib/new_relic/agent/audit_logger.rb +2 -1
- data/lib/new_relic/agent/busy_calculator.rb +10 -8
- data/lib/new_relic/agent/configuration.rb +0 -13
- data/lib/new_relic/agent/configuration/default_source.rb +27 -20
- data/lib/new_relic/agent/configuration/manager.rb +101 -27
- data/lib/new_relic/agent/cross_app_monitor.rb +43 -50
- data/lib/new_relic/agent/cross_app_tracing.rb +13 -12
- data/lib/new_relic/agent/error_collector.rb +31 -35
- data/lib/new_relic/agent/harvester.rb +5 -1
- data/lib/new_relic/agent/hostname.rb +17 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/uri_util.rb +13 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +18 -32
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +15 -15
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +18 -20
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +79 -93
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -4
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +96 -0
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +69 -0
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +21 -13
- data/lib/new_relic/agent/instrumentation/rack.rb +85 -74
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -1
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +39 -0
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +28 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +4 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +34 -30
- data/lib/new_relic/agent/memory_logger.rb +12 -12
- data/lib/new_relic/agent/method_tracer.rb +34 -74
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +3 -3
- data/lib/new_relic/agent/request_sampler.rb +10 -11
- data/lib/new_relic/agent/samplers/vm_sampler.rb +6 -6
- data/lib/new_relic/agent/shim_agent.rb +2 -1
- data/lib/new_relic/agent/sql_sampler.rb +52 -27
- data/lib/new_relic/agent/stats.rb +24 -10
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +5 -17
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +106 -58
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +20 -24
- data/lib/new_relic/agent/supported_versions.rb +3 -1
- data/lib/new_relic/agent/threading/agent_thread.rb +42 -11
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
- data/lib/new_relic/agent/traced_method_stack.rb +28 -18
- data/lib/new_relic/agent/transaction.rb +249 -196
- data/lib/new_relic/agent/transaction_metrics.rb +57 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +10 -7
- data/lib/new_relic/agent/transaction_sampler.rb +81 -45
- data/lib/new_relic/agent/transaction_state.rb +38 -49
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +15 -18
- data/lib/new_relic/agent/vm/rubinius_vm.rb +4 -2
- data/lib/new_relic/cli/commands/deployments.rb +3 -2
- data/lib/new_relic/control/frameworks/ruby.rb +2 -3
- data/lib/new_relic/control/frameworks/sinatra.rb +0 -7
- data/lib/new_relic/control/instance_methods.rb +3 -5
- data/lib/new_relic/json_wrapper.rb +2 -0
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -16
- data/lib/new_relic/metric_spec.rb +10 -38
- data/lib/new_relic/noticed_error.rb +16 -11
- data/lib/new_relic/rack/agent_hooks.rb +4 -10
- data/lib/new_relic/rack/agent_middleware.rb +31 -0
- data/lib/new_relic/rack/browser_monitoring.rb +7 -13
- data/lib/new_relic/rack/developer_mode.rb +16 -59
- data/lib/new_relic/rack/error_collector.rb +16 -54
- data/lib/new_relic/recipes.rb +8 -101
- data/lib/new_relic/recipes/capistrano3.rb +66 -0
- data/lib/new_relic/recipes/capistrano_legacy.rb +98 -0
- data/lib/new_relic/transaction_sample.rb +6 -54
- data/lib/new_relic/transaction_sample/composite_segment.rb +1 -1
- data/lib/new_relic/transaction_sample/segment.rb +12 -4
- data/lib/new_relic/transaction_sample/summary_segment.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +19 -19
- data/lib/tasks/tests.rake +20 -1
- data/lib/tasks/versions.html.erb +0 -4
- data/lib/tasks/versions.rake +4 -3
- data/newrelic.yml +4 -12
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +146 -44
- data/test/config/newrelic.yml +0 -1
- data/test/environments/norails/Gemfile +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +13 -1
- data/test/multiverse/lib/multiverse/suite.rb +26 -9
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
- data/test/multiverse/suites/activemerchant/Envfile +18 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +4 -3
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +35 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +3 -2
- data/test/multiverse/suites/agent_only/exclusive_time_test.rb +178 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +10 -6
- data/test/multiverse/suites/agent_only/marshaling_test.rb +11 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +1 -1
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +5 -1
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +2 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +9 -9
- data/test/multiverse/suites/capistrano/Capfile +26 -0
- data/test/multiverse/suites/capistrano/Envfile +18 -0
- data/test/multiverse/suites/capistrano/config/deploy.rb +10 -0
- data/test/multiverse/suites/capistrano/config/deploy/production.rb +9 -0
- data/test/multiverse/suites/capistrano/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano/deployment_test.rb +47 -0
- data/test/multiverse/suites/capistrano2/Capfile +4 -0
- data/test/multiverse/suites/capistrano2/Envfile +4 -0
- data/test/multiverse/suites/capistrano2/config/deploy.rb +19 -0
- data/test/multiverse/suites/capistrano2/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano2/deployment_test.rb +38 -0
- data/test/multiverse/suites/curb/Envfile +10 -1
- data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
- data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rack/Envfile +25 -0
- data/test/multiverse/suites/rack/example_app.rb +50 -0
- data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +66 -0
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +143 -0
- data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +45 -0
- data/test/multiverse/suites/rack/url_map_test.rb +120 -0
- data/test/multiverse/suites/rails/Envfile +10 -0
- data/test/multiverse/suites/rails/app.rb +28 -63
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -4
- data/test/multiverse/suites/rails/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rails/dummy.txt +1 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +46 -31
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/rails/ignore_test.rb +9 -3
- data/test/multiverse/suites/rails/middleware_instrumentation_test.rb +41 -0
- data/test/multiverse/suites/rails/middlewares.rb +19 -0
- data/test/multiverse/suites/rails/parameter_capture_test.rb +169 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +14 -4
- data/test/multiverse/suites/rails/rails2_app/app/controllers/application.rb +7 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +127 -0
- data/test/multiverse/suites/rails/rails2_app/config/database.yml +18 -0
- data/test/multiverse/suites/rails/rails2_app/config/environment.rb +16 -0
- data/test/multiverse/suites/rails/rails2_app/config/environments/development.rb +10 -0
- data/test/multiverse/suites/rails/rails2_app/config/initializers/load_newrelic_rpm.rb +9 -0
- data/test/multiverse/suites/rails/rails2_app/config/preinitializer.rb +25 -0
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +18 -0
- data/test/multiverse/suites/rails/rails2_app/db/schema.rb +5 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +76 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +2 -4
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +3 -5
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +73 -42
- data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/Envfile +4 -0
- data/test/multiverse/suites/sidekiq/after_suite.rb +7 -0
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +55 -34
- data/test/multiverse/suites/sidekiq/sidekiq_server.rb +30 -0
- data/test/multiverse/suites/sidekiq/test_worker.rb +60 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sinatra/ignoring_test.rb +33 -11
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +3 -1
- data/test/multiverse/suites/typhoeus/Envfile +9 -0
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +10 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +3 -10
- data/test/new_relic/agent/agent_logger_test.rb +24 -6
- data/test/new_relic/agent/agent_test.rb +7 -8
- data/test/new_relic/agent/agent_test_controller.rb +2 -2
- data/test/new_relic/agent/audit_logger_test.rb +5 -1
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/configuration/manager_test.rb +68 -69
- data/test/new_relic/agent/cross_app_monitor_test.rb +32 -14
- data/test/new_relic/agent/cross_app_tracing_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -33
- data/test/new_relic/agent/error_collector_test.rb +45 -14
- data/test/new_relic/agent/harvester_test.rb +9 -0
- data/test/new_relic/agent/hostname_test.rb +41 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +27 -19
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +95 -14
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +189 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +18 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +10 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +3 -1
- data/test/new_relic/agent/javascript_instrumentor_test.rb +28 -41
- data/test/new_relic/agent/memory_logger_test.rb +14 -0
- data/test/new_relic/agent/method_interrobang_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -30
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +5 -21
- data/test/new_relic/agent/method_tracer_test.rb +5 -4
- data/test/new_relic/agent/mock_scope_listener.rb +2 -2
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +17 -5
- data/test/new_relic/agent/request_sampler_test.rb +16 -16
- data/test/new_relic/agent/rpm_agent_test.rb +23 -29
- data/test/new_relic/agent/sql_sampler_test.rb +39 -31
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +189 -117
- data/test/new_relic/agent/stats_engine_test.rb +1 -1
- data/test/new_relic/agent/stats_hash_test.rb +28 -1
- data/test/new_relic/agent/stats_test.rb +1 -12
- data/test/new_relic/agent/threading/agent_thread_test.rb +23 -9
- data/test/new_relic/agent/threading/backtrace_service_test.rb +33 -32
- data/test/new_relic/agent/threading/fake_thread.rb +4 -8
- data/test/new_relic/agent/threading/threaded_test_case.rb +4 -14
- data/test/new_relic/agent/traced_method_stack_test.rb +43 -27
- data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
- data/test/new_relic/agent/transaction_metrics_test.rb +113 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -61
- data/test/new_relic/agent/transaction_sampler_test.rb +176 -228
- data/test/new_relic/agent/transaction_state_test.rb +62 -26
- data/test/new_relic/agent/transaction_test.rb +198 -80
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +4 -4
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +68 -0
- data/test/new_relic/agent_test.rb +31 -27
- data/test/new_relic/cli/commands/deployments_test.rb +7 -2
- data/test/new_relic/control/instance_methods_test.rb +4 -4
- data/test/new_relic/control_test.rb +28 -22
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_external_server.rb +1 -0
- data/test/new_relic/fake_rpm_site.rb +35 -0
- data/test/new_relic/http_client_test_cases.rb +12 -3
- data/test/new_relic/json_wrapper_test.rb +5 -0
- data/test/new_relic/language_support_test.rb +7 -0
- data/test/new_relic/license_test.rb +11 -5
- data/test/new_relic/local_environment_test.rb +0 -18
- data/test/new_relic/metric_data_test.rb +2 -2
- data/test/new_relic/metric_spec_test.rb +4 -23
- data/test/new_relic/multiverse_helpers.rb +1 -3
- data/test/new_relic/noticed_error_test.rb +6 -22
- data/test/new_relic/rack/agent_hooks_test.rb +5 -1
- data/test/new_relic/rack/agent_middleware_test.rb +32 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +14 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +0 -8
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +6 -30
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -2
- data/test/new_relic/transaction_sample/segment_test.rb +47 -47
- data/test/new_relic/transaction_sample_test.rb +9 -8
- data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -8
- data/test/performance/script/runner +13 -0
- data/test/performance/suites/config.rb +5 -2
- data/test/performance/suites/rack_middleware.rb +84 -0
- data/test/performance/suites/rum_autoinsertion.rb +1 -1
- data/test/performance/suites/thread_profiling.rb +1 -1
- data/test/test_helper.rb +12 -10
- data/ui/helpers/developer_mode_helper.rb +3 -43
- data/ui/views/layouts/newrelic_default.rhtml +2 -2
- data/ui/views/newrelic/_sample.rhtml +2 -2
- data/ui/views/newrelic/_sql_row.rhtml +11 -11
- data/ui/views/newrelic/index.rhtml +21 -22
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +15 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +2 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +24 -0
- metadata +108 -31
- metadata.gz.sig +0 -0
- data/lib/new_relic/rack/transaction_reset.rb +0 -20
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -42
- data/test/new_relic/rack/transaction_reset_test.rb +0 -35
- data/ui/views/newrelic/show_source.rhtml +0 -3
@@ -11,12 +11,12 @@ module NewRelic::Agent
|
|
11
11
|
attr_reader :state
|
12
12
|
|
13
13
|
def setup
|
14
|
-
TransactionState.
|
15
|
-
@state = TransactionState.
|
14
|
+
TransactionState.tl_clear_for_testing
|
15
|
+
@state = TransactionState.tl_get
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
19
|
-
TransactionState.
|
19
|
+
TransactionState.tl_clear_for_testing
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_without_transaction_stack_on_thread
|
@@ -25,7 +25,7 @@ module NewRelic::Agent
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_in_background_transaction
|
28
|
-
in_transaction(:
|
28
|
+
in_transaction(:category => :task) do |txn|
|
29
29
|
txn.request = nil # this makes it a "background transaction"
|
30
30
|
assert state.in_background_transaction?
|
31
31
|
end
|
@@ -39,17 +39,6 @@ module NewRelic::Agent
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def test_timings_without_transaction
|
43
|
-
freeze_time
|
44
|
-
|
45
|
-
state.reset
|
46
|
-
timings = state.timings
|
47
|
-
|
48
|
-
assert_equal 0.0, timings.queue_time_in_seconds
|
49
|
-
assert_equal 0.0, timings.app_time_in_seconds
|
50
|
-
assert_equal nil, timings.transaction_name
|
51
|
-
end
|
52
|
-
|
53
42
|
def test_timings_with_transaction
|
54
43
|
earliest_time = freeze_time
|
55
44
|
|
@@ -77,10 +66,8 @@ module NewRelic::Agent
|
|
77
66
|
def test_request_guid_to_include
|
78
67
|
with_config(:apdex_t => 2.0) do
|
79
68
|
freeze_time
|
80
|
-
|
81
|
-
state.request_token = "token"
|
82
|
-
|
83
69
|
in_transaction do |txn|
|
70
|
+
state.request_token = "token"
|
84
71
|
advance_time(4.0)
|
85
72
|
assert_equal state.current_transaction.guid, state.request_guid_to_include
|
86
73
|
end
|
@@ -121,28 +108,28 @@ module NewRelic::Agent
|
|
121
108
|
end
|
122
109
|
|
123
110
|
def test_request_guid_for_event
|
124
|
-
state.request_token = nil
|
125
|
-
state.is_cross_app_caller = true
|
126
|
-
state.referring_transaction_info = nil
|
127
111
|
in_transaction do
|
112
|
+
state.request_token = nil
|
113
|
+
state.is_cross_app_caller = true
|
114
|
+
state.referring_transaction_info = nil
|
128
115
|
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
129
116
|
end
|
130
117
|
end
|
131
118
|
|
132
119
|
def test_request_guid_for_event_if_referring_transaction
|
133
|
-
state.request_token = nil
|
134
|
-
state.is_cross_app_caller = false
|
135
|
-
state.referring_transaction_info = ["another"]
|
136
120
|
in_transaction do
|
121
|
+
state.request_token = nil
|
122
|
+
state.is_cross_app_caller = false
|
123
|
+
state.referring_transaction_info = ["another"]
|
137
124
|
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
138
125
|
end
|
139
126
|
end
|
140
127
|
|
141
128
|
def test_request_guid_for_event_if_there_for_rum
|
142
129
|
with_config(:apdex_t => 2.0) do
|
143
|
-
state.request_token = "token"
|
144
|
-
state.is_cross_app_caller = false
|
145
130
|
in_transaction do
|
131
|
+
state.request_token = "token"
|
132
|
+
state.is_cross_app_caller = false
|
146
133
|
advance_time(10.0)
|
147
134
|
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
148
135
|
end
|
@@ -161,5 +148,54 @@ module NewRelic::Agent
|
|
161
148
|
assert_equal(false, state.is_cross_app_caller?)
|
162
149
|
assert_equal(false, state.is_cross_app_callee?)
|
163
150
|
end
|
151
|
+
|
152
|
+
def test_reset_forces_traced_method_stack_clear
|
153
|
+
state.traced_method_stack.push_frame(state, :reset_me)
|
154
|
+
state.reset
|
155
|
+
assert_empty state.traced_method_stack
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_reset_doesnt_touch_record_tt
|
159
|
+
state.record_tt = false
|
160
|
+
state.reset
|
161
|
+
refute state.record_tt
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_reset_doesnt_touch_record_sql
|
165
|
+
state.record_sql = false
|
166
|
+
state.reset
|
167
|
+
refute state.record_sql
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_reset_doesnt_touch_untraced_stack
|
171
|
+
state.push_traced(true)
|
172
|
+
state.reset
|
173
|
+
assert_equal [true], state.untraced
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_reset_touches_everything!
|
177
|
+
state.request = ::Rack::Request.new({})
|
178
|
+
state.is_cross_app_caller = true
|
179
|
+
state.client_cross_app_id = :client_cross_app_id
|
180
|
+
state.referring_transaction_info = :referring_transaction_info
|
181
|
+
state.request_token = :request_token
|
182
|
+
state.busy_entries = 1
|
183
|
+
state.sql_sampler_transaction_data = Object.new
|
184
|
+
state.transaction_sample_builder = Object.new
|
185
|
+
state.push_traced(true)
|
186
|
+
|
187
|
+
state.reset
|
188
|
+
|
189
|
+
# Anything in this list should be tested explicitly by itself!
|
190
|
+
skip_checking = [:@traced_method_stack, :@record_tt, :@record_sql,
|
191
|
+
:@untraced]
|
192
|
+
variables = state.instance_variables.map(&:to_sym) - skip_checking
|
193
|
+
|
194
|
+
variables.each do |ivar|
|
195
|
+
value = state.instance_variable_get(ivar)
|
196
|
+
assert [0, nil, false, []].include?(value),
|
197
|
+
"Expected #{ivar} to reset, but was #{value}"
|
198
|
+
end
|
199
|
+
end
|
164
200
|
end
|
165
201
|
end
|
@@ -18,7 +18,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def cleanup_transaction
|
21
|
-
NewRelic::Agent::TransactionState.
|
21
|
+
NewRelic::Agent::TransactionState.tl_clear_for_testing
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_request_parsing__none
|
@@ -139,9 +139,11 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
139
139
|
|
140
140
|
with_config(KEY_TRANSACTION_CONFIG, :do_not_cast => true) do
|
141
141
|
in_web_transaction('Controller/slow/txn') do
|
142
|
-
NewRelic::Agent::
|
143
|
-
|
144
|
-
|
142
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
143
|
+
txn = state.current_transaction
|
144
|
+
txn.record_apdex(state, t0 + 3.5)
|
145
|
+
txn.record_apdex(state, t0 + 5.5)
|
146
|
+
txn.record_apdex(state, t0 + 16.5)
|
145
147
|
end
|
146
148
|
|
147
149
|
# apdex_s is 2 because the transaction itself records apdex
|
@@ -157,9 +159,11 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
157
159
|
|
158
160
|
with_config(KEY_TRANSACTION_CONFIG, :do_not_cast => true) do
|
159
161
|
in_web_transaction('Controller/other/txn') do
|
160
|
-
NewRelic::Agent::
|
161
|
-
|
162
|
-
|
162
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
163
|
+
txn = state.current_transaction
|
164
|
+
txn.record_apdex(state, t0 + 0.5)
|
165
|
+
txn.record_apdex(state, t0 + 2)
|
166
|
+
txn.record_apdex(state, t0 + 5)
|
163
167
|
end
|
164
168
|
|
165
169
|
# apdex_s is 2 because the transaction itself records apdex
|
@@ -173,7 +177,9 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
173
177
|
def test_record_apdex_stores_apdex_t_in_min_and_max
|
174
178
|
with_config(:apdex_t => 2.5) do
|
175
179
|
in_web_transaction('Controller/some/txn') do
|
176
|
-
NewRelic::Agent::
|
180
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
181
|
+
txn = state.current_transaction
|
182
|
+
txn.record_apdex(state, Time.now)
|
177
183
|
end
|
178
184
|
end
|
179
185
|
|
@@ -184,6 +190,49 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
184
190
|
)
|
185
191
|
end
|
186
192
|
|
193
|
+
class SillyError < StandardError
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_apdex_success_with_ignored_error
|
197
|
+
filter = Proc.new do |error|
|
198
|
+
error.is_a?(SillyError) ? nil : error
|
199
|
+
end
|
200
|
+
|
201
|
+
with_ignore_error_filter(filter) do
|
202
|
+
txn_name = 'Controller/whatever'
|
203
|
+
in_web_transaction(txn_name) do
|
204
|
+
NewRelic::Agent::Transaction.notice_error(SillyError.new)
|
205
|
+
end
|
206
|
+
|
207
|
+
in_web_transaction(txn_name) do
|
208
|
+
NewRelic::Agent::Transaction.notice_error(RuntimeError.new)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
assert_metrics_recorded(
|
213
|
+
'Apdex' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 1 },
|
214
|
+
'Apdex/whatever' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 1 }
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_apdex_success_with_config_ignored_error
|
219
|
+
txn_name = 'Controller/whatever'
|
220
|
+
with_config(:'error_collector.ignore_errors' => SillyError.name) do
|
221
|
+
in_web_transaction(txn_name) do
|
222
|
+
NewRelic::Agent::Transaction.notice_error(SillyError.new)
|
223
|
+
end
|
224
|
+
|
225
|
+
in_web_transaction(txn_name) do
|
226
|
+
NewRelic::Agent::Transaction.notice_error(RuntimeError.new)
|
227
|
+
end
|
228
|
+
|
229
|
+
assert_metrics_recorded(
|
230
|
+
'Apdex' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 1 },
|
231
|
+
'Apdex/whatever' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 1 }
|
232
|
+
)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
187
236
|
def test_name_is_unset_if_nil
|
188
237
|
in_transaction do |txn|
|
189
238
|
txn.default_name = nil
|
@@ -209,7 +258,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
209
258
|
'replacement' => '*',
|
210
259
|
'replace_all' => true)
|
211
260
|
NewRelic::Agent.instance.transaction_rules << rule
|
212
|
-
NewRelic::Agent::Transaction.freeze_name_and_execute_if_not_ignored
|
261
|
+
NewRelic::Agent::Transaction.tl_current.freeze_name_and_execute_if_not_ignored
|
213
262
|
assert_equal 'Controller/foo/*/bar/*', txn.best_name
|
214
263
|
end
|
215
264
|
ensure
|
@@ -218,24 +267,22 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
218
267
|
end
|
219
268
|
|
220
269
|
def test_end_fires_a_transaction_finished_event
|
221
|
-
name, timestamp, duration
|
270
|
+
name, timestamp, duration = nil
|
222
271
|
NewRelic::Agent.subscribe(:transaction_finished) do |payload|
|
223
272
|
name = payload[:name]
|
224
273
|
timestamp = payload[:start_timestamp]
|
225
274
|
duration = payload[:duration]
|
226
|
-
type = payload[:type]
|
227
275
|
end
|
228
276
|
|
229
277
|
start_time = freeze_time
|
230
278
|
in_web_transaction('Controller/foo/1/bar/22') do
|
231
279
|
advance_time(5)
|
232
|
-
NewRelic::Agent::Transaction.freeze_name_and_execute_if_not_ignored
|
280
|
+
NewRelic::Agent::Transaction.tl_current.freeze_name_and_execute_if_not_ignored
|
233
281
|
end
|
234
282
|
|
235
283
|
assert_equal 'Controller/foo/1/bar/22', name
|
236
284
|
assert_equal start_time.to_f, timestamp
|
237
285
|
assert_equal 5.0, duration
|
238
|
-
assert_equal :controller, type
|
239
286
|
end
|
240
287
|
|
241
288
|
def test_end_fires_a_transaction_finished_event_with_overview_metrics
|
@@ -249,7 +296,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
249
296
|
NewRelic::Agent.record_metric("HttpDispatcher", 2.1)
|
250
297
|
end
|
251
298
|
|
252
|
-
assert_equal 2.1, options[
|
299
|
+
assert_equal 2.1, options['HttpDispatcher'].total_call_time
|
253
300
|
end
|
254
301
|
|
255
302
|
def test_end_fires_a_transaction_finished_event_with_custom_params
|
@@ -272,7 +319,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
272
319
|
end
|
273
320
|
|
274
321
|
in_transaction do
|
275
|
-
NewRelic::Agent::TransactionState.
|
322
|
+
NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = true
|
276
323
|
end
|
277
324
|
|
278
325
|
refute_empty guid
|
@@ -285,7 +332,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
285
332
|
end
|
286
333
|
|
287
334
|
in_transaction do
|
288
|
-
NewRelic::Agent::TransactionState.
|
335
|
+
NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = false
|
289
336
|
end
|
290
337
|
|
291
338
|
refute found_guid
|
@@ -298,7 +345,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
298
345
|
end
|
299
346
|
|
300
347
|
in_transaction do
|
301
|
-
NewRelic::Agent::TransactionState.
|
348
|
+
NewRelic::Agent::TransactionState.tl_get.referring_transaction_info = ["GUID"]
|
302
349
|
end
|
303
350
|
|
304
351
|
assert_equal "GUID", referring_guid
|
@@ -312,7 +359,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
312
359
|
|
313
360
|
in_transaction do
|
314
361
|
# Make sure we don't have referring transaction state floating around
|
315
|
-
NewRelic::Agent::TransactionState.
|
362
|
+
NewRelic::Agent::TransactionState.tl_get.referring_transaction_info = nil
|
316
363
|
end
|
317
364
|
|
318
365
|
refute found_referring_guid
|
@@ -326,26 +373,25 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
326
373
|
end
|
327
374
|
|
328
375
|
def test_user_attributes_alias_to_custom_parameters
|
329
|
-
in_transaction('user_attributes') do
|
330
|
-
txn = NewRelic::Agent::Transaction.current
|
376
|
+
in_transaction('user_attributes') do |txn|
|
331
377
|
txn.set_user_attributes(:set_instance => :set_instance)
|
332
378
|
txn.user_attributes[:indexer_instance] = :indexer_instance
|
333
379
|
|
334
|
-
|
335
|
-
|
380
|
+
txn.set_user_attributes(:set_class => :set_class)
|
381
|
+
txn.user_attributes[:indexer_class] = :indexer_class
|
336
382
|
|
337
|
-
assert_has_custom_parameter(:set_instance)
|
338
|
-
assert_has_custom_parameter(:indexer_instance)
|
383
|
+
assert_has_custom_parameter(txn, :set_instance)
|
384
|
+
assert_has_custom_parameter(txn, :indexer_instance)
|
339
385
|
|
340
|
-
assert_has_custom_parameter(:set_class)
|
341
|
-
assert_has_custom_parameter(:indexer_class)
|
386
|
+
assert_has_custom_parameter(txn, :set_class)
|
387
|
+
assert_has_custom_parameter(txn, :indexer_class)
|
342
388
|
end
|
343
389
|
end
|
344
390
|
|
345
391
|
def test_notice_error_in_current_transaction_saves_it_for_finishing
|
346
|
-
in_transaction('failing') do
|
392
|
+
in_transaction('failing') do |txn|
|
347
393
|
NewRelic::Agent::Transaction.notice_error("")
|
348
|
-
assert_equal 1,
|
394
|
+
assert_equal 1, txn.exceptions.count
|
349
395
|
end
|
350
396
|
end
|
351
397
|
|
@@ -357,39 +403,6 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
357
403
|
assert_equal 1, NewRelic::Agent.instance.error_collector.errors.count
|
358
404
|
end
|
359
405
|
|
360
|
-
def test_notice_error_after_current_transaction_gets_custom_params
|
361
|
-
in_transaction('failing') do
|
362
|
-
NewRelic::Agent.add_custom_parameters(:custom => "parameter")
|
363
|
-
end
|
364
|
-
NewRelic::Agent::Transaction.notice_error("")
|
365
|
-
|
366
|
-
error = NewRelic::Agent.instance.error_collector.errors.first
|
367
|
-
assert_equal({ :custom => "parameter" }, error.params[:custom_params])
|
368
|
-
end
|
369
|
-
|
370
|
-
def test_notice_error_after_current_transcation_doesnt_tromp_passed_params
|
371
|
-
in_transaction('failing') do
|
372
|
-
NewRelic::Agent.add_custom_parameters(:custom => "parameter")
|
373
|
-
end
|
374
|
-
NewRelic::Agent::Transaction.notice_error("", :custom_params => { :passing => true })
|
375
|
-
|
376
|
-
error = NewRelic::Agent.instance.error_collector.errors.first
|
377
|
-
expected = {
|
378
|
-
:custom => "parameter",
|
379
|
-
:passing => true,
|
380
|
-
}
|
381
|
-
assert_equal(expected, error.params[:custom_params])
|
382
|
-
end
|
383
|
-
|
384
|
-
def test_notice_error_after_current_transaction_gets_name
|
385
|
-
in_transaction('failing') do
|
386
|
-
#no-op
|
387
|
-
end
|
388
|
-
NewRelic::Agent::Transaction.notice_error("")
|
389
|
-
error = NewRelic::Agent.instance.error_collector.errors.first
|
390
|
-
assert_equal 'failing', error.path
|
391
|
-
end
|
392
|
-
|
393
406
|
def test_notice_error_without_transaction_notifies_error_collector
|
394
407
|
cleanup_transaction
|
395
408
|
NewRelic::Agent::Transaction.notice_error("")
|
@@ -401,9 +414,9 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
401
414
|
gc_end = mock('gc end')
|
402
415
|
NewRelic::Agent::StatsEngine::GCProfiler.stubs(:take_snapshot).returns(gc_start, gc_end)
|
403
416
|
|
404
|
-
txn = in_transaction do
|
417
|
+
txn = in_transaction do |transaction|
|
405
418
|
NewRelic::Agent::StatsEngine::GCProfiler.expects(:record_delta).with(gc_start, gc_end).returns(42)
|
406
|
-
|
419
|
+
transaction
|
407
420
|
end
|
408
421
|
|
409
422
|
trace = txn.transaction_trace
|
@@ -413,9 +426,9 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
413
426
|
def test_freeze_name_and_execute_if_not_ignored_executes_given_block_if_not_ignored
|
414
427
|
NewRelic::Agent.instance.transaction_rules.expects(:rename).
|
415
428
|
returns('non-ignored-transaction')
|
416
|
-
in_transaction('non-ignored-transaction') do
|
429
|
+
in_transaction('non-ignored-transaction') do |txn|
|
417
430
|
block_was_called = false
|
418
|
-
|
431
|
+
txn.freeze_name_and_execute_if_not_ignored do
|
419
432
|
block_was_called = true
|
420
433
|
end
|
421
434
|
|
@@ -426,9 +439,9 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
426
439
|
def test_freeze_name_and_execute_if_not_ignored_ignores_given_block_if_transaction_ignored
|
427
440
|
NewRelic::Agent.instance.transaction_rules.expects(:rename).
|
428
441
|
returns(nil)
|
429
|
-
in_transaction('ignored-transaction') do
|
442
|
+
in_transaction('ignored-transaction') do |txn|
|
430
443
|
block_was_called = false
|
431
|
-
|
444
|
+
txn.freeze_name_and_execute_if_not_ignored do
|
432
445
|
block_was_called = true
|
433
446
|
end
|
434
447
|
|
@@ -438,18 +451,20 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
438
451
|
|
439
452
|
def test_record_transaction_cpu_positive
|
440
453
|
in_transaction do |txn|
|
454
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
441
455
|
txn.expects(:cpu_burn).twice.returns(1.0)
|
442
|
-
NewRelic::Agent.instance.transaction_sampler.expects(:notice_transaction_cpu_time).twice.with(1.0)
|
443
|
-
txn.record_transaction_cpu
|
456
|
+
NewRelic::Agent.instance.transaction_sampler.expects(:notice_transaction_cpu_time).twice.with(state, 1.0)
|
457
|
+
txn.record_transaction_cpu(state)
|
444
458
|
end
|
445
459
|
end
|
446
460
|
|
447
461
|
def test_record_transaction_cpu_negative
|
448
462
|
in_transaction do |txn|
|
463
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
449
464
|
txn.expects(:cpu_burn).twice.returns(nil)
|
450
465
|
# should not be called for the nil case
|
451
466
|
NewRelic::Agent.instance.transaction_sampler.expects(:notice_transaction_cpu_time).never
|
452
|
-
txn.record_transaction_cpu
|
467
|
+
txn.record_transaction_cpu(state)
|
453
468
|
end
|
454
469
|
end
|
455
470
|
|
@@ -493,18 +508,18 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
493
508
|
end
|
494
509
|
end
|
495
510
|
|
496
|
-
def
|
497
|
-
in_transaction('Controller/parent', :
|
498
|
-
in_transaction('Controller/child', :
|
511
|
+
def test_transaction_takes_child_name_if_similar_category
|
512
|
+
in_transaction('Controller/parent', :category => :sinatra) do
|
513
|
+
in_transaction('Controller/child', :category => :controller) do
|
499
514
|
end
|
500
515
|
end
|
501
516
|
|
502
517
|
assert_metrics_recorded(['Controller/child'])
|
503
518
|
end
|
504
519
|
|
505
|
-
def
|
506
|
-
in_transaction('Controller/parent', :
|
507
|
-
in_transaction('Whatever/child', :
|
520
|
+
def test_transaction_doesnt_take_child_name_if_different_category
|
521
|
+
in_transaction('Controller/parent', :category => :sinatra) do
|
522
|
+
in_transaction('Whatever/child', :category => :task) do
|
508
523
|
end
|
509
524
|
end
|
510
525
|
|
@@ -512,8 +527,8 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
512
527
|
end
|
513
528
|
|
514
529
|
def test_transaction_should_take_child_name_if_frozen_early
|
515
|
-
in_transaction('Controller/parent', :
|
516
|
-
in_transaction('Controller/child', :
|
530
|
+
in_transaction('Controller/parent', :category => :sinatra) do
|
531
|
+
in_transaction('Controller/child', :category => :controller) do |txn|
|
517
532
|
txn.freeze_name_and_execute_if_not_ignored
|
518
533
|
end
|
519
534
|
end
|
@@ -521,8 +536,111 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
521
536
|
assert_metrics_recorded(['Controller/child'])
|
522
537
|
end
|
523
538
|
|
524
|
-
def
|
525
|
-
|
539
|
+
def test_ignored_returns_false_if_a_transaction_is_not_ignored
|
540
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
541
|
+
refute txn.ignore?
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_ignored_returns_true_for_an_ignored_transaction
|
546
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
547
|
+
txn.ignore!
|
548
|
+
assert txn.ignore?
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
def test_ignore_apdex_returns_true_if_apdex_is_ignored
|
553
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
554
|
+
txn.ignore_apdex!
|
555
|
+
assert txn.ignore_apdex?
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
def test_ignore_apdex_returns_false_if_apdex_is_not_ignored
|
560
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
561
|
+
refute txn.ignore_apdex?
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
def test_ignore_enduser_returns_true_if_enduser_is_ignored
|
566
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
567
|
+
txn.ignore_enduser!
|
568
|
+
assert txn.ignore_enduser?
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_ignore_enduser_returns_false_if_enduser_is_not_ignored
|
573
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
574
|
+
refute txn.ignore_enduser?
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
def test_ignored_transactions_do_not_record_metrics
|
579
|
+
in_transaction('Controller/test', :category => :sinatra) do |txn|
|
580
|
+
txn.ignore!
|
581
|
+
end
|
582
|
+
|
583
|
+
assert_metrics_not_recorded(['Controller/test'])
|
584
|
+
end
|
585
|
+
|
586
|
+
def test_nested_transactions_are_ignored_if_nested_transaction_is_ignored
|
587
|
+
in_transaction('Controller/parent', :category => :sinatra) do
|
588
|
+
in_transaction('Controller/child', :category => :controller) do |txn|
|
589
|
+
txn.ignore!
|
590
|
+
end
|
591
|
+
end
|
592
|
+
|
593
|
+
assert_metrics_not_recorded(['Controller/sinatra', 'Controller/child'])
|
594
|
+
end
|
595
|
+
|
596
|
+
def test_nested_transactions_are_ignored_if_double_nested_transaction_is_ignored
|
597
|
+
in_transaction('Controller/parent', :category => :sinatra) do
|
598
|
+
in_transaction('Controller/toddler', :category => :controller) do
|
599
|
+
in_transaction('Controller/infant', :category => :controller) do |txn|
|
600
|
+
txn.ignore!
|
601
|
+
end
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
assert_metrics_not_recorded(['Controller/sinatra', 'Controller/toddler', 'Controller/infant'])
|
606
|
+
end
|
607
|
+
|
608
|
+
def test_failure_during_ignore_error_filter_doesnt_prevent_transaction
|
609
|
+
filter = Proc.new do |*_|
|
610
|
+
raise "HAHAHAHAH, error in the filter for ignoring errors!"
|
611
|
+
end
|
612
|
+
|
613
|
+
with_ignore_error_filter(filter) do
|
614
|
+
expects_logging(:error, includes("HAHAHAHAH"), any_parameters)
|
615
|
+
|
616
|
+
in_transaction("Controller/boom") do
|
617
|
+
NewRelic::Agent::Transaction.notice_error(SillyError.new)
|
618
|
+
end
|
619
|
+
|
620
|
+
assert_metrics_recorded('Controller/boom')
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
def test_multiple_similar_errors_in_transaction_do_not_crash
|
625
|
+
error_class = Class.new(StandardError) do
|
626
|
+
def ==(other)
|
627
|
+
self.message == other.message
|
628
|
+
end
|
629
|
+
end
|
630
|
+
|
631
|
+
in_transaction do |txn|
|
632
|
+
e0 = error_class.new('err')
|
633
|
+
e1 = error_class.new('err')
|
634
|
+
assert_equal(e0, e1)
|
635
|
+
txn.notice_error(e0)
|
636
|
+
txn.notice_error(e1)
|
637
|
+
end
|
638
|
+
|
639
|
+
assert_metrics_recorded('Errors/all' => { :call_count => 2 })
|
640
|
+
end
|
641
|
+
|
642
|
+
def assert_has_custom_parameter(txn, key, value = key)
|
643
|
+
assert_equal(value, txn.custom_parameters[key])
|
526
644
|
end
|
527
645
|
|
528
646
|
end
|