newrelic_rpm 9.17.0 → 9.21.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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +1 -0
  3. data/CHANGELOG.md +105 -1
  4. data/lib/new_relic/agent/agent.rb +2 -0
  5. data/lib/new_relic/agent/agent_helpers/connect.rb +3 -3
  6. data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -3
  7. data/lib/new_relic/agent/agent_helpers/shutdown.rb +1 -1
  8. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -1
  9. data/lib/new_relic/agent/agent_helpers/startup.rb +4 -4
  10. data/lib/new_relic/agent/configuration/default_source.rb +145 -120
  11. data/lib/new_relic/agent/configuration/manager.rb +5 -2
  12. data/lib/new_relic/agent/configuration/yaml_source.rb +4 -4
  13. data/lib/new_relic/agent/database.rb +1 -1
  14. data/lib/new_relic/agent/database_adapter.rb +1 -1
  15. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  16. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -1
  17. data/lib/new_relic/agent/distributed_tracing.rb +2 -0
  18. data/lib/new_relic/agent/external.rb +2 -0
  19. data/lib/new_relic/agent/http_clients/uri_util.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/action_dispatch.rb +1 -1
  21. data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +1 -1
  22. data/lib/new_relic/agent/instrumentation/action_mailbox.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/action_mailer.rb +1 -1
  24. data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
  25. data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +6 -2
  26. data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
  27. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +2 -2
  28. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +11 -9
  29. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
  30. data/lib/new_relic/agent/instrumentation/async_http.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +1 -1
  33. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -0
  34. data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +1 -2
  36. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +1 -0
  37. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +1 -1
  38. data/lib/new_relic/agent/instrumentation/ethon.rb +1 -1
  39. data/lib/new_relic/agent/instrumentation/excon.rb +1 -1
  40. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +1 -1
  41. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +1 -1
  42. data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -4
  43. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +1 -1
  44. data/lib/new_relic/agent/instrumentation/httpx.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/logstasher.rb +1 -1
  46. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +1 -1
  47. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +2 -2
  48. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +1 -1
  49. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -1
  50. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -1
  51. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +3 -3
  52. data/lib/new_relic/agent/instrumentation/net_http.rb +2 -1
  53. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +0 -2
  54. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  55. data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +2 -2
  56. data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +2 -2
  57. data/lib/new_relic/agent/instrumentation/redis/constants.rb +2 -2
  58. data/lib/new_relic/agent/instrumentation/resque.rb +2 -2
  59. data/lib/new_relic/agent/instrumentation/roda.rb +1 -1
  60. data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +1 -1
  61. data/lib/new_relic/agent/instrumentation/ruby_openai.rb +2 -2
  62. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delay_extensions.rb +24 -0
  63. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  64. data/lib/new_relic/agent/instrumentation/sidekiq.rb +9 -1
  65. data/lib/new_relic/agent/instrumentation/stripe.rb +1 -1
  66. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
  67. data/lib/new_relic/agent/llm/chat_completion_summary.rb +1 -1
  68. data/lib/new_relic/agent/llm/embedding.rb +1 -1
  69. data/lib/new_relic/agent/local_log_decorator.rb +1 -1
  70. data/lib/new_relic/agent/logging.rb +1 -1
  71. data/lib/new_relic/agent/messaging.rb +5 -0
  72. data/lib/new_relic/agent/method_tracer.rb +3 -0
  73. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
  74. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +1 -1
  75. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
  76. data/lib/new_relic/agent/new_relic_service.rb +2 -2
  77. data/lib/new_relic/agent/opentelemetry/context/propagation/trace_propagator.rb +66 -0
  78. data/lib/new_relic/agent/opentelemetry/context/propagation.rb +15 -0
  79. data/lib/{tasks/instrumentation_generator/templates/Envfile.tt → new_relic/agent/opentelemetry/context.rb} +9 -5
  80. data/lib/new_relic/agent/opentelemetry/trace/span.rb +31 -0
  81. data/lib/new_relic/agent/opentelemetry/trace/tracer.rb +129 -0
  82. data/lib/new_relic/agent/opentelemetry/trace/tracer_provider.rb +18 -0
  83. data/lib/new_relic/agent/opentelemetry/trace.rb +15 -0
  84. data/lib/new_relic/agent/opentelemetry/transaction_patch.rb +69 -0
  85. data/lib/new_relic/agent/opentelemetry_bridge.rb +32 -0
  86. data/lib/new_relic/agent/parameter_filtering.rb +1 -1
  87. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  88. data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
  89. data/lib/new_relic/agent/serverless_handler.rb +7 -1
  90. data/lib/new_relic/agent/span_event_primitive.rb +8 -1
  91. data/lib/new_relic/agent/tracer.rb +1 -1
  92. data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -1
  93. data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
  94. data/lib/new_relic/agent/transaction/distributed_tracer.rb +3 -3
  95. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -1
  96. data/lib/new_relic/agent/transaction/request_attributes.rb +1 -6
  97. data/lib/new_relic/agent/transaction/trace_context.rb +33 -4
  98. data/lib/new_relic/agent/transaction/tracing.rb +3 -3
  99. data/lib/new_relic/agent/transaction.rb +2 -1
  100. data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -1
  101. data/lib/new_relic/agent/utilization/ecs.rb +22 -0
  102. data/lib/new_relic/agent/utilization/ecs_v4.rb +22 -0
  103. data/lib/new_relic/agent/utilization_data.rb +40 -5
  104. data/lib/new_relic/agent/vm/c_ruby_vm.rb +3 -3
  105. data/lib/new_relic/agent.rb +28 -0
  106. data/lib/new_relic/constants.rb +1 -0
  107. data/lib/new_relic/control/instance_methods.rb +5 -0
  108. data/lib/new_relic/control/instrumentation.rb +1 -1
  109. data/lib/new_relic/dependency_detection.rb +0 -1
  110. data/lib/new_relic/helper.rb +7 -0
  111. data/lib/new_relic/version.rb +1 -1
  112. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  113. data/lib/tasks/helpers/newrelicyml.rb +6 -2
  114. data/newrelic.yml +80 -43
  115. data/newrelic_rpm.gemspec +1 -1
  116. metadata +17 -19
  117. data/lib/tasks/instrumentation_generator/README.md +0 -63
  118. data/lib/tasks/instrumentation_generator/TODO.md +0 -33
  119. data/lib/tasks/instrumentation_generator/instrumentation.thor +0 -130
  120. data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -21
  121. data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -7
  122. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +0 -32
  123. data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +0 -13
  124. data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +0 -3
  125. data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +0 -19
  126. data/lib/tasks/instrumentation_generator/templates/prepend.tt +0 -13
  127. data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +0 -3
  128. data/lib/tasks/instrumentation_generator/templates/test.tt +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c16c3149d187e88f60c408712fa5da2209c4cac08769477b951df4dfb780e95b
4
- data.tar.gz: d6a0c36115e0b2f9db2ceeb806435737865615dc9043b669376bab20f443dce9
3
+ metadata.gz: 28a51810c279118b462ee016c67fd8d62cde2bf457bfc2ca33e687712a3b3514
4
+ data.tar.gz: c9b530fcf6ea3c2775c1100dfa112ba1d356c8a18a2b18535be1184ebcbc7805
5
5
  SHA512:
6
- metadata.gz: fc16046f04498bc268cfe08839f9a98580fede0d249c87bd9000d00a8560b0a99ffb2d504f018bc4a752a2008e1339a106a8dc38e46687ed2ddbf76aef839abf
7
- data.tar.gz: 1b704cc45064a6ccbea20474f1537379b113bdf38788d2a0f7b283e885e0d9cc54c3ea5f935a8d41a81017a416f14adec7a814351c89dbf89d6072c044fb31ff
6
+ metadata.gz: 299297fc139e0ed8475254cfd73d1d43cea58743fcc89c6e9a02c31a59a44545062c47da422c1126306ac55a9d93a3dc028d9a235739c3d1d8cb642df5f0fc18
7
+ data.tar.gz: c41fdc820bcc54b2fd2a61777b979319af9aeabf77c4b9721a2f385bfd4cef62277d84030b281a38ab8e02684f88603e76a45be6cad64324517f310e6ba1d877
data/.build_ignore CHANGED
@@ -21,6 +21,7 @@ README.md
21
21
  test/
22
22
  lib/tasks/bump_version.rb
23
23
  lib/tasks/coverage_report.rb
24
+ lib/tasks/instrumentation_generator/
24
25
  lib/tasks/multiverse.rake
25
26
  lib/tasks/multiverse.rb
26
27
  lib/tasks/tests.rb
data/CHANGELOG.md CHANGED
@@ -1,11 +1,115 @@
1
1
  # New Relic Ruby Agent Release Notes
2
2
 
3
+ ## v9.21.0
4
+
5
+ - **Feature: In Serverless APM mode, use event source name as transaction name prefix**
6
+
7
+ The agent will now use the event source name as a prefix for the transaction name in Serverless APM mode. This will help to better identify the source of the transaction in the New Relic UI. [PR#3245](https://github.com/newrelic/newrelic-ruby-agent/pull/3245)
8
+
9
+ - **Bugfix: Revert changed logic for how we track the thread the span starts in**
10
+
11
+ This change restores the previous behavior of tracking the thread the span starts in, addressing issues that arose from the updated logic. Thank you [@david-zw-liu](https://github.com/david-zw-liu) for bringing this to our attention. [PR#3248](https://github.com/newrelic/newrelic-ruby-agent/pull/3248)
12
+
13
+ ## v9.20.0
14
+
15
+ - **Feature: Add ECS Docker ID for Fargate**
16
+
17
+ Previously, the Ruby agent did not record the Docker ID when running in an AWS ECS Fargate environment. The Docker ID will now be recorded correctly. [PR#3172](https://github.com/newrelic/newrelic-ruby-agent/pull/3172)
18
+
19
+ - **Feature: Add NewRelic::Helper.version_satisfied?**
20
+
21
+ The agent has a new helper method to simplify version comparison. `NewRelic::Helper.version_satisfied?` accepts three arguments: a left-side version number, the comparison operator as a string, and a right-side version number. Our thanks go to [@kekke-n](https://github.com/kekke-n) for this contribution. [PR#3182](https://github.com/newrelic/newrelic-ruby-agent/pull/3182)
22
+
23
+ - **Feature: Add code.stacktrace attribute on datastore spans when duration exceeds configured threshold**
24
+
25
+ The agent will now add the `code.stacktrace` attribute to datastore spans when the duration exceeds the configured threshold. The threshold is configured using the `transaction_tracer.stack_trace_threshold` configuration option. [PR#3220](https://github.com/newrelic/newrelic-ruby-agent/pull/3220)
26
+
27
+ - **Feature: Consolidate "Unknown" constant values**
28
+
29
+ All references to the various capitalization styles for "Unknown" have been consolidated into two constants: `NewRelic::UNKNOWN` and `NewRelic::UNKNOWN_LOWER`. Thank you, [@tsubasa1122](https://github.com/@tsubasa1122), for your contribution! [PR#3185](https://github.com/newrelic/newrelic-ruby-agent/pull/3185)
30
+
31
+ - **Bugfix: Fix Brewfile source links**
32
+
33
+ Previously, the multiverse README's links to the Brewfile were broken. Our thanks go to [@emmanuel-ferdman](https://github.com/emmanuel-ferdman) for submitting a PR to fix them! [PR#3191](https://github.com/newrelic/newrelic-ruby-agent/pull/3191)
34
+
35
+ - **Bugfix: Fix error when using HTTPX 1.5.0**
36
+
37
+ The agent previously encountered an error when using the new HTTPX version 1.5.0. This was due to a change in the way HTTPX stores the response. The agent has been updated to handle this change correctly, and no longer encounters an error when using HTTPX 1.5.0. [PR#3203](https://github.com/newrelic/newrelic-ruby-agent/pull/3203)
38
+
39
+ - **Bugfix: Bugfixes and improvements to debug level agent logs**
40
+
41
+ Improves the information logged at the debug level by the agent when the agent reads in a configuration source. [PR#3221](https://github.com/newrelic/newrelic-ruby-agent/pull/3221)
42
+
43
+ - **Bugfix: Fix risk of server-side forgery for Slack workflow script**
44
+
45
+ Internally, we keep track of gems that are released using a GitHub actions workflow that posts updates on Slack. [@odaysec] identified a way we could reduce the risk of server-side forgery for this workflow. Thank you! [PR#3184](https://github.com/newrelic/newrelic-ruby-agent/pull/3184)
46
+
47
+ - **Bugfix: Replace JSON.load calls with JSON.parse**
48
+
49
+ Generally, JSON.parse is seen as safer than JSON.load. Thank you, [@odaysec](https://github.com/odaysec), for bringing this to our attention! [PR#3183](https://github.com/newrelic/newrelic-ruby-agent/pull/3183) [PR#3230](https://github.com/newrelic/newrelic-ruby-agent/pull/3230)
50
+
51
+ ## v9.19.0
52
+
53
+ - **Feature: Add Thread ID as attribute to all spans**
54
+
55
+ The agent will now record the Thread ID as an attribute on each span. [PR#3122](https://github.com/newrelic/newrelic-ruby-agent/pull/3122)
56
+
57
+ - **Feature: Add support for W3C TraceContext Trace Flag**
58
+
59
+ Previously, the agent would not use the trace flag field of the traceparent header for sampling decisions. This could lead to fragmented traces in the UI. While the default behavior remains unchanged, two new configuration options, `distributed_tracing.sampler.remote_parent_sampled` and `distributed_tracing.sampler.remote_parent_not_sampled`, have been introduced to allow more control over the way sampling decisions are made. [PR#3135](https://github.com/newrelic/newrelic-ruby-agent/pull/3135)
60
+
61
+ - **Bugfix: Include request.uri in Transaction events by default**
62
+
63
+ [The New Relic data dictionary expects Transaction events to have the `request.uri` attribute.](https://docs.newrelic.com/attribute-dictionary/?event=Transaction&attribute=request.uri) The Ruby agent now fulfills this expectation. If you would like to exclude `request.uri` from Transaction events, you can do so by setting `transaction_events.attributes.exclude` to `'request.uri'`. [PR#3103](https://github.com/newrelic/newrelic-ruby-agent/pull/3103)
64
+
65
+ - **Bugfix: Fix error in Active Job instrumentation when using perform_all_later**
66
+
67
+ Previously, when Active Job's `perform_all_later` method was called and the agent was running, a `NoMethodError` would be raised with the message `undefined method 'queue_name' for nil`. The error has been fixed and the name of the segment will reflect the first job in the queue. Our thanks goes to [@tan-linx](https://github.com/tan-linx) for bringing this to our attention and providing a fix. [PR#3110](https://github.com/newrelic/newrelic-ruby-agent/pull/3110)
68
+
69
+ ## v9.18.0
70
+
71
+ - **Feature: Add elasticsearch.capture_cluster_name configuration option**
72
+
73
+ A new configuration option, `elasticsearch.capture_cluster_name`, has been added to control capturing Elasticsearch cluster names. Cluster names are captured by default, but can now be disabled as needed. [PR#3038](https://github.com/newrelic/newrelic-ruby-agent/pull/3038)
74
+
75
+ - **Feature: Add support for sidekiq-delay_extensions**
76
+
77
+ Sidekiq delay extensions were removed from Sidekiq in 7.x and are now avaliable through the [sidekiq-delay_extensions](https://rubygems.org/gems/sidekiq-delay_extensions) gem. Thanks to [@sobrinho](https://github.com/sobrinho), the agent now has continued support for delay extensions.[PR#3056](https://github.com/newrelic/newrelic-ruby-agent/pull/3056)
78
+
79
+ - **Feature: Parallelize calls for vendor metadata**
80
+
81
+ Previously, the agent would make calls for vendor metadata in a serial fashion. This could lead to a delay in starting the agent. Now, the agent will make these calls in parallel, reducing the time it takes to start the agent. [PR#3094](https://github.com/newrelic/newrelic-ruby-agent/pull/3094)
82
+
83
+ - **Bugfix: Prevent a nil segment from causing errors in Net::HTTP instrumentation**
84
+
85
+ When using JRuby, a race condition can happen that causes the segment creation to fail and return `nil`. This would cause an error to occur when methods were later called on the `nil` segment. These methods will no longer be called if the segment is `nil`, preventing that error from occurring. [PR#3046](https://github.com/newrelic/newrelic-ruby-agent/pull/3046)
86
+
87
+ - **Bugfix: JRuby multithreading improvements**
88
+
89
+ Added some additional nil checks and mutexes to prevent issues when using the agent on JRuby with multiple threads. Thanks to @NC-piercej for bringing this to our attention [Issue#3021](https://github.com/newrelic/newrelic-ruby-agent/issues/3021) [PR#3053](https://github.com/newrelic/newrelic-ruby-agent/pull/3053)
90
+
91
+ - **Bugfix: Stop reporting rescued Sidekiq::OverLimit exceptions**
92
+
93
+ When Sidekiq's concurrent rate limiters encounter an `OverLimit` exception, Sidekiq typically handles this by re-enqueuing the job. Previously, all occurrences of `Sidekiq::OverLimit` were logged as errors in New Relic, even when Sidekiq's middleware resolved the exception. New Relic will no longer report errors that are handled by Sidekiq's own middleware. Thanks to [@97jaz](https://github.com/97jaz) for reporting this issue. [Issue#3037](https://github.com/newrelic/newrelic-ruby-agent/issues/3037) [PR#3047](https://github.com/newrelic/newrelic-ruby-agent/pull/3047)
94
+
95
+ - **Bugfix: Protect against nil agents or health checks**
96
+
97
+ In some cases the agent or health checks may be `nil` when they are called. Safe navigation operators have been added for protection on those occasions. [PR#3049](https://github.com/newrelic/newrelic-ruby-agent/pull/3049)
98
+
99
+ - **Bugfix: Ignore Solid Queue `ThreadError: queue empty` error message by default**
100
+
101
+ When using the solid_queue gem, the agent previously generated excessive warn-level logs when the queue was empty. The agent now ignores `queue empty` error messages of the `ThreadError` class by default. This behavior can be adjusted using the `error_collector.ignore_messages` configuration option. [PR#3060](https://github.com/newrelic/newrelic-ruby-agent/pull/3060)
102
+
103
+ - **Bugfix: Refactor URI host handling to accommodate downcasing frozen strings**
104
+
105
+ When URI host string was frozen, a FrozenError would be raised when the agent attempted to downcase the host as part of its data normalization process. Now, the update is friendly for frozen strings. Thank you [@pedrol3001](https://github.com/pedrol3001) for your contribution! [PR#3097](https://github.com/newrelic/newrelic-ruby-agent/pull/3097)
106
+
3
107
  ## v9.17.0
4
108
 
5
109
  - **Feature: Support Ruby 3.4.0**
6
110
 
7
111
  The agent now supports Ruby 3.4.0. We've made incremental changes throughout the preview stage to reach compatibility. This release includes an update to the Thread Profiler for compatibility with Ruby 3.4.0's new backtrace format. [Issue#2992](https://github.com/newrelic/newrelic-ruby-agent/issues/2992) [PR#2997](https://github.com/newrelic/newrelic-ruby-agent/pull/2997)
8
-
112
+
9
113
  - **Feature: Add instrumentation for aws-sdk-firehose**
10
114
 
11
115
  The agent now has instrumentation for the [aws-sdk-firehose](https://rubygems.org/gems/aws-sdk-firehose) gem. [PR#2973](https://github.com/newrelic/newrelic-ruby-agent/pull/2973)
@@ -38,6 +38,7 @@ require 'new_relic/agent/adaptive_sampler'
38
38
  require 'new_relic/agent/serverless_handler'
39
39
  require 'new_relic/agent/connect/request_builder'
40
40
  require 'new_relic/agent/connect/response_handler'
41
+ require 'new_relic/agent/opentelemetry_bridge'
41
42
 
42
43
  require 'new_relic/agent/agent_helpers/connect'
43
44
  require 'new_relic/agent/agent_helpers/harvest'
@@ -100,6 +101,7 @@ module NewRelic
100
101
  @adaptive_sampler = AdaptiveSampler.new(Agent.config[:sampling_target],
101
102
  Agent.config[:sampling_target_period_in_seconds])
102
103
  @serverless_handler = ServerlessHandler.new
104
+ @opentelemetry_bridge = OpenTelemetryBridge.new
103
105
  end
104
106
 
105
107
  def init_event_handlers
@@ -68,7 +68,7 @@ module NewRelic
68
68
  def handle_license_error(error)
69
69
  ::NewRelic::Agent.logger.error(error.message,
70
70
  'Visit newrelic.com to obtain a valid license key, or to upgrade your account.')
71
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::INVALID_LICENSE_KEY)
71
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::INVALID_LICENSE_KEY)
72
72
  disconnect
73
73
  end
74
74
 
@@ -192,7 +192,7 @@ module NewRelic
192
192
  @connected_pid = $$
193
193
  @connect_state = :connected
194
194
  signal_connected
195
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::HEALTHY)
195
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::HEALTHY)
196
196
  rescue NewRelic::Agent::ForceDisconnectException => e
197
197
  handle_force_disconnect(e)
198
198
  rescue NewRelic::Agent::LicenseException => e
@@ -200,7 +200,7 @@ module NewRelic
200
200
  rescue NewRelic::Agent::UnrecoverableAgentException => e
201
201
  handle_unrecoverable_agent_error(e)
202
202
  rescue StandardError, Timeout::Error, NewRelic::Agent::ServerConnectionException => e
203
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
203
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
204
204
  retry if retry_from_error?(e, opts)
205
205
  rescue Exception => e
206
206
  ::NewRelic::Agent.logger.error('Exception of unexpected type during Agent#connect():', e)
@@ -119,7 +119,7 @@ module NewRelic
119
119
  rescue UnrecoverableServerException => e
120
120
  NewRelic::Agent.logger.warn("#{endpoint} data was rejected by remote service, discarding. Error: ", e)
121
121
  rescue ServerConnectionException => e
122
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
122
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
123
123
  log_remote_unavailable(endpoint, e)
124
124
  container.merge!(payload)
125
125
  rescue => e
@@ -134,11 +134,11 @@ module NewRelic
134
134
  rescue ForceRestartException, ForceDisconnectException
135
135
  raise
136
136
  rescue UnrecoverableServerException => e
137
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
137
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
138
138
  NewRelic::Agent.logger.warn('get_agent_commands message was rejected by remote service, discarding. ' \
139
139
  'Error: ', e)
140
140
  rescue ServerConnectionException => e
141
- NewRelic::Agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
141
+ NewRelic::agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_CONNECT)
142
142
  log_remote_unavailable(:get_agent_commands, e)
143
143
  rescue => e
144
144
  NewRelic::Agent.logger.info('Error during check_for_and_handle_agent_commands, will retry later: ', e)
@@ -20,7 +20,7 @@ module NewRelic
20
20
 
21
21
  @started = nil
22
22
 
23
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::SHUTDOWN) if NewRelic::Agent.agent.health_check.healthy?
23
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::SHUTDOWN) if NewRelic::Agent.agent&.health_check&.healthy?
24
24
 
25
25
  Control.reset
26
26
  end
@@ -86,7 +86,7 @@ module NewRelic
86
86
  # is the worker thread that gathers data and talks to the
87
87
  # server.
88
88
  def handle_force_disconnect(error)
89
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FORCED_DISCONNECT)
89
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FORCED_DISCONNECT)
90
90
  ::NewRelic::Agent.logger.warn('Agent received a ForceDisconnectException from the server, disconnecting. ' \
91
91
  "(#{error.message})")
92
92
  disconnect
@@ -132,7 +132,7 @@ module NewRelic
132
132
  if Agent.config[:monitor_mode]
133
133
  true
134
134
  else
135
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::AGENT_DISABLED)
135
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::AGENT_DISABLED)
136
136
  ::NewRelic::Agent.logger.warn('Agent configured not to send data in this environment.')
137
137
  false
138
138
  end
@@ -144,7 +144,7 @@ module NewRelic
144
144
  if Agent.config[:license_key] && Agent.config[:license_key].length > 0
145
145
  true
146
146
  else
147
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::MISSING_LICENSE_KEY)
147
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::MISSING_LICENSE_KEY)
148
148
  ::NewRelic::Agent.logger.warn('No license key found. ' +
149
149
  'This often means your newrelic.yml file was not found, or it lacks a section for the running ' \
150
150
  "environment, '#{NewRelic::Control.instance.env}'. You may also want to try linting your newrelic.yml " \
@@ -165,7 +165,7 @@ module NewRelic
165
165
  if key.length == 40
166
166
  true
167
167
  else
168
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::INVALID_LICENSE_KEY)
168
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::INVALID_LICENSE_KEY)
169
169
  ::NewRelic::Agent.logger.error("Invalid license key: #{key}")
170
170
  false
171
171
  end
@@ -186,7 +186,7 @@ module NewRelic
186
186
  end
187
187
 
188
188
  unless app_name_configured?
189
- NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::MISSING_APP_NAME)
189
+ NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::MISSING_APP_NAME)
190
190
  NewRelic::Agent.logger.error('No application name configured.',
191
191
  'The agent cannot start without at least one. Please check your ',
192
192
  'newrelic.yml and ensure that it is valid and has at least one ',