newrelic_rpm 8.13.1 → 8.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +130 -1
- data/.rubocop_todo.yml +3 -0
- data/CHANGELOG.md +3284 -3148
- data/CONTRIBUTING.md +1 -2
- data/README.md +2 -1
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +14 -466
- data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
- data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +75 -0
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
- data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
- data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
- data/lib/new_relic/agent/configuration/default_source.rb +47 -9
- data/lib/new_relic/agent/datastores.rb +2 -2
- data/lib/new_relic/agent/event_loop.rb +1 -1
- data/lib/new_relic/agent/guid_generator.rb +11 -2
- data/lib/new_relic/agent/heap.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_job.rb +7 -7
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -24
- data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_support.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
- data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +4 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +21 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +27 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +31 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +50 -50
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +5 -5
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +9 -9
- data/lib/new_relic/agent/instrumentation/grape.rb +8 -8
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +4 -4
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/logger.rb +3 -3
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +16 -16
- data/lib/new_relic/agent/instrumentation/mongo.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +6 -6
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack.rb +14 -14
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +5 -3
- data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rake.rb +7 -7
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +29 -8
- data/lib/new_relic/agent/instrumentation/redis.rb +4 -4
- data/lib/new_relic/agent/instrumentation/resque.rb +9 -9
- data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sinatra.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +3 -3
- data/lib/new_relic/agent/instrumentation/tilt.rb +3 -3
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +2 -2
- data/lib/new_relic/agent/method_tracer_helpers.rb +6 -11
- data/lib/new_relic/agent/range_extensions.rb +2 -2
- data/lib/new_relic/agent/tracer.rb +8 -4
- data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
- data/lib/new_relic/agent/transaction/segment.rb +6 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +3 -3
- data/lib/new_relic/agent.rb +7 -0
- data/lib/new_relic/control/instance_methods.rb +6 -2
- data/lib/new_relic/helper.rb +1 -1
- data/lib/new_relic/recipes/helpers/send_deployment.rb +2 -1
- data/lib/new_relic/traced_thread.rb +5 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +13 -2
- data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
- data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
- data/newrelic.yml +23 -5
- data/test/agent_helper.rb +7 -7
- metadata +16 -6
- data/lib/new_relic/agent/agent/shutdown.rb +0 -35
- data/lib/new_relic/agent/agent/special_startup.rb +0 -72
- data/lib/new_relic/agent/agent/start_worker_thread.rb +0 -163
- data/lib/new_relic/agent/agent/startup.rb +0 -197
@@ -0,0 +1,202 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic
|
6
|
+
module Agent
|
7
|
+
module AgentHelpers
|
8
|
+
module Startup
|
9
|
+
# True if we have initialized and completed 'start'
|
10
|
+
def started?
|
11
|
+
@started
|
12
|
+
end
|
13
|
+
|
14
|
+
# Check whether we have already started, which is an error condition
|
15
|
+
def already_started?
|
16
|
+
if started?
|
17
|
+
::NewRelic::Agent.logger.error("Agent Started Already!")
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Logs a bunch of data and starts the agent, if needed
|
23
|
+
def start
|
24
|
+
return unless agent_should_start?
|
25
|
+
|
26
|
+
log_startup
|
27
|
+
check_config_and_start_agent
|
28
|
+
log_version_and_pid
|
29
|
+
|
30
|
+
events.subscribe(:initial_configuration_complete) do
|
31
|
+
log_ignore_url_regexes
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sanity-check the agent configuration and start the agent,
|
36
|
+
# setting up the worker thread and the exit handler to shut
|
37
|
+
# down the agent
|
38
|
+
def check_config_and_start_agent
|
39
|
+
return unless monitoring? && has_correct_license_key?
|
40
|
+
return if using_forking_dispatcher?
|
41
|
+
|
42
|
+
setup_and_start_agent
|
43
|
+
end
|
44
|
+
|
45
|
+
# This is the shared method between the main agent startup and the
|
46
|
+
# after_fork call restarting the thread in deferred dispatchers.
|
47
|
+
#
|
48
|
+
# Treatment of @started and env report is important to get right.
|
49
|
+
def setup_and_start_agent(options = {})
|
50
|
+
@started = true
|
51
|
+
@harvester.mark_started
|
52
|
+
|
53
|
+
unless in_resque_child_process?
|
54
|
+
install_exit_handler
|
55
|
+
environment_for_connect
|
56
|
+
@harvest_samplers.load_samplers unless Agent.config[:disable_samplers]
|
57
|
+
end
|
58
|
+
|
59
|
+
connect_in_foreground if Agent.config[:sync_startup]
|
60
|
+
start_worker_thread(options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Log startup information that we almost always want to know
|
64
|
+
def log_startup
|
65
|
+
log_environment
|
66
|
+
log_dispatcher
|
67
|
+
log_app_name
|
68
|
+
end
|
69
|
+
|
70
|
+
# Log the environment the app thinks it's running in.
|
71
|
+
# Useful in debugging, as this is the key for config YAML lookups.
|
72
|
+
def log_environment
|
73
|
+
::NewRelic::Agent.logger.info("Environment: #{NewRelic::Control.instance.env}")
|
74
|
+
end
|
75
|
+
|
76
|
+
# Logs the dispatcher to the log file to assist with
|
77
|
+
# debugging. When no debugger is present, logs this fact to
|
78
|
+
# assist with proper dispatcher detection
|
79
|
+
def log_dispatcher
|
80
|
+
dispatcher_name = Agent.config[:dispatcher].to_s
|
81
|
+
|
82
|
+
if dispatcher_name.empty?
|
83
|
+
::NewRelic::Agent.logger.info('No known dispatcher detected.')
|
84
|
+
else
|
85
|
+
::NewRelic::Agent.logger.info("Dispatcher: #{dispatcher_name}")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def log_app_name
|
90
|
+
::NewRelic::Agent.logger.info("Application: #{Agent.config[:app_name].join(", ")}")
|
91
|
+
end
|
92
|
+
|
93
|
+
def log_ignore_url_regexes
|
94
|
+
regexes = NewRelic::Agent.config[:'rules.ignore_url_regexes']
|
95
|
+
|
96
|
+
unless regexes.empty?
|
97
|
+
::NewRelic::Agent.logger.info("Ignoring URLs that match the following regexes: " \
|
98
|
+
"#{regexes.map(&:inspect).join(", ")}.")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Classy logging of the agent version and the current pid,
|
103
|
+
# so we can disambiguate processes in the log file and make
|
104
|
+
# sure they're running a reasonable version
|
105
|
+
def log_version_and_pid
|
106
|
+
::NewRelic::Agent.logger.debug("New Relic Ruby Agent #{NewRelic::VERSION::STRING} Initialized: pid = #{$$}")
|
107
|
+
end
|
108
|
+
|
109
|
+
# Logs the configured application names
|
110
|
+
def app_name_configured?
|
111
|
+
names = Agent.config[:app_name]
|
112
|
+
return names.respond_to?(:any?) && names.any?
|
113
|
+
end
|
114
|
+
|
115
|
+
# Connecting in the foreground blocks further startup of the
|
116
|
+
# agent until we have a connection - useful in cases where
|
117
|
+
# you're trying to log a very-short-running process and want
|
118
|
+
# to get statistics from before a server connection
|
119
|
+
# (typically 20 seconds) exists
|
120
|
+
def connect_in_foreground
|
121
|
+
NewRelic::Agent.disable_all_tracing { connect(:keep_retrying => false) }
|
122
|
+
end
|
123
|
+
|
124
|
+
# Warn the user if they have configured their agent not to
|
125
|
+
# send data, that way we can see this clearly in the log file
|
126
|
+
def monitoring?
|
127
|
+
if Agent.config[:monitor_mode]
|
128
|
+
true
|
129
|
+
else
|
130
|
+
::NewRelic::Agent.logger.warn('Agent configured not to send data in this environment.')
|
131
|
+
false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Tell the user when the license key is missing so they can
|
136
|
+
# fix it by adding it to the file
|
137
|
+
def has_license_key?
|
138
|
+
if Agent.config[:license_key] && Agent.config[:license_key].length > 0
|
139
|
+
true
|
140
|
+
else
|
141
|
+
::NewRelic::Agent.logger.warn("No license key found. " +
|
142
|
+
"This often means your newrelic.yml file was not found, or it lacks a section for the running " \
|
143
|
+
"environment, '#{NewRelic::Control.instance.env}'. You may also want to try linting your newrelic.yml " \
|
144
|
+
"to ensure it is valid YML.")
|
145
|
+
false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# A correct license key exists and is of the proper length
|
150
|
+
def has_correct_license_key?
|
151
|
+
has_license_key? && correct_license_length
|
152
|
+
end
|
153
|
+
|
154
|
+
# A license key is an arbitrary 40 character string,
|
155
|
+
# usually looks something like a SHA1 hash
|
156
|
+
def correct_license_length
|
157
|
+
key = Agent.config[:license_key]
|
158
|
+
|
159
|
+
if key.length == 40
|
160
|
+
true
|
161
|
+
else
|
162
|
+
::NewRelic::Agent.logger.error("Invalid license key: #{key}")
|
163
|
+
false
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Check to see if the agent should start, returning +true+ if it should.
|
168
|
+
def agent_should_start?
|
169
|
+
return false if already_started? || disabled?
|
170
|
+
|
171
|
+
if defer_for_delayed_job?
|
172
|
+
::NewRelic::Agent.logger.debug("Deferring startup for DelayedJob")
|
173
|
+
return false
|
174
|
+
end
|
175
|
+
|
176
|
+
if defer_for_resque?
|
177
|
+
::NewRelic::Agent.logger.debug("Deferring startup for Resque in case it daemonizes")
|
178
|
+
return false
|
179
|
+
end
|
180
|
+
|
181
|
+
unless app_name_configured?
|
182
|
+
NewRelic::Agent.logger.error("No application name configured.",
|
183
|
+
"The Agent cannot start without at least one. Please check your ",
|
184
|
+
"newrelic.yml and ensure that it is valid and has at least one ",
|
185
|
+
"value set for app_name in the #{NewRelic::Control.instance.env} ",
|
186
|
+
"environment.")
|
187
|
+
return false
|
188
|
+
end
|
189
|
+
|
190
|
+
return true
|
191
|
+
end
|
192
|
+
|
193
|
+
# The agent is disabled when it is not force enabled by the
|
194
|
+
# 'agent_enabled' option (e.g. in a manual start), or
|
195
|
+
# enabled normally through the configuration file
|
196
|
+
def disabled?
|
197
|
+
!Agent.config[:agent_enabled]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic
|
6
|
+
module Agent
|
7
|
+
module AgentHelpers
|
8
|
+
module Transmit
|
9
|
+
TRANSACTION_EVENT = "TransactionEvent".freeze
|
10
|
+
def transmit_analytic_event_data
|
11
|
+
transmit_single_data_type(:harvest_and_send_analytic_event_data, TRANSACTION_EVENT)
|
12
|
+
end
|
13
|
+
|
14
|
+
CUSTOM_EVENT = "CustomEvent".freeze
|
15
|
+
def transmit_custom_event_data
|
16
|
+
transmit_single_data_type(:harvest_and_send_custom_event_data, CUSTOM_EVENT)
|
17
|
+
end
|
18
|
+
|
19
|
+
ERROR_EVENT = "ErrorEvent".freeze
|
20
|
+
def transmit_error_event_data
|
21
|
+
transmit_single_data_type(:harvest_and_send_error_event_data, ERROR_EVENT)
|
22
|
+
end
|
23
|
+
|
24
|
+
SPAN_EVENT = "SpanEvent".freeze
|
25
|
+
def transmit_span_event_data
|
26
|
+
transmit_single_data_type(:harvest_and_send_span_event_data, SPAN_EVENT)
|
27
|
+
end
|
28
|
+
|
29
|
+
LOG_EVENT = "LogEvent".freeze
|
30
|
+
def transmit_log_event_data
|
31
|
+
transmit_single_data_type(:harvest_and_send_log_event_data, LOG_EVENT)
|
32
|
+
end
|
33
|
+
|
34
|
+
def transmit_single_data_type(harvest_method, supportability_name)
|
35
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
36
|
+
|
37
|
+
msg = "Sending #{supportability_name} data to New Relic Service"
|
38
|
+
::NewRelic::Agent.logger.debug(msg)
|
39
|
+
|
40
|
+
@service.session do # use http keep-alive
|
41
|
+
self.send(harvest_method)
|
42
|
+
end
|
43
|
+
ensure
|
44
|
+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
|
45
|
+
NewRelic::Agent.record_metric("Supportability/#{supportability_name}Harvest", duration)
|
46
|
+
end
|
47
|
+
|
48
|
+
def transmit_data
|
49
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
50
|
+
::NewRelic::Agent.logger.debug("Sending data to New Relic Service")
|
51
|
+
|
52
|
+
@events.notify(:before_harvest)
|
53
|
+
@service.session do # use http keep-alive
|
54
|
+
harvest_and_send_data_types
|
55
|
+
|
56
|
+
check_for_and_handle_agent_commands
|
57
|
+
harvest_and_send_for_agent_commands
|
58
|
+
end
|
59
|
+
ensure
|
60
|
+
NewRelic::Agent::Database.close_connections
|
61
|
+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
|
62
|
+
NewRelic::Agent.record_metric('Supportability/Harvest', duration)
|
63
|
+
end
|
64
|
+
|
65
|
+
def transmit_data_types
|
66
|
+
transmit_data
|
67
|
+
transmit_analytic_event_data
|
68
|
+
transmit_custom_event_data
|
69
|
+
transmit_error_event_data
|
70
|
+
transmit_span_event_data
|
71
|
+
transmit_log_event_data
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -358,6 +358,19 @@ module NewRelic
|
|
358
358
|
:description => 'Sets the level of detail of log messages. Possible log levels, in increasing verbosity, are: `error`, `warn`, `info` or `debug`.'
|
359
359
|
},
|
360
360
|
# General
|
361
|
+
:active_support_custom_events_names => {
|
362
|
+
:default => [],
|
363
|
+
:public => true,
|
364
|
+
:type => Array,
|
365
|
+
:allowed_from_server => false,
|
366
|
+
:description => <<-DESCRIPTION
|
367
|
+
An array of ActiveSupport custom events names to subscribe to and provide
|
368
|
+
instrumentation for. For example,
|
369
|
+
- my.custom.event
|
370
|
+
- another.event
|
371
|
+
- a.third.event
|
372
|
+
DESCRIPTION
|
373
|
+
},
|
361
374
|
:apdex_t => {
|
362
375
|
:default => 0.5,
|
363
376
|
:public => true,
|
@@ -371,7 +384,7 @@ module NewRelic
|
|
371
384
|
:public => true,
|
372
385
|
:type => String,
|
373
386
|
:allowed_from_server => false,
|
374
|
-
:description => 'Your New Relic
|
387
|
+
:description => 'Your New Relic [user key](/docs/apis/intro-apis/new-relic-api-keys/#overview-keys). Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.'
|
375
388
|
},
|
376
389
|
:backport_fast_active_record_connection_lookup => {
|
377
390
|
:default => false,
|
@@ -1439,7 +1452,7 @@ A map of error classes to a list of messages. When an error of one of the classe
|
|
1439
1452
|
If `true`, disables agent middleware for Sinatra. This middleware is responsible for advanced feature support such as [cross application tracing](/docs/apm/transactions/cross-application-traces/cross-application-tracing), [page load timing](/docs/browser/new-relic-browser/getting-started/new-relic-browser), and [error collection](/docs/apm/applications-menu/events/view-apm-error-analytics).
|
1440
1453
|
|
1441
1454
|
<Callout variant="important">
|
1442
|
-
Cross application tracing is deprecated in favor of [distributed tracing](
|
1455
|
+
Cross application tracing is deprecated in favor of [distributed tracing](/docs/apm/distributed-tracing/getting-started/introduction-distributed-tracing). Distributed tracing is on by default for Ruby agent versions 8.0.0 and above. Middlewares are not required to support distributed tracing.
|
1443
1456
|
|
1444
1457
|
To continue using cross application tracing, update the following options in your `newrelic.yml` configuration file:
|
1445
1458
|
|
@@ -1556,6 +1569,14 @@ If `true`, disables agent middleware for Sinatra. This middleware is responsible
|
|
1556
1569
|
:allowed_from_server => false,
|
1557
1570
|
:description => 'Controls auto-instrumentation of bunny at start up. May be one of [auto|prepend|chain|disabled].'
|
1558
1571
|
},
|
1572
|
+
:'instrumentation.concurrent_ruby' => {
|
1573
|
+
:default => 'auto',
|
1574
|
+
:public => true,
|
1575
|
+
:type => String,
|
1576
|
+
:dynamic_name => true,
|
1577
|
+
:allowed_from_server => false,
|
1578
|
+
:description => 'Controls auto-instrumentation of the concurrent-ruby library at start up. May be one of [auto|prepend|chain|disabled].'
|
1579
|
+
},
|
1559
1580
|
:'instrumentation.curb' => {
|
1560
1581
|
:default => instrumentation_value_of(:disable_curb),
|
1561
1582
|
:documentation_default => 'auto',
|
@@ -1789,6 +1810,13 @@ If `true`, disables agent middleware for Sinatra. This middleware is responsible
|
|
1789
1810
|
:allowed_from_server => false,
|
1790
1811
|
:description => "Controls auto-instrumentation of the Thread class at start up to automatically add tracing to all Threads created in the application."
|
1791
1812
|
},
|
1813
|
+
:'thread_ids_enabled' => {
|
1814
|
+
:default => false,
|
1815
|
+
:public => false,
|
1816
|
+
:type => Boolean,
|
1817
|
+
:allowed_from_server => false,
|
1818
|
+
:description => "If enabled, will append the current Thread and Fiber object ids onto the segment names of segments created in Threads and concurrent-ruby"
|
1819
|
+
},
|
1792
1820
|
:'instrumentation.tilt' => {
|
1793
1821
|
:default => "auto",
|
1794
1822
|
:public => true,
|
@@ -1837,6 +1865,16 @@ If `true`, disables agent middleware for Sinatra. This middleware is responsible
|
|
1837
1865
|
:allowed_from_server => false,
|
1838
1866
|
:description => 'Specify a custom host name for [display in the New Relic UI](/docs/apm/new-relic-apm/maintenance/add-rename-remove-hosts#display_name).'
|
1839
1867
|
},
|
1868
|
+
# Rails
|
1869
|
+
:'defer_rails_initialization' => {
|
1870
|
+
:default => false,
|
1871
|
+
:public => false,
|
1872
|
+
:type => Boolean,
|
1873
|
+
:allowed_from_server => false,
|
1874
|
+
:description => 'This configuration option is currently unreachable. Please do not use. ' \
|
1875
|
+
'If `true`, when the agent is in an application using Ruby on Rails, it will start after ' \
|
1876
|
+
'config/initializers have run.'
|
1877
|
+
},
|
1840
1878
|
# Rake
|
1841
1879
|
:'rake.tasks' => {
|
1842
1880
|
:default => [],
|
@@ -1874,7 +1912,7 @@ If `true`, disables agent middleware for Sinatra. This middleware is responsible
|
|
1874
1912
|
:type => Array,
|
1875
1913
|
:allowed_from_server => true,
|
1876
1914
|
:transform => DefaultSource.method(:convert_to_regexp_list),
|
1877
|
-
:description => 'Define transactions you want the agent to ignore, by specifying a list of patterns matching the URI you want to ignore.
|
1915
|
+
:description => 'Define transactions you want the agent to ignore, by specifying a list of patterns matching the URI you want to ignore. For more detail, see [the docs on ignoring specific transactions](/docs/agents/ruby-agent/api-guides/ignoring-specific-transactions/#config-ignoring).'
|
1878
1916
|
},
|
1879
1917
|
# Sidekiq
|
1880
1918
|
:'sidekiq.capture_params' => {
|
@@ -2293,22 +2331,22 @@ If `true`, disables agent middleware for Sinatra. This middleware is responsible
|
|
2293
2331
|
:description => "URI for the New Relic data collection service."
|
2294
2332
|
},
|
2295
2333
|
:'infinite_tracing.batching' => {
|
2296
|
-
:default =>
|
2297
|
-
:public =>
|
2334
|
+
:default => true,
|
2335
|
+
:public => true,
|
2298
2336
|
:type => Boolean,
|
2299
2337
|
:allowed_from_server => false,
|
2300
2338
|
:external => :infinite_tracing,
|
2301
|
-
:description => "If true, data sent to the Trace Observer will be batched
|
2339
|
+
:description => "If true (the default), data sent to the Trace Observer will be batched\ninstead of each " \
|
2302
2340
|
"span being sent individually"
|
2303
2341
|
},
|
2304
2342
|
:'infinite_tracing.compression_level' => {
|
2305
|
-
:default => :
|
2306
|
-
:public =>
|
2343
|
+
:default => :high,
|
2344
|
+
:public => true,
|
2307
2345
|
:type => Symbol,
|
2308
2346
|
:allowed_from_server => false,
|
2309
2347
|
:external => :infinite_tracing,
|
2310
2348
|
:description => "Configure the compression level for data sent to the Trace Observer\nMay be one of " \
|
2311
|
-
|
2349
|
+
"[none|low|medium|high]\n'high' is the default. Set the level to 'none' to disable compression"
|
2312
2350
|
},
|
2313
2351
|
:js_agent_file => {
|
2314
2352
|
:default => '',
|
@@ -53,7 +53,7 @@ module NewRelic
|
|
53
53
|
begin
|
54
54
|
send(method_name_without_newrelic, *args, &blk)
|
55
55
|
ensure
|
56
|
-
|
56
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -126,7 +126,7 @@ module NewRelic
|
|
126
126
|
callback.call(result, segment.name, elapsed_time)
|
127
127
|
end
|
128
128
|
ensure
|
129
|
-
|
129
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -7,14 +7,23 @@ module NewRelic
|
|
7
7
|
module GuidGenerator
|
8
8
|
module_function
|
9
9
|
|
10
|
+
MAX_RAND_16 = 16**16
|
11
|
+
MAX_RAND_32 = 16**32
|
10
12
|
# This method intentionally does not use SecureRandom, because it relies
|
11
13
|
# on urandom, which raises an exception in MRI when the interpreter runs
|
12
14
|
# out of allocated file descriptors.
|
13
15
|
# The guids generated by this method may not be _secure_, but they are
|
14
16
|
# random enough for our purposes.
|
15
17
|
def generate_guid(length = 16)
|
16
|
-
guid =
|
17
|
-
|
18
|
+
guid = case length
|
19
|
+
when 16
|
20
|
+
rand(MAX_RAND_16)
|
21
|
+
when 32
|
22
|
+
rand(MAX_RAND_32)
|
23
|
+
else
|
24
|
+
rand(16**length)
|
25
|
+
end.to_s(16)
|
26
|
+
guid.length < length ? guid.rjust(length, '0') : guid
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
data/lib/new_relic/agent/heap.rb
CHANGED
@@ -8,22 +8,22 @@ DependencyDetection.defer do
|
|
8
8
|
named :activejob
|
9
9
|
|
10
10
|
depends_on do
|
11
|
-
defined?(
|
11
|
+
defined?(ActiveJob::Base)
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
|
15
|
+
NewRelic::Agent.logger.info('Installing ActiveJob instrumentation')
|
16
16
|
|
17
17
|
ActiveSupport.on_load(:active_job) do
|
18
|
-
|
19
|
-
|
18
|
+
ActiveJob::Base.around_enqueue do |job, block|
|
19
|
+
NewRelic::Agent::Instrumentation::ActiveJobHelper.enqueue(job, block)
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
ActiveJob::Base.around_perform do |job, block|
|
23
|
+
NewRelic::Agent::Instrumentation::ActiveJobHelper.perform(job, block)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
NewRelic::Agent::PrependSupportability.record_metrics_for(ActiveJob::Base)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -12,7 +12,7 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
|
15
|
+
NewRelic::Agent.logger.info('Installing ActiveMerchant instrumentation')
|
16
16
|
end
|
17
17
|
|
18
18
|
executes do
|
@@ -42,7 +42,7 @@ DependencyDetection.defer do
|
|
42
42
|
deprecation_msg = 'The Ruby Agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
|
43
43
|
'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \
|
44
44
|
|
45
|
-
|
45
|
+
NewRelic::Agent.logger.log_once(
|
46
46
|
:warn,
|
47
47
|
:deprecated_active_merchant_version,
|
48
48
|
deprecation_msg
|
@@ -84,7 +84,7 @@ module NewRelic
|
|
84
84
|
log_without_newrelic_instrumentation(*args, &block)
|
85
85
|
end
|
86
86
|
ensure
|
87
|
-
|
87
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
else
|
@@ -128,7 +128,7 @@ module NewRelic
|
|
128
128
|
log_without_newrelic_instrumentation(*args, **kwargs, &block)
|
129
129
|
end
|
130
130
|
ensure
|
131
|
-
|
131
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -141,9 +141,9 @@ DependencyDetection.defer do
|
|
141
141
|
@name = :active_record
|
142
142
|
|
143
143
|
depends_on do
|
144
|
-
defined?(
|
145
|
-
(!defined?(
|
146
|
-
|
144
|
+
defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
|
145
|
+
(!defined?(ActiveRecord::VERSION) ||
|
146
|
+
ActiveRecord::VERSION::MAJOR.to_i <= 3)
|
147
147
|
end
|
148
148
|
|
149
149
|
depends_on do
|
@@ -151,18 +151,18 @@ DependencyDetection.defer do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
executes do
|
154
|
-
|
154
|
+
NewRelic::Agent.logger.info('Installing ActiveRecord instrumentation')
|
155
155
|
end
|
156
156
|
|
157
157
|
executes do
|
158
158
|
require 'new_relic/agent/instrumentation/active_record_helper'
|
159
159
|
|
160
|
-
if defined?(
|
160
|
+
if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR.to_i == 3
|
161
161
|
ActiveSupport.on_load(:active_record) do
|
162
|
-
|
162
|
+
NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
|
163
163
|
end
|
164
164
|
else
|
165
|
-
|
165
|
+
NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
@@ -84,9 +84,9 @@ DependencyDetection.defer do
|
|
84
84
|
named :active_record_notifications
|
85
85
|
|
86
86
|
depends_on do
|
87
|
-
defined?(
|
88
|
-
defined?(
|
89
|
-
|
87
|
+
defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
|
88
|
+
defined?(ActiveRecord::VERSION) &&
|
89
|
+
ActiveRecord::VERSION::MAJOR.to_i >= 4
|
90
90
|
end
|
91
91
|
|
92
92
|
depends_on do
|
@@ -95,7 +95,7 @@ DependencyDetection.defer do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
executes do
|
98
|
-
|
98
|
+
NewRelic::Agent.logger.info('Installing notifications based Active Record instrumentation')
|
99
99
|
end
|
100
100
|
|
101
101
|
executes do
|
@@ -105,51 +105,51 @@ DependencyDetection.defer do
|
|
105
105
|
|
106
106
|
executes do
|
107
107
|
ActiveSupport.on_load(:active_record) do
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
NewRelic::Agent::PrependSupportability.record_metrics_for(
|
109
|
+
ActiveRecord::Base,
|
110
|
+
ActiveRecord::Relation
|
111
111
|
)
|
112
112
|
|
113
113
|
# Default to .prepending, unless the ActiveRecord version is <=4
|
114
114
|
# **AND** the :prepend_active_record_instrumentation config is false
|
115
|
-
if
|
116
|
-
||
|
115
|
+
if ActiveRecord::VERSION::MAJOR > 4 \
|
116
|
+
|| NewRelic::Agent.config[:prepend_active_record_instrumentation]
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
ActiveRecord::Base.send(:prepend,
|
119
|
+
NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
|
120
|
+
ActiveRecord::Relation.send(:prepend,
|
121
|
+
NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
|
122
122
|
else
|
123
|
-
|
123
|
+
NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
executes do
|
129
129
|
if NewRelic::Agent.config[:backport_fast_active_record_connection_lookup]
|
130
|
-
major_version =
|
131
|
-
minor_version =
|
130
|
+
major_version = ActiveRecord::VERSION::MAJOR.to_i
|
131
|
+
minor_version = ActiveRecord::VERSION::MINOR.to_i
|
132
132
|
|
133
133
|
activerecord_extension = if major_version == 4
|
134
|
-
|
134
|
+
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x
|
135
135
|
elsif major_version == 5 && minor_version == 0
|
136
|
-
|
136
|
+
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions50
|
137
137
|
elsif major_version == 5 && minor_version == 1
|
138
|
-
|
138
|
+
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions51
|
139
139
|
end
|
140
140
|
|
141
141
|
unless activerecord_extension.nil?
|
142
|
-
|
142
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:prepend, activerecord_extension)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
executes do
|
148
|
-
if
|
149
|
-
&&
|
150
|
-
&&
|
148
|
+
if ActiveRecord::VERSION::MAJOR == 5 \
|
149
|
+
&& ActiveRecord::VERSION::MINOR.to_i == 1 \
|
150
|
+
&& ActiveRecord::VERSION::TINY.to_i >= 6
|
151
151
|
|
152
|
-
|
152
|
+
ActiveRecord::Base.prepend(NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|