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
@@ -28,34 +28,34 @@ class NewRelic::Agent::RpmAgentTest < Minitest::Test
|
|
28
28
|
end
|
29
29
|
|
30
30
|
ignore_called = false
|
31
|
-
|
31
|
+
filter = Proc.new do |e|
|
32
32
|
ignore_called = true
|
33
33
|
nil
|
34
34
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
NewRelic::Agent.instance.error_collector.instance_variable_set(:@ignore_filter, nil)
|
35
|
+
with_ignore_error_filter(filter) do
|
36
|
+
NewRelic::Agent.notice_error(StandardError.new("message"), :request_params => {:x => "y"})
|
37
|
+
end
|
39
38
|
|
40
39
|
assert(ignore_called)
|
41
40
|
end
|
42
41
|
|
43
|
-
def
|
42
|
+
def test_startup_shutdown_shim
|
44
43
|
with_config(:agent_enabled => true) do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
shim_agent = NewRelic::Agent::ShimAgent.instance
|
45
|
+
shim_agent.shutdown
|
46
|
+
refute shim_agent.started?
|
47
|
+
shim_agent.start
|
48
|
+
refute shim_agent.started?
|
49
|
+
end
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
+
def test_startup_shutdown_real
|
53
|
+
with_config(:agent_enabled => true, :monitor_mode => true) do
|
52
54
|
NewRelic::Agent.manual_start :monitor_mode => true, :license_key => ('x' * 40)
|
53
|
-
|
54
|
-
assert
|
55
|
-
|
56
|
-
|
57
|
-
assert !@agent.started?
|
58
|
-
NewRelic::Agent.shutdown
|
55
|
+
agent = NewRelic::Agent.instance
|
56
|
+
assert agent.started?
|
57
|
+
agent.shutdown
|
58
|
+
refute agent.started?
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -89,15 +89,15 @@ class NewRelic::Agent::RpmAgentTest < Minitest::Test
|
|
89
89
|
|
90
90
|
def test_set_record_sql
|
91
91
|
@agent.set_record_sql(false)
|
92
|
-
assert !NewRelic::Agent.
|
92
|
+
assert !NewRelic::Agent.tl_is_sql_recorded?
|
93
93
|
NewRelic::Agent.disable_sql_recording do
|
94
|
-
assert_equal false, NewRelic::Agent.
|
94
|
+
assert_equal false, NewRelic::Agent.tl_is_sql_recorded?
|
95
95
|
NewRelic::Agent.disable_sql_recording do
|
96
|
-
assert_equal false, NewRelic::Agent.
|
96
|
+
assert_equal false, NewRelic::Agent.tl_is_sql_recorded?
|
97
97
|
end
|
98
|
-
assert_equal false, NewRelic::Agent.
|
98
|
+
assert_equal false, NewRelic::Agent.tl_is_sql_recorded?
|
99
99
|
end
|
100
|
-
assert !NewRelic::Agent.
|
100
|
+
assert !NewRelic::Agent.tl_is_sql_recorded?
|
101
101
|
@agent.set_record_sql(nil)
|
102
102
|
end
|
103
103
|
|
@@ -105,12 +105,6 @@ class NewRelic::Agent::RpmAgentTest < Minitest::Test
|
|
105
105
|
assert_match /\d\.\d+\.\d+/, NewRelic::VERSION::STRING
|
106
106
|
end
|
107
107
|
|
108
|
-
def test_record_transaction_should_reject_empty_arguments
|
109
|
-
assert_raises RuntimeError do
|
110
|
-
NewRelic::Agent.record_transaction 0.5
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
108
|
def test_record_transaction
|
115
109
|
NewRelic::Agent.record_transaction 0.5, 'uri' => "/users/create?foo=bar"
|
116
110
|
end
|
@@ -10,11 +10,17 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
10
10
|
agent = NewRelic::Agent.instance
|
11
11
|
stats_engine = NewRelic::Agent::StatsEngine.new
|
12
12
|
agent.stubs(:stats_engine).returns(stats_engine)
|
13
|
+
@state = NewRelic::Agent::TransactionState.tl_get
|
14
|
+
@state.reset
|
13
15
|
@sampler = NewRelic::Agent::SqlSampler.new
|
14
16
|
@connection = stub('ActiveRecord connection', :execute => 'result')
|
15
17
|
NewRelic::Agent::Database.stubs(:get_connection).returns(@connection)
|
16
18
|
end
|
17
19
|
|
20
|
+
def teardown
|
21
|
+
@state.reset
|
22
|
+
end
|
23
|
+
|
18
24
|
# Helpers for DataContainerTests
|
19
25
|
|
20
26
|
def create_container
|
@@ -23,9 +29,9 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
23
29
|
|
24
30
|
def populate_container(sampler, n)
|
25
31
|
n.times do |i|
|
26
|
-
sampler.on_start_transaction nil
|
27
|
-
sampler.notice_sql("SELECT * FROM test#{i}", "Database/test/select", nil, 1)
|
28
|
-
sampler.on_finishing_transaction('txn')
|
32
|
+
sampler.on_start_transaction(@state, nil)
|
33
|
+
sampler.notice_sql("SELECT * FROM test#{i}", "Database/test/select", nil, 1, @state)
|
34
|
+
sampler.on_finishing_transaction(@state, 'txn')
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
@@ -34,38 +40,40 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
34
40
|
# Tests
|
35
41
|
|
36
42
|
def test_on_start_transaction
|
37
|
-
assert_nil @sampler.
|
38
|
-
@sampler.on_start_transaction nil
|
39
|
-
refute_nil @sampler.
|
40
|
-
@sampler.on_finishing_transaction('txn')
|
41
|
-
|
43
|
+
assert_nil @sampler.tl_transaction_data
|
44
|
+
@sampler.on_start_transaction(@state, nil)
|
45
|
+
refute_nil @sampler.tl_transaction_data
|
46
|
+
@sampler.on_finishing_transaction(@state, 'txn')
|
47
|
+
|
48
|
+
# Transaction clearing cleans this @state for us--we don't do it ourselves
|
49
|
+
refute_nil @sampler.tl_transaction_data
|
42
50
|
end
|
43
51
|
|
44
52
|
def test_notice_sql_no_transaction
|
45
|
-
assert_nil @sampler.
|
46
|
-
@sampler.notice_sql
|
53
|
+
assert_nil @sampler.tl_transaction_data
|
54
|
+
@sampler.notice_sql("select * from test", "Database/test/select", nil, 10, @state)
|
47
55
|
end
|
48
56
|
|
49
57
|
def test_notice_sql
|
50
|
-
@sampler.on_start_transaction nil
|
51
|
-
@sampler.notice_sql
|
52
|
-
@sampler.notice_sql
|
58
|
+
@sampler.on_start_transaction(@state, nil)
|
59
|
+
@sampler.notice_sql("select * from test", "Database/test/select", nil, 1.5, @state)
|
60
|
+
@sampler.notice_sql("select * from test2", "Database/test2/select", nil, 1.3, @state)
|
53
61
|
# this sql will not be captured
|
54
|
-
@sampler.notice_sql
|
55
|
-
refute_nil @sampler.
|
56
|
-
assert_equal 2, @sampler.
|
62
|
+
@sampler.notice_sql("select * from test", "Database/test/select", nil, 0, @state)
|
63
|
+
refute_nil @sampler.tl_transaction_data
|
64
|
+
assert_equal 2, @sampler.tl_transaction_data.sql_data.size
|
57
65
|
end
|
58
66
|
|
59
67
|
def test_notice_sql_truncates_query
|
60
|
-
@sampler.on_start_transaction nil
|
68
|
+
@sampler.on_start_transaction(@state, nil)
|
61
69
|
message = 'a' * 17_000
|
62
|
-
@sampler.notice_sql(message, "Database/test/select", nil, 1.5)
|
63
|
-
assert_equal('a' * 16_381 + '...', @sampler.
|
70
|
+
@sampler.notice_sql(message, "Database/test/select", nil, 1.5, @state)
|
71
|
+
assert_equal('a' * 16_381 + '...', @sampler.tl_transaction_data.sql_data[0].sql)
|
64
72
|
end
|
65
73
|
|
66
74
|
def test_harvest_slow_sql
|
67
75
|
data = NewRelic::Agent::TransactionSqlData.new
|
68
|
-
data.set_transaction_info("/c/a",
|
76
|
+
data.set_transaction_info("/c/a", 'guid')
|
69
77
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
70
78
|
data.sql_data.concat [
|
71
79
|
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
|
@@ -94,7 +102,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
94
102
|
|
95
103
|
def test_harvest
|
96
104
|
data = NewRelic::Agent::TransactionSqlData.new
|
97
|
-
data.set_transaction_info("/c/a",
|
105
|
+
data.set_transaction_info("/c/a", 'guid')
|
98
106
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
99
107
|
data.sql_data.concat [NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
|
100
108
|
NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.2),
|
@@ -107,7 +115,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
107
115
|
|
108
116
|
def test_harvest_should_not_take_more_than_10
|
109
117
|
data = NewRelic::Agent::TransactionSqlData.new
|
110
|
-
data.set_transaction_info("/c/a",
|
118
|
+
data.set_transaction_info("/c/a", 'guid')
|
111
119
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
112
120
|
15.times do |i|
|
113
121
|
data.sql_data << NewRelic::Agent::SlowSql.new("select * from test#{(i+97).chr}",
|
@@ -123,7 +131,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
123
131
|
|
124
132
|
def test_harvest_should_aggregate_similar_queries
|
125
133
|
data = NewRelic::Agent::TransactionSqlData.new
|
126
|
-
data.set_transaction_info("/c/a",
|
134
|
+
data.set_transaction_info("/c/a", 'guid')
|
127
135
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
128
136
|
queries = [
|
129
137
|
NewRelic::Agent::SlowSql.new("select * from test where foo in (1, 2) ", "Database/test/select", {}, 1.5),
|
@@ -144,7 +152,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
144
152
|
.returns(dummy_mysql_explain_result({"header0" => 'bar0', "header1" => 'bar1', "header2" => 'bar2'}))
|
145
153
|
|
146
154
|
data = NewRelic::Agent::TransactionSqlData.new
|
147
|
-
data.set_transaction_info("/c/a",
|
155
|
+
data.set_transaction_info("/c/a", 'guid')
|
148
156
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
149
157
|
explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
|
150
158
|
config = { :adapter => 'mysql' }
|
@@ -174,17 +182,17 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
174
182
|
|
175
183
|
def test_sql_trace_should_include_transaction_guid
|
176
184
|
txn_sampler = NewRelic::Agent::TransactionSampler.new
|
177
|
-
txn_sampler.start_builder(Time.now)
|
178
|
-
@sampler.on_start_transaction(Time.now, 'a uri'
|
185
|
+
txn_sampler.start_builder(@state, Time.now)
|
186
|
+
@sampler.on_start_transaction(@state, Time.now, 'a uri')
|
179
187
|
|
180
|
-
assert_equal(NewRelic::Agent.instance.transaction_sampler.
|
181
|
-
NewRelic::Agent.instance.sql_sampler.
|
188
|
+
assert_equal(NewRelic::Agent.instance.transaction_sampler.tl_builder.sample.guid,
|
189
|
+
NewRelic::Agent.instance.sql_sampler.tl_transaction_data.guid)
|
182
190
|
end
|
183
191
|
|
184
192
|
def test_should_not_collect_explain_plans_when_disabled
|
185
193
|
with_config(:'transaction_tracer.explain_enabled' => false) do
|
186
194
|
data = NewRelic::Agent::TransactionSqlData.new
|
187
|
-
data.set_transaction_info("/c/a",
|
195
|
+
data.set_transaction_info("/c/a", 'guid')
|
188
196
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
189
197
|
queries = [
|
190
198
|
NewRelic::Agent::SlowSql.new("select * from test",
|
@@ -210,7 +218,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
210
218
|
def test_sends_obfuscated_queries_when_configured
|
211
219
|
with_config(:'transaction_tracer.record_sql' => 'obfuscated') do
|
212
220
|
data = NewRelic::Agent::TransactionSqlData.new
|
213
|
-
data.set_transaction_info("/c/a",
|
221
|
+
data.set_transaction_info("/c/a", 'guid')
|
214
222
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
215
223
|
data.sql_data.concat([NewRelic::Agent::SlowSql.new("select * from test where foo = 'bar'",
|
216
224
|
"Database/test/select", {}, 1.5),
|
@@ -241,7 +249,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
241
249
|
def test_to_collector_array
|
242
250
|
with_config(:'transaction_tracer.explain_enabled' => false) do
|
243
251
|
data = NewRelic::Agent::TransactionSqlData.new
|
244
|
-
data.set_transaction_info("/c/a",
|
252
|
+
data.set_transaction_info("/c/a", 'guid')
|
245
253
|
data.set_transaction_name("WebTransaction/Controller/c/a")
|
246
254
|
data.sql_data.concat([NewRelic::Agent::SlowSql.new("select * from test",
|
247
255
|
"Database/test/select",
|
@@ -18,6 +18,191 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
18
18
|
super
|
19
19
|
end
|
20
20
|
|
21
|
+
def test_record_unscoped_metrics_records_to_transaction_stats_if_in_txn
|
22
|
+
in_transaction do
|
23
|
+
@engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
|
24
|
+
|
25
|
+
# txn is still active, so metrics should not be merged into global
|
26
|
+
# stats hash yet
|
27
|
+
assert_metrics_not_recorded(['a', 'b'])
|
28
|
+
end
|
29
|
+
|
30
|
+
expected = {
|
31
|
+
:call_count => 1,
|
32
|
+
:total_call_time => 20,
|
33
|
+
:total_exclusive_time => 10
|
34
|
+
}
|
35
|
+
assert_metrics_recorded(
|
36
|
+
'a' => expected,
|
37
|
+
'b' => expected
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_record_unscoped_metrics_records_to_global_metrics_if_no_txn
|
42
|
+
@engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
|
43
|
+
expected = {
|
44
|
+
:call_count => 1,
|
45
|
+
:total_call_time => 20,
|
46
|
+
:total_exclusive_time => 10
|
47
|
+
}
|
48
|
+
assert_metrics_recorded(
|
49
|
+
'a' => expected,
|
50
|
+
'b' => expected
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_record_unscoped_metrics_takes_single_metric_name
|
55
|
+
@engine.tl_record_unscoped_metrics('a', 20)
|
56
|
+
assert_metrics_recorded(
|
57
|
+
'a' => {
|
58
|
+
:call_count => 1,
|
59
|
+
:total_call_time => 20,
|
60
|
+
:total_exclusive_time => 20
|
61
|
+
}
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_record_unscoped_metrics_takes_block_in_txn
|
66
|
+
in_transaction('txn') do
|
67
|
+
@engine.tl_record_unscoped_metrics('a') do |stat|
|
68
|
+
stat.total_call_time = 42
|
69
|
+
stat.call_count = 99
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
expected = { :total_call_time => 42, :call_count => 99 }
|
74
|
+
assert_metrics_recorded('a' => expected)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_record_unscoped_metrics_takes_block_outside_txn
|
78
|
+
@engine.tl_record_unscoped_metrics('a') do |stat|
|
79
|
+
stat.total_call_time = 42
|
80
|
+
stat.call_count = 99
|
81
|
+
end
|
82
|
+
|
83
|
+
expected = { :total_call_time => 42, :call_count => 99 }
|
84
|
+
assert_metrics_recorded('a' => expected)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_record_unscoped_metrics_is_thread_safe
|
88
|
+
threads = []
|
89
|
+
nthreads = 25
|
90
|
+
iterations = 100
|
91
|
+
|
92
|
+
nthreads.times do |tid|
|
93
|
+
threads << Thread.new do
|
94
|
+
iterations.times do
|
95
|
+
@engine.tl_record_unscoped_metrics('m1', 1)
|
96
|
+
@engine.tl_record_unscoped_metrics('m2', 1)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
threads.each { |t| t.join }
|
101
|
+
|
102
|
+
assert_metrics_recorded(
|
103
|
+
'm1' => { :call_count => nthreads * iterations },
|
104
|
+
'm2' => { :call_count => nthreads * iterations }
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_record_scoped_and_unscoped_metrics_records_scoped_and_unscoped
|
109
|
+
in_transaction('txn') do
|
110
|
+
@engine.tl_record_scoped_and_unscoped_metrics('a', nil, 20, 10)
|
111
|
+
assert_metrics_not_recorded('a')
|
112
|
+
end
|
113
|
+
|
114
|
+
expected = {
|
115
|
+
:call_count => 1,
|
116
|
+
:total_call_time => 20,
|
117
|
+
:total_exclusive_time => 10
|
118
|
+
}
|
119
|
+
assert_metrics_recorded(
|
120
|
+
'a' => expected,
|
121
|
+
['a', 'txn'] => expected
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_record_scoped_and_unscoped_metrics_takes_block
|
126
|
+
in_transaction('txn') do
|
127
|
+
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b']) do |stat|
|
128
|
+
stat.total_call_time = 42
|
129
|
+
stat.call_count = 99
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
expected = { :total_call_time => 42, :call_count => 99 }
|
134
|
+
assert_metrics_recorded(
|
135
|
+
'a' => expected,
|
136
|
+
['a', 'txn'] => expected,
|
137
|
+
'b' => expected
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_record_scoped_and_unscoped_metrics_records_multiple_unscoped_metrics
|
142
|
+
in_transaction('txn') do
|
143
|
+
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b', 'c'], 20, 10)
|
144
|
+
assert_metrics_not_recorded(['a', 'b', 'c'])
|
145
|
+
end
|
146
|
+
|
147
|
+
expected = {
|
148
|
+
:call_count => 1,
|
149
|
+
:total_call_time => 20,
|
150
|
+
:total_exclusive_time => 10
|
151
|
+
}
|
152
|
+
assert_metrics_recorded(
|
153
|
+
'a' => expected,
|
154
|
+
['a', 'txn'] => expected,
|
155
|
+
'b' => expected,
|
156
|
+
'c' => expected
|
157
|
+
)
|
158
|
+
assert_metrics_not_recorded([
|
159
|
+
['b', 'txn'],
|
160
|
+
['c', 'txn']
|
161
|
+
])
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_record_scoped_and_unscoped_metrics_is_thread_safe
|
165
|
+
threads = []
|
166
|
+
nthreads = 25
|
167
|
+
iterations = 100
|
168
|
+
|
169
|
+
nthreads.times do |tid|
|
170
|
+
threads << Thread.new do
|
171
|
+
iterations.times do
|
172
|
+
in_transaction('txn') do
|
173
|
+
@engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
|
174
|
+
@engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
threads.each { |t| t.join }
|
180
|
+
|
181
|
+
expected = { :call_count => nthreads * iterations }
|
182
|
+
assert_metrics_recorded(
|
183
|
+
'm1' => expected,
|
184
|
+
'm2' => expected,
|
185
|
+
['m1', 'txn'] => expected,
|
186
|
+
['m2', 'txn'] => expected,
|
187
|
+
'm3' => expected,
|
188
|
+
'm4' => expected
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_record_scoped_and_unscoped_metrics_records_unscoped_if_not_in_txn
|
193
|
+
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b'], 20, 10)
|
194
|
+
|
195
|
+
expected = {
|
196
|
+
:call_count => 1,
|
197
|
+
:total_call_time => 20,
|
198
|
+
:total_exclusive_time => 10
|
199
|
+
}
|
200
|
+
assert_metrics_recorded_exclusive(
|
201
|
+
'a' => expected,
|
202
|
+
'b' => expected
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
21
206
|
def test_get_no_scope
|
22
207
|
s1 = @engine.get_stats "a"
|
23
208
|
s2 = @engine.get_stats "a"
|
@@ -142,130 +327,17 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
142
327
|
assert_equal(t0, result.harvested_at)
|
143
328
|
end
|
144
329
|
|
145
|
-
def
|
330
|
+
def test_record_unscoped_metrics_unscoped_metrics_only
|
146
331
|
in_transaction('scopey') do
|
147
|
-
@engine.
|
332
|
+
@engine.tl_record_unscoped_metrics('foo', 42)
|
148
333
|
end
|
149
334
|
assert_metrics_recorded('foo' => { :call_count => 1, :total_call_time => 42 })
|
150
335
|
assert_metrics_not_recorded([['foo', 'scopey']])
|
151
336
|
end
|
152
337
|
|
153
|
-
def test_record_metrics_records_to_scoped_metric_if_requested
|
154
|
-
in_transaction('scopey') do
|
155
|
-
@engine.record_metrics('foo', 42, :scoped => true)
|
156
|
-
end
|
157
|
-
unscoped_stats = @engine.get_stats('foo', false)
|
158
|
-
scoped_stats = @engine.get_stats('foo', true, true, 'scopey')
|
159
|
-
assert_equal(1, unscoped_stats.call_count, 'missing unscoped metric')
|
160
|
-
assert_equal(1, scoped_stats.call_count, 'missing scoped metric')
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_record_metrics_elides_scoped_metric_if_not_in_transaction
|
164
|
-
@engine.clear_stats
|
165
|
-
@engine.record_metrics('foo', 42, :scoped => true)
|
166
|
-
unscoped_stats = @engine.get_stats('foo', false)
|
167
|
-
assert_equal(1, unscoped_stats.call_count)
|
168
|
-
assert_equal(1, @engine.metrics.size)
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_record_metrics_accepts_block
|
172
|
-
@engine.record_metrics('foo') do |stats|
|
173
|
-
stats.call_count = 999
|
174
|
-
end
|
175
|
-
stats = @engine.get_stats_no_scope('foo')
|
176
|
-
assert_equal(999, stats.call_count)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_record_metrics_is_thread_safe
|
180
|
-
threads = []
|
181
|
-
nthreads = 25
|
182
|
-
iterations = 100
|
183
|
-
nthreads.times do |tid|
|
184
|
-
threads << Thread.new do
|
185
|
-
iterations.times do
|
186
|
-
@engine.record_metrics('m1', 1)
|
187
|
-
@engine.record_metrics('m2', 1)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
threads.each { |t| t.join }
|
192
|
-
|
193
|
-
stats_m1 = @engine.get_stats_no_scope('m1')
|
194
|
-
stats_m2 = @engine.get_stats_no_scope('m2')
|
195
|
-
assert_equal(nthreads * iterations, stats_m1.call_count)
|
196
|
-
assert_equal(nthreads * iterations, stats_m2.call_count)
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_record_metrics_internal_writes_to_global_stats_hash_if_no_txn
|
200
|
-
specs = [
|
201
|
-
NewRelic::MetricSpec.new('foo'),
|
202
|
-
NewRelic::MetricSpec.new('foo', 'scope')
|
203
|
-
]
|
204
|
-
|
205
|
-
2.times { @engine.record_metrics_internal(specs, 10, 5) }
|
206
|
-
|
207
|
-
expected = { :call_count => 2, :total_call_time => 20, :total_exclusive_time => 10 }
|
208
|
-
assert_metrics_recorded('foo' => expected, ['foo', 'scope'] => expected)
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_record_metrics_internal_writes_to_transaction_stats_hash_if_txn
|
212
|
-
specs = [
|
213
|
-
NewRelic::MetricSpec.new('foo'),
|
214
|
-
NewRelic::MetricSpec.new('foo', 'scope')
|
215
|
-
]
|
216
|
-
|
217
|
-
in_transaction do
|
218
|
-
2.times { @engine.record_metrics_internal(specs, 10, 5) }
|
219
|
-
# still in the txn, so metrics should not be visible in the global stats
|
220
|
-
# hash yet
|
221
|
-
assert_metrics_not_recorded(['foo', ['foo, scope']])
|
222
|
-
end
|
223
|
-
|
224
|
-
expected = { :call_count => 2, :total_call_time => 20, :total_exclusive_time => 10 }
|
225
|
-
assert_metrics_recorded('foo' => expected, ['foo', 'scope'] => expected)
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_transaction_stats_are_tracked_separately
|
229
|
-
in_transaction do
|
230
|
-
@engine.record_metrics('foo', 1)
|
231
|
-
assert_nil @engine.lookup_stats('foo')
|
232
|
-
end
|
233
|
-
|
234
|
-
assert_equal 1, @engine.lookup_stats('foo').call_count
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_record_supportability_metric_timed_records_duration_of_block
|
238
|
-
freeze_time
|
239
|
-
2.times do
|
240
|
-
@engine.record_supportability_metric_timed('foo/bar') { advance_time(2.0) }
|
241
|
-
end
|
242
|
-
|
243
|
-
assert_metrics_recorded(['Supportability/foo/bar'] => {
|
244
|
-
:call_count => 2,
|
245
|
-
:total_call_time => 4.0
|
246
|
-
})
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_record_supportability_metric_timed_does_not_break_when_block_raises
|
250
|
-
begin
|
251
|
-
freeze_time
|
252
|
-
@engine.record_supportability_metric_timed('foo/bar') do
|
253
|
-
advance_time(2.0)
|
254
|
-
1 / 0
|
255
|
-
end
|
256
|
-
rescue ZeroDivisionError
|
257
|
-
nil
|
258
|
-
end
|
259
|
-
|
260
|
-
assert_metrics_recorded(['Supportability/foo/bar'] => {
|
261
|
-
:call_count => 1,
|
262
|
-
:total_call_time => 2.0
|
263
|
-
})
|
264
|
-
end
|
265
|
-
|
266
338
|
def test_record_supportability_metric_count_records_counts_only
|
267
|
-
@engine.
|
268
|
-
@engine.
|
339
|
+
@engine.tl_record_supportability_metric_count('foo/bar', 1)
|
340
|
+
@engine.tl_record_supportability_metric_count('foo/bar', 42)
|
269
341
|
assert_metrics_recorded(['Supportability/foo/bar'] => {
|
270
342
|
:call_count => 42,
|
271
343
|
:total_call_time => 0
|