newrelic_rpm 9.5.0 → 9.7.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 +112 -7
- data/CONTRIBUTING.md +0 -7
- data/Rakefile +1 -1
- data/bin/newrelic +2 -9
- data/bin/newrelic_rpm +15 -0
- data/init.rb +2 -2
- data/lib/new_relic/agent/agent.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +2 -2
- data/lib/new_relic/agent/agent_helpers/startup.rb +2 -2
- data/lib/new_relic/agent/attribute_filter.rb +3 -3
- data/lib/new_relic/agent/configuration/default_source.rb +94 -35
- data/lib/new_relic/agent/configuration/manager.rb +8 -7
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +3 -3
- data/lib/new_relic/agent/event_loop.rb +1 -1
- data/lib/new_relic/agent/http_clients/abstract.rb +4 -0
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +80 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -3
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +109 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +0 -3
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +1 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +0 -3
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +91 -0
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +1 -4
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +0 -3
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -2
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
- data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
- data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
- data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +1 -4
- data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +1 -0
- data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +12 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +1 -2
- data/lib/new_relic/agent/instrumentation/roda.rb +2 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -4
- data/lib/new_relic/agent/instrumentation/view_component/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +38 -0
- data/lib/new_relic/agent/instrumentation/view_component/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/view_component.rb +26 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +0 -1
- data/lib/new_relic/agent/messaging.rb +2 -2
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
- data/lib/new_relic/agent/new_relic_service.rb +8 -6
- data/lib/new_relic/agent/obfuscator.rb +0 -2
- data/lib/new_relic/agent/pipe_channel_manager.rb +2 -2
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -2
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/span_event_primitive.rb +16 -4
- data/lib/new_relic/agent/sql_sampler.rb +0 -1
- data/lib/new_relic/agent/system_info.rb +26 -0
- data/lib/new_relic/agent/tracer.rb +5 -6
- data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -2
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -2
- data/lib/new_relic/agent/transaction/request_attributes.rb +1 -3
- data/lib/new_relic/agent/transaction/tracing.rb +11 -1
- data/lib/new_relic/agent/transaction.rb +25 -2
- data/lib/new_relic/agent/transaction_error_primitive.rb +16 -0
- data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
- data/lib/new_relic/agent/utilization/gcp.rb +1 -3
- data/lib/new_relic/agent/vm/{mri_vm.rb → c_ruby_vm.rb} +7 -15
- data/lib/new_relic/agent/vm.rb +2 -2
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +11 -7
- data/lib/new_relic/base64.rb +25 -0
- data/lib/new_relic/cli/command.rb +6 -4
- data/lib/new_relic/constants.rb +5 -0
- data/lib/new_relic/control/frameworks/rails.rb +17 -5
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/language_support.rb +4 -0
- data/lib/new_relic/local_environment.rb +22 -13
- data/lib/new_relic/supportability_helper.rb +1 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/config.rake +1 -1
- data/lib/tasks/helpers/config.html.erb +6 -6
- data/lib/tasks/helpers/newrelicyml.rb +1 -1
- data/lib/tasks/instrumentation_generator/instrumentation.thor +3 -3
- data/lib/tasks/tests.rake +71 -0
- data/newrelic.yml +55 -35
- data/newrelic_rpm.gemspec +5 -4
- data/test/agent_helper.rb +14 -2
- metadata +32 -7
- data/bin/newrelic_cmd +0 -7
@@ -0,0 +1,25 @@
|
|
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 Base64
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def encode64(bin)
|
10
|
+
[bin].pack('m')
|
11
|
+
end
|
12
|
+
|
13
|
+
def decode64(str)
|
14
|
+
str.unpack1('m')
|
15
|
+
end
|
16
|
+
|
17
|
+
def strict_encode64(bin)
|
18
|
+
[bin].pack('m0')
|
19
|
+
end
|
20
|
+
|
21
|
+
def strict_decode64(str)
|
22
|
+
str.unpack1('m0')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -60,11 +60,13 @@ module NewRelic
|
|
60
60
|
extra = []
|
61
61
|
options = ARGV.options do |opts|
|
62
62
|
script_name = File.basename($0)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
|
64
|
+
# TODO: MAJOR VERSION - remove newrelic, deprecated since version x.xx
|
65
|
+
if /newrelic$/.match?(script_name)
|
66
|
+
$stdout.puts "warning: the 'newrelic' script has been renamed 'newrelic_rpm'"
|
67
|
+
script_name = 'newrelic_rpm'
|
67
68
|
end
|
69
|
+
|
68
70
|
opts.banner = "Usage: #{script_name} [ #{@command_names.join(' | ')} ] [options]"
|
69
71
|
opts.separator("use '#{script_name} <command> -h' to see detailed command options")
|
70
72
|
opts
|
data/lib/new_relic/constants.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
module NewRelic
|
6
|
+
ASTERISK = '*'
|
7
|
+
|
6
8
|
PRIORITY_PRECISION = 6
|
7
9
|
|
8
10
|
EMPTY_ARRAY = [].freeze
|
@@ -35,4 +37,7 @@ module NewRelic
|
|
35
37
|
|
36
38
|
CONNECT_RETRY_PERIODS = [15, 15, 30, 60, 120, 300]
|
37
39
|
MAX_RETRY_PERIOD = 300
|
40
|
+
|
41
|
+
SLASH = '/'
|
42
|
+
ROOT = SLASH
|
38
43
|
end
|
@@ -10,6 +10,9 @@ module NewRelic
|
|
10
10
|
# Rails specific configuration, instrumentation, environment values,
|
11
11
|
# etc.
|
12
12
|
class Rails < NewRelic::Control::Frameworks::Ruby
|
13
|
+
BROWSER_MONITORING_INSTALLED_SINGLETON = NewRelic::Agent.config
|
14
|
+
BROWSER_MONITORING_INSTALLED_VARIABLE = :@browser_monitoring_installed
|
15
|
+
|
13
16
|
def env
|
14
17
|
@env ||= (ENV['NEW_RELIC_ENV'] || RAILS_ENV.dup)
|
15
18
|
end
|
@@ -71,7 +74,7 @@ module NewRelic
|
|
71
74
|
# Might not be running if it does not think mongrel, thin,
|
72
75
|
# passenger, etc. is running, if it thinks it's a rake task, or
|
73
76
|
# if the agent_enabled is false.
|
74
|
-
::NewRelic::Agent.logger.info('New Relic
|
77
|
+
::NewRelic::Agent.logger.info('New Relic agent not running. Skipping browser monitoring and agent hooks.')
|
75
78
|
else
|
76
79
|
install_browser_monitoring(rails_config)
|
77
80
|
install_agent_hooks(rails_config)
|
@@ -89,17 +92,17 @@ module NewRelic
|
|
89
92
|
return unless NewRelic::Rack::AgentHooks.needed?
|
90
93
|
|
91
94
|
config.middleware.use(NewRelic::Rack::AgentHooks)
|
92
|
-
::NewRelic::Agent.logger.debug('Installed New Relic
|
95
|
+
::NewRelic::Agent.logger.debug('Installed New Relic agent hooks middleware')
|
93
96
|
rescue => e
|
94
|
-
::NewRelic::Agent.logger.warn('Error installing New Relic
|
97
|
+
::NewRelic::Agent.logger.warn('Error installing New Relic agent hooks middleware', e)
|
95
98
|
end
|
96
99
|
end
|
97
100
|
|
98
101
|
def install_browser_monitoring(config)
|
99
102
|
@install_lock.synchronize do
|
100
|
-
return if
|
103
|
+
return if browser_agent_already_installed?
|
101
104
|
|
102
|
-
|
105
|
+
mark_browser_agent_as_installed
|
103
106
|
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
104
107
|
|
105
108
|
begin
|
@@ -112,6 +115,15 @@ module NewRelic
|
|
112
115
|
end
|
113
116
|
end
|
114
117
|
|
118
|
+
def browser_agent_already_installed?
|
119
|
+
BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_defined?(BROWSER_MONITORING_INSTALLED_VARIABLE) &&
|
120
|
+
BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_get(BROWSER_MONITORING_INSTALLED_VARIABLE)
|
121
|
+
end
|
122
|
+
|
123
|
+
def mark_browser_agent_as_installed
|
124
|
+
BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_set(BROWSER_MONITORING_INSTALLED_VARIABLE, true)
|
125
|
+
end
|
126
|
+
|
115
127
|
def rails_version
|
116
128
|
@rails_version ||= Gem::Version.new(::Rails::VERSION::STRING)
|
117
129
|
end
|
@@ -70,7 +70,7 @@ module NewRelic
|
|
70
70
|
def rails_32_deprecation
|
71
71
|
return unless defined?(Rails::VERSION) && Gem::Version.new(Rails::VERSION::STRING) <= Gem::Version.new('3.2')
|
72
72
|
|
73
|
-
deprecation_msg = 'The Ruby
|
73
|
+
deprecation_msg = 'The Ruby agent is dropping support for Rails 3.2 ' \
|
74
74
|
'in a future major release. Please upgrade your Rails version to continue receiving support. ' \
|
75
75
|
|
76
76
|
Agent.logger.log_once(
|
@@ -83,6 +83,10 @@ module NewRelic
|
|
83
83
|
camelized[0].downcase.concat(camelized[1..-1])
|
84
84
|
end
|
85
85
|
|
86
|
+
def snakeize(string)
|
87
|
+
string.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
88
|
+
end
|
89
|
+
|
86
90
|
def bundled_gem?(gem_name)
|
87
91
|
defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?(gem_name)
|
88
92
|
rescue => e
|
@@ -74,6 +74,7 @@ module NewRelic
|
|
74
74
|
unicorn
|
75
75
|
webrick
|
76
76
|
fastcgi
|
77
|
+
falcon
|
77
78
|
]
|
78
79
|
while dispatchers.any? && @discovered_dispatcher.nil?
|
79
80
|
send('check_for_' + (dispatchers.shift))
|
@@ -126,16 +127,24 @@ module NewRelic
|
|
126
127
|
end
|
127
128
|
|
128
129
|
def check_for_unicorn
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
return unless (defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) &&
|
131
|
+
NewRelic::LanguageSupport.object_space_usable?
|
132
|
+
|
133
|
+
v = find_class_in_object_space(::Unicorn::HttpServer)
|
134
|
+
@discovered_dispatcher = :unicorn if v
|
133
135
|
end
|
134
136
|
|
135
137
|
def check_for_puma
|
136
|
-
|
137
|
-
|
138
|
-
|
138
|
+
return unless defined?(::Puma) && File.basename($0) == 'puma'
|
139
|
+
|
140
|
+
@discovered_dispatcher = :puma
|
141
|
+
end
|
142
|
+
|
143
|
+
def check_for_falcon
|
144
|
+
return unless defined?(::Falcon::Server) &&
|
145
|
+
NewRelic::LanguageSupport.object_space_usable?
|
146
|
+
|
147
|
+
@discovered_dispatcher = :falcon if find_class_in_object_space(::Falcon::Server)
|
139
148
|
end
|
140
149
|
|
141
150
|
def check_for_delayed_job
|
@@ -178,15 +187,15 @@ module NewRelic
|
|
178
187
|
end
|
179
188
|
|
180
189
|
def check_for_litespeed
|
181
|
-
|
182
|
-
|
183
|
-
|
190
|
+
return unless caller.pop.include?('fcgi-bin/RailsRunner.rb')
|
191
|
+
|
192
|
+
@discovered_dispatcher = :litespeed
|
184
193
|
end
|
185
194
|
|
186
195
|
def check_for_passenger
|
187
|
-
|
188
|
-
|
189
|
-
|
196
|
+
return unless defined?(::PhusionPassenger)
|
197
|
+
|
198
|
+
@discovered_dispatcher = :passenger
|
190
199
|
end
|
191
200
|
|
192
201
|
public
|
data/lib/new_relic/version.rb
CHANGED
data/lib/tasks/config.rake
CHANGED
@@ -19,7 +19,7 @@ namespace :newrelic do
|
|
19
19
|
DISABLING => 'Use these settings to toggle instrumentation types during agent startup.',
|
20
20
|
ATTRIBUTES => '[Attributes](/docs/features/agent-attributes) are key-value pairs containing information that determines the properties of an event or transaction. These key-value pairs can be viewed within transaction traces in APM, traced errors in APM, transaction events in dashboards, and page views in dashboards. You can customize exactly which attributes will be sent to each of these destinations',
|
21
21
|
'transaction_tracer' => 'The [transaction traces](/docs/apm/traces/transaction-traces/transaction-traces) feature collects detailed information from a selection of transactions, including a summary of the calling sequence, a breakdown of time spent, and a list of SQL queries and their query plans (on mysql and postgresql). Available features depend on your New Relic subscription level.',
|
22
|
-
'error_collector' => "The agent collects and reports all uncaught exceptions by default. These configuration options allow you to customize the error collection.\n\nFor information on ignored and expected errors, [see this page on Error Analytics in APM](/docs/agents/manage-apm-agents/agent-data/manage-errors-apm-collect-ignore-or-mark-expected/). To set expected errors via the `NewRelic::Agent.notice_error` Ruby method, [consult the Ruby
|
22
|
+
'error_collector' => "The agent collects and reports all uncaught exceptions by default. These configuration options allow you to customize the error collection.\n\nFor information on ignored and expected errors, [see this page on Error Analytics in APM](/docs/agents/manage-apm-agents/agent-data/manage-errors-apm-collect-ignore-or-mark-expected/). To set expected errors via the `NewRelic::Agent.notice_error` Ruby method, [consult the Ruby agent API](/docs/agents/ruby-agent/api-guides/sending-handled-errors-new-relic/).",
|
23
23
|
'browser_monitoring' => "The browser monitoring [page load timing](/docs/browser/new-relic-browser/page-load-timing/page-load-timing-process) feature (sometimes referred to as real user monitoring or RUM) gives you insight into the performance real users are experiencing with your website. This is accomplished by measuring the time it takes for your users' browsers to download and render your web pages by injecting a small amount of JavaScript code into the header and footer of each page.",
|
24
24
|
'application_logging' => "The Ruby agent supports [APM logs in context](/docs/apm/new-relic-apm/getting-started/get-started-logs-context). For some tips on configuring logs for the Ruby agent, see [Configure Ruby logs in context](/docs/logs/logs-context/configure-logs-context-ruby).\n\nAvailable logging-related config options include:",
|
25
25
|
'analytics_events' => '[New Relic dashboards](/docs/query-your-data/explore-query-data/dashboards/introduction-new-relic-one-dashboards) is a resource to gather and visualize data about your software and what it says about your business. With it you can quickly and easily create real-time dashboards to get immediate answers about end-user experiences, clickstreams, mobile activities, and server transactions.'
|
@@ -14,7 +14,7 @@ redirects:
|
|
14
14
|
|
15
15
|
<CONTRIBUTOR_NOTE>
|
16
16
|
This file is automatically generated from values defined in `lib/new_relic/agent/configuration/default_source.rb`.
|
17
|
-
|
17
|
+
Make all changes directly to `default_source.rb.`
|
18
18
|
Submit PRs or raise issues at: https://github.com/newrelic/newrelic-ruby-agent
|
19
19
|
</CONTRIBUTOR_NOTE>
|
20
20
|
|
@@ -42,9 +42,9 @@ In other words, environment variables override all other configuration settings
|
|
42
42
|
|
43
43
|
## View and edit config file options [#Edit]
|
44
44
|
|
45
|
-
The Ruby agent's `newrelic.yml` is a standard YAML configuration file. It typically includes a `Defaults` section at the top, plus sections below for each application environment
|
45
|
+
The Ruby agent's `newrelic.yml` is a standard YAML configuration file. It typically includes a `Defaults` section at the top, plus sections below for each application environment (`Development`, `Test`, `Staging`, and `Production`).
|
46
46
|
|
47
|
-
The Ruby agent determines which section of the `newrelic.yml` config file to read from by looking at certain environment variables to derive the application's environment. This can be useful
|
47
|
+
The Ruby agent determines which section of the `newrelic.yml` config file to read from by looking at certain environment variables to derive the application's environment. This can be useful when you want to use `info` for the `log_level` config setting in your production environment, and you want more verbose `log_level` config settings (such as `debug`) in your development environment.
|
48
48
|
|
49
49
|
Here is an example `newrelic.yml` config file:
|
50
50
|
|
@@ -60,7 +60,7 @@ development:
|
|
60
60
|
log_level: debug
|
61
61
|
```
|
62
62
|
|
63
|
-
|
63
|
+
The Ruby agent looks for the following environment variables, in this order, to find the application environment:
|
64
64
|
|
65
65
|
1. `NEW_RELIC_ENV`
|
66
66
|
2. `RUBY_ENV`
|
@@ -68,9 +68,9 @@ For non-Rails apps, the Ruby agent looks for the following environment variables
|
|
68
68
|
4. `APP_ENV`
|
69
69
|
5. `RACK_ENV`
|
70
70
|
|
71
|
-
If the Ruby agent
|
71
|
+
If the Ruby agent doesn't detect values for any of those environment variables, it will default the application environment to `development` and read from the `development` section of the `newrelic.yml` config file.
|
72
72
|
|
73
|
-
When running the Ruby agent in a Rails app, the agent first looks for the `NEW_RELIC_ENV` environment variable to determine the application environment and which section of the `newrelic.yml` to use. If `NEW_RELIC_ENV` is not present, the agent uses the Rails environment (`RAILS_ENV`
|
73
|
+
When running the Ruby agent in a Rails app, the agent first looks for the `NEW_RELIC_ENV` environment variable to determine the application environment and which section of the `newrelic.yml` to use. If `NEW_RELIC_ENV` is not present, the agent uses the Rails environment (`RAILS_ENV`).
|
74
74
|
|
75
75
|
When you edit the config file, be sure to:
|
76
76
|
|
@@ -16,7 +16,7 @@ module NewRelicYML
|
|
16
16
|
|
17
17
|
HEADER = <<~HEADER
|
18
18
|
#
|
19
|
-
# This file configures the New Relic
|
19
|
+
# This file configures the New Relic agent. New Relic monitors Ruby, Java,
|
20
20
|
# .NET, PHP, Python, Node, and Go applications with deep visibility and low
|
21
21
|
# overhead. For more information, visit www.newrelic.com.
|
22
22
|
|
@@ -82,7 +82,7 @@ class Instrumentation < Thor
|
|
82
82
|
insert_into_file(
|
83
83
|
DEFAULT_SOURCE_LOCATION,
|
84
84
|
config_block(name.downcase),
|
85
|
-
after: ":description => 'Controls auto-instrumentation of bunny at start
|
85
|
+
after: ":description => 'Controls auto-instrumentation of bunny at start-up. May be one of [auto|prepend|chain|disabled].'
|
86
86
|
},\n"
|
87
87
|
)
|
88
88
|
end
|
@@ -103,7 +103,7 @@ class Instrumentation < Thor
|
|
103
103
|
:type => String,
|
104
104
|
:dynamic_name => true,
|
105
105
|
:allowed_from_server => false,
|
106
|
-
:description => 'Controls auto-instrumentation of the #{name} library at start
|
106
|
+
:description => 'Controls auto-instrumentation of the #{name} library at start-up. May be one of [auto|prepend|chain|disabled].'
|
107
107
|
},
|
108
108
|
CONFIG
|
109
109
|
end
|
@@ -111,7 +111,7 @@ class Instrumentation < Thor
|
|
111
111
|
def yaml_block(name)
|
112
112
|
<<~HEREDOC
|
113
113
|
|
114
|
-
# Controls auto-instrumentation of #{name} at start
|
114
|
+
# Controls auto-instrumentation of #{name} at start-up.
|
115
115
|
# May be one of [auto|prepend|chain|disabled]
|
116
116
|
# instrumentation.#{name.downcase}: auto
|
117
117
|
HEREDOC
|
data/lib/tasks/tests.rake
CHANGED
@@ -11,6 +11,75 @@ rescue LoadError
|
|
11
11
|
end
|
12
12
|
|
13
13
|
if defined? Rake::TestTask
|
14
|
+
def name_for_number(content, number)
|
15
|
+
(number - 1).downto(0).each do |i|
|
16
|
+
return Regexp.last_match(1) if content[i] =~ /^\s*def (test_.+)\s*$/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def info_from_test_var
|
21
|
+
return {} unless ENV['TEST'].to_s =~ /^(.+)((?::\d+)+)/
|
22
|
+
|
23
|
+
file = Regexp.last_match(1)
|
24
|
+
numbers = Regexp.last_match(2).split(':').reject(&:empty?).uniq.map(&:to_i)
|
25
|
+
abs = File.expand_path(File.join('../../..', file), __FILE__)
|
26
|
+
raise "File >>#{abs}<< does not exist!" unless File.exist?(abs)
|
27
|
+
|
28
|
+
content = File.read(abs).split("\n")
|
29
|
+
{file: file, numbers: numbers, content: content}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_names_from_test_file(info)
|
33
|
+
info[:numbers].each_with_object([]) do |number, names|
|
34
|
+
name = name_for_number(info[:content], number)
|
35
|
+
unless name
|
36
|
+
warn "Unable to determine a test name given line >>#{number}<< for file >>#{info[:file]}<<"
|
37
|
+
next
|
38
|
+
end
|
39
|
+
names << name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Allow ENV['TEST'] to be set to a test file path with one or more
|
44
|
+
# `:<line number>` patterns on the end of it.
|
45
|
+
#
|
46
|
+
# For example:
|
47
|
+
# TEST=test/new_relic/agent/autostart_test.rb:57 bundle exec rake test
|
48
|
+
#
|
49
|
+
# The `autostart_test.rb` file will be read, and starting from line 57 and
|
50
|
+
# working upwards in the file (downwards by line number), a test definition
|
51
|
+
# will be searched for that matches `def test_<rest of the test name>`.
|
52
|
+
#
|
53
|
+
# Multiple line numbers can be specified like so:
|
54
|
+
# TEST=test/new_relic/agent/autostart_test.rb:57:26 bundle exec rake test
|
55
|
+
#
|
56
|
+
# For this multiple line number based example, both lines 57 and 26 will
|
57
|
+
# serve as separate starting points for the search for a test name.
|
58
|
+
#
|
59
|
+
# All test names that are discovered will be "ORed" into a regex pattern with
|
60
|
+
# pipes ('|') that is passed to Minitest via
|
61
|
+
# `TESTOPTS="--name='test_name1|test_name2'"`
|
62
|
+
#
|
63
|
+
# Once a line with one or more `:<line number>` values on the end of it has
|
64
|
+
# been found, replace the value of ENV['TEST'] with the path leading up to
|
65
|
+
# the first colon before invoking Minitest.
|
66
|
+
#
|
67
|
+
# Why refer to a test by line number instead of just supplying the name
|
68
|
+
# directly? The primary use case is text editor integration. A text editor
|
69
|
+
# can be taught to "run the single unit test containing the line the cursor is
|
70
|
+
# on" by building a string containing the path to the file, a colon, (':'),
|
71
|
+
# and the line number.
|
72
|
+
def process_line_numbers
|
73
|
+
info = info_from_test_var
|
74
|
+
return unless info.key?(:file)
|
75
|
+
|
76
|
+
test_names = test_names_from_test_file(info)
|
77
|
+
raise "Could not determine any test names for file >>#{abs}<< given numbers >>#{numbers}" if test_names.empty?
|
78
|
+
|
79
|
+
ENV['TESTOPTS'] = "#{ENV['TESTOPTS']} --name='#{test_names.map { |n| Regexp.escape(n) }.join('|')}'"
|
80
|
+
ENV['TEST'] = info[:file]
|
81
|
+
end
|
82
|
+
|
14
83
|
namespace :test do
|
15
84
|
tasks = Rake.application.top_level_tasks
|
16
85
|
ENV['TESTOPTS'] ||= ''
|
@@ -21,6 +90,8 @@ if defined? Rake::TestTask
|
|
21
90
|
ENV['TESTOPTS'] += ' --' + seed
|
22
91
|
end
|
23
92
|
|
93
|
+
process_line_numbers
|
94
|
+
|
24
95
|
agent_home = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
25
96
|
|
26
97
|
Rake::TestTask.new(:newrelic) do |t|
|
data/newrelic.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# This file configures the New Relic
|
2
|
+
# This file configures the New Relic agent. New Relic monitors Ruby, Java,
|
3
3
|
# .NET, PHP, Python, Node, and Go applications with deep visibility and low
|
4
4
|
# overhead. For more information, visit www.newrelic.com.
|
5
5
|
|
@@ -102,7 +102,7 @@ common: &default_settings
|
|
102
102
|
# Specify a list of constants that should prevent the agent from starting
|
103
103
|
# automatically. Separate individual constants with a comma ,. For example,
|
104
104
|
# "Rails::Console,UninstrumentedBackgroundJob".
|
105
|
-
# autostart.denylisted_constants: Rails::Console
|
105
|
+
# autostart.denylisted_constants: Rails::Command::ConsoleCommand,Rails::Command::CredentialsCommand,Rails::Command::Db::System::ChangeCommand,Rails::Command::DbConsoleCommand,Rails::Command::DestroyCommand,Rails::Command::DevCommand,Rails::Command::EncryptedCommand,Rails::Command::GenerateCommand,Rails::Command::InitializersCommand,Rails::Command::NotesCommand,Rails::Command::RoutesCommand,Rails::Command::SecretsCommand,Rails::Console,Rails::DBConsole
|
106
106
|
|
107
107
|
# Defines a comma-delimited list of executables that the agent should not
|
108
108
|
# instrument. For example, "rake,my_ruby_script.rb".
|
@@ -341,7 +341,7 @@ common: &default_settings
|
|
341
341
|
# embedded service within another framework and the agent is detecting the Sinatra
|
342
342
|
# app and skipping the at_exit handler as a result. Sinatra classically runs the
|
343
343
|
# entire application in an at_exit block and would otherwise misbehave if the
|
344
|
-
#
|
344
|
+
# agent's at_exit handler was also installed in those circumstances. Note:
|
345
345
|
# send_data_on_exit should also be set to true in tandem with this setting.
|
346
346
|
# force_install_exit_handler: false
|
347
347
|
|
@@ -374,39 +374,51 @@ common: &default_settings
|
|
374
374
|
# Configures the TCP/IP port for the trace observer Host
|
375
375
|
# infinite_tracing.trace_observer.port: 443
|
376
376
|
|
377
|
+
# Controls auto-instrumentation of ActiveSupport::BroadcastLogger at start up. May
|
378
|
+
# be one of: auto, prepend, chain, disabled. Used in Rails versions >= 7.1.
|
379
|
+
# instrumentation.active_support_broadcast_logger: auto
|
380
|
+
|
377
381
|
# Controls auto-instrumentation of ActiveSupport::Logger at start up. May be one
|
378
|
-
# of: auto, prepend, chain, disabled.
|
382
|
+
# of: auto, prepend, chain, disabled. Used in Rails versions below 7.1.
|
379
383
|
# instrumentation.active_support_logger: auto
|
380
384
|
|
381
|
-
# Controls auto-instrumentation of
|
385
|
+
# Controls auto-instrumentation of Async::HTTP at start up. May be one of: auto,
|
386
|
+
# prepend, chain, disabled.
|
387
|
+
# instrumentation.async_http: auto
|
388
|
+
|
389
|
+
# Controls auto-instrumentation of bunny at start-up. May be one of: auto,
|
382
390
|
# prepend, chain, disabled.
|
383
391
|
# instrumentation.bunny: auto
|
384
392
|
|
385
|
-
# Controls auto-instrumentation of the concurrent-ruby library at start
|
393
|
+
# Controls auto-instrumentation of the concurrent-ruby library at start-up. May be
|
386
394
|
# one of: auto, prepend, chain, disabled.
|
387
395
|
# instrumentation.concurrent_ruby: auto
|
388
396
|
|
389
|
-
# Controls auto-instrumentation of Curb at start
|
397
|
+
# Controls auto-instrumentation of Curb at start-up. May be one of: auto, prepend,
|
390
398
|
# chain, disabled.
|
391
399
|
# instrumentation.curb: auto
|
392
400
|
|
393
|
-
# Controls auto-instrumentation of Delayed Job at start
|
401
|
+
# Controls auto-instrumentation of Delayed Job at start-up. May be one of: auto,
|
394
402
|
# prepend, chain, disabled.
|
395
403
|
# instrumentation.delayed_job: auto
|
396
404
|
|
397
|
-
# Controls auto-instrumentation of the elasticsearch library at start
|
405
|
+
# Controls auto-instrumentation of the elasticsearch library at start-up. May be
|
398
406
|
# one of: auto, prepend, chain, disabled.
|
399
407
|
# instrumentation.elasticsearch: auto
|
400
408
|
|
401
|
-
# Controls auto-instrumentation of
|
409
|
+
# Controls auto-instrumentation of ethon at start up. May be one of
|
410
|
+
# [auto|prepend|chain|disabled]
|
411
|
+
# instrumentation.ethon: auto
|
412
|
+
|
413
|
+
# Controls auto-instrumentation of Excon at start-up. May be one of: enabled,
|
402
414
|
# disabled.
|
403
415
|
# instrumentation.excon: enabled
|
404
416
|
|
405
|
-
# Controls auto-instrumentation of the Fiber class at start
|
417
|
+
# Controls auto-instrumentation of the Fiber class at start-up. May be one of:
|
406
418
|
# auto, prepend, chain, disabled.
|
407
419
|
# instrumentation.fiber: auto
|
408
420
|
|
409
|
-
# Controls auto-instrumentation of Grape at start
|
421
|
+
# Controls auto-instrumentation of Grape at start-up. May be one of: auto,
|
410
422
|
# prepend, chain, disabled.
|
411
423
|
# instrumentation.grape: auto
|
412
424
|
|
@@ -419,43 +431,47 @@ common: &default_settings
|
|
419
431
|
# example, "private.com$,exception.*"
|
420
432
|
# instrumentation.grpc.host_denylist: []
|
421
433
|
|
422
|
-
# Controls auto-instrumentation of gRPC clients at start
|
434
|
+
# Controls auto-instrumentation of gRPC clients at start-up. May be one of: auto,
|
423
435
|
# prepend, chain, disabled.
|
424
436
|
# instrumentation.grpc_client: auto
|
425
437
|
|
426
|
-
# Controls auto-instrumentation of gRPC servers at start
|
438
|
+
# Controls auto-instrumentation of gRPC servers at start-up. May be one of: auto,
|
427
439
|
# prepend, chain, disabled.
|
428
440
|
# instrumentation.grpc_server: auto
|
429
441
|
|
430
|
-
# Controls auto-instrumentation of HTTPClient at start
|
442
|
+
# Controls auto-instrumentation of HTTPClient at start-up. May be one of: auto,
|
431
443
|
# prepend, chain, disabled.
|
432
444
|
# instrumentation.httpclient: auto
|
433
445
|
|
434
|
-
# Controls auto-instrumentation of http.rb gem at start
|
446
|
+
# Controls auto-instrumentation of http.rb gem at start-up. May be one of: auto,
|
435
447
|
# prepend, chain, disabled.
|
436
448
|
# instrumentation.httprb: auto
|
437
449
|
|
438
|
-
# Controls auto-instrumentation of
|
450
|
+
# Controls auto-instrumentation of httpx at start up. May be one of
|
451
|
+
# [auto|prepend|chain|disabled]
|
452
|
+
# instrumentation.httpx: auto
|
453
|
+
|
454
|
+
# Controls auto-instrumentation of Ruby standard library Logger at start-up. May
|
439
455
|
# be one of: auto, prepend, chain, disabled.
|
440
456
|
# instrumentation.logger: auto
|
441
457
|
|
442
|
-
# Controls auto-instrumentation of dalli gem for Memcache at start
|
458
|
+
# Controls auto-instrumentation of dalli gem for Memcache at start-up. May be one
|
443
459
|
# of: auto, prepend, chain, disabled.
|
444
460
|
# instrumentation.memcache: auto
|
445
461
|
|
446
|
-
# Controls auto-instrumentation of memcache-client gem for Memcache at start
|
462
|
+
# Controls auto-instrumentation of memcache-client gem for Memcache at start-up.
|
447
463
|
# May be one of: auto, prepend, chain, disabled.
|
448
464
|
# instrumentation.memcache_client: auto
|
449
465
|
|
450
|
-
# Controls auto-instrumentation of memcached gem for Memcache at start
|
466
|
+
# Controls auto-instrumentation of memcached gem for Memcache at start-up. May be
|
451
467
|
# one of: auto, prepend, chain, disabled.
|
452
468
|
# instrumentation.memcached: auto
|
453
469
|
|
454
|
-
# Controls auto-instrumentation of Mongo at start
|
470
|
+
# Controls auto-instrumentation of Mongo at start-up. May be one of: enabled,
|
455
471
|
# disabled.
|
456
472
|
# instrumentation.mongo: enabled
|
457
473
|
|
458
|
-
# Controls auto-instrumentation of Net::HTTP at start
|
474
|
+
# Controls auto-instrumentation of Net::HTTP at start-up. May be one of: auto,
|
459
475
|
# prepend, chain, disabled.
|
460
476
|
# instrumentation.net_http: auto
|
461
477
|
|
@@ -464,7 +480,7 @@ common: &default_settings
|
|
464
480
|
# application startup. May be one of: auto, prepend, chain, disabled.
|
465
481
|
# instrumentation.puma_rack: auto
|
466
482
|
|
467
|
-
# Controls auto-instrumentation of Puma::Rack::URLMap at start
|
483
|
+
# Controls auto-instrumentation of Puma::Rack::URLMap at start-up. May be one of:
|
468
484
|
# auto, prepend, chain, disabled.
|
469
485
|
# instrumentation.puma_rack_urlmap: auto
|
470
486
|
|
@@ -473,27 +489,27 @@ common: &default_settings
|
|
473
489
|
# startup. May be one of: auto, prepend, chain, disabled.
|
474
490
|
# instrumentation.rack: auto
|
475
491
|
|
476
|
-
# Controls auto-instrumentation of Rack::URLMap at start
|
492
|
+
# Controls auto-instrumentation of Rack::URLMap at start-up. May be one of: auto,
|
477
493
|
# prepend, chain, disabled.
|
478
494
|
# instrumentation.rack_urlmap: auto
|
479
495
|
|
480
|
-
# Controls auto-instrumentation of rake at start
|
496
|
+
# Controls auto-instrumentation of rake at start-up. May be one of: auto, prepend,
|
481
497
|
# chain, disabled.
|
482
498
|
# instrumentation.rake: auto
|
483
499
|
|
484
|
-
# Controls auto-instrumentation of Redis at start
|
500
|
+
# Controls auto-instrumentation of Redis at start-up. May be one of: auto,
|
485
501
|
# prepend, chain, disabled.
|
486
502
|
# instrumentation.redis: auto
|
487
503
|
|
488
|
-
# Controls auto-instrumentation of resque at start
|
504
|
+
# Controls auto-instrumentation of resque at start-up. May be one of: auto,
|
489
505
|
# prepend, chain, disabled.
|
490
506
|
# instrumentation.resque: auto
|
491
507
|
|
492
|
-
# Controls auto-instrumentation of Roda at start
|
508
|
+
# Controls auto-instrumentation of Roda at start-up. May be one of: auto, prepend,
|
493
509
|
# chain, disabled.
|
494
510
|
# instrumentation.roda: auto
|
495
511
|
|
496
|
-
# Controls auto-instrumentation of Sinatra at start
|
512
|
+
# Controls auto-instrumentation of Sinatra at start-up. May be one of: auto,
|
497
513
|
# prepend, chain, disabled.
|
498
514
|
# instrumentation.sinatra: auto
|
499
515
|
|
@@ -501,24 +517,28 @@ common: &default_settings
|
|
501
517
|
# disabled.
|
502
518
|
# instrumentation.stripe: enabled
|
503
519
|
|
504
|
-
# Controls auto-instrumentation of the Thread class at start
|
520
|
+
# Controls auto-instrumentation of the Thread class at start-up to allow the agent
|
505
521
|
# to correctly nest spans inside of an asynchronous transaction. This does not
|
506
522
|
# enable the agent to automatically trace all threads created (see
|
507
523
|
# instrumentation.thread.tracing). May be one of: auto, prepend, chain, disabled.
|
508
524
|
# instrumentation.thread: auto
|
509
525
|
|
510
|
-
# Controls auto-instrumentation of the Thread class at start
|
526
|
+
# Controls auto-instrumentation of the Thread class at start-up to automatically
|
511
527
|
# add tracing to all Threads created in the application.
|
512
528
|
# instrumentation.thread.tracing: true
|
513
529
|
|
514
|
-
# Controls auto-instrumentation of the Tilt template rendering library at
|
515
|
-
# up. May be one of: auto, prepend, chain, disabled.
|
530
|
+
# Controls auto-instrumentation of the Tilt template rendering library at
|
531
|
+
# start-up. May be one of: auto, prepend, chain, disabled.
|
516
532
|
# instrumentation.tilt: auto
|
517
533
|
|
518
|
-
# Controls auto-instrumentation of Typhoeus at start
|
534
|
+
# Controls auto-instrumentation of Typhoeus at start-up. May be one of: auto,
|
519
535
|
# prepend, chain, disabled.
|
520
536
|
# instrumentation.typhoeus: auto
|
521
537
|
|
538
|
+
# Controls auto-instrumentation of ViewComponent at startup. May be one of: auto,
|
539
|
+
# prepend, chain, disabled.
|
540
|
+
# instrumentation.view_component: auto
|
541
|
+
|
522
542
|
# A dictionary of label names and values that will be applied to the data sent
|
523
543
|
# from this agent. May also be expressed as a semicolon-delimited ; string of
|
524
544
|
# colon-separated : pairs. For example, Server:One;Data Center:Primary.
|
@@ -668,7 +688,7 @@ common: &default_settings
|
|
668
688
|
# Regexp.new to permit advanced matching. For each hash pair, if either the key or
|
669
689
|
# value is matched the
|
670
690
|
# pair will not be reported. By default, no user_data is reported, so this option
|
671
|
-
# should only be used if
|
691
|
+
# should only be used if
|
672
692
|
# the stripe.user_data.include option is being used.
|
673
693
|
# stripe.user_data.exclude: []
|
674
694
|
|