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
@@ -30,13 +30,13 @@ class MonotonicGCProfilerTest < Minitest::Test
|
|
30
30
|
GC::Profiler.expects(:clear).once
|
31
31
|
profiler.total_time_s
|
32
32
|
end
|
33
|
-
end
|
34
33
|
|
35
|
-
|
36
|
-
|
34
|
+
def test_total_time_does_not_raise_if_called_when_not_enabled
|
35
|
+
NewRelic::LanguageSupport.stubs(:gc_profiler_enabled?).returns(false)
|
36
|
+
GC::Profiler.expects(:total_time).never
|
37
37
|
|
38
|
-
assert_raises(NewRelic::Agent::VM::MonotonicGCProfiler::ProfilerNotEnabledError) do
|
39
38
|
profiler.total_time_s
|
40
39
|
end
|
41
40
|
end
|
41
|
+
|
42
42
|
end
|
@@ -0,0 +1,68 @@
|
|
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 File.expand_path(File.join(__FILE__, "..", "..", "..", "..", "test_helper"))
|
6
|
+
require 'new_relic/agent/vm/rubinius_vm'
|
7
|
+
|
8
|
+
if NewRelic::LanguageSupport.rubinius?
|
9
|
+
class NewRelic::Agent::VM::RubiniusVMTest < Minitest::Test
|
10
|
+
def test_normal_usage
|
11
|
+
with_stats({ :gc => {
|
12
|
+
:full => { :count => 1 },
|
13
|
+
:young => { :count => 2 }
|
14
|
+
}})
|
15
|
+
|
16
|
+
has_major_minor(1, 2)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_missing_full
|
20
|
+
with_stats({ :gc => {
|
21
|
+
:young => { :count => 2 }
|
22
|
+
}})
|
23
|
+
|
24
|
+
has_major_minor(nil, 2)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_missing_full_count
|
28
|
+
with_stats({ :gc => {
|
29
|
+
:full => { },
|
30
|
+
:young => { :count => 2 }
|
31
|
+
}})
|
32
|
+
|
33
|
+
has_major_minor(nil, 2)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_missing_young
|
37
|
+
with_stats({ :gc => {
|
38
|
+
:full => { :count => 1 }
|
39
|
+
}})
|
40
|
+
|
41
|
+
has_major_minor(1, nil)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_missing_young_count
|
45
|
+
with_stats({ :gc => {
|
46
|
+
:full => { :count => 1},
|
47
|
+
:young => { }
|
48
|
+
}})
|
49
|
+
|
50
|
+
has_major_minor(1, nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_missing_gc
|
54
|
+
with_stats({})
|
55
|
+
has_major_minor(nil, nil)
|
56
|
+
end
|
57
|
+
|
58
|
+
def with_stats(stats)
|
59
|
+
GC.stubs(:stat).returns(stats)
|
60
|
+
end
|
61
|
+
|
62
|
+
def has_major_minor(major, minor)
|
63
|
+
snapshot = NewRelic::Agent::VM::RubiniusVM.new.snapshot
|
64
|
+
assert_equal(major, snapshot.major_gc_count)
|
65
|
+
assert_equal(minor, snapshot.minor_gc_count)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def teardown
|
21
|
-
NewRelic::Agent::TransactionState.
|
21
|
+
NewRelic::Agent::TransactionState.tl_clear_for_testing
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_shutdown
|
@@ -126,53 +126,53 @@ module NewRelic
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_is_transaction_traced_true
|
129
|
-
NewRelic::Agent::TransactionState.
|
130
|
-
assert_equal(true, NewRelic::Agent.
|
129
|
+
NewRelic::Agent::TransactionState.tl_get.record_tt = true
|
130
|
+
assert_equal(true, NewRelic::Agent.tl_is_transaction_traced?, 'should be true since the thread local is set')
|
131
131
|
end
|
132
132
|
|
133
133
|
def test_is_transaction_traced_blank
|
134
|
-
NewRelic::Agent::TransactionState.
|
135
|
-
assert_equal(true, NewRelic::Agent.
|
134
|
+
NewRelic::Agent::TransactionState.tl_get.record_tt = nil
|
135
|
+
assert_equal(true, NewRelic::Agent.tl_is_transaction_traced?, 'should be true since the thread local is not set')
|
136
136
|
end
|
137
137
|
|
138
138
|
def test_is_transaction_traced_false
|
139
|
-
NewRelic::Agent::TransactionState.
|
140
|
-
assert_equal(false, NewRelic::Agent.
|
139
|
+
NewRelic::Agent::TransactionState.tl_get.record_tt = false
|
140
|
+
assert_equal(false, NewRelic::Agent.tl_is_transaction_traced?, 'should be false since the thread local is false')
|
141
141
|
end
|
142
142
|
|
143
143
|
def test_is_sql_recorded_true
|
144
|
-
NewRelic::Agent::TransactionState.
|
145
|
-
assert_equal(true, NewRelic::Agent.
|
144
|
+
NewRelic::Agent::TransactionState.tl_get.record_sql = true
|
145
|
+
assert_equal(true, NewRelic::Agent.tl_is_sql_recorded?, 'should be true since the thread local is set')
|
146
146
|
end
|
147
147
|
|
148
148
|
def test_is_sql_recorded_blank
|
149
|
-
NewRelic::Agent::TransactionState.
|
150
|
-
assert_equal(true, NewRelic::Agent.
|
149
|
+
NewRelic::Agent::TransactionState.tl_get.record_sql = nil
|
150
|
+
assert_equal(true, NewRelic::Agent.tl_is_sql_recorded?, 'should be true since the thread local is not set')
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_is_sql_recorded_false
|
154
|
-
NewRelic::Agent::TransactionState.
|
155
|
-
assert_equal(false, NewRelic::Agent.
|
154
|
+
NewRelic::Agent::TransactionState.tl_get.record_sql = false
|
155
|
+
assert_equal(false, NewRelic::Agent.tl_is_sql_recorded?, 'should be false since the thread local is false')
|
156
156
|
end
|
157
157
|
|
158
158
|
def test_is_execution_traced_true
|
159
|
-
NewRelic::Agent::TransactionState.
|
160
|
-
assert_equal(true, NewRelic::Agent.
|
159
|
+
NewRelic::Agent::TransactionState.tl_get.untraced = [true, true]
|
160
|
+
assert_equal(true, NewRelic::Agent.tl_is_execution_traced?, 'should be true since the thread local is set')
|
161
161
|
end
|
162
162
|
|
163
163
|
def test_is_execution_traced_blank
|
164
|
-
NewRelic::Agent::TransactionState.
|
165
|
-
assert_equal(true, NewRelic::Agent.
|
164
|
+
NewRelic::Agent::TransactionState.tl_get.untraced = nil
|
165
|
+
assert_equal(true, NewRelic::Agent.tl_is_execution_traced?, 'should be true since the thread local is not set')
|
166
166
|
end
|
167
167
|
|
168
168
|
def test_is_execution_traced_empty
|
169
|
-
NewRelic::Agent::TransactionState.
|
170
|
-
assert_equal(true, NewRelic::Agent.
|
169
|
+
NewRelic::Agent::TransactionState.tl_get.untraced = []
|
170
|
+
assert_equal(true, NewRelic::Agent.tl_is_execution_traced?, 'should be true since the thread local is an empty array')
|
171
171
|
end
|
172
172
|
|
173
173
|
def test_is_execution_traced_false
|
174
|
-
NewRelic::Agent::TransactionState.
|
175
|
-
assert_equal(false, NewRelic::Agent.
|
174
|
+
NewRelic::Agent::TransactionState.tl_get.untraced = [true, false]
|
175
|
+
assert_equal(false, NewRelic::Agent.tl_is_execution_traced?, 'should be false since the thread local stack has the last element false')
|
176
176
|
end
|
177
177
|
|
178
178
|
def test_instance
|
@@ -188,7 +188,7 @@ module NewRelic
|
|
188
188
|
|
189
189
|
def test_record_metric
|
190
190
|
dummy_engine = NewRelic::Agent.agent.stats_engine
|
191
|
-
dummy_engine.expects(:
|
191
|
+
dummy_engine.expects(:tl_record_unscoped_metrics).with('foo', 12)
|
192
192
|
NewRelic::Agent.record_metric('foo', 12)
|
193
193
|
end
|
194
194
|
|
@@ -208,7 +208,7 @@ module NewRelic
|
|
208
208
|
expected_stats.min_call_time = 1
|
209
209
|
expected_stats.max_call_time = 5
|
210
210
|
expected_stats.sum_of_squares = 999
|
211
|
-
dummy_engine.expects(:
|
211
|
+
dummy_engine.expects(:tl_record_unscoped_metrics).with('foo', expected_stats)
|
212
212
|
NewRelic::Agent.record_metric('foo', stats_hash)
|
213
213
|
end
|
214
214
|
|
@@ -228,7 +228,7 @@ module NewRelic
|
|
228
228
|
expected_stats.max_call_time = 5
|
229
229
|
expected_stats.sum_of_squares = 999
|
230
230
|
|
231
|
-
dummy_engine.expects(:
|
231
|
+
dummy_engine.expects(:tl_record_unscoped_metrics).with('foo', expected_stats)
|
232
232
|
NewRelic::Agent.record_metric('foo', incomplete_stats_hash)
|
233
233
|
end
|
234
234
|
|
@@ -236,7 +236,7 @@ module NewRelic
|
|
236
236
|
dummy_engine = NewRelic::Agent.agent.stats_engine
|
237
237
|
dummy_stats = mock
|
238
238
|
dummy_stats.expects(:increment_count).with(12)
|
239
|
-
dummy_engine.expects(:
|
239
|
+
dummy_engine.expects(:tl_record_unscoped_metrics).with('foo').yields(dummy_stats)
|
240
240
|
NewRelic::Agent.increment_metric('foo', 12)
|
241
241
|
end
|
242
242
|
|
@@ -301,7 +301,11 @@ module NewRelic
|
|
301
301
|
trace_execution_scoped('Custom/something') {}
|
302
302
|
NewRelic::Agent.set_transaction_name('new_name')
|
303
303
|
end
|
304
|
-
|
304
|
+
|
305
|
+
assert_metrics_recorded([
|
306
|
+
'Custom/something',
|
307
|
+
'Controller/new_name'
|
308
|
+
])
|
305
309
|
end
|
306
310
|
|
307
311
|
def test_set_transaction_name_sets_tt_name
|
@@ -316,7 +320,7 @@ module NewRelic
|
|
316
320
|
engine = NewRelic::Agent.instance.stats_engine
|
317
321
|
engine.reset!
|
318
322
|
Transactor.new.txn do
|
319
|
-
NewRelic::Agent::Transaction.
|
323
|
+
NewRelic::Agent::Transaction.tl_current.freeze_name_and_execute_if_not_ignored do
|
320
324
|
NewRelic::Agent.set_transaction_name('new_name')
|
321
325
|
end
|
322
326
|
end
|
@@ -16,8 +16,9 @@ class NewRelic::Cli::DeploymentsTest < Minitest::Test
|
|
16
16
|
def just_exit(status=0); @exit_status ||= status; end
|
17
17
|
end
|
18
18
|
@config = { :license_key => 'a' * 40 }
|
19
|
-
NewRelic::Agent.config.
|
19
|
+
NewRelic::Agent.config.add_config_for_testing(@config)
|
20
20
|
end
|
21
|
+
|
21
22
|
def teardown
|
22
23
|
super
|
23
24
|
return unless @deployment
|
@@ -26,19 +27,23 @@ class NewRelic::Cli::DeploymentsTest < Minitest::Test
|
|
26
27
|
puts @deployment.exit_status
|
27
28
|
NewRelic::Agent.config.remove_config(@config)
|
28
29
|
end
|
30
|
+
|
31
|
+
|
29
32
|
def test_help
|
30
33
|
begin
|
31
34
|
NewRelic::Cli::Deployments.new "-h"
|
32
35
|
fail "should have thrown"
|
33
36
|
rescue NewRelic::Cli::Command::CommandFailure => c
|
34
|
-
assert_match
|
37
|
+
assert_match(/^Usage/, c.message)
|
35
38
|
end
|
36
39
|
end
|
40
|
+
|
37
41
|
def test_bad_command
|
38
42
|
assert_raises NewRelic::Cli::Command::CommandFailure do
|
39
43
|
NewRelic::Cli::Deployments.new ["-foo", "bar"]
|
40
44
|
end
|
41
45
|
end
|
46
|
+
|
42
47
|
def test_interactive
|
43
48
|
mock_the_connection
|
44
49
|
@deployment = NewRelic::Cli::Deployments.new(:appname => 'APP',
|
@@ -17,14 +17,14 @@ class NewRelic::Control::InstanceMethodsTest < Minitest::Test
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_configure_agent_adds_the_yaml_config
|
20
|
-
refute NewRelic::Agent.config.
|
20
|
+
refute NewRelic::Agent.config.config_classes_for_testing.include? NewRelic::Agent::Configuration::YamlSource
|
21
21
|
@test.configure_agent('test', {})
|
22
|
-
assert NewRelic::Agent.config.
|
22
|
+
assert NewRelic::Agent.config.config_classes_for_testing.include? NewRelic::Agent::Configuration::YamlSource
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_configure_agent_adds_the_manual_config
|
26
|
-
refute NewRelic::Agent.config.
|
26
|
+
refute NewRelic::Agent.config.config_classes_for_testing.include? NewRelic::Agent::Configuration::ManualSource
|
27
27
|
@test.configure_agent('test', {})
|
28
|
-
assert NewRelic::Agent.config.
|
28
|
+
assert NewRelic::Agent.config.config_classes_for_testing.include? NewRelic::Agent::Configuration::ManualSource
|
29
29
|
end
|
30
30
|
end
|
@@ -23,14 +23,14 @@ class NewRelic::ControlTest < Minitest::Test
|
|
23
23
|
|
24
24
|
def test_root
|
25
25
|
assert File.directory?(NewRelic::Control.newrelic_root), NewRelic::Control.newrelic_root
|
26
|
-
if defined?(Rails)
|
26
|
+
if defined?(Rails::VERSION)
|
27
27
|
assert File.directory?(File.join(NewRelic::Control.newrelic_root, "lib")), NewRelic::Control.newrelic_root + "/lib"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_info
|
32
32
|
NewRelic::Agent.manual_start
|
33
|
-
if defined?(Rails)
|
33
|
+
if defined?(Rails::VERSION)
|
34
34
|
assert_match /jdbc|postgres|mysql|sqlite/, NewRelic::EnvironmentReport.new["Database adapter"]
|
35
35
|
end
|
36
36
|
end
|
@@ -122,21 +122,21 @@ class NewRelic::ControlTest < Minitest::Test
|
|
122
122
|
def test_transaction_tracer_disabled
|
123
123
|
with_config(:'transaction_tracer.enabled' => false,
|
124
124
|
:developer_mode => false, :monitor_mode => true) do
|
125
|
-
assert(!NewRelic::Agent
|
125
|
+
assert(!NewRelic::Agent.instance.transaction_sampler.enabled?,
|
126
126
|
'transaction tracer enabled when config calls for disabled')
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_sql_tracer_disabled
|
131
131
|
with_config(:'slow_sql.enabled' => false, :monitor_mode => true) do
|
132
|
-
assert(!NewRelic::Agent
|
132
|
+
assert(!NewRelic::Agent.instance.sql_sampler.enabled?,
|
133
133
|
'sql tracer enabled when config calls for disabled')
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_sql_tracer_disabled_with_record_sql_false
|
138
138
|
with_config(:slow_sql => { :enabled => true, :record_sql => 'off' }) do
|
139
|
-
refute NewRelic::Agent
|
139
|
+
refute NewRelic::Agent.instance.sql_sampler.enabled?,
|
140
140
|
'sql tracer enabled when config calls for disabled'
|
141
141
|
end
|
142
142
|
end
|
@@ -145,7 +145,7 @@ class NewRelic::ControlTest < Minitest::Test
|
|
145
145
|
with_config(:'transaction_tracer.enabled' => false,
|
146
146
|
:'slow_sql.enabled' => true,
|
147
147
|
:developer_mode => false, :monitor_mode => true) do
|
148
|
-
refute NewRelic::Agent
|
148
|
+
refute NewRelic::Agent.instance.sql_sampler.enabled?,
|
149
149
|
'sql enabled when transaction tracer disabled'
|
150
150
|
end
|
151
151
|
end
|
@@ -163,10 +163,12 @@ class NewRelic::ControlTest < Minitest::Test
|
|
163
163
|
|
164
164
|
def test_init_plugin_loads_samplers_enabled
|
165
165
|
reset_agent
|
166
|
-
|
167
|
-
|
168
|
-
:
|
169
|
-
:
|
166
|
+
|
167
|
+
with_config(:disable_samplers => false,
|
168
|
+
:disable_harvest_thread => true,
|
169
|
+
:agent_enabled => true,
|
170
|
+
:monitor_mode => true,
|
171
|
+
:license_key => 'a'*40) do
|
170
172
|
NewRelic::Control.instance.init_plugin
|
171
173
|
assert NewRelic::Agent.instance.harvest_samplers.any?
|
172
174
|
end
|
@@ -174,10 +176,12 @@ class NewRelic::ControlTest < Minitest::Test
|
|
174
176
|
|
175
177
|
def test_init_plugin_loads_samplers_disabled
|
176
178
|
reset_agent
|
177
|
-
|
178
|
-
|
179
|
-
:
|
180
|
-
:
|
179
|
+
|
180
|
+
with_config(:disable_samplers => true,
|
181
|
+
:disable_harvest_thread => true,
|
182
|
+
:agent_enabled => true,
|
183
|
+
:monitor_mode => true,
|
184
|
+
:license_key => 'a'*40) do
|
181
185
|
NewRelic::Control.instance.init_plugin
|
182
186
|
refute NewRelic::Agent.instance.harvest_samplers.any?
|
183
187
|
end
|
@@ -188,10 +192,11 @@ class NewRelic::ControlTest < Minitest::Test
|
|
188
192
|
|
189
193
|
NewRelic::Agent.instance.stubs(:defer_for_delayed_job?).returns(true)
|
190
194
|
|
191
|
-
with_config(:disable_samplers
|
192
|
-
:
|
193
|
-
:
|
194
|
-
:
|
195
|
+
with_config(:disable_samplers => false,
|
196
|
+
:disable_harvest_thread => true,
|
197
|
+
:agent_enabled => true,
|
198
|
+
:monitor_mode => true,
|
199
|
+
:license_key => 'a'*40) do
|
195
200
|
NewRelic::Control.instance.init_plugin
|
196
201
|
refute NewRelic::Agent.instance.already_started?
|
197
202
|
refute NewRelic::Agent.instance.harvest_samplers.any?
|
@@ -203,10 +208,11 @@ class NewRelic::ControlTest < Minitest::Test
|
|
203
208
|
|
204
209
|
NewRelic::Agent.instance.stubs(:defer_for_delayed_job?).returns(true)
|
205
210
|
|
206
|
-
with_config(:disable_samplers
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
211
|
+
with_config(:disable_samplers => false,
|
212
|
+
:disable_harvest_thread => true,
|
213
|
+
:agent_enabled => true,
|
214
|
+
:monitor_mode => true,
|
215
|
+
:license_key => 'a'*40) do
|
210
216
|
NewRelic::Control.instance.init_plugin
|
211
217
|
NewRelic::Agent.instance.stubs(:defer_for_delayed_job?).returns(false)
|
212
218
|
NewRelic::Agent.after_fork
|
@@ -96,6 +96,20 @@ class DependencyDetectionTest < Minitest::Test
|
|
96
96
|
assert !executed
|
97
97
|
end
|
98
98
|
|
99
|
+
def test_named_disabling_with_instance_variable
|
100
|
+
executed = false
|
101
|
+
|
102
|
+
DependencyDetection.defer do
|
103
|
+
@name = :testing
|
104
|
+
executes { executed = true }
|
105
|
+
end
|
106
|
+
|
107
|
+
with_config(:disable_testing => true) do
|
108
|
+
DependencyDetection.detect!
|
109
|
+
end
|
110
|
+
|
111
|
+
assert !executed
|
112
|
+
end
|
99
113
|
|
100
114
|
def test_exception_during_depends_on_check_doesnt_propagate
|
101
115
|
DependencyDetection.defer do
|
@@ -0,0 +1,35 @@
|
|
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 'rack'
|
6
|
+
require 'rack/request'
|
7
|
+
require 'fake_server'
|
8
|
+
|
9
|
+
module NewRelic
|
10
|
+
class FakeRpmSite < FakeServer
|
11
|
+
def initialize(*_)
|
12
|
+
super
|
13
|
+
@requests = []
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :requests
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
@requests << unpack(env)
|
20
|
+
[200, {}, ["Fine"]]
|
21
|
+
end
|
22
|
+
|
23
|
+
def unpack(env)
|
24
|
+
::Rack::Request.new(env).params
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset
|
28
|
+
@requests.clear
|
29
|
+
end
|
30
|
+
|
31
|
+
def app
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|