newrelic_rpm 9.12.0 → 9.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +217 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +16 -20
- data/lib/boot/strap.rb +4 -3
- data/lib/new_relic/agent/agent.rb +4 -0
- data/lib/new_relic/agent/agent_helpers/connect.rb +3 -0
- data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -0
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +3 -0
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -0
- data/lib/new_relic/agent/agent_helpers/startup.rb +7 -0
- data/lib/new_relic/agent/aws.rb +6 -0
- data/lib/new_relic/agent/configuration/default_source.rb +363 -31
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -1
- data/lib/new_relic/agent/configuration/manager.rb +23 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +6 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +11 -11
- data/lib/new_relic/agent/database.rb +41 -1
- data/lib/new_relic/agent/distributed_tracing.rb +2 -2
- data/lib/new_relic/agent/health_check.rb +136 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +0 -13
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -8
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +5 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +9 -16
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +0 -2
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +0 -2
- data/lib/new_relic/agent/instrumentation/async_http.rb +1 -2
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose.rb +22 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +91 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis.rb +22 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs.rb +0 -2
- data/lib/new_relic/agent/instrumentation/bunny.rb +3 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +0 -2
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -4
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -23
- data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/dynamodb.rb +0 -2
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +0 -2
- data/lib/new_relic/agent/instrumentation/ethon.rb +0 -4
- data/lib/new_relic/agent/instrumentation/excon.rb +0 -16
- data/lib/new_relic/agent/instrumentation/fiber.rb +0 -2
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +0 -3
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpx.rb +0 -4
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
- data/lib/new_relic/agent/instrumentation/logstasher.rb +0 -2
- data/lib/new_relic/agent/instrumentation/memcache.rb +0 -1
- data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/opensearch.rb +23 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rake.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +72 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/instrumentation.rb +70 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +67 -0
- data/lib/new_relic/agent/instrumentation/rdkafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +7 -6
- data/lib/new_relic/agent/instrumentation/resque.rb +7 -5
- data/lib/new_relic/agent/instrumentation/roda.rb +4 -4
- data/lib/new_relic/agent/instrumentation/ruby_kafka/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/instrumentation.rb +67 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +60 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -14
- data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -19
- data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
- data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
- data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +11 -5
- data/lib/new_relic/agent/instrumentation/view_component.rb +0 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +2 -3
- data/lib/new_relic/agent/local_log_decorator.rb +12 -2
- data/lib/new_relic/agent/log_event_aggregator.rb +28 -2
- data/lib/new_relic/agent/messaging.rb +11 -5
- data/lib/new_relic/agent/new_relic_service.rb +8 -2
- data/lib/new_relic/agent/serverless_handler.rb +241 -12
- data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
- data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
- data/lib/new_relic/agent/span_event_primitive.rb +4 -2
- data/lib/new_relic/agent/system_info.rb +14 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +10 -1
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/request_attributes.rb +13 -1
- data/lib/new_relic/agent/transaction/trace_context.rb +1 -1
- data/lib/new_relic/agent.rb +95 -2
- data/lib/new_relic/control/frameworks/grape.rb +14 -0
- data/lib/new_relic/control/frameworks/padrino.rb +14 -0
- data/lib/new_relic/control/frameworks/rails4.rb +1 -3
- data/lib/new_relic/dependency_detection.rb +11 -13
- data/lib/new_relic/environment_report.rb +2 -2
- data/lib/new_relic/helper.rb +15 -0
- data/lib/new_relic/language_support.rb +3 -1
- data/lib/new_relic/local_environment.rb +1 -4
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
- data/lib/tasks/helpers/newrelicyml.rb +73 -11
- data/lib/tasks/instrumentation_generator/instrumentation.thor +1 -1
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +11 -8
- data/newrelic.yml +224 -79
- data/test/agent_helper.rb +8 -1
- metadata +32 -6
@@ -0,0 +1,33 @@
|
|
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 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AwsSdkLambda::Chain
|
9
|
+
def self.instrument!
|
10
|
+
::Aws::Lambda::Client.class_eval do
|
11
|
+
include NewRelic::Agent::Instrumentation::AwsSdkLambda
|
12
|
+
|
13
|
+
alias_method(:invoke_without_new_relic, :invoke)
|
14
|
+
|
15
|
+
def invoke(*args)
|
16
|
+
invoke_with_new_relic(*args) { invoke_without_new_relic(*args) }
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method(:invoke_async_without_new_relic, :invoke_async)
|
20
|
+
|
21
|
+
def invoke_async(*args)
|
22
|
+
invoke_async_with_new_relic(*args) { invoke_async_without_new_relic(*args) }
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method(:invoke_with_response_stream_without_new_relic, :invoke_with_response_stream)
|
26
|
+
|
27
|
+
def invoke_with_response_stream(*args)
|
28
|
+
invoke_with_response_stream_with_new_relic(*args) { invoke_with_response_stream_without_new_relic(*args) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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 'json'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AwsSdkLambda
|
9
|
+
INSTRUMENTATION_NAME = 'aws_sdk_lambda'
|
10
|
+
AWS_SERVICE = 'lambda'
|
11
|
+
CLOUD_PLATFORM = 'aws_lambda'
|
12
|
+
WRAPPED_RESPONSE = Struct.new(:status_code, :has_status_code?)
|
13
|
+
|
14
|
+
def invoke_with_new_relic(*args)
|
15
|
+
with_tracing(:invoke, *args) { yield }
|
16
|
+
end
|
17
|
+
|
18
|
+
def invoke_async_with_new_relic(*args)
|
19
|
+
with_tracing(:invoke_async, *args) { yield }
|
20
|
+
end
|
21
|
+
|
22
|
+
def invoke_with_response_stream_with_new_relic(*args)
|
23
|
+
with_tracing(:invoke_with_response_stream, *args) { yield }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def with_tracing(action, *args)
|
29
|
+
segment = generate_segment(action, *args)
|
30
|
+
|
31
|
+
# prevent additional instrumentation for things like Net::HTTP from
|
32
|
+
# creating any segments that may appear as redundant / confusing
|
33
|
+
NewRelic::Agent.disable_all_tracing do
|
34
|
+
response = NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
|
35
|
+
process_response(response, segment)
|
36
|
+
response
|
37
|
+
end
|
38
|
+
ensure
|
39
|
+
segment&.finish
|
40
|
+
end
|
41
|
+
|
42
|
+
def process_response(response, segment)
|
43
|
+
process_function_error(response) if response.respond_to?(:function_error)
|
44
|
+
rescue => e
|
45
|
+
NewRelic::Agent.logger.error("Error processing aws-sdk-lambda invocation response: #{e}")
|
46
|
+
end
|
47
|
+
|
48
|
+
# notice error that was raised / unhandled by the function
|
49
|
+
def process_function_error(response)
|
50
|
+
function_error = response.function_error
|
51
|
+
return unless function_error
|
52
|
+
|
53
|
+
msg = "[#{function_error}]"
|
54
|
+
payload = response.payload&.string if response.respond_to?(:payload)
|
55
|
+
payload_hash = JSON.parse(payload) if payload
|
56
|
+
msg = "#{msg} #{payload_hash['errorType']} - #{payload_hash['errorMessage']}" if payload_hash
|
57
|
+
e = StandardError.new(msg)
|
58
|
+
e.set_backtrace(payload_hash['stackTrace']) if payload_hash
|
59
|
+
|
60
|
+
NewRelic::Agent.notice_error(e)
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_segment(action, options = {})
|
64
|
+
function = function_name(options)
|
65
|
+
region = aws_region
|
66
|
+
arn = aws_arn(function, region)
|
67
|
+
segment = NewRelic::Agent::Tracer.start_segment(name: "Lambda/#{action}/#{function}")
|
68
|
+
segment.add_agent_attribute('cloud.account.id', nr_account_id)
|
69
|
+
segment.add_agent_attribute('cloud.platform', CLOUD_PLATFORM)
|
70
|
+
segment.add_agent_attribute('cloud.region', region)
|
71
|
+
segment.add_agent_attribute('cloud.resource_id', arn) if arn
|
72
|
+
segment
|
73
|
+
end
|
74
|
+
|
75
|
+
def function_name(options = {})
|
76
|
+
(options.fetch(:function_name, nil) if options.respond_to?(:fetch)) || NewRelic::UNKNOWN
|
77
|
+
end
|
78
|
+
|
79
|
+
def aws_region
|
80
|
+
config&.region if self.respond_to?(:config)
|
81
|
+
end
|
82
|
+
|
83
|
+
def aws_arn(function, region)
|
84
|
+
NewRelic::Agent::Aws.create_arn(AWS_SERVICE, "function:#{function}", region, nr_account_id)
|
85
|
+
end
|
86
|
+
|
87
|
+
def nr_account_id
|
88
|
+
return @nr_account_id if defined?(@nr_account_id)
|
89
|
+
|
90
|
+
@nr_account_id = NewRelic::Agent::Aws.get_account_id(config)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AwsSdkLambda::Prepend
|
9
|
+
include NewRelic::Agent::Instrumentation::AwsSdkLambda
|
10
|
+
|
11
|
+
def invoke(*args)
|
12
|
+
invoke_with_new_relic(*args) { super }
|
13
|
+
end
|
14
|
+
|
15
|
+
def invoke_async(*args)
|
16
|
+
invoke_async_with_new_relic(*args) { super }
|
17
|
+
end
|
18
|
+
|
19
|
+
def invoke_with_response_stream(*args)
|
20
|
+
invoke_with_response_stream_with_new_relic(*args) { super }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
DependencyDetection.defer do
|
6
|
+
named :aws_sdk_lambda
|
7
|
+
|
8
|
+
depends_on do
|
9
|
+
defined?(Aws::Lambda::Client)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
require_relative 'aws_sdk_lambda/instrumentation'
|
14
|
+
|
15
|
+
if use_prepend?
|
16
|
+
require_relative 'aws_sdk_lambda/prepend'
|
17
|
+
prepend_instrument Aws::Lambda::Client, NewRelic::Agent::Instrumentation::AwsSdkLambda::Prepend
|
18
|
+
else
|
19
|
+
require_relative 'aws_sdk_lambda/chain'
|
20
|
+
chain_instrument NewRelic::Agent::Instrumentation::AwsSdkLambda::Chain
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -14,7 +14,6 @@ DependencyDetection.defer do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
executes do
|
17
|
-
NewRelic::Agent.logger.info('Installing Bunny instrumentation')
|
18
17
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
19
18
|
require 'new_relic/agent/messaging'
|
20
19
|
require 'new_relic/agent/transaction/message_broker_segment'
|
@@ -22,9 +21,9 @@ DependencyDetection.defer do
|
|
22
21
|
|
23
22
|
executes do
|
24
23
|
if use_prepend?
|
25
|
-
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
|
26
|
-
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
|
27
|
-
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
|
24
|
+
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange, 'Bunny::Exchange'
|
25
|
+
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue, 'Bunny::Queue'
|
26
|
+
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer, 'Bunny::Consumer'
|
28
27
|
else
|
29
28
|
chain_instrument NewRelic::Agent::Instrumentation::Bunny::Chain
|
30
29
|
end
|
@@ -16,8 +16,6 @@ DependencyDetection.defer do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
executes do
|
19
|
-
NewRelic::Agent.logger.info('Installing concurrent-ruby instrumentation')
|
20
|
-
|
21
19
|
if use_prepend?
|
22
20
|
prepend_instrument(Concurrent::ThreadPoolExecutor, NewRelic::Agent::Instrumentation::ConcurrentRuby::Prepend)
|
23
21
|
|
@@ -16,17 +16,16 @@ DependencyDetection.defer do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
executes do
|
19
|
-
NewRelic::Agent.logger.info('Installing Curb instrumentation')
|
20
19
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
21
20
|
require 'new_relic/agent/http_clients/curb_wrappers'
|
22
21
|
end
|
23
22
|
|
24
23
|
executes do
|
25
24
|
if use_prepend?
|
26
|
-
prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend
|
27
|
-
prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend
|
25
|
+
prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend, 'Curb::Easy'
|
26
|
+
prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend, 'Curb::Multi'
|
28
27
|
else
|
29
|
-
chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain
|
28
|
+
chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain, NewRelic::Agent::Instrumentation::Curb::Multi::INSTRUMENTATION_NAME
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -82,10 +82,6 @@ DependencyDetection.defer do
|
|
82
82
|
defined?(Delayed) && defined?(Delayed::Worker)
|
83
83
|
end
|
84
84
|
|
85
|
-
executes do
|
86
|
-
NewRelic::Agent.logger.info('Installing DelayedJob instrumentation [part 1/2]')
|
87
|
-
end
|
88
|
-
|
89
85
|
executes do
|
90
86
|
if use_prepend?
|
91
87
|
prepend_instrument Delayed::Worker, NewRelic::Agent::Instrumentation::DelayedJob::Prepend
|
@@ -93,23 +89,4 @@ DependencyDetection.defer do
|
|
93
89
|
chain_instrument NewRelic::Agent::Instrumentation::DelayedJob::Chain
|
94
90
|
end
|
95
91
|
end
|
96
|
-
|
97
|
-
executes do
|
98
|
-
next unless delayed_job_version < Gem::Version.new('4.1.0')
|
99
|
-
|
100
|
-
deprecation_msg = 'Instrumentation for DelayedJob versions below 4.1.0 is deprecated.' \
|
101
|
-
'It will stop being monitored in version 9.0.0. ' \
|
102
|
-
'Please upgrade your DelayedJob version to continue receiving full support. ' \
|
103
|
-
|
104
|
-
NewRelic::Agent.logger.log_once(
|
105
|
-
:warn,
|
106
|
-
:deprecated_delayed_job_version,
|
107
|
-
deprecation_msg
|
108
|
-
)
|
109
|
-
end
|
110
|
-
|
111
|
-
def delayed_job_version
|
112
|
-
# the following line needs else branch coverage
|
113
|
-
Gem.loaded_specs['delayed_job'].version if Gem.loaded_specs['delayed_job'] # rubocop:disable Style/SafeNavigation
|
114
|
-
end
|
115
92
|
end
|
@@ -56,7 +56,7 @@ module NewRelic::Agent::Instrumentation
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def get_arn(params)
|
59
|
-
return unless params[:table_name]
|
59
|
+
return unless params[:table_name]
|
60
60
|
|
61
61
|
NewRelic::Agent::Aws.create_arn(PRODUCT.downcase, "table/#{params[:table_name]}", config&.region, nr_account_id)
|
62
62
|
end
|
@@ -14,8 +14,6 @@ DependencyDetection.defer do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
executes do
|
17
|
-
NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation')
|
18
|
-
|
19
17
|
to_instrument = if Gem::Version.create(Elasticsearch::VERSION) < Gem::Version.create('8.0.0')
|
20
18
|
Elasticsearch::Transport::Client
|
21
19
|
else
|
@@ -21,10 +21,6 @@ DependencyDetection.defer do
|
|
21
21
|
defined?(Ethon) && Gem::Version.new(Ethon::VERSION) >= Gem::Version.new('0.12.0')
|
22
22
|
end
|
23
23
|
|
24
|
-
executes do
|
25
|
-
NewRelic::Agent.logger.info('Installing ethon instrumentation')
|
26
|
-
end
|
27
|
-
|
28
24
|
executes do
|
29
25
|
if use_prepend?
|
30
26
|
# NOTE: by default prepend_instrument will go with the module name that
|
@@ -33,22 +33,6 @@ DependencyDetection.defer do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
executes do
|
37
|
-
next unless Gem::Version.new(Excon::VERSION) < Gem::Version.new('0.56.0')
|
38
|
-
|
39
|
-
deprecation_msg = 'Instrumentation for Excon versions below 0.56.0 is deprecated.' \
|
40
|
-
'They will stop being monitored in version 9.0.0. ' \
|
41
|
-
'Please upgrade your Excon version to continue receiving full support. '
|
42
|
-
|
43
|
-
NewRelic::Agent.logger.log_once(
|
44
|
-
:warn,
|
45
|
-
:deprecated_excon_version,
|
46
|
-
deprecation_msg
|
47
|
-
)
|
48
|
-
|
49
|
-
NewRelic::Agent.record_metric('Supportability/Deprecated/Excon', 1)
|
50
|
-
end
|
51
|
-
|
52
36
|
def install_excon_instrumentation(excon_version)
|
53
37
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
54
38
|
require 'new_relic/agent/http_clients/excon_wrappers'
|
@@ -56,10 +56,7 @@ module NewRelic::Agent::Instrumentation
|
|
56
56
|
|
57
57
|
def name_transaction(route, class_name, version)
|
58
58
|
txn_name = name_for_transaction(route, class_name, version)
|
59
|
-
segment_name = "Middleware/Grape/#{class_name}/call"
|
60
59
|
NewRelic::Agent::Transaction.set_default_transaction_name(txn_name, :grape)
|
61
|
-
txn = NewRelic::Agent::Transaction.tl_current
|
62
|
-
txn.segments.last.name = segment_name
|
63
60
|
end
|
64
61
|
|
65
62
|
def name_for_transaction(route, class_name, version)
|
@@ -19,7 +19,7 @@ DependencyDetection.defer do
|
|
19
19
|
|
20
20
|
depends_on do
|
21
21
|
begin
|
22
|
-
if
|
22
|
+
if NewRelic::Helper.rubygems_specs.map(&:name).include?('newrelic-grape')
|
23
23
|
NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present')
|
24
24
|
false
|
25
25
|
else
|
@@ -13,10 +13,6 @@ DependencyDetection.defer do
|
|
13
13
|
defined?(HTTPX) && Gem::Version.new(HTTPX::VERSION) >= Gem::Version.new('1.0.0')
|
14
14
|
end
|
15
15
|
|
16
|
-
executes do
|
17
|
-
NewRelic::Agent.logger.info('Installing httpx instrumentation')
|
18
|
-
end
|
19
|
-
|
20
16
|
executes do
|
21
17
|
if use_prepend?
|
22
18
|
prepend_instrument HTTPX::Session, NewRelic::Agent::Instrumentation::HTTPX::Prepend
|
@@ -15,12 +15,10 @@ DependencyDetection.defer do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
executes do
|
18
|
-
NewRelic::Agent.logger.info('Installing Logger instrumentation')
|
19
|
-
|
20
18
|
if use_prepend?
|
21
19
|
prepend_instrument Logger, NewRelic::Agent::Instrumentation::Logger::Prepend
|
22
20
|
else
|
23
|
-
chain_instrument NewRelic::Agent::Instrumentation::Logger
|
21
|
+
chain_instrument NewRelic::Agent::Instrumentation::Logger, NewRelic::Agent::Instrumentation::Logger::INSTRUMENTATION_NAME
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -74,7 +74,6 @@ DependencyDetection.defer do
|
|
74
74
|
depends_on { NewRelic::Agent::Instrumentation::Memcache::DalliCAS.should_instrument? }
|
75
75
|
|
76
76
|
executes do
|
77
|
-
NewRelic::Agent.logger.info('Installing Dalli CAS Client Memcache instrumentation')
|
78
77
|
if use_prepend?
|
79
78
|
prepend_module = NewRelic::Agent::Instrumentation::Memcache::Prepend
|
80
79
|
prepend_module.dalli_cas_prependers do |client_class, instrumenting_module|
|
@@ -0,0 +1,21 @@
|
|
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 OpenSearch::Chain
|
7
|
+
def self.instrument!
|
8
|
+
::OpenSearch::Transport::Client.class_eval do
|
9
|
+
include NewRelic::Agent::Instrumentation::OpenSearch
|
10
|
+
|
11
|
+
alias_method(:perform_request_without_tracing, :perform_request)
|
12
|
+
|
13
|
+
def perform_request(*args)
|
14
|
+
perform_request_with_tracing(*args) do
|
15
|
+
perform_request_without_tracing(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module OpenSearch
|
7
|
+
PRODUCT_NAME = 'OpenSearch'
|
8
|
+
OPERATION = 'perform_request'
|
9
|
+
OPERATION_PATTERN = %r{/lib/opensearch/api/(?!.+#{OPERATION})}
|
10
|
+
INSTANCE_METHOD_PATTERN = /:in (?:`|')(?:.+#)?([^']+)'\z/
|
11
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
12
|
+
|
13
|
+
def perform_request_with_tracing(_method, _path, params = NewRelic::EMPTY_HASH, body = nil, _headers = nil, _opts = nil, &_block)
|
14
|
+
return yield unless NewRelic::Agent::Tracer.tracing_enabled?
|
15
|
+
|
16
|
+
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
17
|
+
product: PRODUCT_NAME,
|
18
|
+
operation: nr_operation || OPERATION,
|
19
|
+
host: nr_hosts[:host],
|
20
|
+
port_path_or_id: nr_hosts[:port],
|
21
|
+
database_name: nr_cluster_name
|
22
|
+
)
|
23
|
+
begin
|
24
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
|
25
|
+
ensure
|
26
|
+
if segment
|
27
|
+
segment.notice_nosql_statement(nr_reported_query(body || params))
|
28
|
+
segment.finish
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# See Elasticsearch instrumentation for explanation on Ruby 3.4 changes to match instance method
|
36
|
+
def nr_operation
|
37
|
+
location = caller_locations.detect { |loc| loc.to_s.match?(OPERATION_PATTERN) }
|
38
|
+
return unless location && location.to_s =~ INSTANCE_METHOD_PATTERN
|
39
|
+
|
40
|
+
Regexp.last_match(1)
|
41
|
+
end
|
42
|
+
|
43
|
+
def nr_reported_query(query)
|
44
|
+
return unless NewRelic::Agent.config[:'opensearch.capture_queries']
|
45
|
+
return query unless NewRelic::Agent.config[:'opensearch.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 defined?(@nr_cluster_name)
|
52
|
+
return if nr_hosts.empty?
|
53
|
+
|
54
|
+
NewRelic::Agent.disable_all_tracing do
|
55
|
+
@nr_cluster_name ||= perform_request('GET', '/').body['cluster_name']
|
56
|
+
end
|
57
|
+
rescue StandardError => e
|
58
|
+
NewRelic::Agent.logger.error('Failed to get cluster name for OpenSearch', 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 OpenSearch::Prepend
|
7
|
+
include NewRelic::Agent::Instrumentation::OpenSearch
|
8
|
+
|
9
|
+
def perform_request(*args)
|
10
|
+
perform_request_with_tracing(*args) { super }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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 'opensearch/instrumentation'
|
6
|
+
require_relative 'opensearch/chain'
|
7
|
+
require_relative 'opensearch/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :opensearch
|
11
|
+
|
12
|
+
depends_on do
|
13
|
+
defined?(OpenSearch)
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
if use_prepend?
|
18
|
+
prepend_instrument OpenSearch::Transport::Client, NewRelic::Agent::Instrumentation::OpenSearch::Prepend
|
19
|
+
else
|
20
|
+
chain_instrument NewRelic::Agent::Instrumentation::OpenSearch::Chain
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -22,11 +22,11 @@ DependencyDetection.defer do
|
|
22
22
|
depends_on { defined?(Padrino) && defined?(Padrino::Routing::InstanceMethods) }
|
23
23
|
|
24
24
|
executes do
|
25
|
-
NewRelic::Agent
|
25
|
+
supportability_name = NewRelic::Agent::Instrumentation::Padrino::INSTRUMENTATION_NAME
|
26
26
|
if use_prepend?
|
27
|
-
prepend_instrument Padrino::Application, NewRelic::Agent::Instrumentation::PadrinoTracer::Prepend
|
27
|
+
prepend_instrument Padrino::Application, NewRelic::Agent::Instrumentation::PadrinoTracer::Prepend, supportability_name
|
28
28
|
else
|
29
|
-
chain_instrument NewRelic::Agent::Instrumentation::PadrinoTracer::Chain
|
29
|
+
chain_instrument NewRelic::Agent::Instrumentation::PadrinoTracer::Chain, supportability_name
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -17,7 +17,6 @@ DependencyDetection.defer do
|
|
17
17
|
depends_on { NewRelic::Agent::Instrumentation::Rake.safe_from_third_party_gem? }
|
18
18
|
|
19
19
|
executes do
|
20
|
-
NewRelic::Agent.logger.info('Installing Rake instrumentation')
|
21
20
|
NewRelic::Agent.logger.debug("Instrumenting Rake tasks: #{NewRelic::Agent.config[:'rake.tasks']}")
|
22
21
|
end
|
23
22
|
|
@@ -0,0 +1,72 @@
|
|
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 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module Rdkafka::Chain
|
9
|
+
def self.instrument!
|
10
|
+
::Rdkafka::Producer.class_eval do
|
11
|
+
include NewRelic::Agent::Instrumentation::Rdkafka
|
12
|
+
|
13
|
+
alias_method(:produce_without_new_relic, :produce)
|
14
|
+
|
15
|
+
def produce(**kwargs)
|
16
|
+
produce_with_new_relic(kwargs) do |headers|
|
17
|
+
kwargs[:headers] = headers
|
18
|
+
produce_without_new_relic(**kwargs)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
::Rdkafka::Consumer.class_eval do
|
24
|
+
include NewRelic::Agent::Instrumentation::Rdkafka
|
25
|
+
|
26
|
+
alias_method(:each_without_new_relic, :each)
|
27
|
+
|
28
|
+
def each(**kwargs)
|
29
|
+
each_without_new_relic(**kwargs) do |message|
|
30
|
+
each_with_new_relic(message) do
|
31
|
+
yield(message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
::Rdkafka::Config.class_eval do
|
38
|
+
include NewRelic::Agent::Instrumentation::RdkafkaConfig
|
39
|
+
|
40
|
+
alias_method(:producer_without_new_relic, :producer)
|
41
|
+
alias_method(:consumer_without_new_relic, :consumer)
|
42
|
+
|
43
|
+
if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') ||
|
44
|
+
(Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0'))
|
45
|
+
def producer(**kwargs)
|
46
|
+
producer_without_new_relic(**kwargs).tap do |producer|
|
47
|
+
set_nr_config(producer)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def consumer(**kwargs)
|
52
|
+
consumer_without_new_relic(**kwargs).tap do |consumer|
|
53
|
+
set_nr_config(consumer)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
def producer
|
58
|
+
producer_without_new_relic.tap do |producer|
|
59
|
+
set_nr_config(producer)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def consumer
|
64
|
+
consumer_without_new_relic.tap do |consumer|
|
65
|
+
set_nr_config(consumer)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|