newrelic_rpm 3.7.0.177 → 3.7.1.180
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +28 -1
- data/lib/new_relic/agent.rb +1 -2
- data/lib/new_relic/agent/agent.rb +28 -10
- data/lib/new_relic/agent/agent_logger.rb +4 -3
- data/lib/new_relic/agent/audit_logger.rb +5 -8
- data/lib/new_relic/agent/configuration/default_source.rb +24 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +21 -15
- data/lib/new_relic/agent/datastores/mongo.rb +25 -0
- data/lib/new_relic/agent/datastores/mongo/metric_generator.rb +25 -0
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +189 -0
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +39 -0
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +52 -0
- data/lib/new_relic/agent/harvester.rb +55 -0
- data/lib/new_relic/agent/instrumentation/mongo.rb +139 -0
- data/lib/new_relic/agent/instrumentation/net.rb +6 -11
- data/lib/new_relic/agent/supported_versions.rb +9 -5
- data/lib/new_relic/agent/transaction_sampler.rb +4 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/versions.rake +1 -1
- data/test/agent_helper.rb +4 -0
- data/test/environments/norails/Gemfile +3 -0
- data/test/environments/rails40/Gemfile +5 -1
- data/test/flaky_proxy/Gemfile +3 -0
- data/test/flaky_proxy/README.md +82 -0
- data/test/flaky_proxy/lib/flaky_proxy.rb +22 -0
- data/test/flaky_proxy/lib/flaky_proxy/connection.rb +45 -0
- data/test/flaky_proxy/lib/flaky_proxy/http_message.rb +105 -0
- data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +42 -0
- data/test/flaky_proxy/lib/flaky_proxy/rule.rb +75 -0
- data/test/flaky_proxy/lib/flaky_proxy/rule_set.rb +37 -0
- data/test/flaky_proxy/lib/flaky_proxy/server.rb +22 -0
- data/test/flaky_proxy/script/flaky_proxy +39 -0
- data/test/helpers/exceptions.rb +16 -0
- data/test/helpers/mongo_metric_builder.rb +29 -0
- data/test/multiverse/lib/multiverse/suite.rb +1 -0
- data/test/multiverse/suites/curb/curb_test.rb +0 -1
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +4 -3
- data/test/multiverse/suites/excon/excon_test.rb +0 -1
- data/test/multiverse/suites/httpclient/httpclient_test.rb +0 -1
- data/test/multiverse/suites/mongo/Envfile +66 -0
- data/test/multiverse/suites/mongo/config/newrelic.yml +19 -0
- data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +418 -0
- data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +36 -0
- data/test/multiverse/suites/net_http/net_http_test.rb +2 -4
- data/test/multiverse/suites/rails/Envfile +4 -4
- data/test/multiverse/suites/rails/config/newrelic.yml +1 -1
- data/test/multiverse/suites/rails/error_tracing_test.rb +7 -7
- data/test/multiverse/suites/sidekiq/Envfile +1 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +5 -3
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +5 -3
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +0 -1
- data/test/new_relic/agent/agent_logger_test.rb +9 -1
- data/test/new_relic/agent/agent_test.rb +66 -1
- data/test/new_relic/agent/agent_test_controller.rb +1 -2
- data/test/new_relic/agent/audit_logger_test.rb +12 -4
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +11 -2
- data/test/new_relic/agent/cpu_sampler_test.rb +1 -0
- data/test/new_relic/agent/cross_app_tracing_test.rb +60 -0
- data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +43 -0
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +301 -0
- data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +91 -0
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +71 -0
- data/test/new_relic/agent/harvester_test.rb +85 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +5 -0
- data/test/new_relic/agent/worker_loop_test.rb +3 -5
- data/test/new_relic/http_client_test_cases.rb +65 -81
- data/test/new_relic/noticed_error_test.rb +14 -16
- data/test/performance/lib/performance.rb +1 -0
- data/test/performance/lib/performance/console_reporter.rb +6 -2
- data/test/performance/lib/performance/instrumentor.rb +1 -15
- data/test/performance/lib/performance/platform.rb +35 -0
- data/test/performance/lib/performance/test_case.rb +16 -1
- data/test/performance/suites/marshalling.rb +73 -0
- metadata +48 -19
- metadata.gz.sig +1 -2
@@ -0,0 +1,36 @@
|
|
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 'mongo'
|
6
|
+
require 'newrelic_rpm'
|
7
|
+
require 'new_relic/agent/datastores/mongo'
|
8
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
9
|
+
|
10
|
+
if !NewRelic::Agent::Datastores::Mongo.is_supported_version?
|
11
|
+
|
12
|
+
class NewRelic::Agent::Instrumentation::MongoInstrumentationTest < MiniTest::Unit::TestCase
|
13
|
+
include Mongo
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@client = Mongo::Connection.new(ENV["MONGO_HOST"], ENV["MONGO_PORT"].to_i)
|
17
|
+
@database_name = 'multiverse'
|
18
|
+
@database = @client.db(@database_name)
|
19
|
+
@collection_name = 'tribbles'
|
20
|
+
@collection = @database.collection(@collection_name)
|
21
|
+
|
22
|
+
@tribble = {'name' => 'soterios johnson'}
|
23
|
+
|
24
|
+
NewRelic::Agent.drop_buffered_data
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
NewRelic::Agent.drop_buffered_data
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_records_metrics_for_insert
|
32
|
+
@collection.insert(@tribble)
|
33
|
+
assert_metrics_not_recorded(["Datastore/allWeb", "Datastore/allOther"])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
require "net/http"
|
6
6
|
require "newrelic_rpm"
|
7
|
-
require "test/unit"
|
8
7
|
require "http_client_test_cases"
|
9
8
|
|
10
9
|
require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
|
@@ -108,8 +107,7 @@ class NetHttpTest < MiniTest::Unit::TestCase
|
|
108
107
|
http = create_http(default_uri)
|
109
108
|
http.request(Net::HTTP::Get.new(default_uri.request_uri))
|
110
109
|
|
111
|
-
assert_metrics_recorded(
|
112
|
-
'External/localhost/Net::HTTP/GET'
|
113
|
-
])
|
110
|
+
assert_metrics_recorded(
|
111
|
+
'External/localhost/Net::HTTP/GET' => { :call_count => 1 })
|
114
112
|
end
|
115
113
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
if RUBY_VERSION >= '1.9.3'
|
2
2
|
gemfile <<-RB
|
3
|
-
gem 'rails', '~>4.0.
|
3
|
+
gem 'rails', '~>4.0.2'
|
4
4
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
5
5
|
RB
|
6
6
|
end
|
@@ -8,19 +8,19 @@ end
|
|
8
8
|
omit_mocha!
|
9
9
|
|
10
10
|
gemfile <<-RB
|
11
|
-
gem 'rails', '~>3.2.
|
11
|
+
gem 'rails', '~>3.2.16'
|
12
12
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
13
13
|
gem 'minitest_tu_shim', :require => false
|
14
14
|
RB
|
15
15
|
|
16
16
|
gemfile <<-RB
|
17
|
-
gem 'rails', '~>3.1.
|
17
|
+
gem 'rails', '~>3.1.12'
|
18
18
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
19
19
|
gem 'minitest_tu_shim', :require => false
|
20
20
|
RB
|
21
21
|
|
22
22
|
gemfile <<-RB
|
23
|
-
gem 'rails', '~>3.0.
|
23
|
+
gem 'rails', '~>3.0.20'
|
24
24
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
25
25
|
gem 'minitest_tu_shim', :require => false
|
26
26
|
RB
|
@@ -6,9 +6,12 @@
|
|
6
6
|
require 'rails/test_help'
|
7
7
|
require 'fake_collector'
|
8
8
|
require 'multiverse_helpers'
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'helpers', 'exceptions'))
|
9
10
|
|
10
11
|
class ErrorController < ApplicationController
|
11
12
|
include Rails.application.routes.url_helpers
|
13
|
+
include NewRelic::TestHelpers::Exceptions
|
14
|
+
|
12
15
|
newrelic_ignore :only => :ignored_action
|
13
16
|
|
14
17
|
def controller_error
|
@@ -32,11 +35,11 @@ class ErrorController < ApplicationController
|
|
32
35
|
end
|
33
36
|
|
34
37
|
def ignored_error
|
35
|
-
raise IgnoredError.new('this error should not be noticed')
|
38
|
+
raise NewRelic::TestHelpers::Exceptions::IgnoredError.new('this error should not be noticed')
|
36
39
|
end
|
37
40
|
|
38
41
|
def server_ignored_error
|
39
|
-
raise ServerIgnoredError.new('this is a server ignored error')
|
42
|
+
raise NewRelic::TestHelpers::Exceptions::ServerIgnoredError.new('this is a server ignored error')
|
40
43
|
end
|
41
44
|
|
42
45
|
def frozen_error
|
@@ -65,9 +68,6 @@ class ErrorController < ApplicationController
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
class IgnoredError < StandardError; end
|
69
|
-
class ServerIgnoredError < StandardError; end
|
70
|
-
|
71
71
|
class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
72
72
|
extend Multiverse::Color
|
73
73
|
|
@@ -258,7 +258,7 @@ class ErrorsWithSSCTest < ErrorsWithoutSSCTest
|
|
258
258
|
$collector.stub('connect', {
|
259
259
|
"listen_to_server_config" => true,
|
260
260
|
"agent_run_id" => 1,
|
261
|
-
"error_collector.ignore_errors" => 'IgnoredError,ServerIgnoredError',
|
261
|
+
"error_collector.ignore_errors" => 'NewRelic::TestHelpers::Exceptions::IgnoredError,NewRelic::TestHelpers::Exceptions::ServerIgnoredError',
|
262
262
|
"error_collector.enabled" => true,
|
263
263
|
"error_collector.capture_source" => true,
|
264
264
|
"collect_errors" => true
|
@@ -272,7 +272,7 @@ class ErrorsWithSSCTest < ErrorsWithoutSSCTest
|
|
272
272
|
def test_should_ignore_server_ignored_errors
|
273
273
|
get '/error/server_ignored_error'
|
274
274
|
assert(@error_collector.errors.empty?,
|
275
|
-
'Noticed an error that should have been ignored')
|
275
|
+
'Noticed an error that should have been ignored' + @error_collector.errors.join(', '))
|
276
276
|
end
|
277
277
|
|
278
278
|
end
|
@@ -5,6 +5,9 @@
|
|
5
5
|
require 'sinatra'
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), 'sinatra_test_cases'))
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper'))
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'helpers', 'exceptions'))
|
9
|
+
|
10
|
+
include NewRelic::TestHelpers::Exceptions
|
8
11
|
|
9
12
|
configure do
|
10
13
|
# display exceptions so we see what's going on
|
@@ -40,9 +43,8 @@ get '/pass' do
|
|
40
43
|
"I'm not a teapot."
|
41
44
|
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
set(:error_condition) { |_| condition { raise Error } }
|
46
|
+
error(NewRelic::TestHelpers::Exceptions::TestError) { halt 200, 'nothing happened' }
|
47
|
+
set(:error_condition) { |_| condition { raise NewRelic::TestHelpers::Exceptions::TestError } }
|
46
48
|
get('/error', :error_condition => true) { }
|
47
49
|
|
48
50
|
set(:precondition_check) do |_|
|
@@ -4,8 +4,11 @@
|
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__), 'sinatra_test_cases'))
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper'))
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'helpers', 'exceptions'))
|
7
8
|
|
8
9
|
class SinatraModularTestApp < Sinatra::Base
|
10
|
+
include NewRelic::TestHelpers::Exceptions
|
11
|
+
|
9
12
|
configure do
|
10
13
|
# display exceptions so we see what's going on
|
11
14
|
disable :show_exceptions
|
@@ -40,9 +43,8 @@ class SinatraModularTestApp < Sinatra::Base
|
|
40
43
|
"I'm not a teapot."
|
41
44
|
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
condition { raise Error }
|
46
|
+
error(NewRelic::TestHelpers::Exceptions::TestError) { halt 200, 'nothing happened' }
|
47
|
+
condition { raise NewRelic::TestHelpers::Exceptions::TestError }
|
46
48
|
get('/error') { }
|
47
49
|
|
48
50
|
condition do
|
@@ -260,7 +260,15 @@ class AgentLoggerTest < Test::Unit::TestCase
|
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
|
-
|
263
|
+
def test_should_cache_hostname
|
264
|
+
Socket.expects(:gethostname).once.returns('cachey-mccaherson')
|
265
|
+
logger = create_basic_logger
|
266
|
+
logger.warn("one")
|
267
|
+
logger.warn("two")
|
268
|
+
logger.warn("three")
|
269
|
+
host_regex = /cachey-mccaherson/
|
270
|
+
assert_logged(host_regex, host_regex, host_regex)
|
271
|
+
end
|
264
272
|
|
265
273
|
#
|
266
274
|
# Helpers
|
@@ -7,6 +7,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
9
|
class AgentTest < Test::Unit::TestCase
|
10
|
+
include NewRelic::TestHelpers::Exceptions
|
10
11
|
|
11
12
|
def setup
|
12
13
|
super
|
@@ -471,8 +472,72 @@ module NewRelic
|
|
471
472
|
@agent.send(:graceful_disconnect)
|
472
473
|
assert_equal(1, before_shutdown_call_count)
|
473
474
|
end
|
474
|
-
end
|
475
475
|
|
476
|
+
def test_trap_signals_for_litespeed
|
477
|
+
Signal.expects(:trap).with('SIGUSR1', 'IGNORE')
|
478
|
+
Signal.expects(:trap).with('SIGTERM', 'IGNORE')
|
479
|
+
|
480
|
+
with_config(:dispatcher => :litespeed) do
|
481
|
+
@agent.trap_signals_for_litespeed
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
def test_stop_worker_loop_runs_loop_before_exit_with_force_send_config
|
486
|
+
fake_loop = mock
|
487
|
+
fake_loop.expects(:run_task)
|
488
|
+
fake_loop.stubs(:stop)
|
489
|
+
|
490
|
+
@agent.instance_variable_set(:@worker_loop, fake_loop)
|
491
|
+
|
492
|
+
with_config(:force_send => true) do
|
493
|
+
@agent.stop_worker_loop
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
def test_stop_worker_loop_doesnt_run_loop_if_force_send_is_false
|
498
|
+
fake_loop = mock
|
499
|
+
fake_loop.expects(:run_task).never
|
500
|
+
fake_loop.stubs(:stop)
|
501
|
+
|
502
|
+
@agent.instance_variable_set(:@worker_loop, fake_loop)
|
503
|
+
|
504
|
+
with_config(:force_send => false) do
|
505
|
+
@agent.stop_worker_loop
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
def test_stop_worker_loop_stops_the_loop
|
510
|
+
fake_loop = mock
|
511
|
+
fake_loop.expects(:stop)
|
512
|
+
|
513
|
+
@agent.instance_variable_set(:@worker_loop, fake_loop)
|
514
|
+
|
515
|
+
@agent.stop_worker_loop
|
516
|
+
end
|
517
|
+
|
518
|
+
def test_untraced_graceful_disconnect_logs_errors
|
519
|
+
NewRelic::Agent.stubs(:disable_all_tracing).raises(TestError, 'test')
|
520
|
+
::NewRelic::Agent.logger.expects(:error).with(is_a(TestError))
|
521
|
+
|
522
|
+
@agent.untraced_graceful_disconnect
|
523
|
+
end
|
524
|
+
|
525
|
+
def test_revert_to_default_configuration_removes_manual_and_server_source
|
526
|
+
server_config = NewRelic::Agent::Configuration::ServerSource.new({})
|
527
|
+
Agent.config.apply_config(server_config, 1)
|
528
|
+
|
529
|
+
config_classes = NewRelic::Agent.config.config_stack.map(&:class)
|
530
|
+
|
531
|
+
assert_includes config_classes, NewRelic::Agent::Configuration::ManualSource
|
532
|
+
assert_includes config_classes, NewRelic::Agent::Configuration::ServerSource
|
533
|
+
|
534
|
+
@agent.revert_to_default_configuration
|
535
|
+
|
536
|
+
config_classes = NewRelic::Agent.config.config_stack.map(&:class)
|
537
|
+
assert !config_classes.include?(NewRelic::Agent::Configuration::ManualSource)
|
538
|
+
assert !config_classes.include?(NewRelic::Agent::Configuration::ServerSource)
|
539
|
+
end
|
540
|
+
end
|
476
541
|
|
477
542
|
class AgentStartingTest < Test::Unit::TestCase
|
478
543
|
def test_no_service_if_not_monitoring
|
@@ -11,6 +11,7 @@ class NewRelic::Agent::SuperclassController < ActionController::Base
|
|
11
11
|
end
|
12
12
|
# This is a controller class used in testing controller instrumentation
|
13
13
|
class NewRelic::Agent::AgentTestController < NewRelic::Agent::SuperclassController
|
14
|
+
include NewRelic::TestHelpers::Exceptions
|
14
15
|
# filter_parameter_logging :social_security_number
|
15
16
|
|
16
17
|
@@headers_to_add = nil
|
@@ -42,8 +43,6 @@ class NewRelic::Agent::AgentTestController < NewRelic::Agent::SuperclassControll
|
|
42
43
|
def oops
|
43
44
|
raise "error in before filter"
|
44
45
|
end
|
45
|
-
class TestException < RuntimeError
|
46
|
-
end
|
47
46
|
|
48
47
|
def rescue_action_locally(exception)
|
49
48
|
if exception.is_a? TestException
|
@@ -12,7 +12,6 @@ class AuditLoggerTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
@uri = "http://really.notreal"
|
14
14
|
@marshaller = NewRelic::Agent::NewRelicService::Marshaller.new
|
15
|
-
@hostname = 'dummyhost'
|
16
15
|
@dummy_data = {
|
17
16
|
'foo' => [1, 2, 3],
|
18
17
|
'bar' => {
|
@@ -20,7 +19,6 @@ class AuditLoggerTest < Test::Unit::TestCase
|
|
20
19
|
'jingle' => 'bells'
|
21
20
|
}
|
22
21
|
}
|
23
|
-
Socket.stubs(:gethostname).returns(@hostname)
|
24
22
|
end
|
25
23
|
|
26
24
|
def setup_fake_logger
|
@@ -53,11 +51,12 @@ class AuditLoggerTest < Test::Unit::TestCase
|
|
53
51
|
end
|
54
52
|
|
55
53
|
def test_log_formatter
|
56
|
-
|
54
|
+
Socket.stubs(:gethostname).returns('dummyhost')
|
55
|
+
formatter = NewRelic::Agent::AuditLogger.new.create_log_formatter
|
57
56
|
time = '2012-01-01 00:00:00'
|
58
57
|
msg = 'hello'
|
59
58
|
result = formatter.call(Logger::INFO, time, 'bleh', msg)
|
60
|
-
expected = "[2012-01-01 00:00:00
|
59
|
+
expected = "[2012-01-01 00:00:00 dummyhost (#{$$})] : hello\n"
|
61
60
|
assert_equal(expected, result)
|
62
61
|
end
|
63
62
|
|
@@ -120,4 +119,13 @@ class AuditLoggerTest < Test::Unit::TestCase
|
|
120
119
|
assert_log_contains_string(JSON.dump(@dummy_data))
|
121
120
|
end
|
122
121
|
end
|
122
|
+
|
123
|
+
def test_should_cache_hostname
|
124
|
+
Socket.expects(:gethostname).once.returns('cachey-mccaherson')
|
125
|
+
setup_fake_logger
|
126
|
+
3.times do
|
127
|
+
@logger.log_request(@uri, @dummy_data, @marshaller)
|
128
|
+
end
|
129
|
+
assert_log_contains_string('cachey-mccaherson')
|
130
|
+
end
|
123
131
|
end
|
@@ -33,6 +33,10 @@ class OrphanedConfigTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
AGENT_CONFIG_PATTERN = /Agent\.config\[:['"]?([a-z\._]+)['"]?\]/
|
37
|
+
REGISTER_CALLBACK_PATTERN = /register_callback\(:['"]?([a-z\._]+)['"]?\)/
|
38
|
+
NAMED_DEPENDENCY_PATTERN = /^\s*named[ (]+\:?([a-z\._]+).*$/
|
39
|
+
|
36
40
|
def test_all_default_source_config_keys_are_used_in_the_agent
|
37
41
|
non_test_files = all_rb_files.reject { |filename| filename.include? 'test.rb' }
|
38
42
|
|
@@ -41,8 +45,9 @@ class OrphanedConfigTest < Test::Unit::TestCase
|
|
41
45
|
|
42
46
|
lines.each_with_index do |line, index|
|
43
47
|
captures = []
|
44
|
-
captures << line.scan(
|
45
|
-
captures << line.scan(
|
48
|
+
captures << line.scan(AGENT_CONFIG_PATTERN)
|
49
|
+
captures << line.scan(REGISTER_CALLBACK_PATTERN)
|
50
|
+
captures << line.scan(NAMED_DEPENDENCY_PATTERN).map(&method(:disable_name))
|
46
51
|
|
47
52
|
next if captures.empty?
|
48
53
|
|
@@ -54,4 +59,8 @@ class OrphanedConfigTest < Test::Unit::TestCase
|
|
54
59
|
|
55
60
|
assert_empty @default_keys
|
56
61
|
end
|
62
|
+
|
63
|
+
def disable_name(names)
|
64
|
+
names.map { |name| "disable_#{name}" }
|
65
|
+
end
|
57
66
|
end
|
@@ -0,0 +1,60 @@
|
|
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.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'new_relic/agent/cross_app_tracing'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
class CrossAppTracingTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
attr_reader :segment, :request, :response
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@segment = stub_everything
|
16
|
+
@request = stub_everything(:uri => URI.parse("http://newrelic.com"),
|
17
|
+
:method => "GET")
|
18
|
+
@response = stub_everything
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_start_trace
|
22
|
+
t0, segment = CrossAppTracing.start_trace(request)
|
23
|
+
assert_not_nil t0
|
24
|
+
assert_not_nil segment
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_start_trace_has_time_even_on_agent_failure
|
28
|
+
NewRelic::Agent.instance.stats_engine.stubs(:push_scope).raises("Boom!")
|
29
|
+
t0, segment = CrossAppTracing.start_trace(request)
|
30
|
+
assert_not_nil t0
|
31
|
+
assert_nil segment
|
32
|
+
end
|
33
|
+
|
34
|
+
# Since we log and swallow errors, assert on the logging to ensure these
|
35
|
+
# paths are cleanly accepting nils, not just smothering the exceptions.
|
36
|
+
|
37
|
+
def test_finish_trace_allows_nil_segment
|
38
|
+
expects_no_logging(:error)
|
39
|
+
CrossAppTracing.finish_trace(Time.now, nil, request, response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_finish_trace_allows_nil_request
|
43
|
+
expects_no_logging(:error)
|
44
|
+
expects_pop_scope
|
45
|
+
CrossAppTracing.finish_trace(Time.now, segment, nil, response)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_finish_trace_allows_nil_response
|
49
|
+
expects_no_logging(:error)
|
50
|
+
expects_pop_scope
|
51
|
+
CrossAppTracing.finish_trace(Time.now, segment, request, nil)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def expects_pop_scope
|
56
|
+
NewRelic::Agent.instance.stats_engine.stubs(:pop_scope).once
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|