newrelic_rpm 9.14.0 → 9.18.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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +1 -0
  3. data/CHANGELOG.md +139 -5
  4. data/CONTRIBUTING.md +2 -2
  5. data/lib/boot/strap.rb +4 -3
  6. data/lib/new_relic/agent/agent.rb +4 -0
  7. data/lib/new_relic/agent/agent_helpers/connect.rb +3 -0
  8. data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -0
  9. data/lib/new_relic/agent/agent_helpers/shutdown.rb +3 -0
  10. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -0
  11. data/lib/new_relic/agent/agent_helpers/startup.rb +7 -0
  12. data/lib/new_relic/agent/aws.rb +6 -0
  13. data/lib/new_relic/agent/configuration/default_source.rb +336 -115
  14. data/lib/new_relic/agent/configuration/manager.rb +1 -1
  15. data/lib/new_relic/agent/configuration/yaml_source.rb +6 -1
  16. data/lib/new_relic/agent/database.rb +41 -1
  17. data/lib/new_relic/agent/distributed_tracing.rb +2 -2
  18. data/lib/new_relic/agent/health_check.rb +136 -0
  19. data/lib/new_relic/agent/http_clients/uri_util.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -8
  21. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +5 -1
  22. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +9 -16
  23. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +0 -2
  24. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +0 -2
  25. data/lib/new_relic/agent/instrumentation/async_http.rb +1 -2
  26. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/chain.rb +21 -0
  27. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/instrumentation.rb +66 -0
  28. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/prepend.rb +15 -0
  29. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose.rb +22 -0
  30. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/chain.rb +21 -0
  31. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +91 -0
  32. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/prepend.rb +15 -0
  33. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis.rb +22 -0
  34. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
  35. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
  36. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
  37. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
  38. data/lib/new_relic/agent/instrumentation/aws_sqs.rb +0 -2
  39. data/lib/new_relic/agent/instrumentation/bunny.rb +3 -4
  40. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +0 -2
  41. data/lib/new_relic/agent/instrumentation/curb.rb +3 -4
  42. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -4
  43. data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +3 -4
  44. data/lib/new_relic/agent/instrumentation/dynamodb.rb +0 -2
  45. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +1 -0
  46. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +0 -2
  47. data/lib/new_relic/agent/instrumentation/ethon.rb +0 -4
  48. data/lib/new_relic/agent/instrumentation/fiber.rb +0 -2
  49. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +0 -3
  50. data/lib/new_relic/agent/instrumentation/grape.rb +1 -3
  51. data/lib/new_relic/agent/instrumentation/httpclient.rb +0 -1
  52. data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
  53. data/lib/new_relic/agent/instrumentation/httpx.rb +0 -4
  54. data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
  55. data/lib/new_relic/agent/instrumentation/logstasher.rb +0 -2
  56. data/lib/new_relic/agent/instrumentation/memcache.rb +0 -1
  57. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +3 -3
  58. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +0 -2
  59. data/lib/new_relic/agent/instrumentation/opensearch.rb +0 -2
  60. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  61. data/lib/new_relic/agent/instrumentation/rake.rb +0 -1
  62. data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +2 -1
  63. data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +2 -1
  64. data/lib/new_relic/agent/instrumentation/rdkafka.rb +0 -2
  65. data/lib/new_relic/agent/instrumentation/redis.rb +0 -1
  66. data/lib/new_relic/agent/instrumentation/resque.rb +7 -5
  67. data/lib/new_relic/agent/instrumentation/roda.rb +4 -4
  68. data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +14 -4
  69. data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +0 -2
  70. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delay_extensions.rb +24 -0
  71. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  72. data/lib/new_relic/agent/instrumentation/sidekiq.rb +9 -1
  73. data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -6
  74. data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
  75. data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
  76. data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
  77. data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +11 -8
  78. data/lib/new_relic/agent/instrumentation/view_component.rb +0 -2
  79. data/lib/new_relic/agent/local_log_decorator.rb +12 -2
  80. data/lib/new_relic/agent/log_event_aggregator.rb +28 -2
  81. data/lib/new_relic/agent/new_relic_service.rb +8 -2
  82. data/lib/new_relic/agent/span_event_primitive.rb +4 -2
  83. data/lib/new_relic/agent/threading/backtrace_node.rb +10 -1
  84. data/lib/new_relic/agent/transaction/message_broker_segment.rb +3 -0
  85. data/lib/new_relic/agent/transaction/tracing.rb +4 -5
  86. data/lib/new_relic/agent/transaction.rb +2 -1
  87. data/lib/new_relic/agent/utilization_data.rb +15 -5
  88. data/lib/new_relic/agent.rb +2 -2
  89. data/lib/new_relic/control/frameworks/rails4.rb +1 -5
  90. data/lib/new_relic/control/instance_methods.rb +5 -0
  91. data/lib/new_relic/dependency_detection.rb +11 -13
  92. data/lib/new_relic/environment_report.rb +1 -5
  93. data/lib/new_relic/helper.rb +15 -0
  94. data/lib/new_relic/language_support.rb +1 -5
  95. data/lib/new_relic/version.rb +1 -1
  96. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  97. data/lib/tasks/helpers/newrelicyml.rb +4 -2
  98. data/newrelic.yml +174 -66
  99. data/test/agent_helper.rb +8 -1
  100. metadata +17 -19
  101. data/lib/tasks/instrumentation_generator/README.md +0 -63
  102. data/lib/tasks/instrumentation_generator/TODO.md +0 -33
  103. data/lib/tasks/instrumentation_generator/instrumentation.thor +0 -130
  104. data/lib/tasks/instrumentation_generator/templates/Envfile.tt +0 -9
  105. data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -21
  106. data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -7
  107. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +0 -29
  108. data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +0 -13
  109. data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +0 -3
  110. data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +0 -19
  111. data/lib/tasks/instrumentation_generator/templates/prepend.tt +0 -13
  112. data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +0 -3
  113. data/lib/tasks/instrumentation_generator/templates/test.tt +0 -15
@@ -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,8 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing aws-sdk-sqs instrumentation')
18
-
19
17
  if use_prepend?
20
18
  prepend_instrument Aws::SQS::Client, NewRelic::Agent::Instrumentation::AwsSqs::Prepend
21
19
  else
@@ -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
@@ -31,9 +31,8 @@ module NewRelic::Agent::Instrumentation
31
31
  collection: args[0][:table_name]
32
32
  )
33
33
 
34
- # TODO: Update this when it has been decided how to handle account id for ARN
35
- # arn = get_arn(args[0])
36
- # segment&.add_agent_attribute('cloud.resource_id', arn) if arn
34
+ arn = get_arn(args[0])
35
+ segment&.add_agent_attribute('cloud.resource_id', arn) if arn
37
36
 
38
37
  @nr_captured_request = nil # clear request just in case
39
38
  begin
@@ -57,7 +56,7 @@ module NewRelic::Agent::Instrumentation
57
56
  end
58
57
 
59
58
  def get_arn(params)
60
- return unless params[:table_name] && nr_account_id
59
+ return unless params[:table_name]
61
60
 
62
61
  NewRelic::Agent::Aws.create_arn(PRODUCT.downcase, "table/#{params[:table_name]}", config&.region, nr_account_id)
63
62
  end
@@ -14,8 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing DynamoDB instrumentation')
18
-
19
17
  if use_prepend?
20
18
  prepend_instrument Aws::DynamoDB::Client, NewRelic::Agent::Instrumentation::DynamoDB::Prepend
21
19
  else
@@ -102,6 +102,7 @@ module NewRelic::Agent::Instrumentation
102
102
  end
103
103
 
104
104
  def nr_cluster_name
105
+ return unless NewRelic::Agent.config[:'elasticsearch.capture_cluster_name']
105
106
  return @nr_cluster_name if defined?(@nr_cluster_name)
106
107
  return if nr_hosts.empty?
107
108
 
@@ -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
@@ -14,8 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing Fiber instrumentation')
18
-
19
17
  if use_prepend?
20
18
  prepend_instrument Fiber, NewRelic::Agent::Instrumentation::MonitoredFiber::Prepend
21
19
  else
@@ -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,9 +19,7 @@ DependencyDetection.defer do
19
19
 
20
20
  depends_on do
21
21
  begin
22
- if defined?(Bundler) &&
23
- ((Bundler.rubygems.respond_to?(:installed_specs) && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape')) ||
24
- Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape'))
22
+ if NewRelic::Helper.rubygems_specs.map(&:name).include?('newrelic-grape')
25
23
  NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present')
26
24
  false
27
25
  else
@@ -23,7 +23,6 @@ DependencyDetection.defer do
23
23
  end
24
24
 
25
25
  executes do
26
- NewRelic::Agent.logger.info('Installing HTTPClient instrumentation')
27
26
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
28
27
  require 'new_relic/agent/http_clients/httpclient_wrappers'
29
28
  end
@@ -14,7 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing http.rb Wrappers')
18
17
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
19
18
  require 'new_relic/agent/http_clients/http_rb_wrappers'
20
19
  end
@@ -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
@@ -16,8 +16,6 @@ DependencyDetection.defer do
16
16
  end
17
17
 
18
18
  executes do
19
- NewRelic::Agent.logger.info('Installing LogStasher instrumentation')
20
-
21
19
  if use_prepend?
22
20
  prepend_instrument LogStasher.singleton_class, NewRelic::Agent::Instrumentation::LogStasher::Prepend
23
21
  else
@@ -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|
@@ -21,7 +21,7 @@ module NewRelic
21
21
 
22
22
  begin
23
23
  response = nil
24
- segment.add_request_headers(wrapped_request)
24
+ segment&.add_request_headers(wrapped_request)
25
25
 
26
26
  # RUBY-1244 Disable further tracing in request to avoid double
27
27
  # counting if connection wasn't started (which calls request again).
@@ -34,10 +34,10 @@ module NewRelic
34
34
  wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new(response)
35
35
 
36
36
  if NewRelic::Agent::LLM.openai_parent?(segment)
37
- NewRelic::Agent::LLM.populate_openai_response_headers(wrapped_response, segment.parent)
37
+ NewRelic::Agent::LLM.populate_openai_response_headers(wrapped_response, segment&.parent)
38
38
  end
39
39
 
40
- segment.process_response_headers(wrapped_response)
40
+ segment&.process_response_headers(wrapped_response)
41
41
 
42
42
  response
43
43
  ensure
@@ -16,8 +16,6 @@ module NewRelic
16
16
  end
17
17
 
18
18
  def self.find_all_subscribers
19
- # TODO: need to talk to Rails core about an API for this,
20
- # rather than digging through Listener ivars
21
19
  instance_variable_names = [:@subscribers, :@string_subscribers, :@other_subscribers]
22
20
  all_subscribers = []
23
21
 
@@ -14,8 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing opensearch-ruby instrumentation')
18
-
19
17
  if use_prepend?
20
18
  prepend_instrument OpenSearch::Transport::Client, NewRelic::Agent::Instrumentation::OpenSearch::Prepend
21
19
  else
@@ -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.logger.info('Installing Padrino instrumentation')
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
 
@@ -40,7 +40,8 @@ module NewRelic::Agent::Instrumentation
40
40
  alias_method(:producer_without_new_relic, :producer)
41
41
  alias_method(:consumer_without_new_relic, :consumer)
42
42
 
43
- if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')
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'))
44
45
  def producer(**kwargs)
45
46
  producer_without_new_relic(**kwargs).tap do |producer|
46
47
  set_nr_config(producer)
@@ -36,7 +36,8 @@ module NewRelic::Agent::Instrumentation
36
36
  module Prepend
37
37
  include NewRelic::Agent::Instrumentation::RdkafkaConfig
38
38
 
39
- if defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')
39
+ if (defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')) ||
40
+ (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0'))
40
41
  def producer(**kwargs)
41
42
  super.tap do |producer|
42
43
  set_nr_config(producer)
@@ -10,8 +10,6 @@ DependencyDetection.defer do
10
10
  end
11
11
 
12
12
  executes do
13
- NewRelic::Agent.logger.info('Installing rdkafka instrumentation')
14
-
15
13
  require_relative 'rdkafka/instrumentation'
16
14
  require_relative 'rdkafka/chain'
17
15
  require_relative 'rdkafka/prepend'
@@ -31,7 +31,6 @@ DependencyDetection.defer do
31
31
  end
32
32
 
33
33
  executes do
34
- NewRelic::Agent.logger.info('Installing Redis Instrumentation')
35
34
  if NewRelic::Agent::Instrumentation::Redis::Constants::HAS_REDIS_CLIENT
36
35
  RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::Middleware)
37
36
 
@@ -19,11 +19,13 @@ DependencyDetection.defer do
19
19
  end
20
20
 
21
21
  executes do
22
- NewRelic::Agent.logger.info('Installing Resque instrumentation')
23
- end
24
-
25
- executes do
26
- if NewRelic::Agent.config[:'resque.use_ruby_dns'] && NewRelic::Agent.config[:dispatcher] == :resque
22
+ if NewRelic::Agent.config[:'resque.use_ruby_dns'] &&
23
+ NewRelic::Agent.config[:dispatcher] == :resque &&
24
+ # resolv-replace is no longer part of the language in Ruby 3.4.
25
+ # we don't believe this lib is still necessary for Ruby 3.4 users.
26
+ # however, if we receive customer feedback to the contrary, we can find
27
+ # an alternate approach.
28
+ Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4')
27
29
  NewRelic::Agent.logger.info('Requiring resolv-replace')
28
30
  require 'resolv'
29
31
  require 'resolv-replace'
@@ -20,15 +20,15 @@ DependencyDetection.defer do
20
20
  require_relative '../../rack/agent_hooks'
21
21
  require_relative '../../rack/browser_monitoring'
22
22
 
23
- NewRelic::Agent.logger.info('Installing Roda instrumentation')
24
-
25
23
  if use_prepend?
26
24
  require_relative 'roda/prepend'
27
- prepend_instrument Roda.singleton_class, NewRelic::Agent::Instrumentation::Roda::Build::Prepend
25
+
26
+ supportability_name = NewRelic::Agent::Instrumentation::Roda::Tracer::INSTRUMENTATION_NAME
27
+ prepend_instrument Roda.singleton_class, NewRelic::Agent::Instrumentation::Roda::Build::Prepend, supportability_name
28
28
  prepend_instrument Roda, NewRelic::Agent::Instrumentation::Roda::Prepend
29
29
  else
30
30
  require_relative 'roda/chain'
31
- chain_instrument NewRelic::Agent::Instrumentation::Roda::Build::Chain
31
+ chain_instrument NewRelic::Agent::Instrumentation::Roda::Build::Chain, supportability_name
32
32
  chain_instrument NewRelic::Agent::Instrumentation::Roda::Chain
33
33
  end
34
34
  Roda.class_eval { extend NewRelic::Agent::Instrumentation::Roda::Ignorer }
@@ -20,10 +20,20 @@ module NewRelic::Agent::Instrumentation
20
20
  module Prepend
21
21
  include NewRelic::Agent::Instrumentation::RubyKafka
22
22
 
23
- def each_message(*args)
24
- super do |message|
25
- each_message_with_new_relic(message) do
26
- yield(message)
23
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
24
+ def each_message(**args)
25
+ super do |message|
26
+ each_message_with_new_relic(message) do
27
+ yield(message)
28
+ end
29
+ end
30
+ end
31
+ else
32
+ def each_message(*args)
33
+ super do |message|
34
+ each_message_with_new_relic(message) do
35
+ yield(message)
36
+ end
27
37
  end
28
38
  end
29
39
  end
@@ -14,8 +14,6 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- NewRelic::Agent.logger.info('Installing ruby-kafka instrumentation')
18
-
19
17
  if use_prepend?
20
18
  prepend_instrument Kafka::Producer, NewRelic::Agent::Instrumentation::RubyKafkaProducer::Prepend
21
19
  prepend_instrument Kafka::Consumer, NewRelic::Agent::Instrumentation::RubyKafkaConsumer::Prepend
@@ -0,0 +1,24 @@
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
+ if defined?(Sidekiq::DelayExtensions)
6
+ class Sidekiq::DelayExtensions::GenericJob
7
+ def newrelic_trace_args(msg, queue)
8
+ (target, method_name, *) = ::Sidekiq::DelayExtensions::YAML.unsafe_load(msg['args'][0])
9
+
10
+ if target.is_a?(String)
11
+ target = target.constantize
12
+ end
13
+
14
+ {
15
+ :name => method_name,
16
+ :class_name => target.class.name,
17
+ :category => 'OtherTransaction/SidekiqJob'
18
+ }
19
+ rescue => e
20
+ NewRelic::Agent.logger.error('Failure during deserializing YAML for Sidekiq::DelayExtensions::GenericJob', e)
21
+ NewRelic::Agent::Instrumentation::Sidekiq::Server.default_trace_args(msg)
22
+ end
23
+ end
24
+ end
@@ -6,7 +6,7 @@
6
6
  # Delayed extensions are disabled by default in Sidekiq 5 and 6 and
7
7
  # were removed entirely in Sidekiq 7.
8
8
  #
9
- # see https://github.com/mperham/sidekiq/issues/5076 for the discussion
9
+ # see https://github.com/sidekiq/sidekiq/issues/5076 for the discussion
10
10
  # of the removal, which includes mentions of alternatives
11
11
  if defined?(Sidekiq::VERSION) && Sidekiq::VERSION < '7.0.0'
12
12
  class Sidekiq::Extensions::DelayedClass