newrelic_rpm 8.13.0 → 8.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +3 -0
  4. data/CHANGELOG.md +3258 -3144
  5. data/CONTRIBUTING.md +1 -2
  6. data/README.md +1 -2
  7. data/init.rb +1 -1
  8. data/lib/new_relic/agent/agent.rb +14 -466
  9. data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
  10. data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
  11. data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
  12. data/lib/new_relic/agent/agent_helpers/special_startup.rb +75 -0
  13. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
  14. data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
  15. data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
  16. data/lib/new_relic/agent/configuration/default_source.rb +22 -0
  17. data/lib/new_relic/agent/datastores.rb +2 -2
  18. data/lib/new_relic/agent/guid_generator.rb +11 -2
  19. data/lib/new_relic/agent/instrumentation/active_job.rb +7 -7
  20. data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
  22. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -24
  23. data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
  24. data/lib/new_relic/agent/instrumentation/active_support.rb +12 -0
  25. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
  26. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
  28. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
  29. data/lib/new_relic/agent/instrumentation/bunny.rb +4 -4
  30. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
  32. data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
  33. data/lib/new_relic/agent/instrumentation/data_mapper.rb +50 -50
  34. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -5
  35. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +5 -5
  36. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +1 -1
  37. data/lib/new_relic/agent/instrumentation/excon.rb +9 -9
  38. data/lib/new_relic/agent/instrumentation/grape.rb +8 -8
  39. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +1 -1
  40. data/lib/new_relic/agent/instrumentation/grpc_client.rb +3 -3
  41. data/lib/new_relic/agent/instrumentation/grpc_server.rb +4 -4
  42. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +1 -1
  43. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  44. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/httprb.rb +3 -3
  46. data/lib/new_relic/agent/instrumentation/logger.rb +3 -3
  47. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
  48. data/lib/new_relic/agent/instrumentation/memcache.rb +16 -16
  49. data/lib/new_relic/agent/instrumentation/mongo.rb +1 -1
  50. data/lib/new_relic/agent/instrumentation/net_http.rb +6 -6
  51. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  52. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -5
  53. data/lib/new_relic/agent/instrumentation/rack.rb +14 -14
  54. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
  55. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +3 -3
  56. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +6 -6
  57. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +2 -2
  58. data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +5 -3
  59. data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
  60. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +4 -4
  61. data/lib/new_relic/agent/instrumentation/rake.rb +7 -7
  62. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +29 -10
  63. data/lib/new_relic/agent/instrumentation/redis.rb +4 -4
  64. data/lib/new_relic/agent/instrumentation/resque.rb +9 -9
  65. data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
  66. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
  67. data/lib/new_relic/agent/instrumentation/sinatra.rb +7 -7
  68. data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
  69. data/lib/new_relic/agent/instrumentation/thread.rb +3 -3
  70. data/lib/new_relic/agent/instrumentation/tilt.rb +3 -3
  71. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
  72. data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
  73. data/lib/new_relic/agent/method_tracer_helpers.rb +6 -11
  74. data/lib/new_relic/agent/tracer.rb +1 -1
  75. data/lib/new_relic/agent/transaction/segment.rb +6 -0
  76. data/lib/new_relic/control/instance_methods.rb +6 -2
  77. data/lib/new_relic/recipes/helpers/send_deployment.rb +2 -1
  78. data/lib/new_relic/version.rb +1 -1
  79. data/lib/newrelic_rpm.rb +13 -2
  80. data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
  81. data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
  82. data/newrelic.yml +10 -0
  83. data/test/agent_helper.rb +5 -5
  84. metadata +12 -6
  85. data/lib/new_relic/agent/agent/shutdown.rb +0 -35
  86. data/lib/new_relic/agent/agent/special_startup.rb +0 -72
  87. data/lib/new_relic/agent/agent/start_worker_thread.rb +0 -163
  88. data/lib/new_relic/agent/agent/startup.rb +0 -197
@@ -9,11 +9,11 @@ DependencyDetection.defer do
9
9
  @name = :sidekiq
10
10
 
11
11
  depends_on do
12
- defined?(::Sidekiq) && !NewRelic::Agent.config[:disable_sidekiq]
12
+ defined?(Sidekiq) && !NewRelic::Agent.config[:disable_sidekiq]
13
13
  end
14
14
 
15
15
  executes do
16
- ::NewRelic::Agent.logger.info('Installing Sidekiq instrumentation')
16
+ NewRelic::Agent.logger.info('Installing Sidekiq instrumentation')
17
17
  end
18
18
 
19
19
  executes do
@@ -46,7 +46,7 @@ DependencyDetection.defer do
46
46
  'They will stop being monitored in version 9.0.0. ' \
47
47
  'Please upgrade your Sidekiq version to continue receiving full support. '
48
48
 
49
- ::NewRelic::Agent.logger.log_once(
49
+ NewRelic::Agent.logger.log_once(
50
50
  :warn,
51
51
  :deprecated_sidekiq_version,
52
52
  deprecation_msg
@@ -11,24 +11,24 @@ require_relative 'sinatra/prepend'
11
11
  DependencyDetection.defer do
12
12
  named :sinatra
13
13
 
14
- depends_on { defined?(::Sinatra) && defined?(::Sinatra::Base) }
14
+ depends_on { defined?(Sinatra) && defined?(Sinatra::Base) }
15
15
  depends_on { Sinatra::Base.private_method_defined?(:dispatch!) }
16
16
  depends_on { Sinatra::Base.private_method_defined?(:process_route) }
17
17
  depends_on { Sinatra::Base.private_method_defined?(:route_eval) }
18
18
 
19
19
  executes do
20
- ::NewRelic::Agent.logger.info('Installing Sinatra instrumentation')
20
+ NewRelic::Agent.logger.info('Installing Sinatra instrumentation')
21
21
  end
22
22
 
23
23
  executes do
24
24
  if use_prepend?
25
- prepend_instrument ::Sinatra::Base, NewRelic::Agent::Instrumentation::Sinatra::Prepend
25
+ prepend_instrument Sinatra::Base, NewRelic::Agent::Instrumentation::Sinatra::Prepend
26
26
  else
27
27
  chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Chain
28
28
  end
29
29
 
30
- ::Sinatra::Base.class_eval { register ::NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
31
- ::Sinatra.module_eval { register NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
30
+ Sinatra::Base.class_eval { register NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
31
+ Sinatra.module_eval { register NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
32
32
  end
33
33
 
34
34
  executes do
@@ -37,7 +37,7 @@ DependencyDetection.defer do
37
37
  require 'new_relic/rack/agent_hooks'
38
38
  require 'new_relic/rack/browser_monitoring'
39
39
  if use_prepend?
40
- prepend_instrument ::Sinatra::Base.singleton_class, NewRelic::Agent::Instrumentation::Sinatra::Build::Prepend
40
+ prepend_instrument Sinatra::Base.singleton_class, NewRelic::Agent::Instrumentation::Sinatra::Build::Prepend
41
41
  else
42
42
  chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Build::Chain
43
43
  end
@@ -49,7 +49,7 @@ DependencyDetection.defer do
49
49
  deprecation_msg = 'The Ruby Agent is dropping support for Sinatra versions below 2.0.0 ' \
50
50
  'in version 9.0.0. Please upgrade your Sinatra version to continue receiving full compatibility. ' \
51
51
 
52
- ::NewRelic::Agent.logger.log_once(
52
+ NewRelic::Agent.logger.log_once(
53
53
  :warn,
54
54
  :deprecated_sinatra_version,
55
55
  deprecation_msg
@@ -6,15 +6,15 @@ DependencyDetection.defer do
6
6
  @name = :sunspot
7
7
 
8
8
  depends_on do
9
- defined?(::Sunspot)
9
+ defined?(Sunspot)
10
10
  end
11
11
 
12
12
  executes do
13
- ::NewRelic::Agent.logger.info('Installing Rails Sunspot instrumentation')
13
+ NewRelic::Agent.logger.info('Installing Rails Sunspot instrumentation')
14
14
  deprecation_msg = 'The instrumentation for Sunspot is deprecated. ' \
15
15
  'It will be removed in version 9.0.0.'
16
16
 
17
- ::NewRelic::Agent.logger.log_once(
17
+ NewRelic::Agent.logger.log_once(
18
18
  :warn,
19
19
  :deprecated_sunspot,
20
20
  deprecation_msg
@@ -22,7 +22,7 @@ DependencyDetection.defer do
22
22
  end
23
23
 
24
24
  executes do
25
- ::Sunspot.module_eval do
25
+ Sunspot.module_eval do
26
26
  class << self
27
27
  %w[index index!].each do |method|
28
28
  add_method_tracer method, 'SolrClient/Sunspot/index'
@@ -9,12 +9,12 @@ DependencyDetection.defer do
9
9
  named :thread
10
10
 
11
11
  executes do
12
- ::NewRelic::Agent.logger.info('Installing Thread Instrumentation')
12
+ NewRelic::Agent.logger.info('Installing Thread Instrumentation')
13
13
 
14
14
  if use_prepend?
15
- prepend_instrument ::Thread, ::NewRelic::Agent::Instrumentation::MonitoredThread::Prepend
15
+ prepend_instrument Thread, NewRelic::Agent::Instrumentation::MonitoredThread::Prepend
16
16
  else
17
- chain_instrument ::NewRelic::Agent::Instrumentation::MonitoredThread::Chain
17
+ chain_instrument NewRelic::Agent::Instrumentation::MonitoredThread::Chain
18
18
  end
19
19
  end
20
20
  end
@@ -9,15 +9,15 @@ require_relative 'tilt/prepend'
9
9
  DependencyDetection.defer do
10
10
  named :tilt
11
11
 
12
- depends_on { defined?(::Tilt) }
12
+ depends_on { defined?(Tilt) }
13
13
 
14
14
  executes do
15
- ::NewRelic::Agent.logger.info('Installing Tilt instrumentation')
15
+ NewRelic::Agent.logger.info('Installing Tilt instrumentation')
16
16
  end
17
17
 
18
18
  executes do
19
19
  if use_prepend?
20
- prepend_instrument ::Tilt::Template, NewRelic::Agent::Instrumentation::Tilt::Prepend
20
+ prepend_instrument Tilt::Template, NewRelic::Agent::Instrumentation::Tilt::Prepend
21
21
  else
22
22
  chain_instrument NewRelic::Agent::Instrumentation::Tilt::Chain
23
23
  end
@@ -36,7 +36,7 @@ module NewRelic
36
36
  begin
37
37
  yield
38
38
  ensure
39
- segment.finish if segment
39
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
40
40
  end
41
41
  end
42
42
 
@@ -68,7 +68,7 @@ module NewRelic
68
68
  segment.notice_error(NoticeableError.new(NOTICEABLE_ERROR_CLASS, response_message(request.response)))
69
69
  end
70
70
 
71
- segment.finish if segment
71
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
72
72
  end
73
73
  request.on_complete.unshift(callback)
74
74
  rescue => e
@@ -18,7 +18,7 @@ DependencyDetection.defer do
18
18
  end
19
19
 
20
20
  executes do
21
- ::NewRelic::Agent.logger.info('Installing Typhoeus instrumentation')
21
+ NewRelic::Agent.logger.info('Installing Typhoeus instrumentation')
22
22
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
23
23
  require 'new_relic/agent/http_clients/typhoeus_wrappers'
24
24
  end
@@ -17,8 +17,7 @@ module NewRelic
17
17
  extend self
18
18
 
19
19
  def trace_execution_scoped(metric_names, options = NewRelic::EMPTY_HASH) # THREAD_LOCAL_ACCESS
20
- state = NewRelic::Agent::Tracer.state
21
- return yield unless state.is_execution_traced?
20
+ return yield unless NewRelic::Agent::Tracer.state.is_execution_traced?
22
21
 
23
22
  metric_names = Array(metric_names)
24
23
  first_name = metric_names.shift
@@ -29,19 +28,15 @@ module NewRelic
29
28
  unscoped_metrics: metric_names
30
29
  )
31
30
 
32
- if options[:metric] == false
33
- segment.record_metrics = false
34
- end
31
+ segment.record_metrics = false if options[:metric] == false
35
32
 
36
33
  unless !options.key?(:code_information) || options[:code_information].nil? || options[:code_information].empty?
37
34
  segment.code_information = options[:code_information]
38
35
  end
39
36
 
40
- begin
41
- Tracer.capture_segment_error(segment) { yield }
42
- ensure
43
- segment.finish if segment
44
- end
37
+ Tracer.capture_segment_error(segment) { yield }
38
+ ensure
39
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
45
40
  end
46
41
 
47
42
  def code_information(object, method_name)
@@ -77,7 +72,7 @@ module NewRelic
77
72
  name = Regexp.last_match(1) if object.to_s =~ /^#<Class:(.*)>$/
78
73
  return name if name
79
74
 
80
- raise "Unable to glean a class name from string '#{object}'" unless name
75
+ raise "Unable to glean a class name from string '#{object}'"
81
76
  end
82
77
 
83
78
  # get at the underlying class from the singleton class
@@ -419,7 +419,7 @@ module NewRelic
419
419
  end
420
420
  yield(*args) if block.respond_to?(:call)
421
421
  ensure
422
- segment.finish if segment
422
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
423
423
  end
424
424
  end
425
425
  end
@@ -46,6 +46,12 @@ module NewRelic
46
46
  attributes.merge_custom_attributes(p)
47
47
  end
48
48
 
49
+ def self.finish(segment)
50
+ return unless segment
51
+
52
+ segment.finish
53
+ end
54
+
49
55
  private
50
56
 
51
57
  def record_metrics
@@ -64,8 +64,12 @@ module NewRelic
64
64
 
65
65
  # An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
66
66
  # methods in the module methods.
67
- Module.send(:include, NewRelic::Agent::MethodTracer::ClassMethods)
68
- Module.send(:include, NewRelic::Agent::MethodTracer)
67
+ # Rails applications load the next two lines before any other initializers are run
68
+ unless defined?(Rails::VERSION) && NewRelic::Agent.config[:defer_rails_initialization]
69
+ Module.send(:include, NewRelic::Agent::MethodTracer::ClassMethods)
70
+ Module.send(:include, NewRelic::Agent::MethodTracer)
71
+ end
72
+
69
73
  init_config(options)
70
74
  NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
71
75
  init_instrumentation
@@ -29,7 +29,8 @@ module SendDeployment
29
29
  end
30
30
 
31
31
  def fetch_changelog
32
- has_scm? ? fetch(:newrelic_changelog) : lookup_changelog
32
+ newrelic_changelog = fetch(:newrelic_changelog)
33
+ has_scm? && !newrelic_changelog ? lookup_changelog : newrelic_changelog
33
34
  end
34
35
 
35
36
  def fetch_environment
@@ -6,7 +6,7 @@
6
6
  module NewRelic
7
7
  module VERSION # :nodoc:
8
8
  MAJOR = 8
9
- MINOR = 13
9
+ MINOR = 14
10
10
  TINY = 0
11
11
 
12
12
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
data/lib/newrelic_rpm.rb CHANGED
@@ -20,8 +20,19 @@ require 'new_relic/control'
20
20
  if defined?(Rails::VERSION)
21
21
  module NewRelic
22
22
  class Railtie < Rails::Railtie
23
- initializer "newrelic_rpm.start_plugin", before: :load_config_initializers do |app|
24
- NewRelic::Control.instance.init_plugin(config: app.config)
23
+ if NewRelic::Agent.config[:defer_rails_initialization]
24
+ initializer "newrelic_rpm.include_method_tracers", before: :load_config_initializers do |app|
25
+ Module.send(:include, NewRelic::Agent::MethodTracer::ClassMethods)
26
+ Module.send(:include, NewRelic::Agent::MethodTracer)
27
+ end
28
+
29
+ initializer "newrelic_rpm.start_plugin", after: :load_config_initializers do |app|
30
+ NewRelic::Control.instance.init_plugin(config: app.config)
31
+ end
32
+ else
33
+ initializer "newrelic_rpm.start_plugin", before: :load_config_initializers do |app|
34
+ NewRelic::Control.instance.init_plugin(config: app.config)
35
+ end
25
36
  end
26
37
  end
27
38
  end
@@ -54,7 +54,7 @@ module Sequel
54
54
  super(*args, &blk)
55
55
  ensure
56
56
  notice_sql(sql)
57
- segment.finish if segment
57
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
58
58
  end
59
59
  end
60
60
 
@@ -30,7 +30,7 @@ module Sequel
30
30
  begin
31
31
  NewRelic::Agent.disable_all_tracing { super(*args, &block) }
32
32
  ensure
33
- segment.finish if segment
33
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
34
34
  end
35
35
  end
36
36
  end
data/newrelic.yml CHANGED
@@ -26,6 +26,13 @@ common: &default_settings
26
26
  # All of the following configuration options are optional. Review them, and
27
27
  # uncomment or edit them if they appear relevant to your application needs.
28
28
 
29
+ # An array of ActiveSupport custom events names to subscribe to and provide
30
+ # instrumentation for. For example,
31
+ # - my.custom.event
32
+ # - another.event
33
+ # - a.third.event
34
+ # active_support_custom_events_names: ""
35
+
29
36
  # If `true`, all logging-related features for the agent can be enabled or disabled
30
37
  # independently. If `false`, all logging-related features are disabled.
31
38
  # application_logging.enabled: true
@@ -173,6 +180,9 @@ common: &default_settings
173
180
  # If true, the agent won't sample the CPU usage of the host process.
174
181
  # disable_cpu_sampler: false
175
182
 
183
+ # If true, disables ActiveSupport custom events instrumentation.
184
+ # disable_custom_events_instrumentation: false
185
+
176
186
  # If true, disables DataMapper instrumentation.
177
187
  # disable_data_mapper: false
178
188
 
data/test/agent_helper.rb CHANGED
@@ -844,7 +844,7 @@ ensure
844
844
  end
845
845
 
846
846
  def json_dump_and_encode(object)
847
- Base64.encode64(::JSON.dump(object))
847
+ Base64.encode64(JSON.dump(object))
848
848
  end
849
849
 
850
850
  def get_last_analytics_event
@@ -870,7 +870,7 @@ def load_cross_agent_test(name)
870
870
  test_file_path = File.join(cross_agent_tests_dir, "#{name}.json")
871
871
  data = File.read(test_file_path)
872
872
  data.gsub!('callCount', 'call_count')
873
- data = ::JSON.load(data)
873
+ data = JSON.load(data)
874
874
  data.each { |testcase| testcase['testname'].tr!(' ', '_') if String === testcase['testname'] }
875
875
  data
876
876
  end
@@ -1014,9 +1014,9 @@ def assert_implements(instance, method, *args)
1014
1014
  end
1015
1015
 
1016
1016
  def defer_testing_to_min_supported_rails(test_file, min_rails_version, supports_jruby = true)
1017
- if defined?(::Rails) &&
1018
- defined?(::Rails::VERSION::STRING) &&
1019
- (::Rails::VERSION::STRING.to_f >= min_rails_version) &&
1017
+ if defined?(Rails) &&
1018
+ defined?(Rails::VERSION::STRING) &&
1019
+ (Rails::VERSION::STRING.to_f >= min_rails_version) &&
1020
1020
  (supports_jruby || !NewRelic::LanguageSupport.jruby?)
1021
1021
 
1022
1022
  yield
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.13.0
4
+ version: 8.14.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-11-15 00:00:00.000000000 Z
14
+ date: 2022-12-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -162,10 +162,13 @@ files:
162
162
  - lib/new_relic/agent.rb
163
163
  - lib/new_relic/agent/adaptive_sampler.rb
164
164
  - lib/new_relic/agent/agent.rb
165
- - lib/new_relic/agent/agent/shutdown.rb
166
- - lib/new_relic/agent/agent/special_startup.rb
167
- - lib/new_relic/agent/agent/start_worker_thread.rb
168
- - lib/new_relic/agent/agent/startup.rb
165
+ - lib/new_relic/agent/agent_helpers/connect.rb
166
+ - lib/new_relic/agent/agent_helpers/harvest.rb
167
+ - lib/new_relic/agent/agent_helpers/shutdown.rb
168
+ - lib/new_relic/agent/agent_helpers/special_startup.rb
169
+ - lib/new_relic/agent/agent_helpers/start_worker_thread.rb
170
+ - lib/new_relic/agent/agent_helpers/startup.rb
171
+ - lib/new_relic/agent/agent_helpers/transmit.rb
169
172
  - lib/new_relic/agent/agent_logger.rb
170
173
  - lib/new_relic/agent/attribute_filter.rb
171
174
  - lib/new_relic/agent/attribute_processing.rb
@@ -249,6 +252,7 @@ files:
249
252
  - lib/new_relic/agent/instrumentation/active_record_subscriber.rb
250
253
  - lib/new_relic/agent/instrumentation/active_storage.rb
251
254
  - lib/new_relic/agent/instrumentation/active_storage_subscriber.rb
255
+ - lib/new_relic/agent/instrumentation/active_support.rb
252
256
  - lib/new_relic/agent/instrumentation/active_support_logger.rb
253
257
  - lib/new_relic/agent/instrumentation/active_support_logger/chain.rb
254
258
  - lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb
@@ -264,6 +268,7 @@ files:
264
268
  - lib/new_relic/agent/instrumentation/curb/chain.rb
265
269
  - lib/new_relic/agent/instrumentation/curb/instrumentation.rb
266
270
  - lib/new_relic/agent/instrumentation/curb/prepend.rb
271
+ - lib/new_relic/agent/instrumentation/custom_events_subscriber.rb
267
272
  - lib/new_relic/agent/instrumentation/data_mapper.rb
268
273
  - lib/new_relic/agent/instrumentation/delayed_job/chain.rb
269
274
  - lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb
@@ -334,6 +339,7 @@ files:
334
339
  - lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb
335
340
  - lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb
336
341
  - lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb
342
+ - lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb
337
343
  - lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb
338
344
  - lib/new_relic/agent/instrumentation/rake.rb
339
345
  - lib/new_relic/agent/instrumentation/rake/chain.rb
@@ -1,35 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- module NewRelic
6
- module Agent
7
- module Shutdown
8
- # Attempt a graceful shutdown of the agent, flushing any remaining
9
- # data.
10
- def shutdown
11
- return unless started?
12
-
13
- ::NewRelic::Agent.logger.info("Starting Agent shutdown")
14
-
15
- stop_event_loop
16
- trap_signals_for_litespeed
17
- untraced_graceful_disconnect
18
- revert_to_default_configuration
19
-
20
- @started = nil
21
- Control.reset
22
- end
23
-
24
- def untraced_graceful_disconnect
25
- begin
26
- NewRelic::Agent.disable_all_tracing do
27
- graceful_disconnect
28
- end
29
- rescue => e
30
- ::NewRelic::Agent.logger.error(e)
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,72 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- module NewRelic
6
- module Agent
7
- module SpecialStartup
8
- # If we're using a dispatcher that forks before serving
9
- # requests, we need to wait until the children are forked
10
- # before connecting, otherwise the parent process sends useless data
11
- def using_forking_dispatcher?
12
- # TODO: MAJOR VERSION - remove :rainbows
13
- if [:puma, :passenger, :rainbows, :unicorn].include?(Agent.config[:dispatcher])
14
- ::NewRelic::Agent.logger.info("Deferring startup of agent reporting thread because #{Agent.config[:dispatcher]} may fork.")
15
- true
16
- else
17
- false
18
- end
19
- end
20
-
21
- # Return true if we're using resque and it hasn't had a chance to (potentially)
22
- # daemonize itself. This avoids hanging when there's a Thread started
23
- # before Resque calls Process.daemon (Jira RUBY-857)
24
- def defer_for_resque?
25
- NewRelic::Agent.config[:dispatcher] == :resque &&
26
- NewRelic::Agent::Instrumentation::Resque::Helper.resque_fork_per_job? &&
27
- !PipeChannelManager.listener.started?
28
- end
29
-
30
- def in_resque_child_process?
31
- defined?(@service) && @service.is_a?(PipeService)
32
- end
33
-
34
- def defer_for_delayed_job?
35
- NewRelic::Agent.config[:dispatcher] == :delayed_job &&
36
- !NewRelic::DelayedJobInjection.worker_name
37
- end
38
-
39
- # This matters when the following three criteria are met:
40
- #
41
- # 1. A Sinatra 'classic' application is being run
42
- # 2. The app is being run by executing the main file directly, rather
43
- # than via a config.ru file.
44
- # 3. newrelic_rpm is required *after* sinatra
45
- #
46
- # In this case, the entire application runs from an at_exit handler in
47
- # Sinatra, and if we were to install ours, it would be executed before
48
- # the one in Sinatra, meaning that we'd shutdown the agent too early
49
- # and never collect any data.
50
- def sinatra_classic_app?
51
- (
52
- defined?(Sinatra::Application) &&
53
- Sinatra::Application.respond_to?(:run) &&
54
- Sinatra::Application.run?
55
- )
56
- end
57
-
58
- def should_install_exit_handler?
59
- return false unless Agent.config[:send_data_on_exit]
60
-
61
- !sinatra_classic_app? || Agent.config[:force_install_exit_handler]
62
- end
63
-
64
- def install_exit_handler
65
- return unless should_install_exit_handler?
66
-
67
- NewRelic::Agent.logger.debug("Installing at_exit handler")
68
- at_exit { shutdown }
69
- end
70
- end
71
- end
72
- end