newrelic_rpm 8.8.0 → 8.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +31 -3
- data/.simplecov +5 -0
- data/CHANGELOG.md +18 -0
- data/lib/new_relic/agent/agent/shutdown.rb +34 -0
- data/lib/new_relic/agent/agent/special_startup.rb +70 -0
- data/lib/new_relic/agent/agent/start_worker_thread.rb +163 -0
- data/lib/new_relic/agent/agent/startup.rb +196 -0
- data/lib/new_relic/agent/agent.rb +10 -439
- data/lib/new_relic/agent/agent_logger.rb +3 -5
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command_router.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +10 -10
- data/lib/new_relic/agent/configuration/manager.rb +2 -2
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +11 -3
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
- data/lib/new_relic/agent/instrumentation/sunspot.rb +2 -2
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +6 -1
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -1
- data/lib/new_relic/agent/sql_sampler.rb +1 -1
- data/lib/new_relic/agent/system_info.rb +59 -44
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/agent.rb +1 -1
- data/lib/new_relic/coerce.rb +1 -1
- data/lib/new_relic/collection_helper.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +2 -2
- data/lib/new_relic/local_environment.rb +1 -1
- data/lib/new_relic/metric_data.rb +1 -1
- data/lib/new_relic/metric_spec.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +1 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/config.rake +4 -0
- data/lib/tasks/coverage_report.rake +22 -0
- data/lib/tasks/install.rake +4 -0
- data/lib/tasks/multiverse.rake +4 -0
- data/lib/tasks/tests.rake +4 -1
- data/newrelic.yml +1 -1
- data/newrelic_rpm.gemspec +4 -1
- metadata +36 -2
@@ -100,7 +100,7 @@ module NewRelic
|
|
100
100
|
|
101
101
|
def decoded_id(request)
|
102
102
|
encoded_id = request[NEWRELIC_ID_HEADER_KEY]
|
103
|
-
return
|
103
|
+
return NewRelic::EMPTY_STR if encoded_id.nil? || encoded_id.empty?
|
104
104
|
|
105
105
|
obfuscator.deobfuscate(encoded_id)
|
106
106
|
end
|
@@ -185,7 +185,12 @@ module NewRelic
|
|
185
185
|
merge_data_from_pipe(pipe) unless pipe == wake.out
|
186
186
|
end
|
187
187
|
|
188
|
-
|
188
|
+
begin
|
189
|
+
wake.out.read_nonblock(1) if ready_pipes.include?(wake.out)
|
190
|
+
rescue IO::WaitReadable
|
191
|
+
NewRelic::Agent.logger.error 'Issue while reading from the ready pipe'
|
192
|
+
NewRelic::Agent.logger.error "Ready pipes: #{ready_pipes.map(&:to_s)}, wake.out pipe: #{wake.out}"
|
193
|
+
end
|
189
194
|
end
|
190
195
|
|
191
196
|
break unless should_keep_listening?
|
@@ -87,7 +87,7 @@ module NewRelic
|
|
87
87
|
all_count = 0
|
88
88
|
queue_counts(column_name).each do |column_val, count|
|
89
89
|
all_count += count
|
90
|
-
column_val = "default" if column_val.nil? || column_val ==
|
90
|
+
column_val = "default" if column_val.nil? || column_val == NewRelic::EMPTY_STR
|
91
91
|
metric = "Workers/DelayedJob/queue_length/#{metric_node}/#{column_val}"
|
92
92
|
NewRelic::Agent.record_metric(metric, count)
|
93
93
|
end
|
@@ -39,54 +39,69 @@ module NewRelic
|
|
39
39
|
@processor_info = nil
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.
|
43
|
-
if @processor_info
|
44
|
-
if darwin?
|
45
|
-
@processor_info = {
|
46
|
-
:num_physical_packages => sysctl_value('hw.packages').to_i,
|
47
|
-
:num_physical_cores => sysctl_value('hw.physicalcpu_max').to_i,
|
48
|
-
:num_logical_processors => sysctl_value('hw.logicalcpu_max').to_i
|
49
|
-
}
|
50
|
-
# in case those don't work, try backup values
|
51
|
-
if @processor_info[:num_physical_cores] <= 0
|
52
|
-
@processor_info[:num_physical_cores] = sysctl_value('hw.physicalcpu').to_i
|
53
|
-
end
|
54
|
-
if @processor_info[:num_logical_processors] <= 0
|
55
|
-
@processor_info[:num_logical_processors] = sysctl_value('hw.logicalcpu').to_i
|
56
|
-
end
|
57
|
-
if @processor_info[:num_logical_processors] <= 0
|
58
|
-
@processor_info[:num_logical_processors] = sysctl_value('hw.ncpu').to_i
|
59
|
-
end
|
60
|
-
|
61
|
-
elsif linux?
|
62
|
-
cpuinfo = proc_try_read('/proc/cpuinfo')
|
63
|
-
@processor_info = cpuinfo ? parse_cpuinfo(cpuinfo) : {}
|
42
|
+
def self.processor_info
|
43
|
+
return @processor_info if @processor_info
|
64
44
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# give nils for obviously wrong values
|
74
|
-
@processor_info.keys.each do |key|
|
75
|
-
value = @processor_info[key]
|
76
|
-
if value.is_a?(Numeric) && value <= 0
|
77
|
-
@processor_info[key] = nil
|
78
|
-
end
|
79
|
-
end
|
45
|
+
if darwin?
|
46
|
+
processor_info_darwin
|
47
|
+
elsif linux?
|
48
|
+
processor_info_linux
|
49
|
+
elsif bsd?
|
50
|
+
processor_info_bsd
|
51
|
+
else
|
52
|
+
raise "Couldn't determine OS"
|
80
53
|
end
|
54
|
+
remove_bad_values
|
81
55
|
|
82
56
|
@processor_info
|
83
57
|
rescue
|
84
|
-
|
58
|
+
@processor_info = NewRelic::EMPTY_HASH
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.processor_info_darwin
|
62
|
+
@processor_info = {
|
63
|
+
num_physical_packages: sysctl_value('hw.packages'),
|
64
|
+
num_physical_cores: sysctl_value('hw.physicalcpu_max'),
|
65
|
+
num_logical_processors: sysctl_value('hw.logicalcpu_max')
|
66
|
+
}
|
67
|
+
# in case those don't work, try backup values
|
68
|
+
if @processor_info[:num_physical_cores] <= 0
|
69
|
+
@processor_info[:num_physical_cores] = sysctl_value('hw.physicalcpu')
|
70
|
+
end
|
71
|
+
if @processor_info[:num_logical_processors] <= 0
|
72
|
+
@processor_info[:num_logical_processors] = sysctl_value('hw.logicalcpu')
|
73
|
+
end
|
74
|
+
if @processor_info[:num_logical_processors] <= 0
|
75
|
+
@processor_info[:num_logical_processors] = sysctl_value('hw.ncpu')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.processor_info_linux
|
80
|
+
cpuinfo = proc_try_read('/proc/cpuinfo')
|
81
|
+
@processor_info = cpuinfo ? parse_cpuinfo(cpuinfo) : NewRelic::EMPTY_HASH
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.processor_info_bsd
|
85
|
+
@processor_info = {
|
86
|
+
num_physical_packages: nil,
|
87
|
+
num_physical_cores: nil,
|
88
|
+
num_logical_processors: sysctl_value('hw.ncpu')
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.remove_bad_values
|
93
|
+
# give nils for obviously wrong values
|
94
|
+
@processor_info.keys.each do |key|
|
95
|
+
value = @processor_info[key]
|
96
|
+
if value.is_a?(Numeric) && value <= 0
|
97
|
+
@processor_info[key] = nil
|
98
|
+
end
|
99
|
+
end
|
85
100
|
end
|
86
101
|
|
87
102
|
def self.sysctl_value(name)
|
88
103
|
# make sure to redirect stderr so we don't spew if the name is unknown
|
89
|
-
`sysctl -n #{name} 2>/dev/null
|
104
|
+
`sysctl -n #{name} 2>/dev/null`.to_i
|
90
105
|
end
|
91
106
|
|
92
107
|
def self.parse_cpuinfo(cpuinfo)
|
@@ -143,11 +158,11 @@ module NewRelic
|
|
143
158
|
}
|
144
159
|
end
|
145
160
|
|
146
|
-
def self.num_physical_packages;
|
161
|
+
def self.num_physical_packages; processor_info[:num_physical_packages] end
|
147
162
|
|
148
|
-
def self.num_physical_cores;
|
163
|
+
def self.num_physical_cores; processor_info[:num_physical_cores] end
|
149
164
|
|
150
|
-
def self.num_logical_processors;
|
165
|
+
def self.num_logical_processors; processor_info[:num_logical_processors] end
|
151
166
|
|
152
167
|
def self.processor_arch
|
153
168
|
RbConfig::CONFIG['target_cpu']
|
@@ -243,12 +258,12 @@ module NewRelic
|
|
243
258
|
|
244
259
|
def self.ram_in_mib
|
245
260
|
if darwin?
|
246
|
-
(sysctl_value('hw.memsize')
|
261
|
+
(sysctl_value('hw.memsize') / (1024**2))
|
247
262
|
elsif linux?
|
248
263
|
meminfo = proc_try_read('/proc/meminfo')
|
249
264
|
parse_linux_meminfo_in_mib(meminfo)
|
250
265
|
elsif bsd?
|
251
|
-
(sysctl_value('hw.realmem')
|
266
|
+
(sysctl_value('hw.realmem') / (1024**2))
|
252
267
|
else
|
253
268
|
::NewRelic::Agent.logger.debug("Unable to determine ram_in_mib for host os: #{ruby_os_identifier}")
|
254
269
|
nil
|
@@ -122,8 +122,8 @@ module NewRelic
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def to_log_description
|
125
|
-
"#<ThreadProfile:#{object_id} "\
|
126
|
-
"@profile_id: #{profile_id} "\
|
125
|
+
"#<ThreadProfile:#{object_id} " \
|
126
|
+
"@profile_id: #{profile_id} " \
|
127
127
|
"@command_arguments=#{@command_arguments.inspect}>"
|
128
128
|
end
|
129
129
|
end
|
data/lib/new_relic/agent.rb
CHANGED
@@ -758,7 +758,7 @@ module NewRelic
|
|
758
758
|
def browser_timing_header(nonce = nil)
|
759
759
|
record_api_supportability_metric(:browser_timing_header)
|
760
760
|
|
761
|
-
return
|
761
|
+
return EMPTY_STR unless agent
|
762
762
|
agent.javascript_instrumentor.browser_timing_header(nonce)
|
763
763
|
end
|
764
764
|
|
data/lib/new_relic/coerce.rb
CHANGED
@@ -156,8 +156,8 @@ module DependencyDetection
|
|
156
156
|
|
157
157
|
::NewRelic::Agent.logger.debug("Not installing #{self.name} instrumentation because of configuration #{key}")
|
158
158
|
::NewRelic::Agent.logger.debug \
|
159
|
-
"[DEPRECATED] configuration #{key} for #{self.name} will be removed in the next major release." \
|
160
|
-
"
|
159
|
+
"[DEPRECATED] configuration #{key} for #{self.name} will be removed in the next major release. " \
|
160
|
+
"Use `#{config_key}` with one of `#{VALID_CONFIG_VALUES.map(&:to_s).inspect}`"
|
161
161
|
|
162
162
|
return true
|
163
163
|
end
|
@@ -26,7 +26,7 @@ module NewRelic
|
|
26
26
|
#
|
27
27
|
# If the environment can't be determined, it will be set to nil.
|
28
28
|
#
|
29
|
-
# NewRelic::LocalEnvironment should be accessed through NewRelic::Control#
|
29
|
+
# NewRelic::LocalEnvironment should be accessed through NewRelic::Control#local_env (via the NewRelic::Control singleton).
|
30
30
|
class LocalEnvironment
|
31
31
|
def discovered_dispatcher
|
32
32
|
discover_dispatcher unless @discovered_dispatcher
|
@@ -34,7 +34,7 @@ module NewRelic::Rack
|
|
34
34
|
(status, headers, response) = result
|
35
35
|
|
36
36
|
js_to_inject = NewRelic::Agent.browser_timing_header
|
37
|
-
if (js_to_inject !=
|
37
|
+
if (js_to_inject != NewRelic::EMPTY_STR) && should_instrument?(env, status, headers)
|
38
38
|
response_string = autoinstrument_source(response, headers, js_to_inject)
|
39
39
|
if headers.key?(CONTENT_LENGTH)
|
40
40
|
content_length = response_string ? response_string.bytesize : 0
|
data/lib/new_relic/version.rb
CHANGED
data/lib/tasks/config.rake
CHANGED
@@ -1,3 +1,7 @@
|
|
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
|
+
|
1
5
|
namespace :newrelic do
|
2
6
|
namespace :config do
|
3
7
|
desc "Describe available New Relic configuration settings."
|
@@ -0,0 +1,22 @@
|
|
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
|
+
namespace :coverage do
|
6
|
+
desc "Collates all result sets generated by the different test runners"
|
7
|
+
task :report do
|
8
|
+
require 'simplecov'
|
9
|
+
require 'simplecov_json_formatter'
|
10
|
+
unless ENV['CI']
|
11
|
+
puts 'This task is intended to be run only on the CI.'
|
12
|
+
return
|
13
|
+
end
|
14
|
+
SimpleCov.collate Dir["coverage*/.resultset.json"] do
|
15
|
+
formatter SimpleCov::Formatter::MultiFormatter.new([
|
16
|
+
SimpleCov::Formatter::JSONFormatter,
|
17
|
+
SimpleCov::Formatter::HTMLFormatter
|
18
|
+
])
|
19
|
+
refuse_coverage_drop
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/tasks/install.rake
CHANGED
@@ -1,3 +1,7 @@
|
|
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
|
+
|
1
5
|
namespace :newrelic do
|
2
6
|
desc "Install a default config/newrelic.yml file"
|
3
7
|
task :install do
|
data/lib/tasks/multiverse.rake
CHANGED
@@ -1,2 +1,6 @@
|
|
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
|
+
|
1
5
|
# Guts of task are in a .rb file to allow requiring from external gems
|
2
6
|
require "#{File.join(File.dirname(__FILE__))}/multiverse"
|
data/lib/tasks/tests.rake
CHANGED
@@ -1,3 +1,7 @@
|
|
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
|
+
|
1
5
|
begin
|
2
6
|
require 'rake/testtask'
|
3
7
|
rescue LoadError
|
@@ -31,7 +35,6 @@ if defined? Rake::TestTask
|
|
31
35
|
t.libs << "#{agent_home}/test"
|
32
36
|
t.libs << "#{agent_home}/lib"
|
33
37
|
t.pattern = Array(file_pattern)
|
34
|
-
t.verbose = true
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/newrelic.yml
CHANGED
@@ -91,7 +91,7 @@ common: &default_settings
|
|
91
91
|
# backport_fast_active_record_connection_lookup: false
|
92
92
|
|
93
93
|
# If true, the agent captures attributes from browser monitoring.
|
94
|
-
#
|
94
|
+
# browser_monitoring.attributes.enabled: false
|
95
95
|
|
96
96
|
# Prefix of attributes to exclude from browser monitoring. Allows * as wildcard
|
97
97
|
# at end.
|
data/newrelic_rpm.gemspec
CHANGED
@@ -45,7 +45,6 @@ https://github.com/newrelic/newrelic-ruby-agent/
|
|
45
45
|
|
46
46
|
s.homepage = "https://github.com/newrelic/rpm"
|
47
47
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = Gem::VERSION
|
49
48
|
s.summary = "New Relic Ruby Agent"
|
50
49
|
s.add_development_dependency 'rake', '12.3.3'
|
51
50
|
s.add_development_dependency 'rb-inotify', '0.9.10' # locked to support < Ruby 2.3 (and listen 3.0.8)
|
@@ -61,4 +60,8 @@ https://github.com/newrelic/newrelic-ruby-agent/
|
|
61
60
|
s.add_development_dependency 'bundler'
|
62
61
|
s.add_development_dependency 'rubocop'
|
63
62
|
s.add_development_dependency 'rubocop-performance'
|
63
|
+
if RUBY_VERSION >= '2.7.0'
|
64
|
+
s.add_development_dependency 'simplecov'
|
65
|
+
s.add_development_dependency 'simplecov_json_formatter'
|
66
|
+
end
|
64
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanna McClure
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -209,6 +209,34 @@ dependencies:
|
|
209
209
|
- - ">="
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
|
+
- !ruby/object:Gem::Dependency
|
213
|
+
name: simplecov
|
214
|
+
requirement: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
type: :development
|
220
|
+
prerelease: false
|
221
|
+
version_requirements: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
- !ruby/object:Gem::Dependency
|
227
|
+
name: simplecov_json_formatter
|
228
|
+
requirement: !ruby/object:Gem::Requirement
|
229
|
+
requirements:
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '0'
|
233
|
+
type: :development
|
234
|
+
prerelease: false
|
235
|
+
version_requirements: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - ">="
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '0'
|
212
240
|
description: |
|
213
241
|
New Relic is a performance management system, developed by New Relic,
|
214
242
|
Inc (http://www.newrelic.com). New Relic provides you with deep
|
@@ -233,6 +261,7 @@ files:
|
|
233
261
|
- ".gitignore"
|
234
262
|
- ".project"
|
235
263
|
- ".rubocop.yml"
|
264
|
+
- ".simplecov"
|
236
265
|
- ".yardopts"
|
237
266
|
- Brewfile
|
238
267
|
- CHANGELOG.md
|
@@ -258,6 +287,10 @@ files:
|
|
258
287
|
- lib/new_relic/agent.rb
|
259
288
|
- lib/new_relic/agent/adaptive_sampler.rb
|
260
289
|
- lib/new_relic/agent/agent.rb
|
290
|
+
- lib/new_relic/agent/agent/shutdown.rb
|
291
|
+
- lib/new_relic/agent/agent/special_startup.rb
|
292
|
+
- lib/new_relic/agent/agent/start_worker_thread.rb
|
293
|
+
- lib/new_relic/agent/agent/startup.rb
|
261
294
|
- lib/new_relic/agent/agent_logger.rb
|
262
295
|
- lib/new_relic/agent/attribute_filter.rb
|
263
296
|
- lib/new_relic/agent/attribute_processing.rb
|
@@ -586,6 +619,7 @@ files:
|
|
586
619
|
- lib/tasks/config.html.erb
|
587
620
|
- lib/tasks/config.rake
|
588
621
|
- lib/tasks/config.text.erb
|
622
|
+
- lib/tasks/coverage_report.rake
|
589
623
|
- lib/tasks/install.rake
|
590
624
|
- lib/tasks/multiverse.rake
|
591
625
|
- lib/tasks/multiverse.rb
|