newrelic_rpm 6.15.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +164 -22
- data/CONTRIBUTING.md +13 -2
- data/README.md +2 -2
- data/lib/new_relic/agent.rb +5 -8
- data/lib/new_relic/agent/agent.rb +2 -1
- data/lib/new_relic/agent/autostart.rb +1 -2
- data/lib/new_relic/agent/configuration/default_source.rb +442 -227
- data/lib/new_relic/agent/configuration/manager.rb +3 -3
- data/lib/new_relic/agent/connect/request_builder.rb +4 -2
- data/lib/new_relic/agent/datastores/redis.rb +0 -4
- data/lib/new_relic/agent/distributed_tracing.rb +0 -66
- data/lib/new_relic/agent/error_collector.rb +52 -37
- data/lib/new_relic/agent/error_filter.rb +167 -0
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +10 -152
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +9 -241
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -50
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -0
- data/lib/new_relic/agent/instrumentation/mongo.rb +7 -0
- data/lib/new_relic/agent/instrumentation/net_http.rb +44 -0
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/{net_prepend.rb → net_http/instrumentation.rb} +3 -3
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +18 -53
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +29 -139
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +58 -0
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +13 -154
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +12 -107
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +21 -32
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +35 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -158
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +124 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +12 -7
- data/lib/new_relic/agent/new_relic_service.rb +15 -13
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- data/lib/new_relic/agent/transaction.rb +1 -4
- data/lib/new_relic/control/frameworks/rails.rb +11 -9
- data/lib/new_relic/control/instance_methods.rb +1 -0
- data/lib/new_relic/dependency_detection.rb +116 -10
- data/lib/new_relic/noticed_error.rb +4 -8
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/config.html.erb +14 -25
- data/lib/tasks/config.rake +8 -7
- data/newrelic_rpm.gemspec +1 -1
- metadata +55 -8
- data/cert/cacert.pem +0 -1177
- data/lib/new_relic/agent/instrumentation/http.rb +0 -49
- data/lib/new_relic/agent/instrumentation/net.rb +0 -70
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module Typhoeus
|
7
|
+
module Prepend
|
8
|
+
include NewRelic::Agent::Instrumentation::Typhoeus
|
9
|
+
def run(*args)
|
10
|
+
with_tracing { super }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -83,39 +83,44 @@ module NewRelic
|
|
83
83
|
value.nil? || value.empty?
|
84
84
|
end
|
85
85
|
|
86
|
-
def browser_timing_header #THREAD_LOCAL_ACCESS
|
86
|
+
def browser_timing_header(nonce=nil) #THREAD_LOCAL_ACCESS
|
87
87
|
return '' unless js_enabled_and_ready? # fast exit
|
88
88
|
|
89
89
|
state = NewRelic::Agent::Tracer.state
|
90
90
|
|
91
91
|
return '' unless insert_js?(state) # slower exit
|
92
92
|
|
93
|
-
bt_config = browser_timing_config(state)
|
93
|
+
bt_config = browser_timing_config(state, nonce)
|
94
94
|
return '' if bt_config.empty?
|
95
95
|
|
96
|
-
bt_config + browser_timing_loader
|
96
|
+
bt_config + browser_timing_loader(nonce)
|
97
97
|
rescue => e
|
98
98
|
::NewRelic::Agent.logger.debug "Failure during RUM browser_timing_header construction", e
|
99
99
|
''
|
100
100
|
end
|
101
101
|
|
102
|
-
def browser_timing_loader
|
103
|
-
html_safe_if_needed("\n<script>#{Agent.config[:js_agent_loader]}</script>")
|
102
|
+
def browser_timing_loader(nonce=nil)
|
103
|
+
html_safe_if_needed("\n<script type=\"text/javascript\"#{create_nonce(nonce)}>#{Agent.config[:js_agent_loader]}</script>")
|
104
104
|
end
|
105
105
|
|
106
|
-
def browser_timing_config(state)
|
106
|
+
def browser_timing_config(state, nonce=nil)
|
107
107
|
txn = state.current_transaction
|
108
108
|
return '' if txn.nil?
|
109
109
|
|
110
110
|
txn.freeze_name_and_execute_if_not_ignored do
|
111
111
|
data = data_for_js_agent(txn)
|
112
112
|
json = ::JSON.dump(data)
|
113
|
-
return html_safe_if_needed("\n<script>window.NREUM||(NREUM={});NREUM.info=#{json}</script>")
|
113
|
+
return html_safe_if_needed("\n<script type=\"text/javascript\"#{create_nonce(nonce)}>window.NREUM||(NREUM={});NREUM.info=#{json}</script>")
|
114
114
|
end
|
115
115
|
|
116
116
|
''
|
117
117
|
end
|
118
118
|
|
119
|
+
def create_nonce(nonce=nil)
|
120
|
+
return '' unless nonce
|
121
|
+
" nonce=\"#{nonce.to_s}\""
|
122
|
+
end
|
123
|
+
|
119
124
|
BEACON_KEY = "beacon".freeze
|
120
125
|
ERROR_BEACON_KEY = "errorBeacon".freeze
|
121
126
|
LICENSE_KEY_KEY = "licenseKey".freeze
|
@@ -41,7 +41,6 @@ module NewRelic
|
|
41
41
|
@configured_collector = collector
|
42
42
|
@request_timeout = Agent.config[:timeout]
|
43
43
|
@ssl_cert_store = nil
|
44
|
-
@use_bundled_certs = false
|
45
44
|
@in_session = nil
|
46
45
|
@agent_id = nil
|
47
46
|
@shared_tcp_connection = nil
|
@@ -299,7 +298,7 @@ module NewRelic
|
|
299
298
|
end
|
300
299
|
|
301
300
|
def set_cert_store(conn)
|
302
|
-
if
|
301
|
+
if NewRelic::Agent.config[:ca_bundle_path]
|
303
302
|
conn.cert_store = ssl_cert_store
|
304
303
|
else
|
305
304
|
::NewRelic::Agent.logger.debug("Using default security certificates")
|
@@ -348,13 +347,8 @@ module NewRelic
|
|
348
347
|
start_connection(conn)
|
349
348
|
conn
|
350
349
|
rescue Timeout::Error
|
351
|
-
|
352
|
-
|
353
|
-
@use_bundled_certs = true
|
354
|
-
retry
|
355
|
-
else
|
356
|
-
raise
|
357
|
-
end
|
350
|
+
::NewRelic::Agent.logger.info ("Timeout while attempting to connect. You may need to install system-level CA Certificates, as the ruby agent no longer includes these.")
|
351
|
+
raise
|
358
352
|
end
|
359
353
|
|
360
354
|
# The path to the certificate file used to verify the SSL
|
@@ -363,9 +357,6 @@ module NewRelic
|
|
363
357
|
if path_override = NewRelic::Agent.config[:ca_bundle_path]
|
364
358
|
NewRelic::Agent.logger.warn("Couldn't find CA bundle from configured ca_bundle_path: #{path_override}") unless File.exist? path_override
|
365
359
|
path_override
|
366
|
-
else
|
367
|
-
::NewRelic::Agent.increment_metric("Supportability/Ruby/Certificate/BundleRequired")
|
368
|
-
File.expand_path(File.join(control.newrelic_root, 'cert', 'cacert.pem'))
|
369
360
|
end
|
370
361
|
end
|
371
362
|
|
@@ -435,7 +426,18 @@ module NewRelic
|
|
435
426
|
size = data.size
|
436
427
|
|
437
428
|
# Preconnect needs to always use the configured collector host, not the redirect host
|
438
|
-
endpoint_specific_collector = (method == :preconnect) ? @configured_collector : @collector
|
429
|
+
# endpoint_specific_collector = (method == :preconnect) ? @configured_collector : @collector
|
430
|
+
|
431
|
+
# This is a temporary workaround due to errors occurring on the staging collector. The prod collector does not have the same issue.
|
432
|
+
# The staging collector does not respond correctly when using the configured collector host for preconnect, so must use the redirect host
|
433
|
+
# Once this issue is resolved on the staging collector, use the original line that is commented out above.
|
434
|
+
endpoint_specific_collector = if method == :preconnect && (@configured_collector && @configured_collector.name != 'staging-collector.newrelic.com')
|
435
|
+
::NewRelic::Agent.logger.debug "Using configured collector for preconnect: #{@configured_collector}"
|
436
|
+
@configured_collector
|
437
|
+
else
|
438
|
+
::NewRelic::Agent.logger.debug "Using redirect host for collector: #{@collector}"
|
439
|
+
@collector
|
440
|
+
end
|
439
441
|
|
440
442
|
uri = remote_method_uri(method)
|
441
443
|
full_uri = "#{endpoint_specific_collector}#{uri}"
|
@@ -65,7 +65,7 @@ module NewRelic
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# This is called when we are done with the transaction.
|
68
|
-
def on_finishing_transaction(state, name
|
68
|
+
def on_finishing_transaction(state, name)
|
69
69
|
return unless enabled?
|
70
70
|
|
71
71
|
data = state.sql_sampler_transaction_data
|
@@ -359,10 +359,10 @@ module NewRelic
|
|
359
359
|
# need to hash the same way in every process, to be able to aggregate slow SQL traces
|
360
360
|
def consistent_hash(string)
|
361
361
|
if NewRelic::Agent.config[:'slow_sql.use_longer_sql_id']
|
362
|
-
Digest::
|
362
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**63-1)
|
363
363
|
else
|
364
364
|
# from when sql_id needed to fit in an INT(11)
|
365
|
-
Digest::
|
365
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**31-1)
|
366
366
|
end
|
367
367
|
end
|
368
368
|
end
|
@@ -464,7 +464,7 @@ module NewRelic
|
|
464
464
|
@ignore_apdex = options[:ignore_apdex] if options.key? :ignore_apdex
|
465
465
|
@ignore_enduser = options[:ignore_enduser] if options.key? :ignore_enduser
|
466
466
|
|
467
|
-
nest_initial_segment if
|
467
|
+
nest_initial_segment if segments.length == 1
|
468
468
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
469
469
|
segment = create_segment nested_name
|
470
470
|
set_default_transaction_name(options[:transaction_name], category)
|
@@ -571,9 +571,6 @@ module NewRelic
|
|
571
571
|
AttributeFilter::DST_ERROR_COLLECTOR
|
572
572
|
|
573
573
|
if http_response_code
|
574
|
-
add_agent_attribute(:httpResponseCode, http_response_code.to_s, default_destinations)
|
575
|
-
# Sending status code as an int with http.statusCode key is correct
|
576
|
-
# The above attribute is deprecated and should be removed in agent version 7.0.0
|
577
574
|
add_agent_attribute(:'http.statusCode', http_response_code, default_destinations)
|
578
575
|
end
|
579
576
|
|
@@ -82,15 +82,17 @@ module NewRelic
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def install_browser_monitoring(config)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
@install_lock.synchronize do
|
86
|
+
return if defined?(@browser_monitoring_installed) && @browser_monitoring_installed
|
87
|
+
@browser_monitoring_installed = true
|
88
|
+
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
89
|
+
begin
|
90
|
+
require 'new_relic/rack/browser_monitoring'
|
91
|
+
config.middleware.use NewRelic::Rack::BrowserMonitoring
|
92
|
+
::NewRelic::Agent.logger.debug("Installed New Relic Browser Monitoring middleware")
|
93
|
+
rescue => e
|
94
|
+
::NewRelic::Agent.logger.warn("Error installing New Relic Browser Monitoring middleware", e)
|
95
|
+
end
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
@@ -21,6 +21,7 @@ module DependencyDetection
|
|
21
21
|
end
|
22
22
|
|
23
23
|
@items << item
|
24
|
+
return item
|
24
25
|
end
|
25
26
|
|
26
27
|
def detect!
|
@@ -51,16 +52,25 @@ module DependencyDetection
|
|
51
52
|
class Dependent
|
52
53
|
attr_reader :executed
|
53
54
|
attr_accessor :name
|
55
|
+
attr_writer :config_name
|
56
|
+
attr_reader :dependencies
|
57
|
+
attr_reader :prepend_conflicts
|
58
|
+
|
59
|
+
|
54
60
|
def executed!
|
55
61
|
@executed = true
|
56
62
|
end
|
57
63
|
|
58
|
-
|
64
|
+
def config_name
|
65
|
+
@config_name || @name
|
66
|
+
end
|
59
67
|
|
60
68
|
def initialize
|
61
69
|
@dependencies = []
|
62
70
|
@executes = []
|
71
|
+
@prepend_conflicts = []
|
63
72
|
@name = nil
|
73
|
+
@config_name = nil
|
64
74
|
end
|
65
75
|
|
66
76
|
def dependencies_satisfied?
|
@@ -70,13 +80,46 @@ module DependencyDetection
|
|
70
80
|
def source_location_for klass, method_name
|
71
81
|
Object.instance_method(:method).bind(klass.allocate).call(method_name).source_location.to_s
|
72
82
|
end
|
73
|
-
|
83
|
+
|
84
|
+
# Extracts the instrumented library name from the instrumenting module's name
|
85
|
+
# Given "NewRelic::Agent::Instrumentation::NetHTTP::Prepend"
|
86
|
+
# Will extract "NetHTTP" which is in the 2nd to last spot
|
87
|
+
def extract_supportability_name instrumenting_module
|
88
|
+
instrumenting_module.to_s.split("::")[-2]
|
89
|
+
end
|
90
|
+
|
91
|
+
def log_and_instrument method, instrumenting_module, supportability_name
|
92
|
+
supportability_name ||= extract_supportability_name(instrumenting_module)
|
93
|
+
NewRelic::Agent.logger.info "Installing New Relic supported #{supportability_name} instrumentation using #{method}"
|
94
|
+
NewRelic::Agent.record_metric("Supportability/Instrumentation/#{supportability_name}/#{method}", 0.0)
|
95
|
+
yield
|
96
|
+
end
|
97
|
+
|
98
|
+
def prepend_instrument target_class, instrumenting_module, supportability_name=nil
|
99
|
+
log_and_instrument("Prepend", instrumenting_module, supportability_name) do
|
100
|
+
target_class.send :prepend, instrumenting_module
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def chain_instrument instrumenting_module, supportability_name=nil
|
105
|
+
log_and_instrument("MethodChaining", instrumenting_module, supportability_name) do
|
106
|
+
instrumenting_module.instrument!
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def chain_instrument_target target, instrumenting_module, supportability_name=nil
|
111
|
+
NewRelic::Agent.logger.info "Installing deferred #{target} instrumentation"
|
112
|
+
log_and_instrument("MethodChaining", instrumenting_module, supportability_name) do
|
113
|
+
instrumenting_module.instrument! target
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
74
117
|
def execute
|
75
118
|
@executes.each do |x|
|
76
119
|
begin
|
77
120
|
x.call
|
78
121
|
rescue => err
|
79
|
-
NewRelic::Agent.logger.error
|
122
|
+
NewRelic::Agent.logger.error "Error while installing #{self.name} instrumentation:", err
|
80
123
|
break
|
81
124
|
end
|
82
125
|
end
|
@@ -102,24 +145,87 @@ module DependencyDetection
|
|
102
145
|
end
|
103
146
|
|
104
147
|
def allowed_by_config?
|
105
|
-
|
106
|
-
|
148
|
+
!(disabled_configured? || deprecated_disabled_configured?)
|
149
|
+
end
|
150
|
+
|
151
|
+
# TODO: Remove in 8.0
|
152
|
+
# will only return true if a disabled key is found and is truthy
|
153
|
+
def deprecated_disabled_configured?
|
154
|
+
return false if self.name.nil?
|
107
155
|
|
108
156
|
key = "disable_#{self.name}".to_sym
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
157
|
+
return false unless ::NewRelic::Agent.config[key] == true
|
158
|
+
|
159
|
+
::NewRelic::Agent.logger.debug("Not installing #{self.name} instrumentation because of configuration #{key}")
|
160
|
+
::NewRelic::Agent.logger.debug \
|
161
|
+
"[DEPRECATED] configuration #{key} for #{self.name} will be removed in the next major release." \
|
162
|
+
" Use `#{config_key}` with one of `#{VALID_CONFIG_VALUES.map(&:to_s).inspect}`"
|
163
|
+
|
164
|
+
return true
|
165
|
+
end
|
166
|
+
|
167
|
+
def config_key
|
168
|
+
return nil if self.config_name.nil?
|
169
|
+
@config_key ||= "instrumentation.#{self.config_name}".to_sym
|
170
|
+
end
|
171
|
+
|
172
|
+
VALID_CONFIG_VALUES = [:auto, :disabled, :prepend, :chain]
|
173
|
+
AUTO_CONFIG_VALUE = VALID_CONFIG_VALUES[0]
|
174
|
+
|
175
|
+
VALID_CONFIG_VALUES.each do |value|
|
176
|
+
define_method "#{value}_configured?" do
|
177
|
+
value == config_value
|
114
178
|
end
|
115
179
|
end
|
116
180
|
|
181
|
+
# returns only a valid value for instrumentation configuration
|
182
|
+
# If user uses "enabled" it's converted to "auto"
|
183
|
+
def valid_config_value retrieved_value
|
184
|
+
VALID_CONFIG_VALUES.include?(retrieved_value) ? retrieved_value : AUTO_CONFIG_VALUE
|
185
|
+
end
|
186
|
+
|
187
|
+
# fetches and transform potentially invalid value given to one of the valid config values
|
188
|
+
# logs the resolved value during debug mode.
|
189
|
+
def fetch_config_value(key)
|
190
|
+
valid_value = valid_config_value(::NewRelic::Agent.config[key].to_s.to_sym)
|
191
|
+
::NewRelic::Agent.logger.debug("Using #{valid_value} configuration value for #{self.name} to configure instrumentation")
|
192
|
+
return valid_value
|
193
|
+
end
|
194
|
+
|
195
|
+
def config_value
|
196
|
+
return AUTO_CONFIG_VALUE unless config_key
|
197
|
+
fetch_config_value(config_key)
|
198
|
+
end
|
199
|
+
|
117
200
|
def named(new_name)
|
118
201
|
self.name = new_name
|
119
202
|
end
|
120
203
|
|
204
|
+
def configure_with(new_config_name)
|
205
|
+
self.config_name = new_config_name
|
206
|
+
end
|
207
|
+
|
121
208
|
def executes &block
|
122
209
|
@executes << block if block_given?
|
123
210
|
end
|
211
|
+
|
212
|
+
def conflicts_with_prepend &block
|
213
|
+
@prepend_conflicts << block if block_given?
|
214
|
+
end
|
215
|
+
|
216
|
+
def use_prepend?
|
217
|
+
prepend_configured? || (auto_configured? && !prepend_conflicts?)
|
218
|
+
end
|
219
|
+
|
220
|
+
def prepend_conflicts?
|
221
|
+
@prepend_conflicts.any? do |conflict|
|
222
|
+
begin
|
223
|
+
conflict.call
|
224
|
+
rescue => err
|
225
|
+
NewRelic::Agent.logger.error( "Error while checking prepend conflicts #{self.name}:", err )
|
226
|
+
false # assumes no conflicts exist since `prepend` is preferred method of instrumenting
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
124
230
|
end
|
125
231
|
end
|
@@ -33,7 +33,7 @@ class NewRelic::NoticedError
|
|
33
33
|
ERROR_CLASS_KEY = "#{ERROR_PREFIX_KEY}.class"
|
34
34
|
ERROR_EXPECTED_KEY = "#{ERROR_PREFIX_KEY}.expected"
|
35
35
|
|
36
|
-
def initialize(path, exception, timestamp = Time.now)
|
36
|
+
def initialize(path, exception, timestamp = Time.now, expected = false)
|
37
37
|
@exception_id = exception.object_id
|
38
38
|
@path = path
|
39
39
|
|
@@ -58,7 +58,7 @@ class NewRelic::NoticedError
|
|
58
58
|
@attributes_from_notice_error = nil
|
59
59
|
@attributes = nil
|
60
60
|
@timestamp = timestamp
|
61
|
-
@expected =
|
61
|
+
@expected = expected
|
62
62
|
end
|
63
63
|
|
64
64
|
def ==(other)
|
@@ -70,11 +70,7 @@ class NewRelic::NoticedError
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def self.passes_message_allowlist(exception_class)
|
73
|
-
|
74
|
-
|
75
|
-
allowed = NewRelic::Agent.config[:'strip_exception_messages.allowed_classes'].concat(NewRelic::Agent.config[:'strip_exception_messages.whitelist'])
|
76
|
-
|
77
|
-
allowed.any? do |klass|
|
73
|
+
NewRelic::Agent.config[:'strip_exception_messages.allowed_classes'].any? do |klass|
|
78
74
|
exception_class <= klass
|
79
75
|
end
|
80
76
|
end
|
@@ -108,7 +104,7 @@ class NewRelic::NoticedError
|
|
108
104
|
params[:file_name] = file_name if file_name
|
109
105
|
params[:line_number] = line_number if line_number
|
110
106
|
params[:stack_trace] = stack_trace if stack_trace
|
111
|
-
params[
|
107
|
+
params[ERROR_EXPECTED_KEY.to_sym] = expected
|
112
108
|
params
|
113
109
|
end
|
114
110
|
|
@@ -13,7 +13,6 @@ module NewRelic
|
|
13
13
|
API_SUPPORTABILITY_METRICS = [
|
14
14
|
:insert_distributed_trace_headers,
|
15
15
|
:accept_distributed_trace_headers,
|
16
|
-
:create_distributed_trace_headers,
|
17
16
|
:add_custom_attributes,
|
18
17
|
:add_custom_span_attributes,
|
19
18
|
:add_instrumentation,
|
@@ -75,7 +74,7 @@ module NewRelic
|
|
75
74
|
caller_location = caller_locations.first.label
|
76
75
|
|
77
76
|
message = "Bad argument passed to ##{caller_location}. " \
|
78
|
-
"Expected #{klass} for `#{name}` but got #{
|
77
|
+
"Expected #{klass} for `#{name}` but got #{arg.class}"
|
79
78
|
|
80
79
|
NewRelic::Agent.logger.warn message
|
81
80
|
nil
|