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
@@ -60,10 +60,13 @@ module NewRelic
60
60
  extra = []
61
61
  options = ARGV.options do |opts|
62
62
  script_name = File.basename($0)
63
- if /newrelic_cmd$/.match?(script_name)
64
- $stdout.puts "warning: the 'newrelic_cmd' script has been renamed 'newrelic'"
65
- script_name = 'newrelic'
63
+
64
+ # TODO: MAJOR VERSION - remove newrelic, deprecated since version x.xx
65
+ if /newrelic$/.match?(script_name)
66
+ $stdout.puts "warning: the 'newrelic' script has been renamed 'newrelic_rpm'"
67
+ script_name = 'newrelic_rpm'
66
68
  end
69
+
67
70
  opts.banner = "Usage: #{script_name} [ #{@command_names.join(' | ')} ] [options]"
68
71
  opts.separator("use '#{script_name} <command> -h' to see detailed command options")
69
72
  opts
@@ -3,15 +3,20 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  module NewRelic
6
+ ASTERISK = '*'
7
+
6
8
  PRIORITY_PRECISION = 6
7
9
 
8
10
  EMPTY_ARRAY = [].freeze
9
11
  EMPTY_HASH = {}.freeze
10
12
  EMPTY_STR = ''
11
13
 
14
+ LANGUAGE = 'ruby'
15
+
12
16
  HTTP = 'HTTP'
13
17
  HTTPS = 'HTTPS'
14
18
  UNKNOWN = 'Unknown'
19
+ UNKNOWN_LOWER = 'unknown'
15
20
 
16
21
  FORMAT_NON_RACK = 0
17
22
  FORMAT_RACK = 1
@@ -35,4 +40,7 @@ module NewRelic
35
40
 
36
41
  CONNECT_RETRY_PERIODS = [15, 15, 30, 60, 120, 300]
37
42
  MAX_RETRY_PERIOD = 300
43
+
44
+ SLASH = '/'
45
+ ROOT = SLASH
38
46
  end
@@ -49,19 +49,13 @@ module NewRelic
49
49
  # maybe it is already loaded by some external system
50
50
  # i.e. rpm_contrib or user extensions?
51
51
  end
52
- NewRelic::Control::Frameworks.const_get(camelize(framework.to_s))
52
+ NewRelic::Control::Frameworks.const_get(NewRelic::LanguageSupport.camelize(framework.to_s))
53
53
  end
54
54
 
55
55
  # The root directory for the plugin or gem
56
56
  def newrelic_root
57
57
  File.expand_path(File.join('..', '..', '..', '..'), __FILE__)
58
58
  end
59
-
60
- def camelize(snake_case_name)
61
- snake_case_name.gsub(/(\_|^)[a-z]/) do |substring|
62
- substring[-1].capitalize!
63
- end
64
- end
65
59
  end
66
60
  extend ClassMethods
67
61
  end
@@ -0,0 +1,14 @@
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 'new_relic/control/frameworks/ruby'
6
+ module NewRelic
7
+ class Control
8
+ module Frameworks
9
+ # Contains basic control logic for Grape
10
+ class Grape < NewRelic::Control::Frameworks::Ruby
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
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 'new_relic/control/frameworks/sinatra'
6
+ module NewRelic
7
+ class Control
8
+ module Frameworks
9
+ # Contains basic control logic for Padrino
10
+ class Padrino < NewRelic::Control::Frameworks::Sinatra
11
+ end
12
+ end
13
+ end
14
+ end
@@ -10,6 +10,9 @@ module NewRelic
10
10
  # Rails specific configuration, instrumentation, environment values,
11
11
  # etc.
12
12
  class Rails < NewRelic::Control::Frameworks::Ruby
13
+ BROWSER_MONITORING_INSTALLED_SINGLETON = NewRelic::Agent.config
14
+ BROWSER_MONITORING_INSTALLED_VARIABLE = :@browser_monitoring_installed
15
+
13
16
  def env
14
17
  @env ||= (ENV['NEW_RELIC_ENV'] || RAILS_ENV.dup)
15
18
  end
@@ -71,7 +74,7 @@ module NewRelic
71
74
  # Might not be running if it does not think mongrel, thin,
72
75
  # passenger, etc. is running, if it thinks it's a rake task, or
73
76
  # if the agent_enabled is false.
74
- ::NewRelic::Agent.logger.info('New Relic Agent not running. Skipping browser monitoring and agent hooks.')
77
+ ::NewRelic::Agent.logger.info('New Relic agent not running. Skipping browser monitoring and agent hooks.')
75
78
  else
76
79
  install_browser_monitoring(rails_config)
77
80
  install_agent_hooks(rails_config)
@@ -89,17 +92,17 @@ module NewRelic
89
92
  return unless NewRelic::Rack::AgentHooks.needed?
90
93
 
91
94
  config.middleware.use(NewRelic::Rack::AgentHooks)
92
- ::NewRelic::Agent.logger.debug('Installed New Relic Agent Hooks middleware')
95
+ ::NewRelic::Agent.logger.debug('Installed New Relic agent hooks middleware')
93
96
  rescue => e
94
- ::NewRelic::Agent.logger.warn('Error installing New Relic Agent Hooks middleware', e)
97
+ ::NewRelic::Agent.logger.warn('Error installing New Relic agent hooks middleware', e)
95
98
  end
96
99
  end
97
100
 
98
101
  def install_browser_monitoring(config)
99
102
  @install_lock.synchronize do
100
- return if defined?(@browser_monitoring_installed) && @browser_monitoring_installed
103
+ return if browser_agent_already_installed?
101
104
 
102
- @browser_monitoring_installed = true
105
+ mark_browser_agent_as_installed
103
106
  return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
104
107
 
105
108
  begin
@@ -112,6 +115,15 @@ module NewRelic
112
115
  end
113
116
  end
114
117
 
118
+ def browser_agent_already_installed?
119
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_defined?(BROWSER_MONITORING_INSTALLED_VARIABLE) &&
120
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_get(BROWSER_MONITORING_INSTALLED_VARIABLE)
121
+ end
122
+
123
+ def mark_browser_agent_as_installed
124
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_set(BROWSER_MONITORING_INSTALLED_VARIABLE, true)
125
+ end
126
+
115
127
  def rails_version
116
128
  @rails_version ||= Gem::Version.new(::Rails::VERSION::STRING)
117
129
  end
@@ -9,9 +9,7 @@ module NewRelic
9
9
  module Frameworks
10
10
  class Rails4 < NewRelic::Control::Frameworks::Rails3
11
11
  def rails_gem_list
12
- Bundler.rubygems.all_specs.map do |gem|
13
- "#{gem.name} (#{gem.version})"
14
- end
12
+ NewRelic::Helper.rubygems_specs.map { |gem| "#{gem.name} (#{gem.version})" }
15
13
  end
16
14
 
17
15
  def append_plugin_list
@@ -0,0 +1,20 @@
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 'new_relic/control/frameworks/ruby'
6
+ module NewRelic
7
+ class Control
8
+ module Frameworks
9
+ # Contains basic control logic for Roda
10
+ class Roda < NewRelic::Control::Frameworks::Ruby
11
+ protected
12
+
13
+ def install_shim
14
+ super
15
+ ::Roda.class_eval { include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -73,9 +73,12 @@ module NewRelic
73
73
  init_config(options)
74
74
  NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
75
75
  init_instrumentation
76
+ init_security_agent
77
+ report_agent_version_metric
76
78
  end
77
79
 
78
80
  def determine_env(options)
81
+ options[:env] = :serverless if local_env.discovered_dispatcher == :serverless
79
82
  env = options[:env] || self.env
80
83
  env = env.to_s
81
84
 
@@ -95,6 +98,12 @@ module NewRelic
95
98
  def configure_agent(env, options)
96
99
  manual = Agent::Configuration::ManualSource.new(options)
97
100
  Agent.config.replace_or_add_config(manual)
101
+
102
+ # if manual config sees serverless mode enabled, then the proc
103
+ # must have returned 'true'. don't bother with YAML and high security
104
+ # in a serverless context
105
+ return if Agent.config[:'serverless_mode.enabled']
106
+
98
107
  yaml_source = Agent::Configuration::YamlSource.new(config_file_path, env)
99
108
  log_yaml_source_failures(yaml_source) if yaml_source.failed?
100
109
  Agent.config.replace_or_add_config(yaml_source)
@@ -163,6 +172,10 @@ module NewRelic
163
172
  def stdout
164
173
  STDOUT
165
174
  end
175
+
176
+ def report_agent_version_metric
177
+ NewRelic::Agent.record_metric_once("Supportability/AgentVersion/newrelic_rpm/#{NewRelic::VERSION::STRING}")
178
+ end
166
179
  end
167
180
  include InstanceMethods
168
181
  end
@@ -62,16 +62,15 @@ module NewRelic
62
62
  File.join(instrumentation_path, app.to_s, '*.rb')
63
63
  @instrumentation_files.each { |pattern| load_instrumentation_files(pattern) }
64
64
  DependencyDetection.detect!
65
- ruby_deprecation
66
65
  rails_32_deprecation
67
66
  ::NewRelic::Agent.logger.info('Finished instrumentation')
68
67
  end
69
68
  end
70
69
 
71
70
  def rails_32_deprecation
72
- return unless defined?(Rails::VERSION) && Gem::Version.new(Rails::VERSION::STRING) <= Gem::Version.new('3.2')
71
+ return unless defined?(Rails::VERSION) && NewRelic::Helper.version_satisfied?(Rails::VERSION::STRING, '<=', '3.2')
73
72
 
74
- deprecation_msg = 'The Ruby Agent is dropping support for Rails 3.2 ' \
73
+ deprecation_msg = 'The Ruby agent is dropping support for Rails 3.2 ' \
75
74
  'in a future major release. Please upgrade your Rails version to continue receiving support. ' \
76
75
 
77
76
  Agent.logger.log_once(
@@ -81,19 +80,6 @@ module NewRelic
81
80
  )
82
81
  end
83
82
 
84
- def ruby_deprecation
85
- return unless RUBY_VERSION < '2.4.0'
86
-
87
- deprecation_msg = 'The Ruby Agent is dropping support for Rubies below 2.4 ' \
88
- 'in version 9.0.0. Please upgrade your Ruby version to continue receiving support. ' \
89
-
90
- ::NewRelic::Agent.logger.log_once(
91
- :warn,
92
- :deprecated_ruby_version,
93
- deprecation_msg
94
- )
95
- end
96
-
97
83
  include Instrumentation
98
84
  end
99
85
  end
@@ -43,6 +43,10 @@ module NewRelic
43
43
  DependencyDetection.detect!
44
44
  end
45
45
  end
46
+
47
+ def init_security_agent
48
+ SecurityInterface.instance.init_agent
49
+ end
46
50
  end
47
51
  end
48
52
  end
@@ -0,0 +1,57 @@
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 'singleton'
6
+
7
+ module NewRelic
8
+ class Control
9
+ class SecurityInterface
10
+ include Singleton
11
+
12
+ attr_accessor :wait
13
+
14
+ SUPPORTABILITY_PREFIX_SECURITY = 'Supportability/Ruby/SecurityAgent/Enabled/'
15
+ SUPPORTABILITY_PREFIX_SECURITY_AGENT = 'Supportability/Ruby/SecurityAgent/Agent/Enabled/'
16
+ ENABLED = 'enabled'
17
+ DISABLED = 'disabled'
18
+
19
+ def agent_started?
20
+ (@agent_started ||= false) == true
21
+ end
22
+
23
+ def waiting?
24
+ (@wait ||= false) == true
25
+ end
26
+
27
+ def init_agent
28
+ return if agent_started? || waiting?
29
+
30
+ record_supportability_metrics
31
+
32
+ if Agent.config[:'security.agent.enabled'] && !Agent.config[:high_security]
33
+ Agent.logger.info('Invoking New Relic security module')
34
+ require 'newrelic_security'
35
+
36
+ @agent_started = true
37
+ else
38
+ Agent.logger.info('New Relic Security is completely disabled by one of the user-provided configurations: `security.agent.enabled` or `high_security`. Not loading security capabilities.')
39
+ Agent.logger.info("high_security = #{Agent.config[:high_security]}")
40
+ Agent.logger.info("security.agent.enabled = #{Agent.config[:'security.agent.enabled']}")
41
+ end
42
+ rescue LoadError
43
+ Agent.logger.info('New Relic security agent not found - skipping')
44
+ rescue StandardError => exception
45
+ Agent.logger.error("Exception in New Relic security module loading: #{exception} #{exception.backtrace}")
46
+ end
47
+
48
+ def record_supportability_metrics
49
+ Agent.config[:'security.agent.enabled'] ? security_agent_metric(ENABLED) : security_agent_metric(DISABLED)
50
+ end
51
+
52
+ def security_agent_metric(setting)
53
+ NewRelic::Agent.record_metric_once(SUPPORTABILITY_PREFIX_SECURITY_AGENT + setting)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -8,7 +8,6 @@ require 'new_relic/local_environment'
8
8
  require 'new_relic/language_support'
9
9
  require 'new_relic/helper'
10
10
 
11
- require 'singleton'
12
11
  require 'erb'
13
12
  require 'socket'
14
13
  require 'net/https'
@@ -18,6 +17,7 @@ require 'new_relic/control/server_methods'
18
17
  require 'new_relic/control/instrumentation'
19
18
  require 'new_relic/control/class_methods'
20
19
  require 'new_relic/control/instance_methods'
20
+ require 'new_relic/control/security_interface'
21
21
 
22
22
  require 'new_relic/agent'
23
23
  require 'new_relic/delayed_job_injection'
@@ -25,9 +25,9 @@ module DependencyDetection
25
25
 
26
26
  def detect!
27
27
  @items.each do |item|
28
- if item.dependencies_satisfied?
29
- item.execute
30
- end
28
+ next if item.executed || item.disabled_configured?
29
+
30
+ item.dependencies_satisfied? ? item.execute : item.configure_as_unsatisfied
31
31
  end
32
32
  end
33
33
 
@@ -62,6 +62,17 @@ module DependencyDetection
62
62
  !executed and check_dependencies
63
63
  end
64
64
 
65
+ def configure_as_unsatisfied
66
+ # TODO: currently using :unsatisfied for Padrino will clobber the value
67
+ # already set for Sinatra, so skip Padrino and circle back with a
68
+ # new Padrino specific solution in the future.
69
+ #
70
+ # https://github.com/newrelic/newrelic-ruby-agent/issues/2912
71
+ return if name == :padrino
72
+
73
+ NewRelic::Agent.config.instance_variable_get(:@cache)[config_key] = :unsatisfied
74
+ end
75
+
65
76
  def source_location_for(klass, method_name)
66
77
  Object.instance_method(:method).bind(klass.allocate).call(method_name).source_location.to_s
67
78
  end
@@ -133,8 +144,6 @@ module DependencyDetection
133
144
  !(disabled_configured? || deprecated_disabled_configured?)
134
145
  end
135
146
 
136
- # TODO: MAJOR VERSION
137
- # will only return true if a disabled key is found and is truthy
138
147
  def deprecated_disabled_configured?
139
148
  return false if self.name.nil?
140
149
 
@@ -142,12 +151,7 @@ module DependencyDetection
142
151
  return false unless ::NewRelic::Agent.config[key] == true
143
152
 
144
153
  ::NewRelic::Agent.logger.debug("Not installing #{self.name} instrumentation because of configuration #{key}")
145
- ::NewRelic::Agent.logger.debug( \
146
- "[DEPRECATED] configuration #{key} for #{self.name} will be removed in the next major release. " \
147
- "Use `#{config_key}` with one of `#{VALID_CONFIG_VALUES.map(&:to_s).inspect}`"
148
- )
149
-
150
- return true
154
+ true
151
155
  end
152
156
 
153
157
  def config_key
@@ -175,10 +179,18 @@ module DependencyDetection
175
179
  # logs the resolved value during debug mode.
176
180
  def fetch_config_value(key)
177
181
  valid_value = valid_config_value(::NewRelic::Agent.config[key].to_s.to_sym)
178
- ::NewRelic::Agent.logger.debug("Using #{valid_value} configuration value for #{self.name} to configure instrumentation")
179
182
  return valid_value
180
183
  end
181
184
 
185
+ # update any :auto config value to be either :prepend or :chain after auto
186
+ # determination has selected one of those to use
187
+ def update_config_value(use_prepend)
188
+ if config_key && auto_configured?
189
+ NewRelic::Agent.config.instance_variable_get(:@cache)[config_key] = use_prepend ? :prepend : :chain
190
+ end
191
+ use_prepend
192
+ end
193
+
182
194
  def config_value
183
195
  return AUTO_CONFIG_VALUE unless config_key
184
196
 
@@ -202,7 +214,7 @@ module DependencyDetection
202
214
  end
203
215
 
204
216
  def use_prepend?
205
- prepend_configured? || (auto_configured? && !prepend_conflicts?)
217
+ update_config_value(prepend_configured? || (auto_configured? && !prepend_conflicts?))
206
218
  end
207
219
 
208
220
  def prepend_conflicts?
@@ -44,7 +44,7 @@ module NewRelic
44
44
  ####################################
45
45
  report_on('Gems') do
46
46
  begin
47
- Bundler.rubygems.all_specs.map { |gem| "#{gem.name}(#{gem.version})" }
47
+ NewRelic::Helper.rubygems_specs.map { |gem| "#{gem.name}(#{gem.version})" }
48
48
  rescue
49
49
  # There are certain rubygem, bundler, rails combinations (e.g. gem
50
50
  # 1.6.2, rails 2.3, bundler 1.2.3) where the code above throws an error
@@ -67,7 +67,7 @@ module NewRelic
67
67
  report_on('Physical Cores') { ::NewRelic::Agent::SystemInfo.num_physical_cores }
68
68
  report_on('Arch') { ::NewRelic::Agent::SystemInfo.processor_arch }
69
69
  report_on('OS version') { ::NewRelic::Agent::SystemInfo.os_version }
70
- report_on('OS') { ::NewRelic::Agent::SystemInfo.ruby_os_identifier }
70
+ report_on('OS') { ::NewRelic::Agent::SystemInfo.os_distribution }
71
71
  report_on('Database adapter') { ::NewRelic::Agent::DatabaseAdapter.value }
72
72
  report_on('Framework') { Agent.config[:framework].to_s }
73
73
  report_on('Dispatcher') { Agent.config[:dispatcher].to_s }
@@ -82,5 +82,27 @@ module NewRelic
82
82
  File.exist?(executable_path) && File.file?(executable_path) && File.executable?(executable_path)
83
83
  end
84
84
  end
85
+
86
+ def version_satisfied?(left, operator, right)
87
+ left = Gem::Version.new(left) unless left.is_a?(Gem::Version)
88
+ right = Gem::Version.new(right) unless right.is_a?(Gem::Version)
89
+
90
+ left.public_send(operator, right)
91
+ end
92
+
93
+ # Bundler version 2.5.12 deprecated all_specs and added installed_specs.
94
+ # To support newer Bundler versions, try to use installed_specs first,
95
+ # then fall back to all_specs.
96
+ # All callers expect this to be an array, so return an array if Bundler isn't defined
97
+ # @api private
98
+ def rubygems_specs
99
+ return [] unless defined?(Bundler)
100
+
101
+ if Bundler.rubygems.respond_to?(:installed_specs)
102
+ Bundler.rubygems.installed_specs
103
+ else
104
+ Bundler.rubygems.all_specs
105
+ end
106
+ end
85
107
  end
86
108
  end
@@ -78,8 +78,19 @@ module NewRelic
78
78
  camelized.split(/\-|\_/).map(&:capitalize).join
79
79
  end
80
80
 
81
+ def camelize_with_first_letter_downcased(string)
82
+ camelized = camelize(string)
83
+ camelized[0].downcase.concat(camelized[1..-1])
84
+ end
85
+
86
+ def snakeize(string)
87
+ string.gsub(/(.)([A-Z])/, '\1_\2').downcase
88
+ end
89
+
81
90
  def bundled_gem?(gem_name)
82
- defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?(gem_name)
91
+ return false unless defined?(Bundler)
92
+
93
+ NewRelic::Helper.rubygems_specs.map(&:name).include?(gem_name)
83
94
  rescue => e
84
95
  ::NewRelic::Agent.logger.info("Could not determine if third party #{gem_name} gem is installed", e)
85
96
  false
@@ -8,7 +8,7 @@ module NewRelic
8
8
  File.join(File.dirname(__FILE__), '..', '..', 'CHANGELOG.md')
9
9
  end
10
10
 
11
- FOOTER = <<'EOS'
11
+ FOOTER = <<EOS
12
12
  See https://github.com/newrelic/newrelic-ruby-agent/blob/main/CHANGELOG.md for a full list of
13
13
  changes.
14
14
  EOS
@@ -60,18 +60,20 @@ module NewRelic
60
60
 
61
61
  def discover_dispatcher
62
62
  dispatchers = %w[
63
+ serverless
64
+ puma
65
+ sidekiq
66
+ falcon
67
+ delayed_job
68
+ unicorn
63
69
  passenger
70
+ resque
64
71
  torquebox
65
72
  trinidad
66
73
  glassfish
67
- resque
68
- sidekiq
69
- delayed_job
70
- puma
71
74
  thin
72
75
  mongrel
73
76
  litespeed
74
- unicorn
75
77
  webrick
76
78
  fastcgi
77
79
  ]
@@ -126,16 +128,21 @@ module NewRelic
126
128
  end
127
129
 
128
130
  def check_for_unicorn
129
- if (defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) && NewRelic::LanguageSupport.object_space_usable?
130
- v = find_class_in_object_space(::Unicorn::HttpServer)
131
- @discovered_dispatcher = :unicorn if v
132
- end
131
+ return unless (defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) &&
132
+ NewRelic::LanguageSupport.object_space_usable?
133
+
134
+ v = find_class_in_object_space(::Unicorn::HttpServer)
135
+ @discovered_dispatcher = :unicorn if v
133
136
  end
134
137
 
135
138
  def check_for_puma
136
- if defined?(::Puma) && File.basename($0) == 'puma'
137
- @discovered_dispatcher = :puma
138
- end
139
+ return unless defined?(::Puma) && File.basename($0) == 'puma'
140
+
141
+ @discovered_dispatcher = :puma
142
+ end
143
+
144
+ def check_for_falcon
145
+ @discovered_dispatcher = :falcon if defined?(::Falcon::Server) && File.basename($PROGRAM_NAME) == 'falcon'
139
146
  end
140
147
 
141
148
  def check_for_delayed_job
@@ -178,15 +185,21 @@ module NewRelic
178
185
  end
179
186
 
180
187
  def check_for_litespeed
181
- if caller.pop.include?('fcgi-bin/RailsRunner.rb')
182
- @discovered_dispatcher = :litespeed
183
- end
188
+ return unless caller.pop.include?('fcgi-bin/RailsRunner.rb')
189
+
190
+ @discovered_dispatcher = :litespeed
184
191
  end
185
192
 
186
193
  def check_for_passenger
187
- if defined?(::PhusionPassenger)
188
- @discovered_dispatcher = :passenger
189
- end
194
+ return unless defined?(::PhusionPassenger)
195
+
196
+ @discovered_dispatcher = :passenger
197
+ end
198
+
199
+ def check_for_serverless
200
+ return unless NewRelic::Agent.config[:'serverless_mode.enabled']
201
+
202
+ @discovered_dispatcher = :serverless
190
203
  end
191
204
 
192
205
  public
@@ -13,7 +13,7 @@ class NewRelic::NoticedError
13
13
  attr_accessor :path, :timestamp, :message, :exception_class_name,
14
14
  :request_uri, :request_port, :file_name, :line_number,
15
15
  :stack_trace, :attributes_from_notice_error, :attributes,
16
- :expected
16
+ :expected, :transaction_id
17
17
 
18
18
  attr_reader :error_group, :exception_id, :is_internal
19
19
 
@@ -45,6 +45,7 @@ class NewRelic::NoticedError
45
45
  @is_internal = (exception.class < NewRelic::Agent::InternalAgentError)
46
46
 
47
47
  extract_class_name_and_message_from(exception)
48
+ @transaction_id = NewRelic::Agent::Tracer&.current_transaction&.guid
48
49
 
49
50
  # clamp long messages to 4k so that we don't send a lot of
50
51
  # overhead across the wire
@@ -79,11 +80,13 @@ class NewRelic::NoticedError
79
80
  include NewRelic::Coerce
80
81
 
81
82
  def to_collector_array(encoder = nil)
82
- [NewRelic::Helper.time_to_millis(timestamp),
83
+ arr = [NewRelic::Helper.time_to_millis(timestamp),
83
84
  string(path),
84
85
  string(message),
85
86
  string(exception_class_name),
86
87
  processed_attributes]
88
+ arr << @transaction_id if @transaction_id
89
+ arr
87
90
  end
88
91
 
89
92
  # Note that we process attributes lazily and store the result. This is because
@@ -23,7 +23,7 @@ module NewRelic::Rack
23
23
  #
24
24
  class AgentHooks < AgentMiddleware
25
25
  def self.needed?
26
- !NewRelic::Agent.config[:disable_middleware_instrumentation]
26
+ NewRelic::Agent.config[:disable_middleware_instrumentation]
27
27
  end
28
28
 
29
29
  def traced_call(env)
@@ -26,22 +26,6 @@ module NewRelic
26
26
  prefix = ::NewRelic::Agent::Instrumentation::ControllerInstrumentation::TransactionNamer.prefix_for_category(nil, @category)
27
27
  "#{prefix}#{self.class.name}/call"
28
28
  end
29
-
30
- # If middleware tracing is disabled, we'll still inject our agent-specific
31
- # middlewares, and still trace those, but we don't want to capture HTTP
32
- # response codes, since middleware that's outside of ours might change the
33
- # response code before it goes back to the client.
34
- def capture_http_response_code(state, result)
35
- return if NewRelic::Agent.config[:disable_middleware_instrumentation]
36
-
37
- super
38
- end
39
-
40
- def capture_response_content_type(state, result)
41
- return if NewRelic::Agent.config[:disable_middleware_instrumentation]
42
-
43
- super
44
- end
45
29
  end
46
30
  end
47
31
  end