newrelic_rpm 3.12.0.288 → 3.12.1.298
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +42 -0
- data/Rakefile +5 -5
- data/lib/new_relic/agent.rb +23 -11
- data/lib/new_relic/agent/agent.rb +17 -67
- data/lib/new_relic/agent/agent_logger.rb +9 -33
- data/lib/new_relic/agent/attribute_processing.rb +2 -2
- data/lib/new_relic/agent/autostart.rb +1 -18
- data/lib/new_relic/agent/aws_info.rb +90 -0
- data/lib/new_relic/agent/configuration/default_source.rb +45 -16
- data/lib/new_relic/agent/configuration/dotted_hash.rb +0 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +1 -31
- data/lib/new_relic/agent/configuration/server_source.rb +0 -1
- data/lib/new_relic/agent/configuration/yaml_source.rb +26 -7
- data/lib/new_relic/agent/database.rb +5 -5
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +0 -1
- data/lib/new_relic/agent/datastores/metric_helper.rb +15 -3
- data/lib/new_relic/agent/error_collector.rb +28 -18
- data/lib/new_relic/agent/instrumentation/active_record.rb +8 -2
- data/lib/new_relic/agent/instrumentation/active_record_4.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +49 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +8 -20
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -2
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -0
- data/lib/new_relic/agent/log_once.rb +39 -0
- data/lib/new_relic/agent/memory_logger.rb +8 -1
- data/lib/new_relic/agent/method_tracer.rb +5 -1
- data/lib/new_relic/agent/new_relic_service.rb +13 -14
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -3
- data/lib/new_relic/agent/sql_sampler.rb +4 -15
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +1 -1
- data/lib/new_relic/agent/stats_engine/samplers.rb +0 -6
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +92 -35
- data/lib/new_relic/agent/system_info.rb +53 -6
- data/lib/new_relic/agent/transaction.rb +4 -13
- data/lib/new_relic/agent/transaction/attributes.rb +2 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +1 -1
- data/lib/new_relic/agent/transaction_event_aggregator.rb +1 -9
- data/lib/new_relic/agent/transaction_sample_builder.rb +0 -6
- data/lib/new_relic/agent/transaction_sampler.rb +1 -13
- data/lib/new_relic/agent/utilization_data.rb +29 -42
- data/lib/new_relic/agent/worker_loop.rb +2 -3
- data/lib/new_relic/cli/commands/deployments.rb +5 -0
- data/lib/new_relic/coerce.rb +1 -1
- data/lib/new_relic/collection_helper.rb +0 -2
- data/lib/new_relic/control/instance_methods.rb +4 -1
- data/lib/new_relic/control/instrumentation.rb +1 -9
- data/lib/new_relic/control/server_methods.rb +3 -56
- data/lib/new_relic/helper.rb +1 -0
- data/lib/new_relic/language_support.rb +21 -0
- data/lib/new_relic/local_environment.rb +1 -0
- data/lib/new_relic/metric_data.rb +1 -1
- data/lib/new_relic/noticed_error.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +9 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +2 -2
- data/lib/tasks/multiverse.rake +2 -0
- data/lib/tasks/multiverse.rb +50 -0
- data/test/agent_helper.rb +24 -5
- data/test/fixtures/cross_agent_tests/aws.json +218 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/cases.json +40 -11
- data/test/fixtures/cross_agent_tests/docker_container_id/invalid-characters.txt +9 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/invalid-length.txt +9 -0
- data/test/multiverse/lib/multiverse/suite.rb +3 -0
- data/test/multiverse/suites/active_record/Envfile +18 -12
- data/test/multiverse/suites/active_record/active_record_test.rb +203 -9
- data/test/multiverse/suites/active_record/app/models/models.rb +16 -9
- data/test/multiverse/suites/active_record/config/database.rb +3 -2
- data/test/multiverse/suites/active_record/db/migrate/20150413011200_add_timestamps_to_orders.rb +16 -0
- data/test/multiverse/suites/active_record/db/migrate/20150414084400_create_groups.rb +21 -0
- data/test/multiverse/suites/agent_only/agent_attributes_test.rb +26 -3
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -1
- data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +68 -0
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/ssl_test.rb +2 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +20 -1
- data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +43 -104
- data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +2 -2
- data/test/multiverse/suites/high_security/high_security_test.rb +2 -2
- data/test/multiverse/suites/rack/http_response_code_test.rb +4 -4
- data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +38 -0
- data/test/multiverse/suites/sidekiq/test_worker.rb +13 -1
- data/test/new_relic/agent/agent_test.rb +0 -70
- data/test/new_relic/agent/attribute_processing_test.rb +10 -5
- data/test/new_relic/agent/autostart_test.rb +0 -31
- data/test/new_relic/agent/aws_info_test.rb +61 -0
- data/test/new_relic/agent/configuration/manager_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +25 -1
- data/test/new_relic/agent/database_test.rb +16 -15
- data/test/new_relic/agent/datastores/metric_helper_test.rb +35 -0
- data/test/new_relic/agent/error_collector_test.rb +28 -5
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +23 -20
- data/test/new_relic/agent/memory_logger_test.rb +18 -0
- data/test/new_relic/agent/new_relic_service_test.rb +2 -9
- data/test/new_relic/agent/rpm_agent_test.rb +0 -10
- data/test/new_relic/agent/sql_sampler_test.rb +4 -4
- data/test/new_relic/agent/stats_engine/stats_hash_test.rb +18 -22
- data/test/new_relic/agent/system_info_test.rb +81 -23
- data/test/new_relic/agent/transaction_event_aggregator_test.rb +0 -7
- data/test/new_relic/agent/transaction_test.rb +1 -1
- data/test/new_relic/agent/utilization_data_test.rb +135 -6
- data/test/new_relic/cli/commands/deployments_test.rb +12 -2
- data/test/new_relic/control/instrumentation_test.rb +0 -15
- data/test/new_relic/control_test.rb +0 -63
- data/test/new_relic/fake_collector.rb +4 -17
- data/test/new_relic/language_support_test.rb +30 -0
- data/test/new_relic/license_test.rb +2 -0
- data/test/new_relic/multiverse_helpers.rb +12 -0
- data/test/performance/suites/stats_hash.rb +6 -5
- data/test/test_helper.rb +1 -2
- metadata +13 -4
- data/lib/new_relic/agent/shim_agent.rb +0 -33
- data/test/new_relic/agent/shim_agent_test.rb +0 -20
@@ -20,7 +20,6 @@ class NewRelic::Agent::TransactionEventAggregator
|
|
20
20
|
TIMESTAMP_KEY = 'timestamp'.freeze
|
21
21
|
NAME_KEY = 'name'.freeze
|
22
22
|
DURATION_KEY = 'duration'.freeze
|
23
|
-
HTTP_RESPONSE_CODE_KEY = 'httpResponseCode'.freeze
|
24
23
|
GUID_KEY = 'nr.guid'.freeze
|
25
24
|
REFERRING_TRANSACTION_GUID_KEY = 'nr.referringTransactionGuid'.freeze
|
26
25
|
CAT_TRIP_ID_KEY = 'nr.tripId'.freeze
|
@@ -161,7 +160,7 @@ class NewRelic::Agent::TransactionEventAggregator
|
|
161
160
|
if main_event.include?(SYNTHETICS_RESOURCE_ID_KEY)
|
162
161
|
# Try adding to synthetics buffer. If anything is rejected, give it a
|
163
162
|
# shot in the main transaction events (where it may get sampled)
|
164
|
-
|
163
|
+
_, rejected = @synthetics_samples.append_with_reject(event)
|
165
164
|
|
166
165
|
if rejected
|
167
166
|
@samples.append(rejected)
|
@@ -228,17 +227,10 @@ class NewRelic::Agent::TransactionEventAggregator
|
|
228
227
|
optionally_append(SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
|
229
228
|
optionally_append(SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
|
230
229
|
optionally_append(SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
|
231
|
-
append_http_response_code(sample, payload)
|
232
230
|
append_cat_alternate_path_hashes(sample, payload)
|
233
231
|
sample
|
234
232
|
end
|
235
233
|
|
236
|
-
def append_http_response_code(sample, payload)
|
237
|
-
unless NewRelic::Agent.config[:disable_middleware_instrumentation]
|
238
|
-
optionally_append(HTTP_RESPONSE_CODE_KEY, :http_response_code, sample, payload)
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
234
|
def append_cat_alternate_path_hashes(sample, payload)
|
243
235
|
if payload.include?(:cat_alternate_path_hashes)
|
244
236
|
sample[CAT_ALTERNATE_PATH_HASHES_KEY] = payload[:cat_alternate_path_hashes].sort.join(',')
|
@@ -3,7 +3,6 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'new_relic/collection_helper'
|
6
|
-
require 'new_relic/control'
|
7
6
|
require 'new_relic/agent/transaction'
|
8
7
|
require 'new_relic/agent/transaction/trace'
|
9
8
|
|
@@ -137,11 +136,6 @@ module NewRelic
|
|
137
136
|
|
138
137
|
depth
|
139
138
|
end
|
140
|
-
|
141
|
-
def sample
|
142
|
-
@sample
|
143
|
-
end
|
144
|
-
|
145
139
|
end
|
146
140
|
end
|
147
141
|
end
|
@@ -2,8 +2,6 @@
|
|
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'
|
6
|
-
require 'new_relic/control'
|
7
5
|
require 'new_relic/agent/transaction_sample_builder'
|
8
6
|
require 'new_relic/agent/transaction/developer_mode_sample_buffer'
|
9
7
|
require 'new_relic/agent/transaction/slowest_sample_buffer'
|
@@ -22,15 +20,6 @@ module NewRelic
|
|
22
20
|
#
|
23
21
|
# @api public
|
24
22
|
class TransactionSampler
|
25
|
-
|
26
|
-
# Module defining methods stubbed out when the agent is disabled
|
27
|
-
module Shim #:nodoc:
|
28
|
-
def on_start_transaction(*args); end
|
29
|
-
def notice_push_frame(*args); end
|
30
|
-
def notice_pop_frame(*args); end
|
31
|
-
def on_finishing_transaction(*args); end
|
32
|
-
end
|
33
|
-
|
34
23
|
attr_reader :last_sample, :dev_mode_sample_buffer, :xray_sample_buffer
|
35
24
|
|
36
25
|
def initialize
|
@@ -71,7 +60,6 @@ module NewRelic
|
|
71
60
|
def on_start_transaction(state, start_time)
|
72
61
|
if enabled?
|
73
62
|
start_builder(state, start_time.to_f)
|
74
|
-
builder = state.transaction_sample_builder
|
75
63
|
end
|
76
64
|
end
|
77
65
|
|
@@ -195,7 +183,7 @@ module NewRelic
|
|
195
183
|
# @api public
|
196
184
|
# @deprecated Use {Datastores.notice_sql} instead.
|
197
185
|
#
|
198
|
-
def notice_sql(sql, config, duration, state=nil,
|
186
|
+
def notice_sql(sql, config, duration, state=nil, explainer=nil) #THREAD_LOCAL_ACCESS sometimes
|
199
187
|
# some statements (particularly INSERTS with large BLOBS
|
200
188
|
# may be very large; we should trim them to a maximum usable length
|
201
189
|
state ||= TransactionState.tl_get
|
@@ -2,19 +2,12 @@
|
|
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/aws_info'
|
6
|
+
|
5
7
|
module NewRelic
|
6
8
|
module Agent
|
7
9
|
class UtilizationData
|
8
|
-
|
9
|
-
REMOTE_DATA_VALID_CHARS = /^[0-9a-zA-Z_ .\/-]$/.freeze
|
10
|
-
|
11
|
-
def harvest!
|
12
|
-
[hostname, container_id, cpu_count, instance_type]
|
13
|
-
end
|
14
|
-
|
15
|
-
# No persistent data, so no need for merging or resetting
|
16
|
-
def merge!(*_); end
|
17
|
-
def reset!(*_); end
|
10
|
+
METADATA_VERSION = 1
|
18
11
|
|
19
12
|
def hostname
|
20
13
|
NewRelic::Agent::Hostname.get
|
@@ -29,49 +22,43 @@ module NewRelic
|
|
29
22
|
::NewRelic::Agent::SystemInfo.num_logical_processors
|
30
23
|
end
|
31
24
|
|
32
|
-
def
|
33
|
-
|
34
|
-
remote_fetch('instance-type')
|
35
|
-
end
|
36
|
-
rescue Timeout::Error
|
37
|
-
NewRelic::Agent.logger.debug("UtilizationData timed out fetching remote keys.")
|
38
|
-
nil
|
39
|
-
rescue StandardError, LoadError => e
|
40
|
-
NewRelic::Agent.logger.debug("UtilizationData encountered error fetching remote keys:\n#{e}")
|
41
|
-
nil
|
25
|
+
def ram_in_mib
|
26
|
+
::NewRelic::Agent::SystemInfo.ram_in_mib
|
42
27
|
end
|
43
28
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
29
|
+
def to_collector_hash
|
30
|
+
result = {
|
31
|
+
:metadata_version => METADATA_VERSION,
|
32
|
+
:logical_processors => cpu_count,
|
33
|
+
:total_ram_mib => ram_in_mib,
|
34
|
+
:hostname => hostname
|
35
|
+
}
|
50
36
|
|
51
|
-
|
37
|
+
append_aws_info(result)
|
38
|
+
append_docker_info(result)
|
52
39
|
|
53
|
-
|
54
|
-
NewRelic::Agent.logger.warn("Fetching instance metadata for #{remote_key.inspect} returned invalid data: #{request.inspect}")
|
55
|
-
end
|
56
|
-
|
57
|
-
data
|
40
|
+
result
|
58
41
|
end
|
59
42
|
|
60
|
-
def
|
61
|
-
return
|
62
|
-
return nil unless data_str.size <= 255
|
43
|
+
def append_aws_info(collector_hash)
|
44
|
+
return unless Agent.config[:'utilization.detect_aws']
|
63
45
|
|
64
|
-
|
65
|
-
next if ch =~ REMOTE_DATA_VALID_CHARS
|
66
|
-
code_point = ch[0].ord # this works in Ruby 1.8.7 - 2.1.2
|
67
|
-
next if code_point >= 0x80
|
46
|
+
aws_info = AWSInfo.new
|
68
47
|
|
69
|
-
|
48
|
+
if aws_info.loaded?
|
49
|
+
collector_hash[:vendors] ||= {}
|
50
|
+
collector_hash[:vendors][:aws] = aws_info.to_collector_hash
|
70
51
|
end
|
71
|
-
|
72
|
-
data_str
|
73
52
|
end
|
74
53
|
|
54
|
+
def append_docker_info(collector_hash)
|
55
|
+
return unless Agent.config[:'utilization.detect_docker']
|
56
|
+
|
57
|
+
if docker_container_id = container_id
|
58
|
+
collector_hash[:vendors] ||= {}
|
59
|
+
collector_hash[:vendors][:docker] = {:id => docker_container_id}
|
60
|
+
end
|
61
|
+
end
|
75
62
|
end
|
76
63
|
end
|
77
64
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'thread'
|
6
|
+
|
6
7
|
module NewRelic
|
7
8
|
module Agent
|
8
9
|
|
@@ -76,9 +77,7 @@ module NewRelic
|
|
76
77
|
@should_run = false
|
77
78
|
end
|
78
79
|
|
79
|
-
# Executes the block given to the worker loop, and handles
|
80
|
-
# possible errors. Also updates the execution time so that the
|
81
|
-
# next run occurs on schedule, even if we execute at some odd time
|
80
|
+
# Executes the block given to the worker loop, and handles errors.
|
82
81
|
def run_task
|
83
82
|
if @propagate_errors
|
84
83
|
@task.call
|
@@ -44,6 +44,11 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
44
44
|
|
45
45
|
def load_yaml_from_env(env)
|
46
46
|
yaml = NewRelic::Agent::Configuration::YamlSource.new(NewRelic::Agent.config[:config_path], env)
|
47
|
+
if yaml.failed?
|
48
|
+
messages = yaml.failures.flatten.map(&:to_s).join("\n")
|
49
|
+
raise NewRelic::Cli::Command::CommandFailure.new("Error in loading newrelic.yml.\n#{messages}")
|
50
|
+
end
|
51
|
+
|
47
52
|
NewRelic::Agent.config.replace_or_add_config(yaml)
|
48
53
|
end
|
49
54
|
|
data/lib/new_relic/coerce.rb
CHANGED
@@ -68,7 +68,6 @@ module NewRelic
|
|
68
68
|
Module.send :include, NewRelic::Agent::MethodTracer
|
69
69
|
init_config(options)
|
70
70
|
NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
|
71
|
-
NewRelic::Agent.agent.start_service_if_needed
|
72
71
|
if Agent.config[:agent_enabled] && !NewRelic::Agent.instance.started?
|
73
72
|
start_agent
|
74
73
|
install_instrumentation
|
@@ -144,7 +143,11 @@ module NewRelic
|
|
144
143
|
|
145
144
|
def initialize(local_env, config_file_override=nil)
|
146
145
|
@local_env = local_env
|
146
|
+
@started_in_env = nil
|
147
|
+
|
148
|
+
@instrumented = nil
|
147
149
|
@instrumentation_files = []
|
150
|
+
|
148
151
|
@config_file_override = config_file_override
|
149
152
|
end
|
150
153
|
|
@@ -23,16 +23,8 @@ module NewRelic
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
# Install stubs to the proper location so the app code will not fail
|
27
|
-
# if the agent is not running.
|
28
26
|
def install_shim
|
29
|
-
#
|
30
|
-
if @instrumented
|
31
|
-
NewRelic::Agent.logger.error "Cannot install the Agent shim after instrumentation has already been installed!"
|
32
|
-
NewRelic::Agent.logger.error caller.join("\n")
|
33
|
-
else
|
34
|
-
NewRelic::Agent.agent = NewRelic::Agent::ShimAgent.instance
|
35
|
-
end
|
27
|
+
# implemented only in subclasses
|
36
28
|
end
|
37
29
|
|
38
30
|
# Add instrumentation. Don't call this directly. Use NewRelic::Agent#add_instrumentation.
|
@@ -6,15 +6,12 @@ module NewRelic
|
|
6
6
|
class Control
|
7
7
|
|
8
8
|
# Structs holding info for the remote server and proxy server
|
9
|
-
class Server < Struct.new :name, :port
|
9
|
+
class Server < Struct.new :name, :port #:nodoc:
|
10
10
|
def to_s; "#{name}:#{port}"; end
|
11
11
|
end
|
12
12
|
|
13
|
-
ProxyServer = Struct.new :name, :port, :user, :password #:nodoc:
|
14
|
-
|
15
13
|
# Contains methods that deal with connecting to the server
|
16
14
|
module ServerMethods
|
17
|
-
|
18
15
|
def server
|
19
16
|
@remote_server ||= server_from_host(nil)
|
20
17
|
end
|
@@ -22,61 +19,11 @@ module NewRelic
|
|
22
19
|
# the server we should contact for api requests, like uploading
|
23
20
|
# deployments and the like
|
24
21
|
def api_server
|
25
|
-
@api_server ||= NewRelic::Control::Server.new(Agent.config[:api_host], Agent.config[:api_port]
|
22
|
+
@api_server ||= NewRelic::Control::Server.new(Agent.config[:api_host], Agent.config[:api_port])
|
26
23
|
end
|
27
24
|
|
28
|
-
# a new instances of the proxy server - this passes through if
|
29
|
-
# there is no proxy, otherwise it has proxy configuration
|
30
|
-
# information pulled from the config file
|
31
|
-
def proxy_server
|
32
|
-
@proxy_server ||= NewRelic::Control::ProxyServer.new(Agent.config[:proxy_host],
|
33
|
-
Agent.config[:proxy_port],
|
34
|
-
Agent.config[:proxy_user],
|
35
|
-
Agent.config[:proxy_pass])
|
36
|
-
end
|
37
|
-
|
38
|
-
# turns a hostname into an ip address and returns a
|
39
|
-
# NewRelic::Control::Server that contains the configuration info
|
40
25
|
def server_from_host(hostname=nil)
|
41
|
-
|
42
|
-
|
43
|
-
# if the host is not an IP address, turn it into one
|
44
|
-
NewRelic::Control::Server.new(host, Agent.config[:port],
|
45
|
-
convert_to_ip_address(host))
|
46
|
-
end
|
47
|
-
|
48
|
-
# Check to see if we need to look up the IP address
|
49
|
-
# If it's an IP address already, we pass it through.
|
50
|
-
# If it's nil, or localhost, we don't bother.
|
51
|
-
# Otherwise, use `resolve_ip_address` to find one
|
52
|
-
def convert_to_ip_address(host)
|
53
|
-
# here we leave it as a host name since the cert verification
|
54
|
-
# needs it in host form
|
55
|
-
return host if Agent.config[:ssl]
|
56
|
-
# We won't talk directly to the host, so no need to resolve if proxy configured
|
57
|
-
return host if Agent.config[:proxy_host]
|
58
|
-
return nil if host.nil? || host.downcase == "localhost"
|
59
|
-
ip = resolve_ip_address(host)
|
60
|
-
|
61
|
-
::NewRelic::Agent.logger.debug "Resolved #{host} to #{ip}"
|
62
|
-
ip
|
63
|
-
end
|
64
|
-
|
65
|
-
# Look up the ip address of the host using the pure ruby lookup
|
66
|
-
# to prevent blocking. If that fails, fall back to the regular
|
67
|
-
# IPSocket library. Return nil if we can't find the host ip
|
68
|
-
# address and don't have a good default.
|
69
|
-
def resolve_ip_address(host)
|
70
|
-
Resolv.getaddress(host)
|
71
|
-
rescue => e
|
72
|
-
::NewRelic::Agent.logger.warn("DNS Error caching IP address:", e)
|
73
|
-
begin
|
74
|
-
::NewRelic::Agent.logger.debug("Trying native DNS lookup since Resolv failed")
|
75
|
-
IPSocket.getaddress(host)
|
76
|
-
rescue => e
|
77
|
-
::NewRelic::Agent.logger.error("Could not look up server address: #{e}")
|
78
|
-
nil
|
79
|
-
end
|
26
|
+
NewRelic::Control::Server.new(hostname || Agent.config[:host], Agent.config[:port])
|
80
27
|
end
|
81
28
|
end
|
82
29
|
|
data/lib/new_relic/helper.rb
CHANGED
@@ -111,6 +111,27 @@ module NewRelic::LanguageSupport
|
|
111
111
|
RUBY_VERSION >= '1.9.0'
|
112
112
|
end
|
113
113
|
|
114
|
+
def constantize(const_name)
|
115
|
+
const_name.to_s.sub(/\A::/,'').split('::').inject(Object) do |namespace, name|
|
116
|
+
begin
|
117
|
+
result = namespace.const_get(name)
|
118
|
+
|
119
|
+
# const_get looks up the inheritence chain, so if it's a class
|
120
|
+
# in the constant make sure we found the one in our namespace.
|
121
|
+
#
|
122
|
+
# Can't help if the constant isn't a class...
|
123
|
+
if result.is_a?(Module)
|
124
|
+
expected_name = "#{namespace}::#{name}".gsub(/^Object::/, "")
|
125
|
+
return unless expected_name == result.to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
result
|
129
|
+
rescue NameError
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
114
135
|
def test_forkability
|
115
136
|
child = Process.fork { exit! }
|
116
137
|
# calling wait here doesn't seem like it should necessary, but it seems to
|
@@ -7,7 +7,7 @@ require 'new_relic/coerce'
|
|
7
7
|
module NewRelic
|
8
8
|
class MetricData
|
9
9
|
# nil, or a NewRelic::MetricSpec object if we have no cached ID
|
10
|
-
|
10
|
+
attr_reader :metric_spec
|
11
11
|
# nil or a cached integer ID for the metric from the collector.
|
12
12
|
attr_accessor :metric_id
|
13
13
|
# the actual statistics object
|
@@ -74,7 +74,7 @@ class NewRelic::NoticedError
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def self.passes_message_whitelist(exception_class)
|
77
|
-
NewRelic::Agent.config.
|
77
|
+
NewRelic::Agent.config[:'strip_exception_messages.whitelist'].any? do |klass|
|
78
78
|
exception_class <= klass
|
79
79
|
end
|
80
80
|
end
|