newrelic_rpm 3.17.1.326 → 3.17.2.327
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -21
- data/{CHANGELOG → CHANGELOG.md} +143 -93
- data/lib/new_relic/agent/configuration/default_source.rb +31 -19
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_4.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_5.rb +89 -0
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +2 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +8 -6
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails5/action_controller.rb +12 -3
- data/lib/new_relic/agent/instrumentation/redis.rb +2 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/new_relic_service.rb +6 -2
- data/lib/new_relic/agent/transaction/datastore_segment.rb +31 -7
- data/lib/new_relic/agent/transaction/tracing.rb +6 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/version.rb +3 -3
- data/newrelic_rpm.gemspec +2 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails22/Gemfile +2 -1
- data/test/environments/rails23/Gemfile +6 -1
- data/test/fixtures/cross_agent_tests/datastores/README.md +1 -1
- data/test/fixtures/cross_agent_tests/datastores/datastore_api.json +443 -0
- data/test/fixtures/cross_agent_tests/datastores/datastore_instances.json +0 -47
- data/test/multiverse/lib/multiverse/runner.rb +2 -1
- data/test/multiverse/suites/memcached/dalli_test.rb +5 -12
- data/test/multiverse/suites/resque/instrumentation_test.rb +4 -0
- data/test/multiverse/suites/sidekiq/sidekiq_server.rb +5 -1
- data/test/multiverse/suites/sinatra/Envfile +8 -0
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +27 -9
- data/test/multiverse/suites/typhoeus/Envfile +5 -0
- data/test/new_relic/agent/api_tests/datastore_api_test.rb +64 -0
- data/test/new_relic/agent/configuration/default_source_test.rb +6 -3
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +27 -1
- data/test/new_relic/agent/instrumentation/instance_identification_test.rb +4 -22
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +7 -0
- data/test/new_relic/agent/new_relic_service_test.rb +10 -2
- data/test/new_relic/agent/transaction/datastore_segment_test.rb +96 -6
- data/test/new_relic/agent/transaction/tracing_test.rb +9 -0
- data/test/new_relic/agent_test.rb +2 -1
- data/test/new_relic/latest_changes_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +4 -0
- data/test/script/before_install/gemstash_mirror.sh +10 -0
- data/test/script/before_install/jruby_bundler.sh +22 -0
- data/test/script/before_install/revert_rubygems.sh +15 -0
- data/test/script/before_script/install_mongodb.sh +12 -0
- metadata +11 -5
- data/test/script/install_mongodb.sh +0 -6
@@ -31,22 +31,6 @@
|
|
31
31
|
"port": 5252,
|
32
32
|
"expected_instance_metric": "Datastore/instance/Postgres/datanerd-01/5252"
|
33
33
|
},
|
34
|
-
{
|
35
|
-
"name": "instance metric uses system hostname when db reports default host IPv4",
|
36
|
-
"system_hostname": "datanerd-01",
|
37
|
-
"db_hostname": "0.0.0.0",
|
38
|
-
"product": "MySQL",
|
39
|
-
"port": 3600,
|
40
|
-
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01/3600"
|
41
|
-
},
|
42
|
-
{
|
43
|
-
"name": "instance metric uses system hostname when db reports default host IPv6",
|
44
|
-
"system_hostname": "datanerd-01",
|
45
|
-
"db_hostname": "0:0:0:0:0:0:0:0",
|
46
|
-
"product": "MySQL",
|
47
|
-
"port": 5757,
|
48
|
-
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01/5757"
|
49
|
-
},
|
50
34
|
{
|
51
35
|
"name": "instance metric uses system hostname when db reports default host IPv6 shorthand",
|
52
36
|
"system_hostname": "datanerd-01",
|
@@ -63,13 +47,6 @@
|
|
63
47
|
"port": 8420,
|
64
48
|
"expected_instance_metric": "Datastore/instance/MySQL/accounts-db/8420"
|
65
49
|
},
|
66
|
-
{
|
67
|
-
"name": "detects default UDS case",
|
68
|
-
"system_hostname": "datanerd-01",
|
69
|
-
"db_hostname": "localhost",
|
70
|
-
"product": "MySQL",
|
71
|
-
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01/default"
|
72
|
-
},
|
73
50
|
{
|
74
51
|
"name": "instance metric uses unix socket path if provided",
|
75
52
|
"system_hostname": "datanerd-01",
|
@@ -78,30 +55,6 @@
|
|
78
55
|
"unix_socket": "/var/mysql/mysql.sock",
|
79
56
|
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01//var/mysql/mysql.sock"
|
80
57
|
},
|
81
|
-
{
|
82
|
-
"name": "instance metric reports unknown if host empty",
|
83
|
-
"system_hostname": "datanerd-01",
|
84
|
-
"db_hostname": "",
|
85
|
-
"product": "MySQL",
|
86
|
-
"port": 3600,
|
87
|
-
"expected_instance_metric": "Datastore/instance/MySQL/unknown/3600"
|
88
|
-
},
|
89
|
-
{
|
90
|
-
"name": "instance metric reports unknown if port empty",
|
91
|
-
"system_hostname": "datanerd-01",
|
92
|
-
"db_hostname": "localhost",
|
93
|
-
"product": "MySQL",
|
94
|
-
"port": "",
|
95
|
-
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01/unknown"
|
96
|
-
},
|
97
|
-
{
|
98
|
-
"name": "instance metric reports unknown if unix_socket empty",
|
99
|
-
"system_hostname": "datanerd-01",
|
100
|
-
"db_hostname": "localhost",
|
101
|
-
"product": "MySQL",
|
102
|
-
"unix_socket": "",
|
103
|
-
"expected_instance_metric": "Datastore/instance/MySQL/datanerd-01/unknown"
|
104
|
-
},
|
105
58
|
{
|
106
59
|
"name": "instance metric with ip v6 host",
|
107
60
|
"system_hostname": "datanerd-01",
|
@@ -85,12 +85,13 @@ module Multiverse
|
|
85
85
|
"agent" => ["agent_only", "bare", "config_file_loading",
|
86
86
|
"deferred_instrumentation", "high_security", "no_json"],
|
87
87
|
"api" => ["grape"],
|
88
|
-
"background" => ["delayed_job", "
|
88
|
+
"background" => ["delayed_job", "resque", "sidekiq"],
|
89
89
|
"database" => ["datamapper", "mongo", "redis", "sequel"],
|
90
90
|
"httpclients" => ["curb", "excon", "httpclient", "typhoeus", "net_http", "httprb"],
|
91
91
|
"rails" => ["active_record", "rails"],
|
92
92
|
"serialization" => ["json", "marshalling", "yajl"],
|
93
93
|
"sinatra" => ["sinatra", "padrino"],
|
94
|
+
"rake" => ["rake"],
|
94
95
|
|
95
96
|
"rest" => [] # Specially handled below
|
96
97
|
}
|
@@ -29,38 +29,31 @@ if defined?(Dalli)
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_assign_instance_to_with_ip_and_port
|
32
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
33
32
|
segment = mock('datastore_segment')
|
34
|
-
segment.expects(:
|
35
|
-
segment.expects(:port_path_or_id=).with(11211)
|
33
|
+
segment.expects(:set_instance_info).with('127.0.0.1', 11211)
|
36
34
|
server = ::Dalli::Server.new '127.0.0.1:11211'
|
37
35
|
::NewRelic::Agent::Instrumentation::Memcache::Dalli.assign_instance_to(segment, server)
|
38
36
|
end
|
39
37
|
|
40
38
|
def test_assign_instance_to_with_name_and_port
|
41
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
42
39
|
segment = mock('datastore_segment')
|
43
|
-
segment.expects(:
|
44
|
-
segment.expects(:port_path_or_id=).with(11211)
|
40
|
+
segment.expects(:set_instance_info).with('jonan.gummy_planet', 11211)
|
45
41
|
server = ::Dalli::Server.new 'jonan.gummy_planet:11211'
|
46
42
|
::NewRelic::Agent::Instrumentation::Memcache::Dalli.assign_instance_to(segment, server)
|
47
43
|
end
|
48
44
|
|
49
45
|
def test_assign_instance_to_with_unix_domain_socket
|
50
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
51
46
|
segment = mock('datastore_segment')
|
52
|
-
segment.expects(:
|
53
|
-
segment.expects(:port_path_or_id=).with('/tmp/jonanfs.sock')
|
47
|
+
segment.expects(:set_instance_info).with('localhost', '/tmp/jonanfs.sock')
|
54
48
|
server = ::Dalli::Server.new '/tmp/jonanfs.sock'
|
55
49
|
::NewRelic::Agent::Instrumentation::Memcache::Dalli.assign_instance_to(segment, server)
|
56
50
|
end
|
57
51
|
|
58
52
|
def test_assign_instance_to_when_exception_raised
|
59
|
-
NewRelic::Agent::Hostname.stubs(:get).raises("oops")
|
60
53
|
segment = mock('datastore_segment')
|
61
|
-
segment.expects(:
|
62
|
-
segment.expects(:port_path_or_id=).with('unknown')
|
54
|
+
segment.expects(:set_instance_info).with('unknown', 'unknown')
|
63
55
|
server = ::Dalli::Server.new '/tmp/jonanfs.sock'
|
56
|
+
server.stubs(:hostname).raises("oops")
|
64
57
|
::NewRelic::Agent::Instrumentation::Memcache::Dalli.assign_instance_to(segment, server)
|
65
58
|
end
|
66
59
|
|
@@ -8,6 +8,8 @@ require 'sidekiq/cli'
|
|
8
8
|
class SidekiqServer
|
9
9
|
include Singleton
|
10
10
|
|
11
|
+
THREAD_JOIN_TIMEOUT = 30
|
12
|
+
|
11
13
|
attr_reader :queue_name
|
12
14
|
|
13
15
|
def initialize
|
@@ -26,6 +28,8 @@ class SidekiqServer
|
|
26
28
|
def stop
|
27
29
|
puts "Trying to stop Sidekiq gracefully from #{$$}"
|
28
30
|
Process.kill("INT", $$)
|
29
|
-
@cli_thread.join
|
31
|
+
if @cli_thread.join(THREAD_JOIN_TIMEOUT).nil?
|
32
|
+
puts "#{$$} Sidekiq::CLI thread timeout on exit"
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
@@ -40,7 +40,7 @@ class SinatraErrorTracingTest < Minitest::Test
|
|
40
40
|
def test_ignores_notfound_errors_by_default
|
41
41
|
get '/ignored_boom'
|
42
42
|
assert_equal 404, last_response.status
|
43
|
-
assert_match %r{Sinatra doesn&rsquo
|
43
|
+
assert_match %r{Sinatra doesn(’|’)t know this ditty\.}, last_response.body
|
44
44
|
|
45
45
|
errors = harvest_error_traces!
|
46
46
|
assert_equal(0, errors.size)
|
@@ -21,9 +21,15 @@ module SinatraTestCases
|
|
21
21
|
'GET /route/no_match'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if NewRelic::VersionNumber.new(Sinatra::VERSION).major_version < 2
|
25
|
+
# get /\/regex.*/
|
26
|
+
def regex_segment
|
27
|
+
'GET (?-mix:\/regex.*)'
|
28
|
+
end
|
29
|
+
else
|
30
|
+
def regex_segment
|
31
|
+
'GET \/regex.*'
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
# get '/precondition'
|
@@ -178,25 +184,37 @@ module SinatraTestCases
|
|
178
184
|
end
|
179
185
|
|
180
186
|
def test_rack_request_params_errors_are_swallowed
|
181
|
-
|
187
|
+
trigger_error_on_params
|
182
188
|
|
183
189
|
get '/pass'
|
184
|
-
|
190
|
+
|
191
|
+
expected_status = NewRelic::VersionNumber.new(Sinatra::VERSION).major_version < 2 ? 200 : 400
|
192
|
+
|
193
|
+
assert_equal expected_status, last_response.status
|
185
194
|
end
|
186
195
|
|
187
196
|
def test_rack_request_params_errors_are_logged
|
188
197
|
NewRelic::Agent.logger.stubs(:debug)
|
189
198
|
NewRelic::Agent.logger.expects(:debug).with("Failed to get params from Rack request.", kind_of(StandardError)).at_least_once
|
190
199
|
|
191
|
-
|
200
|
+
trigger_error_on_params
|
192
201
|
|
193
202
|
get '/pass'
|
194
203
|
end
|
195
204
|
|
196
|
-
|
197
|
-
|
205
|
+
|
206
|
+
if NewRelic::VersionNumber.new(Sinatra::VERSION).major_version < 2
|
207
|
+
def trigger_error_on_params
|
208
|
+
Sinatra::Request.any_instance.
|
198
209
|
stubs(:params).returns({}).
|
199
|
-
then.raises("Rack::Request#params error")
|
210
|
+
then.raises(StandardError.new "Rack::Request#params error")
|
211
|
+
end
|
212
|
+
else
|
213
|
+
def trigger_error_on_params
|
214
|
+
Sinatra::Request.any_instance.
|
215
|
+
stubs(:params).
|
216
|
+
raises(Sinatra::BadRequest.new)
|
217
|
+
end
|
200
218
|
end
|
201
219
|
|
202
220
|
def test_root_path_naming
|
@@ -13,6 +13,11 @@ gemfile <<-RB
|
|
13
13
|
|
14
14
|
# We try translating URIs through Addressable if it's there, so test with it.
|
15
15
|
gem 'addressable', :require => 'addressable/uri'
|
16
|
+
if RUBY_VERSION < '1.9.3'
|
17
|
+
gem 'public_suffix', '< 1.4'
|
18
|
+
elsif RUBY_VERSION < '2.0'
|
19
|
+
gem 'public_suffix', '< 1.5'
|
20
|
+
end
|
16
21
|
RB
|
17
22
|
|
18
23
|
gemfile <<-RB
|
@@ -0,0 +1,64 @@
|
|
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
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
5
|
+
require 'new_relic/agent/transaction'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
class DatastoreApiTest < Minitest::Test
|
10
|
+
def setup
|
11
|
+
freeze_time
|
12
|
+
NewRelic::Agent.drop_buffered_data
|
13
|
+
end
|
14
|
+
|
15
|
+
load_cross_agent_test('datastores/datastore_api').each do |test|
|
16
|
+
define_method :"test_#{test['test_name'].tr(' ', '_')}" do
|
17
|
+
NewRelic::Agent::Hostname.stubs(:get).returns(test['input']['system_hostname'])
|
18
|
+
|
19
|
+
params = test['input']['parameters']
|
20
|
+
txn_helper_method = test['input']['is_web'] ? :in_web_transaction : :in_background_transaction
|
21
|
+
config = test['input']['configuration'].merge(:disable_harvest_thread => true)
|
22
|
+
|
23
|
+
with_config config do
|
24
|
+
send(txn_helper_method) do
|
25
|
+
segment = NewRelic::Agent::Transaction.start_datastore_segment(
|
26
|
+
params['product'], params['operation'], params['collection'],
|
27
|
+
params['host'], params['port_path_or_id'], params['database_name']
|
28
|
+
)
|
29
|
+
segment.notice_sql "select * from foo"
|
30
|
+
advance_time 2.0
|
31
|
+
segment.finish
|
32
|
+
end
|
33
|
+
|
34
|
+
host, port_path_or_id, database_name =
|
35
|
+
test['expectation']['transaction_segment_and_slow_query_trace'].values_at('host', 'port_path_or_id', 'database_name')
|
36
|
+
|
37
|
+
segment_name = test['expectation']['metrics_scoped'][0]
|
38
|
+
|
39
|
+
assert_metrics_recorded test['expectation']['metrics_unscoped']
|
40
|
+
assert_expected_tt_segment_params segment_name, host, port_path_or_id, database_name
|
41
|
+
assert_expected_slow_sql_params host, port_path_or_id, database_name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def assert_expected_tt_segment_params segment_name, host, port_path_or_id, database_name
|
47
|
+
trace = last_transaction_trace
|
48
|
+
segment = find_node_with_name trace, segment_name
|
49
|
+
|
50
|
+
assert_equal host, segment[:host]
|
51
|
+
assert_equal port_path_or_id, segment[:port_path_or_id]
|
52
|
+
assert_equal database_name, segment[:database_name]
|
53
|
+
end
|
54
|
+
|
55
|
+
def assert_expected_slow_sql_params host, port_path_or_id, database_name
|
56
|
+
sql_trace = last_sql_trace
|
57
|
+
|
58
|
+
assert_equal host, sql_trace.params[:host]
|
59
|
+
assert_equal port_path_or_id, sql_trace.params[:port_path_or_id]
|
60
|
+
assert_equal database_name, sql_trace.params[:database_name]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -35,13 +35,16 @@ module NewRelic::Agent::Configuration
|
|
35
35
|
NewRelic::Control.instance.local_env.stubs(:discovered_dispatcher).returns(:unicorn)
|
36
36
|
|
37
37
|
@default_source.keys.each do |key|
|
38
|
-
|
38
|
+
config_value = fetch_config_value(key)
|
39
|
+
actual_type = get_config_value_class(config_value)
|
39
40
|
expected_type = @defaults[key][:type]
|
40
41
|
|
41
42
|
if @defaults[key][:allow_nil]
|
42
|
-
|
43
|
+
assertion = (NilClass === config_value) || (expected_type === config_value)
|
44
|
+
assert assertion, "Default value for #{key} should be NilClass or #{expected_type}, is #{actual_type}."
|
43
45
|
else
|
44
|
-
|
46
|
+
assertion = expected_type === config_value
|
47
|
+
assert assertion, "Default value for #{key} should be #{expected_type}, is #{actual_type}."
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -61,6 +61,22 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
61
61
|
assert_metrics_recorded('Datastore/instance/MySQL/jonan.gummy_planet/3306')
|
62
62
|
end
|
63
63
|
|
64
|
+
def test_records_datastore_instance_metric_with_one_datum_missing
|
65
|
+
config = { :adapter => "mysql", :host => "jonan.gummy_planet", :port => "" }
|
66
|
+
@subscriber.stubs(:active_record_config).returns(config)
|
67
|
+
|
68
|
+
simulate_query(2)
|
69
|
+
|
70
|
+
assert_metrics_recorded('Datastore/instance/MySQL/jonan.gummy_planet/unknown')
|
71
|
+
|
72
|
+
config = { :adapter => "mysql", :host => "", :port => 3306 }
|
73
|
+
@subscriber.stubs(:active_record_config).returns(config)
|
74
|
+
|
75
|
+
simulate_query(2)
|
76
|
+
|
77
|
+
assert_metrics_recorded('Datastore/instance/MySQL/unknown/3306')
|
78
|
+
end
|
79
|
+
|
64
80
|
def test_does_not_record_datastore_instance_metric_for_unsupported_adapter
|
65
81
|
config = { :adapter => "JonanDB", :host => "jonan.gummy_planet" }
|
66
82
|
@subscriber.stubs(:active_record_config).returns(config)
|
@@ -81,6 +97,15 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
81
97
|
end
|
82
98
|
end
|
83
99
|
|
100
|
+
def test_does_not_record_datastore_instance_metric_if_both_are_empty
|
101
|
+
config = { :adapter => "", :host => "" }
|
102
|
+
@subscriber.stubs(:active_record_config).returns(config)
|
103
|
+
|
104
|
+
simulate_query(2)
|
105
|
+
|
106
|
+
assert_metrics_not_recorded('Datastore/instance/unknown/unknown')
|
107
|
+
end
|
108
|
+
|
84
109
|
def test_does_not_record_database_name_if_disabled
|
85
110
|
config = { :host => "jonan.gummy_planet", :database => "pizza_cube" }
|
86
111
|
@subscriber.stubs(:active_record_config).returns(config)
|
@@ -93,8 +118,9 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
93
118
|
end
|
94
119
|
|
95
120
|
def test_records_unknown_unknown_when_error_gathering_instance_data
|
96
|
-
NewRelic::Agent::
|
121
|
+
NewRelic::Agent::Instrumentation::ActiveRecordHelper::InstanceIdentification.stubs(:postgres_unix_domain_socket_case?).raises StandardError.new
|
97
122
|
NewRelic::Agent::Instrumentation::ActiveRecordHelper::InstanceIdentification.stubs(:mysql_default_case?).raises StandardError.new
|
123
|
+
|
98
124
|
config = {:adapter => 'mysql', :host => "127.0.0.1"}
|
99
125
|
@subscriber.stubs(:active_record_config).returns(config)
|
100
126
|
|
@@ -24,12 +24,11 @@ module NewRelic
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_for_constructs_id_with_unspecified_configuration
|
27
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
28
27
|
config = {}
|
29
28
|
host = InstanceIdentification.host(config)
|
30
29
|
ppid = InstanceIdentification.port_path_or_id(config)
|
31
30
|
|
32
|
-
assert_equal "
|
31
|
+
assert_equal "localhost", host
|
33
32
|
assert_equal "default", ppid
|
34
33
|
end
|
35
34
|
|
@@ -57,30 +56,15 @@ module NewRelic
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def test_for_constructs_id_with_port_without_host
|
60
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
61
59
|
config = { :port => 1337 }
|
62
60
|
|
63
61
|
host = InstanceIdentification.host(config)
|
64
62
|
ppid = InstanceIdentification.port_path_or_id(config)
|
65
63
|
|
66
|
-
assert_equal "
|
64
|
+
assert_equal "localhost", host
|
67
65
|
assert_equal "1337", ppid
|
68
66
|
end
|
69
67
|
|
70
|
-
def test_for_constructs_id_with_detected_localhost
|
71
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
72
|
-
|
73
|
-
%w[localhost 0.0.0.0 127.0.0.1 0:0:0:0:0:0:0:1 0:0:0:0:0:0:0:0 ::1 ::].each do |host|
|
74
|
-
config = { :host => host }
|
75
|
-
|
76
|
-
host = InstanceIdentification.host(config)
|
77
|
-
ppid = InstanceIdentification.port_path_or_id(config)
|
78
|
-
|
79
|
-
assert_equal "jonan.pizza_cube", host
|
80
|
-
assert_equal "default", ppid
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
68
|
def test_for_constructs_id_with_default_port
|
85
69
|
config = {
|
86
70
|
:adapter => "mysql",
|
@@ -95,7 +79,6 @@ module NewRelic
|
|
95
79
|
end
|
96
80
|
|
97
81
|
def test_for_constructs_id_with_postgres_directory
|
98
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
99
82
|
config = {
|
100
83
|
:adapter => "postgresql",
|
101
84
|
:host => "/tmp"
|
@@ -104,12 +87,11 @@ module NewRelic
|
|
104
87
|
host = InstanceIdentification.host(config)
|
105
88
|
ppid = InstanceIdentification.port_path_or_id(config)
|
106
89
|
|
107
|
-
assert_equal "
|
90
|
+
assert_equal "localhost", host
|
108
91
|
assert_equal "default", ppid
|
109
92
|
end
|
110
93
|
|
111
94
|
def test_for_constructs_id_with_mysql_socket
|
112
|
-
NewRelic::Agent::Hostname.stubs(:get).returns("jonan.pizza_cube")
|
113
95
|
%w[ mysql mysql2 jdbcmysql ].each do |adapter|
|
114
96
|
config = {
|
115
97
|
:adapter => adapter,
|
@@ -119,7 +101,7 @@ module NewRelic
|
|
119
101
|
host = InstanceIdentification.host(config)
|
120
102
|
ppid = InstanceIdentification.port_path_or_id(config)
|
121
103
|
|
122
|
-
assert_equal "
|
104
|
+
assert_equal "localhost", host
|
123
105
|
assert_equal "/var/run/mysqld.sock", ppid
|
124
106
|
end
|
125
107
|
end
|