newrelic_rpm 3.18.1.330 → 4.0.0.332
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -74
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTING.md +14 -6
- data/LICENSE +1 -88
- data/lib/new_relic/agent.rb +2 -103
- data/lib/new_relic/agent/agent.rb +3 -32
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
- data/lib/new_relic/agent/configuration/default_source.rb +1 -8
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +1 -1
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
- data/lib/new_relic/agent/error_collector.rb +8 -21
- data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
- data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
- data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
- data/lib/new_relic/agent/method_tracer.rb +1 -60
- data/lib/new_relic/agent/new_relic_service.rb +3 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
- data/lib/new_relic/agent/pipe_service.rb +1 -3
- data/lib/new_relic/agent/rules_engine.rb +2 -17
- data/lib/new_relic/agent/stats_engine.rb +0 -2
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
- data/lib/new_relic/agent/supported_versions.rb +12 -19
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +0 -3
- data/lib/new_relic/agent/transaction/attributes.rb +1 -10
- data/lib/new_relic/agent/vm.rb +1 -4
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
- data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
- data/lib/new_relic/control.rb +1 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -1
- data/lib/new_relic/control/frameworks/rails3.rb +1 -2
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/rails5.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
- data/lib/new_relic/helper.rb +6 -13
- data/lib/new_relic/language_support.rb +44 -139
- data/lib/new_relic/metric_spec.rb +0 -17
- data/lib/new_relic/noticed_error.rb +18 -27
- data/lib/new_relic/version.rb +3 -48
- data/lib/tasks/versions.rake +7 -5
- data/newrelic_rpm.gemspec +1 -16
- data/test/agent_helper.rb +4 -2
- data/test/environments/lib/environments/runner.rb +5 -14
- data/test/environments/norails/Gemfile +0 -8
- data/test/environments/rails21/Gemfile +0 -8
- data/test/environments/rails21/config/database.yml +1 -1
- data/test/environments/rails22/Gemfile +0 -8
- data/test/environments/rails22/config/database.yml +1 -1
- data/test/environments/rails23/Gemfile +1 -7
- data/test/environments/rails23/config/database.yml +1 -1
- data/test/environments/rails30/Gemfile +0 -1
- data/test/environments/rails30/config/database.yml +1 -1
- data/test/environments/rails31/Gemfile +0 -3
- data/test/environments/rails31/config/database.yml +1 -1
- data/test/environments/rails32/Gemfile +0 -3
- data/test/environments/rails32/config/database.yml +1 -1
- data/test/environments/rails40/Gemfile +0 -26
- data/test/environments/rails40/config/database.yml +1 -1
- data/test/environments/rails41/Gemfile +0 -18
- data/test/environments/rails41/config/database.yml +1 -1
- data/test/environments/rails42/Gemfile +0 -22
- data/test/environments/rails42/config/database.yml +1 -1
- data/test/environments/rails50/Gemfile +0 -13
- data/test/environments/rails50/config/database.yml +1 -1
- data/test/helpers/logging.rb +37 -0
- data/test/helpers/minitest.rb +50 -0
- data/test/helpers/misc.rb +87 -0
- data/test/helpers/transaction_sample.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +6 -91
- data/test/multiverse/script/runner +1 -1
- data/test/multiverse/suites/active_record/Envfile +1 -28
- data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
- data/test/multiverse/suites/active_record/config/database.rb +2 -3
- data/test/multiverse/suites/active_record/config/database.yml +0 -2
- data/test/multiverse/suites/activemerchant/Envfile +4 -18
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
- data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
- data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
- data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
- data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
- data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
- data/test/multiverse/suites/capistrano/Envfile +2 -4
- data/test/multiverse/suites/capistrano2/Envfile +0 -4
- data/test/multiverse/suites/curb/Envfile +3 -7
- data/test/multiverse/suites/datamapper/Envfile +2 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
- data/test/multiverse/suites/delayed_job/Envfile +28 -41
- data/test/multiverse/suites/excon/Envfile +0 -3
- data/test/multiverse/suites/grape/Envfile +0 -4
- data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
- data/test/multiverse/suites/json/Envfile +1 -9
- data/test/multiverse/suites/marshalling/Envfile +0 -9
- data/test/multiverse/suites/memcached/Envfile +5 -23
- data/test/multiverse/suites/mongo/Envfile +9 -11
- data/test/multiverse/suites/padrino/Envfile +0 -6
- data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
- data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
- data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
- data/test/multiverse/suites/rails/Envfile +1 -19
- data/test/multiverse/suites/rails/activejob_test.rb +1 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
- data/test/multiverse/suites/rake/Envfile +15 -22
- data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sequel/database.rb +1 -4
- data/test/multiverse/suites/sidekiq/Envfile +13 -23
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
- data/test/multiverse/suites/typhoeus/Envfile +0 -19
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
- data/test/multiverse/suites/yajl/Envfile +5 -0
- data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
- data/test/new_relic/agent/agent/start_test.rb +3 -3
- data/test/new_relic/agent/agent_logger_test.rb +2 -2
- data/test/new_relic/agent/agent_test.rb +2 -2
- data/test/new_relic/agent/attribute_processing_test.rb +3 -4
- data/test/new_relic/agent/audit_logger_test.rb +4 -6
- data/test/new_relic/agent/aws_info_test.rb +17 -1
- data/test/new_relic/agent/busy_calculator_test.rb +14 -16
- data/test/new_relic/agent/configuration/manager_test.rb +1 -7
- data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +2 -10
- data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
- data/test/new_relic/agent/datastores/redis_test.rb +14 -16
- data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
- data/test/new_relic/agent/error_collector_test.rb +16 -49
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
- data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
- data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
- data/test/new_relic/agent/method_tracer_test.rb +35 -76
- data/test/new_relic/agent/new_relic_service_test.rb +86 -102
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
- data/test/new_relic/agent/pipe_service_test.rb +2 -3
- data/test/new_relic/agent/rpm_agent_test.rb +0 -4
- data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
- data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
- data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
- data/test/new_relic/agent/sized_buffer_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
- data/test/new_relic/agent/stats_test.rb +6 -8
- data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
- data/test/new_relic/agent/transaction_test.rb +2 -10
- data/test/new_relic/agent/utilization_data_test.rb +17 -1
- data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
- data/test/new_relic/agent_test.rb +0 -43
- data/test/new_relic/coerce_test.rb +1 -3
- data/test/new_relic/fake_collector.rb +3 -3
- data/test/new_relic/fake_external_server.rb +1 -1
- data/test/new_relic/fake_server.rb +1 -1
- data/test/new_relic/http_client_test_cases.rb +3 -3
- data/test/new_relic/language_support_test.rb +6 -12
- data/test/new_relic/latest_changes_test.rb +0 -11
- data/test/new_relic/license_test.rb +3 -8
- data/test/new_relic/multiverse_helpers.rb +1 -1
- data/test/new_relic/noticed_error_test.rb +11 -7
- data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
- data/test/nullverse/nullverse_helper.rb +1 -1
- data/test/performance/lib/performance.rb +1 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
- data/test/performance/lib/performance/platform.rb +1 -8
- data/test/performance/script/runner +1 -3
- data/test/performance/suites/active_record.rb +3 -24
- data/test/test_helper.rb +9 -216
- metadata +9 -45
- data/lib/conditional_vendored_dependency_detection.rb +0 -7
- data/lib/new_relic/agent/hash_extensions.rb +0 -41
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
- data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
- data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
- data/lib/new_relic/json_wrapper.rb +0 -78
- data/lib/new_relic/okjson.rb +0 -602
- data/lib/new_relic/rack/error_collector.rb +0 -27
- data/lib/new_relic/timer_lib.rb +0 -31
- data/test/helpers/runtime_detection.rb +0 -17
- data/test/multiverse/suites/no_json/Envfile +0 -12
- data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
- data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
- data/test/new_relic/agent/hash_extensions_test.rb +0 -59
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
- data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
- data/test/new_relic/json_wrapper_test.rb +0 -32
- data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
- data/test/new_relic/rack/error_collector_test.rb +0 -83
- data/test/new_relic/version_number_test.rb +0 -101
- data/test/script/before_install/revert_rubygems.sh +0 -15
- data/test/script/before_install/update_bundler.sh +0 -12
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -5,39 +5,33 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
6
6
|
|
7
7
|
class NewRelic::LanguageSupportTest < Minitest::Test
|
8
|
-
include ::NewRelic::TestHelpers::RuntimeDetection
|
9
8
|
|
10
9
|
def test_object_space_usable_on_jruby_with_object_space_enabled
|
11
|
-
return unless jruby?
|
10
|
+
return unless NewRelic::LanguageSupport.jruby?
|
12
11
|
JRuby.objectspace = true
|
13
12
|
assert_truthy NewRelic::LanguageSupport.object_space_usable?
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_object_space_not_usable_on_jruby_with_object_space_disabled
|
17
|
-
return unless jruby?
|
16
|
+
return unless NewRelic::LanguageSupport.jruby?
|
18
17
|
JRuby.objectspace = false
|
19
18
|
assert_falsy NewRelic::LanguageSupport.object_space_usable?
|
20
19
|
end
|
21
20
|
|
22
|
-
def test_object_space_not_usable_on_rubinius
|
23
|
-
return unless rubinius?
|
24
|
-
assert_falsy NewRelic::LanguageSupport.object_space_usable?
|
25
|
-
end
|
26
|
-
|
27
21
|
def test_gc_profiler_unavailable_without_constant
|
28
22
|
undefine_constant(:'GC::Profiler') do
|
29
|
-
|
23
|
+
refute NewRelic::LanguageSupport.gc_profiler_usable?
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
33
27
|
def test_gc_profiler_unavailable_on_jruby
|
34
|
-
return unless jruby?
|
28
|
+
return unless NewRelic::LanguageSupport.jruby?
|
35
29
|
assert_equal false, NewRelic::LanguageSupport.gc_profiler_usable?
|
36
30
|
end
|
37
31
|
|
38
32
|
def test_gc_profiler_disabled_without_constant
|
39
33
|
undefine_constant(:'GC::Profiler') do
|
40
|
-
|
34
|
+
refute NewRelic::LanguageSupport.gc_profiler_enabled?
|
41
35
|
end
|
42
36
|
end
|
43
37
|
|
@@ -66,7 +60,7 @@ class NewRelic::LanguageSupportTest < Minitest::Test
|
|
66
60
|
end
|
67
61
|
|
68
62
|
def test_gc_profiler_disabled_on_jruby
|
69
|
-
return unless defined?(::GC::Profiler) && jruby?
|
63
|
+
return unless defined?(::GC::Profiler) && NewRelic::LanguageSupport.jruby?
|
70
64
|
|
71
65
|
::GC::Profiler.stubs(:enabled?).returns(true)
|
72
66
|
assert_equal false, NewRelic::LanguageSupport.gc_profiler_enabled?
|
@@ -6,17 +6,6 @@ require File.expand_path(File.join(__FILE__,'..','..','test_helper'))
|
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
class LatestChangesTest < MiniTest::Test
|
9
|
-
def setup
|
10
|
-
# 1.8.7 returns relative paths for __FILE__. test:env environment then
|
11
|
-
# can't find the CHANGELOG since current dir is test app instead of gem.
|
12
|
-
#
|
13
|
-
# This doesn't impact production usage of NewRelic::LatestChanges on
|
14
|
-
# the gem post-installation, since that's run in our gem's context. So
|
15
|
-
# just fix up the pathing in the test for finding default changelog.
|
16
|
-
if RUBY_VERSION < '1.9.1'
|
17
|
-
NewRelic::LatestChanges.stubs(:default_changelog).returns(File.join(File.dirname(__FILE__), '..', '..', 'CHANGELOG.md'))
|
18
|
-
end
|
19
|
-
end
|
20
9
|
|
21
10
|
def test_read_default_changelog
|
22
11
|
result = NewRelic::LatestChanges.read
|
@@ -27,14 +27,9 @@ class LicenseTest < Minitest::Test
|
|
27
27
|
# the source code.
|
28
28
|
EXPECTED_LICENSE_OCCURRENCES = {
|
29
29
|
['/newrelic_rpm.gemspec', 'MIT'] => 1, # licenses specificiation, which includes MIT for MIT-licensed portions of code
|
30
|
-
['/
|
31
|
-
['/
|
32
|
-
['/
|
33
|
-
['/lib/new_relic/timer_lib.rb', 'Copyright'] => 1, # timer_lib license info
|
34
|
-
['/LICENSE', 'GPL'] => 1, # dual license info for system_timer
|
35
|
-
['/LICENSE', 'MIT'] => 3,
|
36
|
-
['/LICENSE', '(c)'] => 3,
|
37
|
-
['/LICENSE', 'Copyright'] => 11,
|
30
|
+
['/LICENSE', 'MIT'] => 2,
|
31
|
+
['/LICENSE', '(c)'] => 2,
|
32
|
+
['/LICENSE', 'Copyright'] => 4,
|
38
33
|
['/LICENSE', 'rights reserved'] => 1,
|
39
34
|
['/ui/views/layouts/newrelic_default.rhtml', 'rights reserved'] => 1,
|
40
35
|
['/ui/views/newrelic/file/javascript/jquery-1.4.2.js', 'GPL'] => 3,
|
@@ -176,7 +176,7 @@ module MultiverseHelpers
|
|
176
176
|
raw_attributes = @js_data["atts"]
|
177
177
|
|
178
178
|
if raw_attributes
|
179
|
-
attributes =
|
179
|
+
attributes = ::JSON.load @instrumentor.obfuscator.deobfuscate(raw_attributes)
|
180
180
|
@js_custom_attributes = attributes['u']
|
181
181
|
@js_agent_attributes = attributes['a']
|
182
182
|
end
|
@@ -5,6 +5,8 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
6
6
|
require 'new_relic/agent/transaction/attributes'
|
7
7
|
|
8
|
+
class FooError < StandardError; end
|
9
|
+
|
8
10
|
class NewRelic::Agent::NoticedErrorTest < Minitest::Test
|
9
11
|
include NewRelic::TestHelpers::Exceptions
|
10
12
|
|
@@ -173,13 +175,6 @@ class NewRelic::Agent::NoticedErrorTest < Minitest::Test
|
|
173
175
|
end
|
174
176
|
end
|
175
177
|
|
176
|
-
def test_handles_exception_with_nil_cause
|
177
|
-
e = Exception.new('Buffy FOREVER')
|
178
|
-
e.stubs(:cause).returns(nil)
|
179
|
-
error = NewRelic::NoticedError.new(@path, e, @time)
|
180
|
-
assert_equal(error.message.to_s, 'Buffy FOREVER')
|
181
|
-
end
|
182
|
-
|
183
178
|
def test_handles_exception_with_nil_original_exception
|
184
179
|
e = Exception.new('Buffy FOREVER')
|
185
180
|
e.stubs(:original_exception).returns(nil)
|
@@ -187,6 +182,15 @@ class NewRelic::Agent::NoticedErrorTest < Minitest::Test
|
|
187
182
|
assert_equal(error.message.to_s, 'Buffy FOREVER')
|
188
183
|
end
|
189
184
|
|
185
|
+
if defined?(Rails) && Rails::VERSION::MAJOR < 5
|
186
|
+
def test_uses_original_exception_class_name
|
187
|
+
orig = FooError.new
|
188
|
+
e = mock('exception', original_exception: orig)
|
189
|
+
error = NewRelic::NoticedError.new(@path, e, @time)
|
190
|
+
assert_equal(error.exception_class_name, 'FooError')
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
190
194
|
def test_intrinsics_always_get_sent
|
191
195
|
with_config(:'error_collector.attributes.enabled' => false) do
|
192
196
|
attributes = NewRelic::Agent::Transaction::Attributes.new(NewRelic::Agent.instance.attribute_filter)
|
@@ -5,7 +5,6 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..',
|
6
6
|
'test_helper'))
|
7
7
|
require 'rack/test'
|
8
|
-
require 'new_relic/agent/instrumentation/rack'
|
9
8
|
require 'new_relic/rack/browser_monitoring'
|
10
9
|
|
11
10
|
ENV['RACK_ENV'] = 'test'
|
@@ -48,7 +47,6 @@ EOL
|
|
48
47
|
|
49
48
|
[200, {'Content-Type' => 'text/html'}, response]
|
50
49
|
end
|
51
|
-
include NewRelic::Agent::Instrumentation::Rack
|
52
50
|
end
|
53
51
|
|
54
52
|
def app
|
@@ -154,7 +152,7 @@ EOL
|
|
154
152
|
|
155
153
|
def test_with_invalid_us_ascii_encoding
|
156
154
|
response = "<html><body>Jürgen</body></html>"
|
157
|
-
response.force_encoding(Encoding.find("US-ASCII"))
|
155
|
+
response.force_encoding(Encoding.find("US-ASCII"))
|
158
156
|
TestApp.next_response = Rack::Response.new(response)
|
159
157
|
|
160
158
|
get '/'
|
@@ -5,7 +5,7 @@
|
|
5
5
|
module Performance
|
6
6
|
module Instrumentation
|
7
7
|
class MRIGCStats < Instrumentor
|
8
|
-
platforms :
|
8
|
+
platforms :mri_20, :mri_21, :mri_22, :mri_23, :mri_24
|
9
9
|
on_by_default
|
10
10
|
|
11
11
|
def before(*)
|
@@ -24,11 +24,9 @@ module Performance
|
|
24
24
|
:gc_runs => @stats_after[:count] - @stats_before[:count],
|
25
25
|
:live_objects => heap_live_after - heap_live_before
|
26
26
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
res[:allocations] = allocs_after - allocs_before
|
31
|
-
end
|
27
|
+
allocs_before = @stats_before[:total_allocated_objects] || @stats_before[:total_allocated_object]
|
28
|
+
allocs_after = @stats_after[:total_allocated_objects] || @stats_after[:total_allocated_object]
|
29
|
+
res[:allocations] = allocs_after - allocs_before
|
32
30
|
res
|
33
31
|
end
|
34
32
|
end
|
@@ -12,22 +12,15 @@ module Performance
|
|
12
12
|
defined?(JRUBY_VERSION)
|
13
13
|
end
|
14
14
|
|
15
|
-
def ree?
|
16
|
-
defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /MBARI/
|
17
|
-
end
|
18
|
-
|
19
15
|
def match?(p)
|
20
16
|
case p
|
21
17
|
when :jruby then jruby?
|
22
18
|
when :mri then !jruby?
|
23
|
-
when :ree then !jruby? && ree?
|
24
|
-
when :mri_18 then !jruby? && RUBY_VERSION =~ /^1\.8\./
|
25
|
-
when :mri_19 then !jruby? && RUBY_VERSION =~ /^1\.9\./
|
26
|
-
when :mri_193 then !jruby? && RUBY_VERSION =~ /^1\.9\.3/
|
27
19
|
when :mri_20 then !jruby? && RUBY_VERSION =~ /^2\.0\./
|
28
20
|
when :mri_21 then !jruby? && RUBY_VERSION =~ /^2\.1\./
|
29
21
|
when :mri_22 then !jruby? && RUBY_VERSION =~ /^2\.2\./
|
30
22
|
when :mri_23 then !jruby? && RUBY_VERSION =~ /^2\.3\./
|
23
|
+
when :mri_24 then !jruby? && RUBY_VERSION =~ /^2\.4\./
|
31
24
|
end
|
32
25
|
end
|
33
26
|
|
@@ -8,9 +8,7 @@ require 'optparse'
|
|
8
8
|
require 'rubygems'
|
9
9
|
require 'json'
|
10
10
|
|
11
|
-
require File.
|
12
|
-
|
13
|
-
target_versions = nil
|
11
|
+
require File.expand_path('../../lib/performance', __FILE__)
|
14
12
|
|
15
13
|
options = {}
|
16
14
|
parser = OptionParser.new do |opts|
|
@@ -2,30 +2,9 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'new_relic/agent/instrumentation/active_record_helper'
|
5
6
|
|
6
7
|
class ActiveRecordTest < Performance::TestCase
|
7
|
-
def setup
|
8
|
-
require 'new_relic/agent/instrumentation/active_record_helper'
|
9
|
-
|
10
|
-
ActiveRecordTest.const_set(:ActiveRecordHelper, NewRelic::Agent::Instrumentation::ActiveRecordHelper) unless defined?(ActiveRecordHelper)
|
11
|
-
|
12
|
-
if ActiveRecordHelper.respond_to?(:metrics_for)
|
13
|
-
@run = ActiveRecordHelper.method(:metrics_for)
|
14
|
-
else
|
15
|
-
# Mimics what was buried in the instrumentation that we replaced with
|
16
|
-
# calls to metrics_for in the new instrumentation. Can run against SHA
|
17
|
-
# 399d8ed for baselining (3.10 tags won't work since the perf testing
|
18
|
-
# changed on dev post 3.10)
|
19
|
-
@run = proc do |name, sql, adapter, *_|
|
20
|
-
metric = ActiveRecordHelper.metric_for_name(name) ||
|
21
|
-
ActiveRecordHelper.metric_for_sql(sql)
|
22
|
-
remote_service_metric = ActiveRecordHelper.remote_service_metric("host", adapter)
|
23
|
-
|
24
|
-
metrics = [metric, remote_service_metric].compact
|
25
|
-
metrics += ActiveRecordHelper.rollup_metrics_for(metric)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
8
|
|
30
9
|
NAME = "Model Load"
|
31
10
|
SQL = "SELECT * FROM star"
|
@@ -33,7 +12,7 @@ class ActiveRecordTest < Performance::TestCase
|
|
33
12
|
|
34
13
|
def test_helper_by_name
|
35
14
|
measure do
|
36
|
-
|
15
|
+
NewRelic::Agent::Instrumentation::ActiveRecordHelper.product_operation_collection_for NAME, SQL, ADAPTER
|
37
16
|
end
|
38
17
|
end
|
39
18
|
|
@@ -41,7 +20,7 @@ class ActiveRecordTest < Performance::TestCase
|
|
41
20
|
|
42
21
|
def test_helper_by_sql
|
43
22
|
measure do
|
44
|
-
|
23
|
+
NewRelic::Agent::Instrumentation::ActiveRecordHelper.product_operation_collection_for UNKNOWN_NAME, SQL, ADAPTER
|
45
24
|
end
|
46
25
|
end
|
47
26
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
# define special constant so DefaultSource.framework can return :test
|
5
6
|
module NewRelic; TEST = true; end unless defined? NewRelic::TEST
|
7
|
+
|
6
8
|
ENV['RAILS_ENV'] = 'test'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
$LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"ui/helpers")
|
13
|
-
$LOAD_PATH.uniq!
|
9
|
+
|
10
|
+
$: << File.expand_path('../../lib', __FILE__)
|
11
|
+
$: << File.expand_path('../../test', __FILE__)
|
12
|
+
$: << File.expand_path('../../ui/helpers', __FILE__) # TODO remove after #1493 merges
|
13
|
+
$:.uniq!
|
14
14
|
|
15
15
|
require 'rubygems'
|
16
16
|
require 'rake'
|
@@ -18,58 +18,10 @@ require 'rake'
|
|
18
18
|
require 'minitest/autorun'
|
19
19
|
require 'mocha/setup'
|
20
20
|
|
21
|
-
unless defined?(Minitest::Test)
|
22
|
-
Minitest::Test = MiniTest::Unit::TestCase
|
23
|
-
end
|
24
|
-
|
25
21
|
require 'hometown'
|
26
22
|
Hometown.watch(::Thread)
|
27
23
|
|
28
|
-
|
29
|
-
# disable the threads everywhere, but not all tests have newrelic.yml loaded to
|
30
|
-
# us to rely on, so instead we'll just watch for it.
|
31
|
-
class Minitest::Test
|
32
|
-
def before_setup
|
33
|
-
if self.respond_to?(:name)
|
34
|
-
test_method_name = self.name
|
35
|
-
else
|
36
|
-
test_method_name = self.__name__
|
37
|
-
end
|
38
|
-
|
39
|
-
NewRelic::Agent.logger.info("*** #{self.class}##{test_method_name} **")
|
40
|
-
|
41
|
-
@__thread_count = ruby_threads.count
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
def after_teardown
|
46
|
-
unfreeze_time
|
47
|
-
|
48
|
-
threads = ruby_threads
|
49
|
-
if @__thread_count != threads.count
|
50
|
-
backtraces = threads.map do |thread|
|
51
|
-
trace = Hometown.for(thread)
|
52
|
-
trace.backtrace.join("\n ")
|
53
|
-
end.join("\n\n")
|
54
|
-
|
55
|
-
fail "Thread count changed in this test from #{@__thread_count} to #{threads.count}\n#{backtraces}"
|
56
|
-
end
|
57
|
-
|
58
|
-
super
|
59
|
-
end
|
60
|
-
|
61
|
-
# We only want to count threads that were spun up from Ruby (i.e.
|
62
|
-
# Thread.new) JRuby has system threads we don't care to track.
|
63
|
-
def ruby_threads
|
64
|
-
Thread.list.select { |t| Hometown.for(t) }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Dir.glob('test/helpers/*').each { |f| require f }
|
69
|
-
|
70
|
-
Dir.glob(File.join(NEWRELIC_PLUGIN_DIR,'test/helpers/*.rb')).each do |helper|
|
71
|
-
require helper
|
72
|
-
end
|
24
|
+
Dir[File.expand_path('../helpers/*', __FILE__)].each {|f| require f.sub(/.*test\//,'')}
|
73
25
|
|
74
26
|
# We can speed things up in tests that don't need to load rails.
|
75
27
|
# You can also run the tests in a mode without rails. Many tests
|
@@ -79,7 +31,7 @@ if ENV["NO_RAILS"]
|
|
79
31
|
require 'newrelic_rpm'
|
80
32
|
else
|
81
33
|
begin
|
82
|
-
require 'config/environment'
|
34
|
+
require './config/environment'
|
83
35
|
require 'newrelic_rpm'
|
84
36
|
rescue LoadError
|
85
37
|
puts "Running tests in standalone mode."
|
@@ -105,162 +57,3 @@ end
|
|
105
57
|
# This is the public method recommended for plugin developers to share our
|
106
58
|
# agent helpers. Use it so we don't accidentally break it.
|
107
59
|
NewRelic::Agent.require_test_helper
|
108
|
-
|
109
|
-
def default_service(stubbed_method_overrides = {})
|
110
|
-
service = stub
|
111
|
-
stubbed_method_defaults = {
|
112
|
-
:connect => {},
|
113
|
-
:shutdown => nil,
|
114
|
-
:agent_id= => nil,
|
115
|
-
:agent_id => nil,
|
116
|
-
:collector => stub_everything,
|
117
|
-
:request_timeout= => nil,
|
118
|
-
:metric_data => nil,
|
119
|
-
:error_data => nil,
|
120
|
-
:transaction_sample_data => nil,
|
121
|
-
:sql_trace_data => nil,
|
122
|
-
:get_agent_commands => [],
|
123
|
-
:agent_command_results => nil,
|
124
|
-
:analytic_event_data => nil,
|
125
|
-
:valid_to_marshal? => true
|
126
|
-
}
|
127
|
-
|
128
|
-
service.stubs(stubbed_method_defaults.merge(stubbed_method_overrides))
|
129
|
-
|
130
|
-
# When session gets called yield to the given block.
|
131
|
-
service.stubs(:session).yields
|
132
|
-
service
|
133
|
-
end
|
134
|
-
|
135
|
-
def with_verbose_logging
|
136
|
-
orig_logger = NewRelic::Agent.logger
|
137
|
-
$stderr.puts '', '---', ''
|
138
|
-
new_logger = NewRelic::Agent::AgentLogger.new('', Logger.new($stderr) )
|
139
|
-
NewRelic::Agent.logger = new_logger
|
140
|
-
|
141
|
-
with_config(:log_level => 'debug') do
|
142
|
-
yield
|
143
|
-
end
|
144
|
-
ensure
|
145
|
-
NewRelic::Agent.logger = orig_logger
|
146
|
-
end
|
147
|
-
|
148
|
-
# Need to be a bit sloppy when testing against the logging--let everything
|
149
|
-
# through, but check we (at least) get our particular message we care about
|
150
|
-
def expects_logging(level, *with_params)
|
151
|
-
::NewRelic::Agent.logger.stubs(level)
|
152
|
-
::NewRelic::Agent.logger.expects(level).with(*with_params).once
|
153
|
-
end
|
154
|
-
|
155
|
-
def expects_no_logging(level)
|
156
|
-
::NewRelic::Agent.logger.expects(level).never
|
157
|
-
end
|
158
|
-
|
159
|
-
# Sometimes need to test cases where we muddle with the global logger
|
160
|
-
# If so, use this method to ensure it gets restored after we're done
|
161
|
-
def without_logger
|
162
|
-
logger = ::NewRelic::Agent.logger
|
163
|
-
::NewRelic::Agent.logger = nil
|
164
|
-
yield
|
165
|
-
ensure
|
166
|
-
::NewRelic::Agent.logger = logger
|
167
|
-
end
|
168
|
-
|
169
|
-
def fixture_tcp_socket( response )
|
170
|
-
# Don't actually talk to Google.
|
171
|
-
socket = stub("socket") do
|
172
|
-
stubs(:closed?).returns(false)
|
173
|
-
stubs(:close)
|
174
|
-
stubs(:setsockopt)
|
175
|
-
|
176
|
-
# Simulate a bunch of socket-ey stuff since Mocha doesn't really
|
177
|
-
# provide any other way to do it
|
178
|
-
class << self
|
179
|
-
attr_accessor :response, :write_checker
|
180
|
-
end
|
181
|
-
|
182
|
-
def self.check_write
|
183
|
-
self.write_checker = Proc.new
|
184
|
-
end
|
185
|
-
|
186
|
-
def self.write( buf )
|
187
|
-
self.write_checker.call( buf ) if self.write_checker
|
188
|
-
buf.length
|
189
|
-
end
|
190
|
-
|
191
|
-
def self.sysread( size, buf='' )
|
192
|
-
@data ||= response.to_s
|
193
|
-
raise EOFError if @data.empty?
|
194
|
-
buf.replace @data.slice!( 0, size )
|
195
|
-
buf
|
196
|
-
end
|
197
|
-
class << self
|
198
|
-
alias_method :read_nonblock, :sysread
|
199
|
-
end
|
200
|
-
|
201
|
-
end
|
202
|
-
|
203
|
-
socket.response = response
|
204
|
-
TCPSocket.stubs( :open ).returns( socket )
|
205
|
-
|
206
|
-
return socket
|
207
|
-
end
|
208
|
-
|
209
|
-
def dummy_mysql_explain_result(hash=nil)
|
210
|
-
hash ||= {
|
211
|
-
'Id' => '1',
|
212
|
-
'Select Type' => 'SIMPLE',
|
213
|
-
'Table' => 'sandwiches',
|
214
|
-
'Type' => 'range',
|
215
|
-
'Possible Keys' => 'PRIMARY',
|
216
|
-
'Key' => 'PRIMARY',
|
217
|
-
'Key Length' => '4',
|
218
|
-
'Ref' => '',
|
219
|
-
'Rows' => '1',
|
220
|
-
'Extra' => 'Using index'
|
221
|
-
}
|
222
|
-
explain_result = mock('explain result')
|
223
|
-
explain_result.stubs(:each_hash).yields(hash)
|
224
|
-
explain_result
|
225
|
-
end
|
226
|
-
|
227
|
-
module TransactionSampleTestHelper
|
228
|
-
module_function
|
229
|
-
def make_sql_transaction(*sql)
|
230
|
-
sampler = nil
|
231
|
-
state = NewRelic::Agent::TransactionState.tl_get
|
232
|
-
|
233
|
-
in_transaction('/path') do
|
234
|
-
sampler = NewRelic::Agent.instance.transaction_sampler
|
235
|
-
sampler.notice_push_frame(state, "a")
|
236
|
-
explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
|
237
|
-
sql.each {|sql_statement| sampler.notice_sql(sql_statement, {:adapter => "mysql"}, 0, state, explainer) }
|
238
|
-
sleep 0.02
|
239
|
-
yield if block_given?
|
240
|
-
sampler.notice_pop_frame(state, "a")
|
241
|
-
end
|
242
|
-
|
243
|
-
return sampler.last_sample
|
244
|
-
end
|
245
|
-
|
246
|
-
def run_sample_trace(path='/path')
|
247
|
-
sampler = nil
|
248
|
-
state = NewRelic::Agent::TransactionState.tl_get
|
249
|
-
|
250
|
-
request = stub(:path => path)
|
251
|
-
|
252
|
-
in_transaction("Controller/sandwiches/index", :request => request) do
|
253
|
-
sampler = NewRelic::Agent.instance.transaction_sampler
|
254
|
-
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0, state)
|
255
|
-
sampler.notice_push_frame(state, "ab")
|
256
|
-
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0, state)
|
257
|
-
yield sampler if block_given?
|
258
|
-
sampler.notice_pop_frame(state, "ab")
|
259
|
-
sampler.notice_push_frame(state, "lew")
|
260
|
-
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0, state)
|
261
|
-
sampler.notice_pop_frame(state, "lew")
|
262
|
-
end
|
263
|
-
|
264
|
-
return sampler.last_sample
|
265
|
-
end
|
266
|
-
end
|