newrelic_rpm 9.1.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 (360) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +27 -0
  3. data/CHANGELOG.md +841 -7
  4. data/CONTRIBUTING.md +2 -9
  5. data/README.md +25 -22
  6. data/Rakefile +2 -2
  7. data/bin/newrelic +3 -9
  8. data/bin/newrelic_rpm +15 -0
  9. data/init.rb +2 -2
  10. data/lib/boot/strap.rb +102 -0
  11. data/lib/new_relic/agent/agent.rb +11 -2
  12. data/lib/new_relic/agent/agent_helpers/connect.rb +13 -8
  13. data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -0
  14. data/lib/new_relic/agent/agent_helpers/shutdown.rb +4 -1
  15. data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -1
  16. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +4 -3
  17. data/lib/new_relic/agent/agent_helpers/startup.rb +11 -3
  18. data/lib/new_relic/agent/agent_logger.rb +3 -1
  19. data/lib/new_relic/agent/attribute_filter.rb +3 -3
  20. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  21. data/lib/new_relic/agent/aws.rb +68 -0
  22. data/lib/new_relic/agent/configuration/default_source.rb +918 -166
  23. data/lib/new_relic/agent/configuration/environment_source.rb +15 -3
  24. data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
  25. data/lib/new_relic/agent/configuration/manager.rb +72 -11
  26. data/lib/new_relic/agent/configuration/security_policy_source.rb +11 -0
  27. data/lib/new_relic/agent/configuration/yaml_source.rb +22 -2
  28. data/lib/new_relic/agent/connect/request_builder.rb +1 -1
  29. data/lib/new_relic/agent/custom_event_aggregator.rb +27 -1
  30. data/lib/new_relic/agent/database/obfuscation_helpers.rb +11 -11
  31. data/lib/new_relic/agent/database/obfuscator.rb +1 -0
  32. data/lib/new_relic/agent/database.rb +41 -1
  33. data/lib/new_relic/agent/database_adapter.rb +1 -1
  34. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
  35. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  36. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -1
  37. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +4 -8
  38. data/lib/new_relic/agent/distributed_tracing.rb +5 -3
  39. data/lib/new_relic/agent/error_collector.rb +40 -11
  40. data/lib/new_relic/agent/event_loop.rb +1 -1
  41. data/lib/new_relic/agent/external.rb +2 -0
  42. data/lib/new_relic/agent/harvester.rb +1 -1
  43. data/lib/new_relic/agent/health_check.rb +136 -0
  44. data/lib/new_relic/agent/http_clients/abstract.rb +4 -0
  45. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +80 -0
  46. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -3
  47. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +109 -0
  48. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +0 -3
  49. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +1 -3
  50. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +0 -3
  51. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +91 -0
  52. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +1 -4
  53. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +0 -3
  54. data/lib/new_relic/agent/http_clients/uri_util.rb +1 -1
  55. data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +1 -1
  56. data/lib/new_relic/agent/instrumentation/action_dispatch.rb +1 -1
  57. data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +1 -1
  58. data/lib/new_relic/agent/instrumentation/action_mailbox.rb +1 -1
  59. data/lib/new_relic/agent/instrumentation/action_mailer.rb +1 -1
  60. data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
  61. data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +6 -2
  62. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -16
  63. data/lib/new_relic/agent/instrumentation/active_record.rb +8 -13
  64. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +8 -5
  65. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +13 -10
  66. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
  67. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +9 -16
  68. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  69. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +17 -0
  70. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  71. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +21 -0
  72. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  73. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
  74. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  75. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  76. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  77. data/lib/new_relic/agent/instrumentation/async_http.rb +27 -0
  78. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/chain.rb +21 -0
  79. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/instrumentation.rb +66 -0
  80. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/prepend.rb +15 -0
  81. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose.rb +22 -0
  82. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/chain.rb +21 -0
  83. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +91 -0
  84. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/prepend.rb +15 -0
  85. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis.rb +22 -0
  86. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
  87. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
  88. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
  89. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
  90. data/lib/new_relic/agent/instrumentation/aws_sqs/chain.rb +37 -0
  91. data/lib/new_relic/agent/instrumentation/aws_sqs/instrumentation.rb +67 -0
  92. data/lib/new_relic/agent/instrumentation/aws_sqs/prepend.rb +21 -0
  93. data/lib/new_relic/agent/instrumentation/aws_sqs.rb +23 -0
  94. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  95. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +23 -0
  96. data/lib/new_relic/agent/instrumentation/bunny.rb +4 -5
  97. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
  98. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
  99. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
  100. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +2 -3
  101. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -2
  102. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
  103. data/lib/new_relic/agent/instrumentation/curb.rb +4 -5
  104. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
  105. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
  106. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -23
  107. data/lib/new_relic/agent/instrumentation/dynamodb/chain.rb +27 -0
  108. data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +64 -0
  109. data/lib/new_relic/agent/instrumentation/dynamodb/prepend.rb +19 -0
  110. data/lib/new_relic/agent/instrumentation/dynamodb.rb +23 -0
  111. data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -3
  112. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +65 -10
  113. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -4
  114. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  115. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  116. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  117. data/lib/new_relic/agent/instrumentation/ethon.rb +35 -0
  118. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
  119. data/lib/new_relic/agent/instrumentation/excon.rb +1 -17
  120. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +11 -4
  121. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +2 -6
  122. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +10 -3
  123. data/lib/new_relic/agent/instrumentation/fiber.rb +1 -3
  124. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -3
  125. data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
  126. data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
  127. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +5 -2
  128. data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
  129. data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
  130. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +5 -1
  131. data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
  132. data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
  133. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  134. data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -5
  135. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  136. data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
  137. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  138. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  139. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  140. data/lib/new_relic/agent/instrumentation/httpx.rb +23 -0
  141. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  142. data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
  143. data/lib/new_relic/agent/instrumentation/logstasher/chain.rb +21 -0
  144. data/lib/new_relic/agent/instrumentation/logstasher/instrumentation.rb +24 -0
  145. data/lib/new_relic/agent/instrumentation/logstasher/prepend.rb +13 -0
  146. data/lib/new_relic/agent/instrumentation/logstasher.rb +25 -0
  147. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +4 -2
  148. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +2 -2
  149. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +13 -4
  150. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +4 -2
  151. data/lib/new_relic/agent/instrumentation/memcache.rb +4 -5
  152. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +3 -5
  153. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +13 -3
  154. data/lib/new_relic/agent/instrumentation/net_http.rb +2 -1
  155. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -2
  156. data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
  157. data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
  158. data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
  159. data/lib/new_relic/agent/instrumentation/opensearch.rb +23 -0
  160. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
  161. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  162. data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
  163. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +9 -0
  164. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
  165. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +1 -1
  166. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +10 -5
  167. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
  168. data/lib/new_relic/agent/instrumentation/rake.rb +1 -2
  169. data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +72 -0
  170. data/lib/new_relic/agent/instrumentation/rdkafka/instrumentation.rb +70 -0
  171. data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +67 -0
  172. data/lib/new_relic/agent/instrumentation/rdkafka.rb +25 -0
  173. data/lib/new_relic/agent/instrumentation/redis/cluster_middleware.rb +26 -0
  174. data/lib/new_relic/agent/instrumentation/redis/constants.rb +2 -2
  175. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +18 -11
  176. data/lib/new_relic/agent/instrumentation/redis/middleware.rb +3 -0
  177. data/lib/new_relic/agent/instrumentation/redis.rb +11 -5
  178. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  179. data/lib/new_relic/agent/instrumentation/resque.rb +8 -6
  180. data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
  181. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  182. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
  183. data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
  184. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
  185. data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
  186. data/lib/new_relic/agent/instrumentation/ruby_kafka/chain.rb +55 -0
  187. data/lib/new_relic/agent/instrumentation/ruby_kafka/instrumentation.rb +67 -0
  188. data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +60 -0
  189. data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +25 -0
  190. data/lib/new_relic/agent/instrumentation/ruby_openai/chain.rb +36 -0
  191. data/lib/new_relic/agent/instrumentation/ruby_openai/instrumentation.rb +196 -0
  192. data/lib/new_relic/agent/instrumentation/ruby_openai/prepend.rb +20 -0
  193. data/lib/new_relic/agent/instrumentation/ruby_openai.rb +35 -0
  194. data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
  195. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  196. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delay_extensions.rb +24 -0
  197. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +2 -2
  198. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  199. data/lib/new_relic/agent/instrumentation/sidekiq.rb +13 -16
  200. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
  201. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
  202. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
  203. data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -19
  204. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  205. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +98 -0
  206. data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
  207. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -5
  208. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
  209. data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
  210. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
  211. data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
  212. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +7 -3
  213. data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
  214. data/lib/new_relic/agent/instrumentation/view_component/chain.rb +21 -0
  215. data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +45 -0
  216. data/lib/{tasks/instrumentation_generator/templates/instrumentation.tt → new_relic/agent/instrumentation/view_component/prepend.rb} +4 -4
  217. data/lib/new_relic/agent/instrumentation/view_component.rb +24 -0
  218. data/lib/new_relic/agent/javascript_instrumentor.rb +2 -4
  219. data/lib/new_relic/agent/llm/chat_completion_message.rb +25 -0
  220. data/lib/new_relic/agent/llm/chat_completion_summary.rb +66 -0
  221. data/lib/new_relic/agent/llm/embedding.rb +60 -0
  222. data/lib/new_relic/agent/llm/llm_event.rb +95 -0
  223. data/lib/new_relic/agent/llm/response_headers.rb +80 -0
  224. data/lib/new_relic/agent/llm.rb +49 -0
  225. data/lib/new_relic/agent/local_log_decorator.rb +20 -3
  226. data/lib/new_relic/agent/log_event_aggregator.rb +149 -26
  227. data/lib/new_relic/agent/log_event_attributes.rb +115 -0
  228. data/lib/new_relic/agent/logging.rb +5 -5
  229. data/lib/new_relic/agent/messaging.rb +18 -7
  230. data/lib/new_relic/agent/method_tracer.rb +4 -1
  231. data/lib/new_relic/agent/method_tracer_helpers.rb +26 -5
  232. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
  233. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  234. data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
  235. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
  236. data/lib/new_relic/agent/new_relic_service.rb +61 -28
  237. data/lib/new_relic/agent/obfuscator.rb +0 -2
  238. data/lib/new_relic/agent/opentelemetry/context/propagation/trace_propagator.rb +66 -0
  239. data/lib/new_relic/agent/opentelemetry/context/propagation.rb +15 -0
  240. data/lib/{tasks/instrumentation_generator/templates/Envfile.tt → new_relic/agent/opentelemetry/context.rb} +9 -5
  241. data/lib/new_relic/agent/opentelemetry/trace/span.rb +31 -0
  242. data/lib/new_relic/agent/opentelemetry/trace/tracer.rb +129 -0
  243. data/lib/new_relic/agent/opentelemetry/trace/tracer_provider.rb +18 -0
  244. data/lib/new_relic/agent/opentelemetry/trace.rb +15 -0
  245. data/lib/new_relic/agent/opentelemetry/transaction_patch.rb +69 -0
  246. data/lib/new_relic/agent/opentelemetry_bridge.rb +32 -0
  247. data/lib/new_relic/agent/parameter_filtering.rb +1 -1
  248. data/lib/new_relic/agent/pipe_channel_manager.rb +2 -2
  249. data/lib/new_relic/agent/pipe_service.rb +1 -1
  250. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -2
  251. data/lib/new_relic/agent/rules_engine.rb +1 -1
  252. data/lib/new_relic/agent/sampler.rb +1 -0
  253. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  254. data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
  255. data/lib/new_relic/agent/serverless_handler.rb +406 -0
  256. data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
  257. data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
  258. data/lib/new_relic/agent/span_event_primitive.rb +32 -15
  259. data/lib/new_relic/agent/sql_sampler.rb +0 -1
  260. data/lib/new_relic/agent/system_info.rb +40 -0
  261. data/lib/new_relic/agent/threading/agent_thread.rb +1 -2
  262. data/lib/new_relic/agent/threading/backtrace_node.rb +10 -1
  263. data/lib/new_relic/agent/tracer.rb +16 -16
  264. data/lib/new_relic/agent/transaction/abstract_segment.rb +103 -41
  265. data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
  266. data/lib/new_relic/agent/transaction/distributed_tracer.rb +3 -3
  267. data/lib/new_relic/agent/transaction/distributed_tracing.rb +7 -8
  268. data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -12
  269. data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -3
  270. data/lib/new_relic/agent/transaction/request_attributes.rb +54 -11
  271. data/lib/new_relic/agent/transaction/trace_context.rb +34 -5
  272. data/lib/new_relic/agent/transaction/tracing.rb +20 -4
  273. data/lib/new_relic/agent/transaction.rb +38 -13
  274. data/lib/new_relic/agent/transaction_error_primitive.rb +39 -19
  275. data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
  276. data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -1
  277. data/lib/new_relic/agent/utilization/ecs.rb +22 -0
  278. data/lib/new_relic/agent/utilization/ecs_v4.rb +22 -0
  279. data/lib/new_relic/agent/utilization/gcp.rb +1 -3
  280. data/lib/new_relic/agent/utilization/vendor.rb +5 -7
  281. data/lib/new_relic/agent/utilization_data.rb +40 -5
  282. data/lib/new_relic/agent/vm/{mri_vm.rb → c_ruby_vm.rb} +10 -18
  283. data/lib/new_relic/agent/vm.rb +2 -2
  284. data/lib/new_relic/agent/worker_loop.rb +1 -1
  285. data/lib/new_relic/agent.rb +286 -17
  286. data/lib/new_relic/base64.rb +25 -0
  287. data/lib/new_relic/cli/command.rb +6 -3
  288. data/lib/new_relic/constants.rb +8 -0
  289. data/lib/new_relic/control/class_methods.rb +1 -7
  290. data/lib/new_relic/control/frameworks/grape.rb +14 -0
  291. data/lib/new_relic/control/frameworks/padrino.rb +14 -0
  292. data/lib/new_relic/control/frameworks/rails.rb +17 -5
  293. data/lib/new_relic/control/frameworks/rails4.rb +1 -3
  294. data/lib/new_relic/control/frameworks/roda.rb +20 -0
  295. data/lib/new_relic/control/instance_methods.rb +13 -0
  296. data/lib/new_relic/control/instrumentation.rb +2 -16
  297. data/lib/new_relic/control/private_instance_methods.rb +4 -0
  298. data/lib/new_relic/control/security_interface.rb +57 -0
  299. data/lib/new_relic/control.rb +1 -1
  300. data/lib/new_relic/dependency_detection.rb +25 -13
  301. data/lib/new_relic/environment_report.rb +2 -2
  302. data/lib/new_relic/helper.rb +22 -0
  303. data/lib/new_relic/language_support.rb +12 -1
  304. data/lib/new_relic/latest_changes.rb +1 -1
  305. data/lib/new_relic/local_environment.rb +31 -18
  306. data/lib/new_relic/noticed_error.rb +5 -2
  307. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  308. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  309. data/lib/new_relic/rack/browser_monitoring.rb +29 -13
  310. data/lib/new_relic/supportability_helper.rb +5 -1
  311. data/lib/new_relic/thread_local_storage.rb +31 -0
  312. data/lib/new_relic/traced_thread.rb +2 -3
  313. data/lib/new_relic/version.rb +1 -1
  314. data/lib/sequel/extensions/new_relic_instrumentation.rb +4 -3
  315. data/lib/tasks/bump_version.rake +21 -0
  316. data/lib/tasks/config.rake +11 -5
  317. data/lib/tasks/coverage_report.rake +1 -1
  318. data/lib/tasks/gha.rake +31 -0
  319. data/lib/tasks/helpers/config.html.erb +94 -0
  320. data/lib/tasks/helpers/format.rb +11 -7
  321. data/lib/tasks/helpers/newrelicyml.rb +211 -0
  322. data/lib/tasks/helpers/version_bump.rb +62 -0
  323. data/lib/tasks/newrelic.rb +1 -0
  324. data/lib/tasks/newrelicyml.rake +13 -0
  325. data/lib/tasks/tests.rake +71 -0
  326. data/newrelic.yml +657 -251
  327. data/newrelic_rpm.gemspec +17 -10
  328. data/test/agent_helper.rb +38 -4
  329. metadata +230 -44
  330. data/.gitignore +0 -43
  331. data/.project +0 -23
  332. data/.rubocop.yml +0 -1909
  333. data/.rubocop_todo.yml +0 -61
  334. data/.simplecov +0 -15
  335. data/.snyk +0 -11
  336. data/.yardopts +0 -27
  337. data/Brewfile +0 -12
  338. data/DOCKER.md +0 -167
  339. data/Dockerfile +0 -10
  340. data/Guardfile +0 -26
  341. data/bin/newrelic_cmd +0 -6
  342. data/config/database.yml +0 -5
  343. data/config.dot +0 -278
  344. data/docker-compose.yml +0 -107
  345. data/lefthook.yml +0 -9
  346. data/lib/new_relic/agent/range_extensions.rb +0 -27
  347. data/lib/tasks/helpers/removers.rb +0 -33
  348. data/lib/tasks/instrumentation_generator/README.md +0 -63
  349. data/lib/tasks/instrumentation_generator/TODO.md +0 -33
  350. data/lib/tasks/instrumentation_generator/instrumentation.thor +0 -121
  351. data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -22
  352. data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -8
  353. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +0 -29
  354. data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +0 -3
  355. data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +0 -19
  356. data/lib/tasks/instrumentation_generator/templates/prepend.tt +0 -13
  357. data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +0 -3
  358. data/lib/tasks/instrumentation_generator/templates/test.tt +0 -15
  359. data/lib/tasks/multiverse.rake +0 -6
  360. data/lib/tasks/multiverse.rb +0 -83
@@ -156,7 +156,7 @@ module NewRelic
156
156
  end
157
157
 
158
158
  if !errors.empty?
159
- ::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in Agent Event Loop:", *errors)
159
+ ::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in agent event loop:", *errors)
160
160
  end
161
161
  end
162
162
 
@@ -29,6 +29,7 @@ module NewRelic
29
29
  #
30
30
  # @param request_metadata [String] received obfuscated request metadata
31
31
  #
32
+ # @!scope class
32
33
  # @api public
33
34
  #
34
35
  def process_request_metadata(request_metadata)
@@ -74,6 +75,7 @@ module NewRelic
74
75
  #
75
76
  # @return [String] obfuscated response metadata to send
76
77
  #
78
+ # @!scope class
77
79
  # @api public
78
80
  #
79
81
  def get_response_metadata
@@ -38,7 +38,7 @@ module NewRelic
38
38
  end
39
39
 
40
40
  def harvest_thread_enabled?
41
- !NewRelic::Agent.config[:disable_harvest_thread]
41
+ !NewRelic::Agent.config[:disable_harvest_thread] && !NewRelic::Agent.config[:'serverless_mode.enabled']
42
42
  end
43
43
 
44
44
  def restart_harvest_thread
@@ -0,0 +1,136 @@
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
+ class HealthCheck
8
+ def initialize
9
+ @start_time = nano_time
10
+ @continue = true
11
+ @status = HEALTHY
12
+ # the following assignments may set @continue = false if they are invalid
13
+ set_enabled
14
+ set_delivery_location
15
+ set_frequency
16
+ end
17
+
18
+ HEALTHY = {healthy: true, last_error: 'NR-APM-000', message: 'Healthy'}.freeze
19
+ INVALID_LICENSE_KEY = {healthy: false, last_error: 'NR-APM-001', message: 'Invalid license key (HTTP status code 401)'}.freeze
20
+ MISSING_LICENSE_KEY = {healthy: false, last_error: 'NR-APM-002', message: 'License key missing in configuration'}.freeze
21
+ FORCED_DISCONNECT = {healthy: false, last_error: 'NR-APM-003', message: 'Forced disconnect received from New Relic (HTTP status code 410)'}.freeze
22
+ HTTP_ERROR = {healthy: false, last_error: 'NR-APM-004', message: 'HTTP error response code [%s] recevied from New Relic while sending data type [%s]'}.freeze
23
+ MISSING_APP_NAME = {healthy: false, last_error: 'NR-APM-005', message: 'Missing application name in agent configuration'}.freeze
24
+ APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'}.freeze
25
+ PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'}.freeze
26
+ AGENT_DISABLED = {healthy: false, last_error: 'NR-APM-008', message: 'Agent is disabled via configuration'}.freeze
27
+ FAILED_TO_CONNECT = {healthy: false, last_error: 'NR-APM-009', message: 'Failed to connect to New Relic data collector'}.freeze
28
+ FAILED_TO_PARSE_CONFIG = {healthy: false, last_error: 'NR-APM-010', message: 'Agent config file is not able to be parsed'}.freeze
29
+ SHUTDOWN = {healthy: true, last_error: 'NR-APM-099', message: 'Agent has shutdown'}.freeze
30
+
31
+ def create_and_run_health_check_loop
32
+ return unless health_checks_enabled? && @continue
33
+
34
+ NewRelic::Agent.logger.debug('Agent Control health check conditions met. Starting health checks.')
35
+ NewRelic::Agent.record_metric('Supportability/AgentControl/Health/enabled', 1)
36
+
37
+ Thread.new do
38
+ while @continue
39
+ begin
40
+ sleep @frequency
41
+ write_file
42
+ @continue = false if @status == SHUTDOWN
43
+ rescue StandardError => e
44
+ NewRelic::Agent.logger.error("Aborting Agent Control health check. Error raised: #{e}")
45
+ @continue = false
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ def update_status(status, options = [])
52
+ return unless @continue
53
+
54
+ @status = status.dup
55
+ update_message(options) unless options.empty?
56
+ end
57
+
58
+ def healthy?
59
+ @status == HEALTHY
60
+ end
61
+
62
+ private
63
+
64
+ def set_enabled
65
+ @enabled = if ENV['NEW_RELIC_AGENT_CONTROL_ENABLED'] == 'true'
66
+ true
67
+ else
68
+ NewRelic::Agent.logger.debug('NEW_RELIC_AGENT_CONTROL_ENABLED not true, disabling health checks')
69
+ @continue = false
70
+ false
71
+ end
72
+ end
73
+
74
+ def set_delivery_location
75
+ @delivery_location = if ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_DELIVERY_LOCATION']
76
+ # The spec states file paths for the delivery location will begin with file://
77
+ # This does not create a valid path in Ruby, so remove the prefix when present
78
+ ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_DELIVERY_LOCATION']&.gsub('file://', '')
79
+ else
80
+ # The spec default is 'file:///newrelic/apm/health', but since we're just going to remove it anyway...
81
+ '/newrelic/apm/health'
82
+ end
83
+ end
84
+
85
+ def set_frequency
86
+ @frequency = ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY'] ? ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY'].to_i : 5
87
+
88
+ if @frequency <= 0
89
+ NewRelic::Agent.logger.debug('NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY zero or less, disabling health checks')
90
+ @continue = false
91
+ end
92
+ end
93
+
94
+ def contents
95
+ <<~CONTENTS
96
+ healthy: #{@status[:healthy]}
97
+ status: #{@status[:message]}#{last_error}
98
+ start_time_unix_nano: #{@start_time}
99
+ status_time_unix_nano: #{nano_time}
100
+ CONTENTS
101
+ end
102
+
103
+ def last_error
104
+ @status[:healthy] ? '' : "\nlast_error: #{@status[:last_error]}"
105
+ end
106
+
107
+ def nano_time
108
+ Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
109
+ end
110
+
111
+ def file_name
112
+ "health-#{NewRelic::Agent::GuidGenerator.generate_guid(32)}.yml"
113
+ end
114
+
115
+ def write_file
116
+ @file ||= "#{@delivery_location}/#{file_name}"
117
+
118
+ File.write(@file, contents)
119
+ rescue StandardError => e
120
+ NewRelic::Agent.logger.error("Agent Control health check raised an error while writing a file: #{e}")
121
+ @continue = false
122
+ end
123
+
124
+ def health_checks_enabled?
125
+ @enabled && @delivery_location && @frequency > 0
126
+ end
127
+
128
+ def update_message(options)
129
+ @status[:message] = sprintf(@status[:message], *options)
130
+ rescue StandardError => e
131
+ NewRelic::Agent.logger.debug("Error raised while updating Agent Control health check message: #{e}." \
132
+ "options = #{options}, @status[:message] = #{@status[:message]}")
133
+ end
134
+ end
135
+ end
136
+ end
@@ -14,6 +14,10 @@ module NewRelic
14
14
  #
15
15
  # @api public
16
16
  class AbstractRequest
17
+ LHOST = 'host'
18
+ UHOST = 'Host'
19
+ COLON = ':'
20
+
17
21
  %i[[] []= type host_from_header host method headers uri].each do |name|
18
22
  define_method(name) do
19
23
  not_implemented(name)
@@ -0,0 +1,80 @@
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 'abstract'
6
+ require 'resolv'
7
+
8
+ module NewRelic
9
+ module Agent
10
+ module HTTPClients
11
+ class AsyncHTTPResponse < AbstractResponse
12
+ def get_status_code
13
+ get_status_code_using(:status)
14
+ end
15
+
16
+ def [](key)
17
+ to_hash[key.downcase]&.first
18
+ end
19
+
20
+ def to_hash
21
+ @wrapped_response.headers.to_h
22
+ end
23
+ end
24
+
25
+ class AsyncHTTPRequest < AbstractRequest
26
+ def initialize(connection, method, url, headers)
27
+ @connection = connection
28
+ @method = method
29
+ @url = ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(url)
30
+ @headers = headers
31
+ end
32
+
33
+ ASYNC_HTTP = 'Async::HTTP'
34
+
35
+ def type
36
+ ASYNC_HTTP
37
+ end
38
+
39
+ def host_from_header
40
+ if hostname = (self[LHOST] || self[UHOST])
41
+ hostname.split(COLON).first
42
+ end
43
+ end
44
+
45
+ def host
46
+ host_from_header || uri.host.to_s
47
+ end
48
+
49
+ def [](key)
50
+ return headers[key] unless headers.is_a?(Array)
51
+
52
+ headers.each do |header|
53
+ return header[1] if header[0].casecmp?(key)
54
+ end
55
+ nil
56
+ end
57
+
58
+ def []=(key, value)
59
+ if headers.is_a?(Array)
60
+ headers << [key, value]
61
+ else
62
+ headers[key] = value
63
+ end
64
+ end
65
+
66
+ def uri
67
+ @url
68
+ end
69
+
70
+ def headers
71
+ @headers
72
+ end
73
+
74
+ def method
75
+ @method
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -7,10 +7,8 @@ require_relative 'abstract'
7
7
  module NewRelic
8
8
  module Agent
9
9
  module HTTPClients
10
- class CurbRequest
10
+ class CurbRequest < AbstractRequest
11
11
  CURB = 'Curb'
12
- LHOST = 'host'
13
- UHOST = 'Host'
14
12
 
15
13
  def initialize(curlobj)
16
14
  @curlobj = curlobj
@@ -0,0 +1,109 @@
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 'uri'
6
+ require_relative 'abstract'
7
+
8
+ module NewRelic
9
+ module Agent
10
+ module HTTPClients
11
+ class EthonHTTPResponse < AbstractResponse
12
+ def initialize(easy)
13
+ @easy = easy
14
+ end
15
+
16
+ def status_code
17
+ @easy.response_code
18
+ end
19
+
20
+ def [](key)
21
+ headers[format_key(key)]
22
+ end
23
+
24
+ def headers
25
+ # Ethon::Easy#response_headers will return '' if headers are unset
26
+ @easy.response_headers.scan(/\n([^:]+?): ([^:\n]+?)\r/).each_with_object({}) do |pair, hash|
27
+ hash[format_key(pair[0])] = pair[1]
28
+ end
29
+ end
30
+ alias to_hash headers
31
+
32
+ private
33
+
34
+ def format_key(key)
35
+ key.tr('-', '_').downcase
36
+ end
37
+ end
38
+
39
+ class EthonHTTPRequest < AbstractRequest
40
+ attr_reader :uri
41
+
42
+ DEFAULT_ACTION = 'GET'
43
+ DEFAULT_HOST = 'UNKNOWN_HOST'
44
+ ETHON = 'Ethon'
45
+
46
+ def initialize(easy)
47
+ @easy = easy
48
+ @uri = uri_from_easy
49
+ end
50
+
51
+ def type
52
+ ETHON
53
+ end
54
+
55
+ def host_from_header
56
+ self[LHOST] || self[UHOST]
57
+ end
58
+
59
+ def uri_from_easy
60
+ # anticipate `Ethon::Easy#url` being `example.com` without a protocol
61
+ # defined and use an 'http' protocol prefix for `URI.parse` to work
62
+ # with the URL as desired
63
+ url_str = @easy.url.match?(':') ? @easy.url : "http://#{@easy.url}"
64
+ begin
65
+ URI.parse(url_str)
66
+ rescue URI::InvalidURIError => e
67
+ NewRelic::Agent.logger.debug("Failed to parse URI '#{url_str}': #{e.class} - #{e.message}")
68
+ URI.parse(NewRelic::EMPTY_STR)
69
+ end
70
+ end
71
+
72
+ def host
73
+ host_from_header || uri.host&.downcase || DEFAULT_HOST
74
+ end
75
+
76
+ def method
77
+ return DEFAULT_ACTION unless @easy.instance_variable_defined?(action_instance_var)
78
+
79
+ @easy.instance_variable_get(action_instance_var)
80
+ end
81
+
82
+ def action_instance_var
83
+ NewRelic::Agent::Instrumentation::Ethon::Easy::ACTION_INSTANCE_VAR
84
+ end
85
+
86
+ def []=(key, value)
87
+ headers[key] = value
88
+ @easy.headers = headers
89
+ end
90
+
91
+ def headers
92
+ @headers ||= if @easy.instance_variable_defined?(headers_instance_var)
93
+ @easy.instance_variable_get(headers_instance_var)
94
+ else
95
+ {}
96
+ end
97
+ end
98
+
99
+ def headers_instance_var
100
+ NewRelic::Agent::Instrumentation::Ethon::Easy::HEADERS_INSTANCE_VAR
101
+ end
102
+
103
+ def [](key)
104
+ headers[key]
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -47,9 +47,6 @@ module NewRelic
47
47
  attr_reader :method
48
48
 
49
49
  EXCON = 'Excon'
50
- LHOST = 'host'
51
- UHOST = 'Host'
52
- COLON = ':'
53
50
 
54
51
  def initialize(datum)
55
52
  @datum = datum
@@ -20,8 +20,6 @@ module NewRelic
20
20
 
21
21
  class HTTPRequest < AbstractRequest
22
22
  HTTP_RB = 'http.rb'
23
- HOST = 'host'
24
- COLON = ':'
25
23
 
26
24
  def initialize(wrapped_request)
27
25
  @wrapped_request = wrapped_request
@@ -36,7 +34,7 @@ module NewRelic
36
34
  end
37
35
 
38
36
  def host_from_header
39
- if hostname = self[HOST]
37
+ if hostname = self[LHOST]
40
38
  hostname.split(COLON).first
41
39
  end
42
40
  end
@@ -26,9 +26,6 @@ module NewRelic
26
26
  attr_reader :request
27
27
 
28
28
  HTTP_CLIENT = 'HTTPClient'.freeze
29
- LHOST = 'host'.freeze
30
- UHOST = 'Host'.freeze
31
- COLON = ':'.freeze
32
29
 
33
30
  def initialize(request)
34
31
  @request = request
@@ -0,0 +1,91 @@
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 'abstract'
6
+
7
+ module NewRelic
8
+ module Agent
9
+ module HTTPClients
10
+ # HTTPX returns an instance of HTTPX::ErrorResponse on error,
11
+ # and that instance itself yields the underlying HTTP response
12
+ # object via #response, but depending on the error that HTTP
13
+ # response object could be unset.
14
+ class HTTPXErrorResponse
15
+ def status; end
16
+ def headers; {}; end
17
+ end
18
+
19
+ class HTTPXHTTPResponse < AbstractResponse
20
+ def initialize(response)
21
+ if response.is_a?(::HTTPX::ErrorResponse)
22
+ @response = response.response || HTTPXErrorResponse.new
23
+ else
24
+ @response = response
25
+ end
26
+ end
27
+
28
+ def status_code
29
+ @response.status
30
+ end
31
+
32
+ def [](key)
33
+ headers[format_key(key)]
34
+ end
35
+
36
+ def headers
37
+ headers ||= @response.headers.to_hash.each_with_object({}) do |(k, v), h|
38
+ h[format_key(k)] = v
39
+ end
40
+ end
41
+ alias to_hash headers
42
+
43
+ private
44
+
45
+ def format_key(key)
46
+ key.tr('-', '_').downcase
47
+ end
48
+ end
49
+
50
+ class HTTPXHTTPRequest < AbstractRequest
51
+ attr_reader :uri
52
+
53
+ DEFAULT_HOST = 'UNKNOWN_HOST'
54
+ TYPE = 'HTTPX'
55
+
56
+ def initialize(request)
57
+ @request = request
58
+ @uri = request.uri
59
+ end
60
+
61
+ def type
62
+ TYPE
63
+ end
64
+
65
+ def host_from_header
66
+ self[LHOST] || self[UHOST]
67
+ end
68
+
69
+ def host
70
+ host_from_header || uri.host&.downcase || DEFAULT_HOST
71
+ end
72
+
73
+ def method
74
+ @request.verb
75
+ end
76
+
77
+ def []=(key, value)
78
+ @request.headers[key] = value
79
+ end
80
+
81
+ def headers
82
+ @request.headers
83
+ end
84
+
85
+ def [](key)
86
+ @request.headers[key]
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -30,11 +30,8 @@ module NewRelic
30
30
  NET_HTTP
31
31
  end
32
32
 
33
- HOST = 'host'
34
- COLON = ':'
35
-
36
33
  def host_from_header
37
- if hostname = self[HOST]
34
+ if hostname = self[LHOST]
38
35
  hostname.split(COLON).first
39
36
  end
40
37
  end
@@ -48,9 +48,6 @@ module NewRelic
48
48
  TYPHOEUS
49
49
  end
50
50
 
51
- LHOST = 'host'.freeze
52
- UHOST = 'Host'.freeze
53
-
54
51
  def host_from_header
55
52
  self[LHOST] || self[UHOST]
56
53
  end
@@ -36,7 +36,7 @@ module NewRelic
36
36
  uri = ::URI.parse(url)
37
37
  end
38
38
  end
39
- uri.host&.downcase!
39
+ uri.host = uri.host&.downcase
40
40
  uri
41
41
  end
42
42
 
@@ -23,7 +23,7 @@ module NewRelic
23
23
 
24
24
  def metric_name(name, payload)
25
25
  controller_name = controller_name_for_metric(payload)
26
- "Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub(/\.action_controller/, '')}"
26
+ "Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub('.action_controller', '')}"
27
27
  end
28
28
 
29
29
  def controller_name_for_metric(payload)
@@ -16,7 +16,7 @@ DependencyDetection.defer do
16
16
  defined?(ActionDispatch) &&
17
17
  defined?(ActionPack) &&
18
18
  ActionPack.respond_to?(:gem_version) &&
19
- ActionPack.gem_version >= Gem::Version.new('6.0.0') && # notifications for dispatch added in Rails 6
19
+ NewRelic::Helper.version_satisfied?(ActionPack.gem_version, '>=', '6.0.0') && # notifications for dispatch added in Rails 6
20
20
  !NewRelic::Agent::Instrumentation::ActionDispatchSubscriber.subscribed?
21
21
  end
22
22
 
@@ -45,7 +45,7 @@ module NewRelic
45
45
  end
46
46
 
47
47
  PATTERN = /\A([^\.]+)\.action_dispatch\z/
48
- UNKNOWN = 'unknown'.freeze
48
+ UNKNOWN = NewRelic::UNKNOWN_LOWER
49
49
 
50
50
  METHOD_NAME_MAPPING = Hash.new do |h, k|
51
51
  if PATTERN =~ k
@@ -15,7 +15,7 @@ DependencyDetection.defer do
15
15
  defined?(ActiveSupport) &&
16
16
  defined?(ActionMailbox) &&
17
17
  ActionMailbox.respond_to?(:gem_version) && # 'require "action_mailbox"' doesn't require version...
18
- ActionMailbox.gem_version >= Gem::Version.new('7.1.0.alpha') && # notifications added in Rails 7.1
18
+ NewRelic::Helper.version_satisfied?(ActionMailbox.gem_version, '>=', '7.1.0.alpha') && # notifications added in Rails 7.1
19
19
  !NewRelic::Agent::Instrumentation::ActionMailboxSubscriber.subscribed?
20
20
  end
21
21
 
@@ -15,7 +15,7 @@ DependencyDetection.defer do
15
15
  defined?(ActiveSupport) &&
16
16
  defined?(ActionMailer) &&
17
17
  ActionMailer.respond_to?(:gem_version) &&
18
- ActionMailer.gem_version >= Gem::Version.new('5.0') &&
18
+ NewRelic::Helper.version_satisfied?(ActionMailer.gem_version, '>=', '5.0') &&
19
19
  !NewRelic::Agent::Instrumentation::ActionMailerSubscriber.subscribed?
20
20
  end
21
21
 
@@ -30,7 +30,7 @@ DependencyDetection.defer do
30
30
  executes do
31
31
  if defined?(ActiveSupport) &&
32
32
  ActiveJob.respond_to?(:gem_version) &&
33
- ActiveJob.gem_version >= Gem::Version.new('6.0.0') &&
33
+ NewRelic::Helper.version_satisfied?(ActiveJob.gem_version, '>=', '6.0.0') &&
34
34
  !NewRelic::Agent.config[:disable_activejob] &&
35
35
  !NewRelic::Agent::Instrumentation::ActiveJobSubscriber.subscribed?
36
36
  NewRelic::Agent.logger.info('Installing notifications based ActiveJob instrumentation')
@@ -8,7 +8,7 @@ module NewRelic
8
8
  module Agent
9
9
  module Instrumentation
10
10
  class ActiveJobSubscriber < NotificationsSubscriber
11
- PAYLOAD_KEYS = %i[adapter db_runtime error job wait]
11
+ PAYLOAD_KEYS = %i[adapter db_runtime error job wait jobs]
12
12
 
13
13
  def add_segment_params(segment, payload)
14
14
  PAYLOAD_KEYS.each do |key|
@@ -16,8 +16,12 @@ module NewRelic
16
16
  end
17
17
  end
18
18
 
19
+ # NOTE: For `enqueue_all.active_job`, only the first job is used to determine the queue.
20
+ # Therefore, this assumes all jobs given as arguments for perform_all_later share the same queue.
19
21
  def metric_name(name, payload)
20
- queue = payload[:job].queue_name
22
+ job = payload[:job] || payload[:jobs].first
23
+
24
+ queue = job.queue_name
21
25
  method = method_from_name(name)
22
26
  "Ruby/ActiveJob/#{queue}/#{method}"
23
27
  end
@@ -27,25 +27,12 @@ DependencyDetection.defer do
27
27
  actions = [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
28
28
  actions.each do |operation|
29
29
  if implemented_methods.include?(operation)
30
- add_method_tracer operation, [-> (*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
31
- -> (*) { "ActiveMerchant/gateway/#{gateway_name}" },
32
- -> (*) { "ActiveMerchant/operation/#{operation}" }]
30
+ add_method_tracer operation, [->(*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
31
+ ->(*) { "ActiveMerchant/gateway/#{gateway_name}" },
32
+ ->(*) { "ActiveMerchant/operation/#{operation}" }]
33
33
  end
34
34
  end
35
35
  end
36
36
  end
37
37
  end
38
-
39
- executes do
40
- next unless Gem::Version.new(ActiveMerchant::VERSION) < Gem::Version.new('1.65.0')
41
-
42
- deprecation_msg = 'The Ruby Agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
43
- 'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \
44
-
45
- NewRelic::Agent.logger.log_once(
46
- :warn,
47
- :deprecated_active_merchant_version,
48
- deprecation_msg
49
- )
50
- end
51
38
  end