newrelic_rpm 8.11.0 → 8.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/Brewfile +1 -0
- data/CHANGELOG.md +45 -16
- data/bin/nrdebug +2 -0
- data/docker-compose.yml +22 -0
- data/lib/new_relic/agent/agent/shutdown.rb +1 -0
- data/lib/new_relic/agent/agent/special_startup.rb +2 -0
- data/lib/new_relic/agent/agent/startup.rb +1 -0
- data/lib/new_relic/agent/attributes.rb +1 -0
- data/lib/new_relic/agent/audit_logger.rb +1 -0
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -0
- data/lib/new_relic/agent/configuration/default_source.rb +26 -4
- data/lib/new_relic/agent/configuration/dotted_hash.rb +1 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
- data/lib/new_relic/agent/configuration/manager.rb +3 -0
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -0
- data/lib/new_relic/agent/connect/request_builder.rb +1 -0
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +1 -0
- data/lib/new_relic/agent/database.rb +7 -0
- data/lib/new_relic/agent/database_adapter.rb +2 -0
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +3 -2
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
- data/lib/new_relic/agent/datastores/nosql_obfuscator.rb +41 -0
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +3 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +3 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +1 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +1 -0
- data/lib/new_relic/agent/encoding_normalizer.rb +2 -0
- data/lib/new_relic/agent/error_collector.rb +3 -0
- data/lib/new_relic/agent/error_filter.rb +1 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -0
- data/lib/new_relic/agent/event_aggregator.rb +1 -0
- data/lib/new_relic/agent/event_loop.rb +2 -0
- data/lib/new_relic/agent/http_clients/abstract.rb +2 -0
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +29 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -0
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +1 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +1 -0
- data/lib/new_relic/agent/local_log_decorator.rb +1 -0
- data/lib/new_relic/agent/log_event_aggregator.rb +1 -0
- data/lib/new_relic/agent/messaging.rb +1 -0
- data/lib/new_relic/agent/method_tracer.rb +4 -0
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +2 -0
- data/lib/new_relic/agent/rules_engine.rb +1 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +5 -0
- data/lib/new_relic/agent/span_event_primitive.rb +1 -0
- data/lib/new_relic/agent/stats.rb +1 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -0
- data/lib/new_relic/agent/system_info.rb +3 -0
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -0
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -0
- data/lib/new_relic/agent/threading/thread_profile.rb +3 -0
- data/lib/new_relic/agent/tracer.rb +4 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/datastore_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +4 -0
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +1 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +1 -0
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -0
- data/lib/new_relic/agent/transaction/segment.rb +1 -0
- data/lib/new_relic/agent/transaction/trace.rb +4 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +1 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +2 -0
- data/lib/new_relic/agent/transaction.rb +10 -0
- data/lib/new_relic/agent/transaction_event_aggregator.rb +1 -0
- data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -0
- data/lib/new_relic/agent/utilization/pcf.rb +1 -0
- data/lib/new_relic/agent/utilization/vendor.rb +2 -0
- data/lib/new_relic/agent/utilization_data.rb +3 -0
- data/lib/new_relic/agent.rb +4 -2
- data/lib/new_relic/cli/commands/install.rb +1 -0
- data/lib/new_relic/coerce.rb +6 -0
- data/lib/new_relic/collection_helper.rb +1 -0
- data/lib/new_relic/control/frameworks/rails.rb +5 -0
- data/lib/new_relic/control/instrumentation.rb +2 -0
- data/lib/new_relic/dependency_detection.rb +2 -0
- data/lib/new_relic/helper.rb +1 -0
- data/lib/new_relic/language_support.rb +1 -0
- data/lib/new_relic/latest_changes.rb +1 -0
- data/lib/new_relic/local_environment.rb +6 -0
- data/lib/new_relic/metric_spec.rb +2 -0
- data/lib/new_relic/rack/agent_middleware.rb +2 -0
- data/lib/new_relic/traced_thread.rb +1 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/helpers/format.rb +3 -0
- data/lib/tasks/instrumentation_generator/instrumentation.thor +27 -5
- data/lib/tasks/instrumentation_generator/templates/chain.tt +2 -1
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +3 -2
- data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +2 -1
- data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/prepend.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/test.tt +1 -1
- data/newrelic.yml +13 -3
- data/newrelic_rpm.gemspec +6 -6
- data/test/agent_helper.rb +6 -0
- metadata +11 -77
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +0 -43
@@ -123,11 +123,13 @@ module NewRelic
|
|
123
123
|
|
124
124
|
def exception_tagged_with?(ivar, exception)
|
125
125
|
return false if exception_is_java_object?(exception)
|
126
|
+
|
126
127
|
exception.instance_variable_defined?(ivar)
|
127
128
|
end
|
128
129
|
|
129
130
|
def tag_exception_using(ivar, exception)
|
130
131
|
return if exception_is_java_object?(exception) || exception.frozen?
|
132
|
+
|
131
133
|
begin
|
132
134
|
exception.instance_variable_set(ivar, true)
|
133
135
|
rescue => e
|
@@ -137,6 +139,7 @@ module NewRelic
|
|
137
139
|
|
138
140
|
def tag_exception(exception)
|
139
141
|
return if exception_is_java_object?(exception) || exception.frozen?
|
142
|
+
|
140
143
|
begin
|
141
144
|
exception.instance_variable_set(EXCEPTION_TAG_IVAR, true)
|
142
145
|
rescue => e
|
@@ -155,6 +155,7 @@ module NewRelic
|
|
155
155
|
result = []
|
156
156
|
code_list.each do |code|
|
157
157
|
result << code && next if code.is_a?(Integer)
|
158
|
+
|
158
159
|
m = code.match(/(\d{3})(-\d{3})?/)
|
159
160
|
if m.nil? || m[1].nil?
|
160
161
|
::NewRelic::Agent.logger.warn("Invalid HTTP status code: '#{code}'; ignoring config")
|
@@ -34,6 +34,7 @@ module NewRelic
|
|
34
34
|
def calculate_next_fire_time
|
35
35
|
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
36
36
|
return now if @interval == 0
|
37
|
+
|
37
38
|
fire_time = @last_fired_at || now
|
38
39
|
while fire_time <= now
|
39
40
|
fire_time += @interval
|
@@ -80,6 +81,7 @@ module NewRelic
|
|
80
81
|
|
81
82
|
def next_timeout
|
82
83
|
return nil if @timers.empty?
|
84
|
+
|
83
85
|
timeout = @timers.values.map(&:next_fire_time).min - Process.clock_gettime(Process::CLOCK_REALTIME)
|
84
86
|
timeout < 0 ? 0 : timeout
|
85
87
|
end
|
@@ -47,6 +47,7 @@ module NewRelic
|
|
47
47
|
if wrapped_response.nil?
|
48
48
|
raise ArgumentError, WHINY_NIL_ERROR % self.class
|
49
49
|
end
|
50
|
+
|
50
51
|
@wrapped_response = wrapped_response
|
51
52
|
end
|
52
53
|
|
@@ -64,6 +65,7 @@ module NewRelic
|
|
64
65
|
|
65
66
|
def get_status_code_using(method_name)
|
66
67
|
return unless @wrapped_response.respond_to?(method_name)
|
68
|
+
|
67
69
|
code = @wrapped_response.send(method_name).to_i
|
68
70
|
code == 0 ? nil : code
|
69
71
|
end
|
@@ -38,6 +38,7 @@ DependencyDetection.defer do
|
|
38
38
|
|
39
39
|
executes do
|
40
40
|
next unless Gem::Version.new(ActiveMerchant::VERSION) < Gem::Version.new('1.65.0')
|
41
|
+
|
41
42
|
deprecation_msg = 'The Ruby Agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
|
42
43
|
'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \
|
43
44
|
|
@@ -10,6 +10,7 @@ module NewRelic
|
|
10
10
|
class ActiveStorageSubscriber < NotificationsSubscriber
|
11
11
|
def start(name, id, payload)
|
12
12
|
return unless state.is_execution_traced?
|
13
|
+
|
13
14
|
start_segment(name, id, payload)
|
14
15
|
rescue => e
|
15
16
|
log_notification_error(e, name, 'start')
|
@@ -17,6 +18,7 @@ module NewRelic
|
|
17
18
|
|
18
19
|
def finish(name, id, payload)
|
19
20
|
return unless state.is_execution_traced?
|
21
|
+
|
20
22
|
finish_segment(id, payload)
|
21
23
|
rescue => e
|
22
24
|
log_notification_error(e, name, 'finish')
|
@@ -14,6 +14,7 @@ module NewRelic
|
|
14
14
|
parse_query_without_newrelic(*args)
|
15
15
|
ensure
|
16
16
|
return unless txn = ::NewRelic::Agent::Tracer.current_transaction
|
17
|
+
|
17
18
|
txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
|
18
19
|
end
|
19
20
|
end
|
@@ -96,6 +96,7 @@ DependencyDetection.defer do
|
|
96
96
|
|
97
97
|
executes do
|
98
98
|
next unless delayed_job_version < Gem::Version.new('4.1.0')
|
99
|
+
|
99
100
|
deprecation_msg = 'Instrumentation for DelayedJob versions below 4.1.0 is deprecated.' \
|
100
101
|
'It will stop being monitored in version 9.0.0. ' \
|
101
102
|
'Please upgrade your DelayedJob version to continue receiving full support. ' \
|
@@ -0,0 +1,29 @@
|
|
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::Agent::Instrumentation
|
6
|
+
module Elasticsearch
|
7
|
+
def self.instrument!
|
8
|
+
to_instrument = if ::Gem::Version.create(::Elasticsearch::VERSION) <
|
9
|
+
::Gem::Version.create("8.0.0")
|
10
|
+
::Elasticsearch::Transport::Client
|
11
|
+
else
|
12
|
+
::Elastic::Transport::Client
|
13
|
+
end
|
14
|
+
|
15
|
+
to_instrument.class_eval do
|
16
|
+
include NewRelic::Agent::Instrumentation::Elasticsearch
|
17
|
+
|
18
|
+
alias_method(:perform_request_without_tracing, :perform_request)
|
19
|
+
alias_method(:perform_request, :perform_request_with_tracing)
|
20
|
+
|
21
|
+
def perform_request(*args)
|
22
|
+
perform_request_with_tracing(*args) do
|
23
|
+
perform_request_without_tracing(*args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
+
require_relative '../../datastores/nosql_obfuscator'
|
5
|
+
|
6
|
+
module NewRelic::Agent::Instrumentation
|
7
|
+
module Elasticsearch
|
8
|
+
PRODUCT_NAME = 'Elasticsearch'
|
9
|
+
OPERATION = 'perform_request'
|
10
|
+
|
11
|
+
def perform_request_with_tracing(method, path, params = {}, body = nil, headers = nil)
|
12
|
+
return yield unless NewRelic::Agent::Tracer.tracing_enabled?
|
13
|
+
|
14
|
+
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
15
|
+
product: PRODUCT_NAME,
|
16
|
+
operation: nr_operation || OPERATION,
|
17
|
+
host: nr_hosts[:host],
|
18
|
+
port_path_or_id: path,
|
19
|
+
database_name: nr_cluster_name
|
20
|
+
)
|
21
|
+
begin
|
22
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
|
23
|
+
ensure
|
24
|
+
if segment
|
25
|
+
segment.notice_nosql_statement(nr_reported_query(body || params))
|
26
|
+
segment.finish
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def nr_operation
|
34
|
+
operation_index = caller_locations.index do |line|
|
35
|
+
string = line.to_s
|
36
|
+
string.include?('lib/elasticsearch/api') && !string.include?(OPERATION)
|
37
|
+
end
|
38
|
+
return nil unless operation_index
|
39
|
+
|
40
|
+
caller_locations[operation_index].to_s.split('`')[-1].gsub(/\W/, "")
|
41
|
+
end
|
42
|
+
|
43
|
+
def nr_reported_query(query)
|
44
|
+
return unless NewRelic::Agent.config[:'elasticsearch.capture_queries']
|
45
|
+
return query unless NewRelic::Agent.config[:'elasticsearch.obfuscate_queries']
|
46
|
+
|
47
|
+
NewRelic::Agent::Datastores::NosqlObfuscator.obfuscate_statement(query)
|
48
|
+
end
|
49
|
+
|
50
|
+
def nr_cluster_name
|
51
|
+
return @nr_cluster_name if @nr_cluster_name
|
52
|
+
return if nr_hosts.empty?
|
53
|
+
|
54
|
+
NewRelic::Agent.disable_all_tracing do
|
55
|
+
@nr_cluster_name ||= perform_request('GET', '_cluster/health').body["cluster_name"]
|
56
|
+
end
|
57
|
+
rescue StandardError => e
|
58
|
+
NewRelic::Agent.logger.error("Failed to get cluster name for elasticsearch", e)
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def nr_hosts
|
63
|
+
@nr_hosts ||= (transport.hosts.first || NewRelic::EMPTY_HASH)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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::Agent::Instrumentation
|
6
|
+
module Elasticsearch::Prepend
|
7
|
+
include NewRelic::Agent::Instrumentation::Elasticsearch
|
8
|
+
|
9
|
+
def perform_request(*args)
|
10
|
+
perform_request_with_tracing(*args) { super }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
+
require_relative 'elasticsearch/instrumentation'
|
6
|
+
require_relative 'elasticsearch/chain'
|
7
|
+
require_relative 'elasticsearch/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :elasticsearch
|
11
|
+
|
12
|
+
depends_on do
|
13
|
+
defined?(::Elasticsearch)
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
::NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation')
|
18
|
+
|
19
|
+
to_instrument = if ::Gem::Version.create(::Elasticsearch::VERSION) < ::Gem::Version.create("8.0.0")
|
20
|
+
::Elasticsearch::Transport::Client
|
21
|
+
else
|
22
|
+
::Elastic::Transport::Client
|
23
|
+
end
|
24
|
+
|
25
|
+
if use_prepend?
|
26
|
+
prepend_instrument to_instrument, NewRelic::Agent::Instrumentation::Elasticsearch::Prepend
|
27
|
+
else
|
28
|
+
chain_instrument NewRelic::Agent::Instrumentation::Elasticsearch
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -15,21 +15,25 @@ module NewRelic
|
|
15
15
|
# and AuditLogger without them having to know the inner details.
|
16
16
|
def self.mark_skip_instrumenting(logger)
|
17
17
|
return if logger.frozen?
|
18
|
+
|
18
19
|
logger.instance_variable_set(:@skip_instrumenting, true)
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.clear_skip_instrumenting(logger)
|
22
23
|
return if logger.frozen?
|
24
|
+
|
23
25
|
logger.instance_variable_set(:@skip_instrumenting, false)
|
24
26
|
end
|
25
27
|
|
26
28
|
def mark_skip_instrumenting
|
27
29
|
return if frozen?
|
30
|
+
|
28
31
|
@skip_instrumenting = true
|
29
32
|
end
|
30
33
|
|
31
34
|
def clear_skip_instrumenting
|
32
35
|
return if frozen?
|
36
|
+
|
33
37
|
@skip_instrumenting = false
|
34
38
|
end
|
35
39
|
|
@@ -14,6 +14,7 @@ module NewRelic
|
|
14
14
|
def started(event)
|
15
15
|
begin
|
16
16
|
return unless NewRelic::Agent::Tracer.tracing_enabled?
|
17
|
+
|
17
18
|
segments[event.operation_id] = start_segment(event)
|
18
19
|
rescue Exception => e
|
19
20
|
log_notification_error('started', e)
|
@@ -33,6 +34,7 @@ module NewRelic
|
|
33
34
|
def completed(event)
|
34
35
|
begin
|
35
36
|
return unless NewRelic::Agent::Tracer.tracing_enabled?
|
37
|
+
|
36
38
|
segment = segments.delete(event.operation_id)
|
37
39
|
return unless segment
|
38
40
|
|
@@ -76,6 +76,7 @@ module NewRelic
|
|
76
76
|
# defensive.
|
77
77
|
return if defined?(exception_object)
|
78
78
|
return unless defined?(::ActiveSupport::VERSION)
|
79
|
+
|
79
80
|
if ::ActiveSupport::VERSION::STRING < "5.0.0"
|
80
81
|
# Earlier versions of Rails did not add the exception itself to the
|
81
82
|
# payload accessible via :exception_object, so we create a stand-in
|
@@ -85,6 +86,7 @@ module NewRelic
|
|
85
86
|
def exception_object(payload)
|
86
87
|
exception_class, message = payload[:exception]
|
87
88
|
return nil unless exception_class
|
89
|
+
|
88
90
|
NewRelic::Agent::NoticeableError.new(exception_class, message)
|
89
91
|
end
|
90
92
|
else
|
@@ -23,6 +23,7 @@ module NewRelic
|
|
23
23
|
|
24
24
|
def check_for_late_instrumentation(app)
|
25
25
|
return if defined?(@checked_for_late_instrumentation) && @checked_for_late_instrumentation
|
26
|
+
|
26
27
|
@checked_for_late_instrumentation = true
|
27
28
|
if middleware_instrumentation_enabled?
|
28
29
|
if ::NewRelic::Agent::Instrumentation::MiddlewareProxy.needs_wrapping?(app)
|
@@ -49,12 +50,14 @@ module NewRelic
|
|
49
50
|
|
50
51
|
def run_with_tracing(app)
|
51
52
|
return yield(app) unless middleware_instrumentation_enabled?
|
53
|
+
|
52
54
|
yield(::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true))
|
53
55
|
end
|
54
56
|
|
55
57
|
def use_with_tracing(middleware_class)
|
56
58
|
return if middleware_class.nil?
|
57
59
|
return yield(middleware_class) unless middleware_instrumentation_enabled?
|
60
|
+
|
58
61
|
yield(::NewRelic::Agent::Instrumentation::MiddlewareProxy.for_class(middleware_class))
|
59
62
|
end
|
60
63
|
end
|
@@ -37,6 +37,7 @@ module NewRelic
|
|
37
37
|
|
38
38
|
def safe_from_third_party_gem?
|
39
39
|
return true unless NewRelic::LanguageSupport.bundled_gem?("newrelic-rake")
|
40
|
+
|
40
41
|
::NewRelic::Agent.logger.info("Not installing New Relic supported Rake instrumentation because the third party newrelic-rake gem is present")
|
41
42
|
false
|
42
43
|
end
|
@@ -103,6 +103,7 @@ DependencyDetection.defer do
|
|
103
103
|
|
104
104
|
executes do
|
105
105
|
next unless Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new('5.0.0')
|
106
|
+
|
106
107
|
deprecation_msg = 'Instrumentation for Sidekiq versions below 5.0.0 is deprecated.' \
|
107
108
|
'They will stop being monitored in version 9.0.0. ' \
|
108
109
|
'Please upgrade your Sidekiq version to continue receiving full support. '
|
@@ -45,6 +45,7 @@ DependencyDetection.defer do
|
|
45
45
|
|
46
46
|
executes do
|
47
47
|
next unless Gem::Version.new(Sinatra::VERSION) < Gem::Version.new('2.0.0')
|
48
|
+
|
48
49
|
deprecation_msg = 'The Ruby Agent is dropping support for Sinatra versions below 2.0.0 ' \
|
49
50
|
'in version 9.0.0. Please upgrade your Sinatra version to continue receiving full compatibility. ' \
|
50
51
|
|
@@ -14,6 +14,7 @@ module NewRelic
|
|
14
14
|
# So here we are only grabbing the file name and name of directory it is in
|
15
15
|
def create_filename_for_metric(file)
|
16
16
|
return file unless defined?(::Sinatra) && defined?(::Sinatra::Base)
|
17
|
+
|
17
18
|
file.split('/')[-2..-1].join('/')
|
18
19
|
rescue NoMethodError
|
19
20
|
file
|
@@ -86,6 +86,7 @@ module NewRelic
|
|
86
86
|
def trace_execution_unscoped(metric_names, options = NewRelic::EMPTY_HASH) # THREAD_LOCAL_ACCESS
|
87
87
|
NewRelic::Agent.record_api_supportability_metric(:trace_execution_unscoped) unless options[:internal]
|
88
88
|
return yield unless NewRelic::Agent.tl_is_execution_traced?
|
89
|
+
|
89
90
|
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
90
91
|
begin
|
91
92
|
yield
|
@@ -251,6 +252,7 @@ module NewRelic
|
|
251
252
|
# may get removed as well.
|
252
253
|
def remove_method_tracer(method_name) # :nodoc:
|
253
254
|
return unless Agent.config[:agent_enabled]
|
255
|
+
|
254
256
|
if _nr_traced_method_module.method_defined?(method_name)
|
255
257
|
_nr_traced_method_module.send(:remove_method, method_name)
|
256
258
|
::NewRelic::Agent.logger.debug("removed method tracer #{method_name}\n")
|
@@ -264,6 +266,7 @@ module NewRelic
|
|
264
266
|
def _nr_add_method_tracer_now(method_name, metric_name, options)
|
265
267
|
NewRelic::Agent.record_api_supportability_metric(:add_method_tracer)
|
266
268
|
return unless newrelic_method_exists?(method_name)
|
269
|
+
|
267
270
|
remove_method_tracer(method_name) if method_traced?(method_name)
|
268
271
|
|
269
272
|
options = _nr_validate_method_tracer_options(method_name, options)
|
@@ -304,6 +307,7 @@ module NewRelic
|
|
304
307
|
_nr_traced_method_module.module_eval do
|
305
308
|
define_method(method_name) do |*args, &block|
|
306
309
|
return super(*args, &block) unless NewRelic::Agent.tl_is_execution_traced?
|
310
|
+
|
307
311
|
scoped_metric_eval, unscoped_metrics_eval = nil, []
|
308
312
|
|
309
313
|
scoped_metric_eval = case scoped_metric
|
@@ -524,6 +524,7 @@ module NewRelic
|
|
524
524
|
uri = String.new('/agent_listener/invoke_raw_method?')
|
525
525
|
uri << params.map do |k, v|
|
526
526
|
next unless v
|
527
|
+
|
527
528
|
"#{k}=#{v}"
|
528
529
|
end.compact.join('&')
|
529
530
|
uri
|
@@ -592,6 +593,7 @@ module NewRelic
|
|
592
593
|
# than the limit configured in the control object
|
593
594
|
def check_post_size(post_string, endpoint)
|
594
595
|
return if post_string.size < Agent.config[:max_payload_size_in_bytes]
|
596
|
+
|
595
597
|
::NewRelic::Agent.logger.debug("Tried to send too much data: #{post_string.size} bytes")
|
596
598
|
NewRelic::Agent.increment_metric("Supportability/Agent/Collector/#{endpoint}/MaxPayloadSizeLimit")
|
597
599
|
raise UnrecoverableServerException.new('413 Request Entity Too Large')
|
@@ -160,6 +160,7 @@ module NewRelic
|
|
160
160
|
|
161
161
|
def start
|
162
162
|
return if @started == true
|
163
|
+
|
163
164
|
@started = true
|
164
165
|
@thread = NewRelic::Agent::Threading::AgentThread.create('Pipe Channel Manager') do
|
165
166
|
now = nil
|
@@ -207,6 +208,7 @@ module NewRelic
|
|
207
208
|
|
208
209
|
def stop
|
209
210
|
return unless @started == true
|
211
|
+
|
210
212
|
stop_listener_thread
|
211
213
|
close_all_pipes
|
212
214
|
@wake.close
|
@@ -75,12 +75,14 @@ module NewRelic
|
|
75
75
|
|
76
76
|
def can_run?
|
77
77
|
return false if @broken
|
78
|
+
|
78
79
|
m = get_memory rescue nil
|
79
80
|
m && m > 0
|
80
81
|
end
|
81
82
|
|
82
83
|
def get_sample
|
83
84
|
return nil if @broken
|
85
|
+
|
84
86
|
begin
|
85
87
|
m = get_memory
|
86
88
|
if m.nil?
|
@@ -99,6 +101,7 @@ module NewRelic
|
|
99
101
|
class JavaHeapSampler < Base
|
100
102
|
def get_memory
|
101
103
|
raise "Can't sample Java heap unless running in JRuby" unless defined? JRuby
|
104
|
+
|
102
105
|
java.lang.Runtime.getRuntime.totalMemory / (1024 * 1024).to_f rescue nil
|
103
106
|
end
|
104
107
|
|
@@ -121,6 +124,7 @@ module NewRelic
|
|
121
124
|
# if for some reason the ps command doesn't work on the resident os,
|
122
125
|
# then don't execute it any more.
|
123
126
|
raise "Faulty command: `#{@command} #{process}`" if memory.nil? || memory <= 0
|
127
|
+
|
124
128
|
memory
|
125
129
|
end
|
126
130
|
|
@@ -140,6 +144,7 @@ module NewRelic
|
|
140
144
|
if proc_status =~ /RSS:\s*(\d+) kB/i
|
141
145
|
return $1.to_f / 1024.0
|
142
146
|
end
|
147
|
+
|
143
148
|
raise "Unable to find RSS in #{proc_status_file}"
|
144
149
|
end
|
145
150
|
|
@@ -52,6 +52,7 @@ module NewRelic
|
|
52
52
|
# an error is present. Otherwise, returns nil when no error present.
|
53
53
|
def error_attributes(segment)
|
54
54
|
return if Agent.config[:high_security] || !segment.noticed_error
|
55
|
+
|
55
56
|
segment.noticed_error.build_error_attributes
|
56
57
|
segment.noticed_error_attributes
|
57
58
|
end
|
@@ -224,6 +224,7 @@ module NewRelic
|
|
224
224
|
cgroup_info.split("\n").each do |line|
|
225
225
|
parts = line.split(':')
|
226
226
|
next unless parts.size == 3
|
227
|
+
|
227
228
|
_, subsystems, cgroup_id = parts
|
228
229
|
subsystems = subsystems.split(',')
|
229
230
|
subsystems.each do |subsystem|
|
@@ -240,6 +241,7 @@ module NewRelic
|
|
240
241
|
# for details on why we do it this way.
|
241
242
|
def self.proc_try_read(path)
|
242
243
|
return nil unless File.exist?(path)
|
244
|
+
|
243
245
|
content = String.new('')
|
244
246
|
File.open(path) do |f|
|
245
247
|
loop do
|
@@ -281,6 +283,7 @@ module NewRelic
|
|
281
283
|
|
282
284
|
def self.boot_id
|
283
285
|
return nil unless linux?
|
286
|
+
|
284
287
|
if bid = proc_try_read('/proc/sys/kernel/random/boot_id')
|
285
288
|
bid.chomp!
|
286
289
|
|