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
@@ -359,7 +359,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
359
359
|
|
360
360
|
def test_profile_data_does_not_normalize_encodings
|
361
361
|
@http_handle.respond_to(:profile_data, nil)
|
362
|
-
NewRelic::
|
362
|
+
NewRelic::Agent::EncodingNormalizer.expects(:normalize_object).never
|
363
363
|
@service.profile_data([])
|
364
364
|
end
|
365
365
|
|
@@ -441,122 +441,114 @@ class NewRelicServiceTest < Minitest::Test
|
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
end
|
444
|
+
def test_json_marshaller_handles_responses_from_collector
|
445
|
+
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
446
|
+
assert_equal ['beep', 'boop'], marshaller.load('{"return_value": ["beep","boop"]}')
|
447
|
+
end
|
449
448
|
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
end
|
449
|
+
def test_json_marshaller_handles_errors_from_collector
|
450
|
+
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
451
|
+
assert_raises(NewRelic::Agent::NewRelicService::CollectorError,
|
452
|
+
'JavaCrash: error message') do
|
453
|
+
marshaller.load('{"exception": {"message": "error message", "error_type": "JavaCrash"}}')
|
456
454
|
end
|
455
|
+
end
|
457
456
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
457
|
+
def test_json_marshaller_logs_on_empty_response_from_collector
|
458
|
+
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
459
|
+
expects_logging(:error, any_parameters)
|
460
|
+
assert_nil marshaller.load('')
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_json_marshaller_logs_on_nil_response_from_collector
|
464
|
+
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
465
|
+
expects_logging(:error, any_parameters)
|
466
|
+
assert_nil marshaller.load(nil)
|
467
|
+
end
|
463
468
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
469
|
+
def test_raises_serialization_error_if_json_serialization_fails
|
470
|
+
::JSON.stubs(:dump).raises(RuntimeError.new('blah'))
|
471
|
+
assert_raises(NewRelic::Agent::SerializationError) do
|
472
|
+
@service.send(:invoke_remote, 'wiggle', [{}])
|
468
473
|
end
|
474
|
+
end
|
469
475
|
|
470
|
-
|
471
|
-
|
476
|
+
def test_raises_serialization_error_if_encoding_normalization_fails
|
477
|
+
with_config(:normalize_json_string_encodings => true) do
|
478
|
+
@http_handle.respond_to(:wiggle, 'hi')
|
479
|
+
NewRelic::Agent::EncodingNormalizer.stubs(:normalize_object).raises('blah')
|
472
480
|
assert_raises(NewRelic::Agent::SerializationError) do
|
473
481
|
@service.send(:invoke_remote, 'wiggle', [{}])
|
474
482
|
end
|
475
483
|
end
|
484
|
+
end
|
476
485
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
@service.send(:invoke_remote, 'wiggle', [{}])
|
483
|
-
end
|
484
|
-
end
|
486
|
+
def test_skips_normalization_if_configured_to
|
487
|
+
@http_handle.respond_to(:wiggle, 'hello')
|
488
|
+
with_config(:normalize_json_string_encodings => false) do
|
489
|
+
NewRelic::Agent::EncodingNormalizer.expects(:normalize_object).never
|
490
|
+
@service.send(:invoke_remote, 'wiggle', [{ 'foo' => 'bar' }])
|
485
491
|
end
|
492
|
+
end
|
486
493
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
def test_json_marshaller_handles_binary_strings
|
496
|
-
input_string = (0..255).to_a.pack("C*")
|
497
|
-
roundtripped_string = roundtrip_data(input_string)
|
498
|
-
|
499
|
-
if NewRelic::LanguageSupport.supports_string_encodings?
|
500
|
-
assert_equal(Encoding.find('ASCII-8BIT'), input_string.encoding)
|
501
|
-
end
|
502
|
-
|
503
|
-
expected = force_to_utf8(input_string.dup)
|
504
|
-
assert_equal(expected, roundtripped_string)
|
505
|
-
end
|
494
|
+
def test_json_marshaller_handles_binary_strings
|
495
|
+
input_string = (0..255).to_a.pack("C*")
|
496
|
+
roundtripped_string = roundtrip_data(input_string)
|
497
|
+
assert_equal(Encoding.find('ASCII-8BIT'), input_string.encoding)
|
498
|
+
expected = force_to_utf8(input_string.dup)
|
499
|
+
assert_equal(expected, roundtripped_string)
|
500
|
+
end
|
506
501
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
roundtripped_string = roundtrip_data(input_string)
|
502
|
+
def test_json_marshaller_handles_strings_with_incorrect_encoding
|
503
|
+
input_string = (0..255).to_a.pack("C*").force_encoding("UTF-8")
|
504
|
+
roundtripped_string = roundtrip_data(input_string)
|
511
505
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
end
|
506
|
+
assert_equal(Encoding.find('UTF-8'), input_string.encoding)
|
507
|
+
expected = input_string.dup.force_encoding('ISO-8859-1').encode('UTF-8')
|
508
|
+
assert_equal(expected, roundtripped_string)
|
509
|
+
end
|
517
510
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
end
|
511
|
+
def test_json_marshaller_failure_when_not_normalizing
|
512
|
+
input_string = (0..255).to_a.pack("C*")
|
513
|
+
assert_raises(NewRelic::Agent::SerializationError) do
|
514
|
+
roundtrip_data(input_string, false)
|
523
515
|
end
|
516
|
+
end
|
524
517
|
|
525
|
-
|
526
|
-
|
527
|
-
|
518
|
+
def test_json_marshaller_should_handle_crazy_strings
|
519
|
+
root = generate_object_graph_with_crazy_strings
|
520
|
+
result = roundtrip_data(root)
|
528
521
|
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
522
|
+
# Note that there's technically a possibility of collision here:
|
523
|
+
# if two of the randomly-generated key strings happen to normalize to the
|
524
|
+
# same value, we might see <100 results, but the chances of this seem
|
525
|
+
# vanishingly small.
|
526
|
+
assert_equal(100, result.length)
|
527
|
+
end
|
535
528
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
529
|
+
def test_normalization_should_account_for_to_collector_array
|
530
|
+
binary_string = generate_random_byte_sequence
|
531
|
+
data = DummyDataClass.new(binary_string, [])
|
532
|
+
result = roundtrip_data(data)
|
540
533
|
|
541
|
-
|
542
|
-
|
543
|
-
|
534
|
+
expected_string = force_to_utf8(binary_string)
|
535
|
+
assert_equal(expected_string, result[0])
|
536
|
+
end
|
544
537
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
538
|
+
def test_normalization_should_account_for_to_collector_array_with_nested_encodings
|
539
|
+
binary_string = generate_random_byte_sequence
|
540
|
+
data = DummyDataClass.new(binary_string, [binary_string])
|
541
|
+
result = roundtrip_data(data)
|
549
542
|
|
550
|
-
|
551
|
-
|
543
|
+
expected_string = force_to_utf8(binary_string)
|
544
|
+
assert_equal(expected_string, result[0])
|
552
545
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
546
|
+
base64_encoded_compressed_json_field = result[1]
|
547
|
+
compressed_json_field = Base64.decode64(base64_encoded_compressed_json_field)
|
548
|
+
json_field = Zlib::Inflate.inflate(compressed_json_field)
|
549
|
+
field = JSON.parse(json_field)
|
557
550
|
|
558
|
-
|
559
|
-
end
|
551
|
+
assert_equal([expected_string], field)
|
560
552
|
end
|
561
553
|
|
562
554
|
def test_compress_request_if_needed_compresses_large_payloads
|
@@ -782,11 +774,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
782
774
|
end
|
783
775
|
|
784
776
|
def force_to_utf8(string)
|
785
|
-
|
786
|
-
string.force_encoding('ISO-8859-1').encode('UTF-8')
|
787
|
-
else
|
788
|
-
Iconv.iconv('utf-8', 'iso-8859-1', string).join
|
789
|
-
end
|
777
|
+
string.force_encoding('ISO-8859-1').encode('UTF-8')
|
790
778
|
end
|
791
779
|
|
792
780
|
def generate_random_byte_sequence(length=255, encoding=nil)
|
@@ -811,11 +799,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
811
799
|
end
|
812
800
|
|
813
801
|
def random_encoding
|
814
|
-
|
815
|
-
Encoding.list.sample
|
816
|
-
else
|
817
|
-
nil
|
818
|
-
end
|
802
|
+
Encoding.list.sample
|
819
803
|
end
|
820
804
|
|
821
805
|
def roundtrip_data(data, normalize = true)
|
@@ -40,24 +40,23 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
|
|
40
40
|
NewRelic::Agent::PipeChannelManager.listener.close_all_pipes
|
41
41
|
end
|
42
42
|
|
43
|
-
if NewRelic::LanguageSupport.can_fork?
|
43
|
+
if NewRelic::LanguageSupport.can_fork?
|
44
44
|
def test_listener_merges_timeslice_metrics
|
45
45
|
metric = 'Custom/test/method'
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
NewRelic::Agent.record_metric(metric, 1.0)
|
48
48
|
|
49
49
|
start_listener_with_pipe(666)
|
50
50
|
|
51
51
|
run_child(666) do
|
52
52
|
NewRelic::Agent.after_fork
|
53
53
|
new_engine = NewRelic::Agent::StatsEngine.new
|
54
|
-
new_engine.
|
54
|
+
new_engine.tl_record_unscoped_metrics(metric, 2.0)
|
55
55
|
service = NewRelic::Agent::PipeService.new(666)
|
56
56
|
service.metric_data(new_engine.harvest!)
|
57
57
|
end
|
58
58
|
|
59
59
|
assert_metrics_recorded(metric => { :total_call_time => 3.0 })
|
60
|
-
engine.reset!
|
61
60
|
end
|
62
61
|
|
63
62
|
def test_listener_merges_transaction_traces
|
@@ -259,10 +258,6 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
|
|
259
258
|
end
|
260
259
|
|
261
260
|
def test_listener_pipes_race_condition
|
262
|
-
# 1.8.7 doesn't have easy singleton_class access, but also doesn't have
|
263
|
-
# races thanks to green threads and the GIL, so pitch it!
|
264
|
-
return if RUBY_VERSION < "1.9.2"
|
265
|
-
|
266
261
|
begin
|
267
262
|
listener = NewRelic::Agent::PipeChannelManager.listener
|
268
263
|
listener.instance_variable_set(:@select_timeout, 0.00001)
|
@@ -36,8 +36,7 @@ class PipeServiceTest < Minitest::Test
|
|
36
36
|
service.metric_data({})
|
37
37
|
end
|
38
38
|
|
39
|
-
if NewRelic::LanguageSupport.can_fork?
|
40
|
-
!NewRelic::LanguageSupport.using_version?('1.9.1')
|
39
|
+
if NewRelic::LanguageSupport.can_fork?
|
41
40
|
|
42
41
|
def test_metric_data
|
43
42
|
received_data = data_from_forked_process do
|
@@ -128,7 +127,7 @@ class PipeServiceTest < Minitest::Test
|
|
128
127
|
|
129
128
|
def generate_metric_data(metric_name, data=1.0)
|
130
129
|
engine = NewRelic::Agent::StatsEngine.new
|
131
|
-
engine.
|
130
|
+
engine.tl_record_unscoped_metrics(metric_name, data)
|
132
131
|
engine.harvest!
|
133
132
|
end
|
134
133
|
|
@@ -88,8 +88,4 @@ class NewRelic::Agent::RpmAgentTest < Minitest::Test
|
|
88
88
|
def test_agent_version_string
|
89
89
|
assert_match(/\d\.\d+\.\d+/, NewRelic::VERSION::STRING)
|
90
90
|
end
|
91
|
-
|
92
|
-
def test_record_transaction
|
93
|
-
NewRelic::Agent.record_transaction 0.5, 'uri' => "/users/create?foo=bar"
|
94
|
-
end
|
95
91
|
end
|
@@ -2,8 +2,8 @@
|
|
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 File.expand_path
|
6
|
-
require '
|
5
|
+
require File.expand_path '../../../test_helper', __FILE__
|
6
|
+
require 'new_relic/agent/event_buffer_test_cases'
|
7
7
|
|
8
8
|
module NewRelic::Agent
|
9
9
|
class SampledBufferTest < Minitest::Test
|
@@ -48,4 +48,32 @@ class NewRelic::Agent::Samplers::CpuSamplerTest < Minitest::Test
|
|
48
48
|
Object.const_set('JRUBY_VERSION', string)
|
49
49
|
end
|
50
50
|
|
51
|
+
def test_cpu_sampler_records_user_and_system_time
|
52
|
+
timeinfo0 = mock
|
53
|
+
timeinfo0.stubs(:utime).returns(10.0)
|
54
|
+
timeinfo0.stubs(:stime).returns(5.0)
|
55
|
+
|
56
|
+
timeinfo1 = mock
|
57
|
+
timeinfo1.stubs(:utime).returns(14.0) # +5s
|
58
|
+
timeinfo1.stubs(:stime).returns(7.0) # +2s
|
59
|
+
|
60
|
+
elapsed = 10
|
61
|
+
|
62
|
+
freeze_time
|
63
|
+
Process.stubs(:times).returns(timeinfo0, timeinfo1)
|
64
|
+
NewRelic::Agent::SystemInfo.stubs(:num_logical_processors).returns(4)
|
65
|
+
|
66
|
+
s = NewRelic::Agent::Samplers::CpuSampler.new # this calls poll
|
67
|
+
advance_time(elapsed)
|
68
|
+
s.poll
|
69
|
+
|
70
|
+
assert_metrics_recorded({
|
71
|
+
'CPU/User Time' => { :call_count => 1, :total_call_time => 4.0 },
|
72
|
+
'CPU/System Time' => { :call_count => 1, :total_call_time => 2.0 },
|
73
|
+
# (4s user time) / ((10s elapsed time) * 4 cpus) = 0.1
|
74
|
+
'CPU/User/Utilization' => { :call_count => 1, :total_call_time => 0.1 },
|
75
|
+
# (2s system time) / ((10s elapsed time) * 4 cpus) = 0.05
|
76
|
+
'CPU/System/Utilization' => { :call_count => 1, :total_call_time => 0.05 }
|
77
|
+
})
|
78
|
+
end
|
51
79
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# encoding: utf-8
|
3
|
+
# This file is distributed under New Relic's license terms.
|
4
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
5
|
+
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
7
|
+
require 'new_relic/agent/samplers/memory_sampler'
|
8
|
+
|
9
|
+
class NewRelic::Agent::Samplers::MemorySamplerTest < Minitest::Test
|
10
|
+
def setup
|
11
|
+
@stats_engine = NewRelic::Agent::StatsEngine.new
|
12
|
+
NewRelic::Agent.instance.stubs(:stats_engine).returns(@stats_engine)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_memory__default
|
16
|
+
stub_sampler_get_memory
|
17
|
+
s = NewRelic::Agent::Samplers::MemorySampler.new
|
18
|
+
s.poll
|
19
|
+
s.poll
|
20
|
+
s.poll
|
21
|
+
assert_metrics_recorded "Memory/Physical" => {:call_count => 3, :total_call_time => 999}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_memory__linux
|
25
|
+
return if RUBY_PLATFORM =~ /darwin/
|
26
|
+
NewRelic::Agent::Samplers::MemorySampler.any_instance.stubs(:platform).returns 'linux'
|
27
|
+
stub_sampler_get_memory
|
28
|
+
s = NewRelic::Agent::Samplers::MemorySampler.new
|
29
|
+
s.poll
|
30
|
+
s.poll
|
31
|
+
s.poll
|
32
|
+
|
33
|
+
assert_metrics_recorded "Memory/Physical" => {:call_count => 3, :total_call_time => 999}
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_memory__solaris
|
37
|
+
return if defined? JRuby
|
38
|
+
NewRelic::Agent::Samplers::MemorySampler.any_instance.stubs(:platform).returns 'solaris'
|
39
|
+
NewRelic::Agent::Samplers::MemorySampler::ShellPS.any_instance.stubs(:get_memory).returns 999
|
40
|
+
s = NewRelic::Agent::Samplers::MemorySampler.new
|
41
|
+
s.poll
|
42
|
+
assert_metrics_recorded "Memory/Physical" => {:call_count => 1, :total_call_time => 999}
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_memory__windows
|
46
|
+
return if defined? JRuby
|
47
|
+
NewRelic::Agent::Samplers::MemorySampler.any_instance.stubs(:platform).returns 'win32'
|
48
|
+
assert_raises NewRelic::Agent::Sampler::Unsupported do
|
49
|
+
NewRelic::Agent::Samplers::MemorySampler.new
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_memory__is_supported
|
54
|
+
NewRelic::Agent::Samplers::MemorySampler.stubs(:platform).returns 'windows'
|
55
|
+
assert !NewRelic::Agent::Samplers::MemorySampler.supported_on_this_platform? || defined? JRuby
|
56
|
+
end
|
57
|
+
|
58
|
+
def stub_sampler_get_memory
|
59
|
+
if defined? JRuby
|
60
|
+
NewRelic::Agent::Samplers::MemorySampler::JavaHeapSampler.any_instance.stubs(:get_memory).returns 333
|
61
|
+
else
|
62
|
+
NewRelic::Agent::Samplers::MemorySampler::ShellPS.any_instance.stubs(:get_memory).returns 333
|
63
|
+
NewRelic::Agent::Samplers::MemorySampler::ProcStatus.any_instance.stubs(:get_memory).returns 333
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
-
require '
|
6
|
+
require 'new_relic/agent/event_buffer_test_cases'
|
7
7
|
require 'new_relic/agent/sized_buffer'
|
8
8
|
|
9
9
|
module NewRelic::Agent
|
@@ -30,7 +30,7 @@ class NewRelic::Agent::StatsEngine
|
|
30
30
|
|
31
31
|
def test_init_profiler_for_ruby_19_and_greater
|
32
32
|
return unless defined?(::GC::Profiler)
|
33
|
-
return if NewRelic::LanguageSupport.
|
33
|
+
return if NewRelic::LanguageSupport.jruby?
|
34
34
|
|
35
35
|
::GC::Profiler.stubs(:enabled?).returns(true)
|
36
36
|
|
@@ -38,26 +38,14 @@ class NewRelic::Agent::StatsEngine
|
|
38
38
|
GCProfiler.init.class)
|
39
39
|
end
|
40
40
|
|
41
|
-
def test_init_profiler_for_rbx_uses_stdlib
|
42
|
-
return unless defined?(::Rubinius::GC)
|
43
|
-
|
44
|
-
assert_equal(GCProfiler::CoreGCProfiler,
|
45
|
-
GCProfiler.init.class)
|
46
|
-
end
|
47
|
-
|
48
41
|
def test_record_delta_returns_nil_when_snapshots_are_nil
|
49
42
|
result = GCProfiler.record_delta(nil, nil)
|
50
43
|
assert_nil(result)
|
51
44
|
assert_metrics_not_recorded([GCProfiler::GC_ROLLUP, GCProfiler::GC_WEB, GCProfiler::GC_OTHER])
|
52
45
|
end
|
53
46
|
|
54
|
-
using_jruby = NewRelic::LanguageSupport.jruby?
|
55
|
-
using_ree = NewRelic::LanguageSupport.ree?
|
56
|
-
using_ruby18 = NewRelic::LanguageSupport.using_version?('1.8')
|
57
|
-
using_ruby19_plus = !using_ruby18
|
58
|
-
|
59
47
|
# Only run these tests in environments where GCProfiler is usable
|
60
|
-
if !
|
48
|
+
if !NewRelic::LanguageSupport.jruby?
|
61
49
|
def test_record_delta_returns_delta_in_seconds
|
62
50
|
GCProfiler.init
|
63
51
|
|