newrelic_rpm 8.15.0 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (342) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +26 -0
  3. data/CHANGELOG.md +538 -44
  4. data/CONTRIBUTING.md +1 -1
  5. data/Gemfile +1 -1
  6. data/README.md +11 -6
  7. data/Rakefile +9 -9
  8. data/Thorfile +1 -1
  9. data/bin/newrelic +1 -0
  10. data/bin/newrelic_cmd +1 -0
  11. data/bin/nrdebug +36 -36
  12. data/init.rb +1 -1
  13. data/lib/new_relic/agent/agent.rb +3 -16
  14. data/lib/new_relic/agent/agent_helpers/connect.rb +5 -10
  15. data/lib/new_relic/agent/agent_helpers/harvest.rb +4 -4
  16. data/lib/new_relic/agent/agent_helpers/shutdown.rb +5 -5
  17. data/lib/new_relic/agent/agent_helpers/special_startup.rb +3 -4
  18. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +47 -39
  19. data/lib/new_relic/agent/agent_helpers/startup.rb +13 -13
  20. data/lib/new_relic/agent/agent_helpers/transmit.rb +6 -6
  21. data/lib/new_relic/agent/agent_logger.rb +9 -9
  22. data/lib/new_relic/agent/attribute_filter.rb +2 -4
  23. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  24. data/lib/new_relic/agent/attribute_processing.rb +2 -2
  25. data/lib/new_relic/agent/audit_logger.rb +5 -5
  26. data/lib/new_relic/agent/autostart.rb +1 -1
  27. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  28. data/lib/new_relic/agent/commands/agent_command_router.rb +5 -4
  29. data/lib/new_relic/agent/commands/thread_profiler_session.rb +8 -8
  30. data/lib/new_relic/agent/configuration/default_source.rb +428 -586
  31. data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
  32. data/lib/new_relic/agent/configuration/high_security_source.rb +3 -5
  33. data/lib/new_relic/agent/configuration/manager.rb +16 -2
  34. data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -26
  35. data/lib/new_relic/agent/configuration/server_source.rb +24 -24
  36. data/lib/new_relic/agent/configuration/yaml_source.rb +17 -4
  37. data/lib/new_relic/agent/connect/request_builder.rb +1 -1
  38. data/lib/new_relic/agent/connect/response_handler.rb +1 -1
  39. data/lib/new_relic/agent/custom_event_aggregator.rb +4 -4
  40. data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
  41. data/lib/new_relic/agent/database/obfuscation_helpers.rb +2 -2
  42. data/lib/new_relic/agent/database/obfuscator.rb +2 -2
  43. data/lib/new_relic/agent/database.rb +4 -18
  44. data/lib/new_relic/agent/datastores/metric_helper.rb +5 -5
  45. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -11
  46. data/lib/new_relic/agent/datastores/redis.rb +6 -6
  47. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +8 -10
  48. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -10
  49. data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +7 -7
  50. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
  51. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +6 -6
  52. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +7 -7
  53. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +4 -4
  54. data/lib/new_relic/agent/distributed_tracing.rb +6 -6
  55. data/lib/new_relic/agent/error_collector.rb +36 -8
  56. data/lib/new_relic/agent/error_filter.rb +5 -5
  57. data/lib/new_relic/agent/error_trace_aggregator.rb +5 -4
  58. data/lib/new_relic/agent/event_loop.rb +3 -3
  59. data/lib/new_relic/agent/external.rb +1 -1
  60. data/lib/new_relic/agent/harvester.rb +1 -3
  61. data/lib/new_relic/agent/heap.rb +2 -1
  62. data/lib/new_relic/agent/hostname.rb +1 -1
  63. data/lib/new_relic/agent/http_clients/abstract.rb +9 -21
  64. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
  65. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +7 -3
  66. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
  67. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +7 -5
  68. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +4 -0
  69. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +6 -2
  70. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
  71. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
  72. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +8 -5
  73. data/lib/new_relic/agent/http_clients/uri_util.rb +2 -2
  74. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -19
  75. data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +42 -0
  76. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -2
  77. data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
  78. data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
  79. data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
  80. data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
  81. data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
  82. data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
  83. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +10 -10
  84. data/lib/new_relic/agent/instrumentation/active_job.rb +16 -3
  85. data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
  86. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
  87. data/lib/new_relic/agent/instrumentation/active_record.rb +4 -3
  88. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +38 -36
  89. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +5 -4
  90. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
  91. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +3 -2
  92. data/lib/new_relic/agent/instrumentation/active_storage.rb +4 -0
  93. data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -30
  94. data/lib/new_relic/agent/instrumentation/active_support.rb +21 -6
  95. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  96. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
  97. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  98. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
  99. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  100. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
  101. data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
  102. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  103. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  104. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  105. data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
  106. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  107. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +12 -3
  108. data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
  109. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
  110. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
  111. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
  112. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -6
  113. data/lib/new_relic/agent/instrumentation/curb/chain.rb +1 -1
  114. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +9 -5
  115. data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
  116. data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
  117. data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +2 -1
  118. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
  119. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -1
  120. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -1
  121. data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -2
  122. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +8 -4
  123. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -2
  124. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  125. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  126. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  127. data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
  128. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +5 -1
  129. data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
  130. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +27 -0
  131. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +23 -0
  132. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +25 -0
  133. data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
  134. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +8 -4
  135. data/lib/new_relic/agent/instrumentation/grape.rb +4 -4
  136. data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
  137. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +7 -2
  138. data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
  139. data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
  140. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +8 -4
  141. data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
  142. data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
  143. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  144. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  145. data/lib/new_relic/agent/instrumentation/httprb.rb +1 -1
  146. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  147. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  148. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  149. data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
  150. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
  151. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  152. data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
  153. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +3 -1
  154. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +14 -5
  155. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +3 -1
  156. data/lib/new_relic/agent/instrumentation/memcache.rb +12 -12
  157. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +3 -3
  158. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
  159. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +6 -8
  160. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
  161. data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
  162. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +46 -1
  163. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +7 -3
  164. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
  165. data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
  166. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -1
  167. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +7 -2
  168. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
  169. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +4 -4
  170. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +14 -1
  171. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +12 -15
  172. data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
  173. data/lib/new_relic/agent/instrumentation/redis/constants.rb +1 -1
  174. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +6 -1
  175. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  176. data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
  177. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  178. data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
  179. data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
  180. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  181. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
  182. data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
  183. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
  184. data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
  185. data/lib/new_relic/agent/instrumentation/sequel.rb +8 -9
  186. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +10 -10
  187. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  188. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  189. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  190. data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -3
  191. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
  192. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +10 -5
  193. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -4
  194. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  195. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
  196. data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
  197. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -8
  198. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
  199. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +6 -1
  200. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +10 -6
  201. data/lib/new_relic/agent/javascript_instrumentor.rb +29 -24
  202. data/lib/new_relic/agent/linking_metadata.rb +2 -2
  203. data/lib/new_relic/agent/log_event_aggregator.rb +64 -17
  204. data/lib/new_relic/agent/log_event_attributes.rb +115 -0
  205. data/lib/new_relic/agent/logging.rb +77 -37
  206. data/lib/new_relic/agent/messaging.rb +9 -7
  207. data/lib/new_relic/agent/method_tracer.rb +7 -7
  208. data/lib/new_relic/agent/method_tracer_helpers.rb +27 -6
  209. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -5
  210. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -1
  211. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  212. data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
  213. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
  214. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
  215. data/lib/new_relic/agent/new_relic_service.rb +47 -32
  216. data/lib/new_relic/agent/obfuscator.rb +1 -1
  217. data/lib/new_relic/agent/parameter_filtering.rb +6 -6
  218. data/lib/new_relic/agent/pipe_channel_manager.rb +7 -6
  219. data/lib/new_relic/agent/pipe_service.rb +5 -3
  220. data/lib/new_relic/agent/priority_sampled_buffer.rb +1 -1
  221. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
  222. data/lib/new_relic/agent/rules_engine.rb +1 -1
  223. data/lib/new_relic/agent/sampler.rb +2 -1
  224. data/lib/new_relic/agent/sampler_collection.rb +1 -1
  225. data/lib/new_relic/agent/samplers/cpu_sampler.rb +5 -5
  226. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -9
  227. data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -9
  228. data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
  229. data/lib/new_relic/agent/span_event_aggregator.rb +4 -4
  230. data/lib/new_relic/agent/span_event_primitive.rb +18 -6
  231. data/lib/new_relic/agent/sql_sampler.rb +2 -2
  232. data/lib/new_relic/agent/stats.rb +1 -1
  233. data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
  234. data/lib/new_relic/agent/system_info.rb +36 -10
  235. data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
  236. data/lib/new_relic/agent/threading/backtrace_node.rb +3 -3
  237. data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
  238. data/lib/new_relic/agent/threading/thread_profile.rb +5 -5
  239. data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
  240. data/lib/new_relic/agent/tracer.rb +25 -16
  241. data/lib/new_relic/agent/transaction/abstract_segment.rb +109 -48
  242. data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
  243. data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -6
  244. data/lib/new_relic/agent/transaction/distributed_tracing.rb +13 -14
  245. data/lib/new_relic/agent/transaction/external_request_segment.rb +16 -13
  246. data/lib/new_relic/agent/transaction/message_broker_segment.rb +2 -3
  247. data/lib/new_relic/agent/transaction/request_attributes.rb +47 -11
  248. data/lib/new_relic/agent/transaction/segment.rb +1 -1
  249. data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
  250. data/lib/new_relic/agent/transaction/trace.rb +1 -1
  251. data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
  252. data/lib/new_relic/agent/transaction/trace_node.rb +8 -7
  253. data/lib/new_relic/agent/transaction/tracing.rb +10 -4
  254. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
  255. data/lib/new_relic/agent/transaction.rb +90 -58
  256. data/lib/new_relic/agent/transaction_error_primitive.rb +21 -5
  257. data/lib/new_relic/agent/transaction_event_aggregator.rb +4 -4
  258. data/lib/new_relic/agent/transaction_event_primitive.rb +22 -3
  259. data/lib/new_relic/agent/transaction_sampler.rb +3 -3
  260. data/lib/new_relic/agent/transaction_time_aggregator.rb +7 -3
  261. data/lib/new_relic/agent/utilization/aws.rb +1 -1
  262. data/lib/new_relic/agent/utilization/azure.rb +3 -3
  263. data/lib/new_relic/agent/utilization/gcp.rb +4 -6
  264. data/lib/new_relic/agent/utilization/pcf.rb +1 -1
  265. data/lib/new_relic/agent/utilization/vendor.rb +6 -8
  266. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  267. data/lib/new_relic/agent/vm/mri_vm.rb +9 -8
  268. data/lib/new_relic/agent/worker_loop.rb +1 -1
  269. data/lib/new_relic/agent.rb +133 -36
  270. data/lib/new_relic/cli/command.rb +4 -3
  271. data/lib/new_relic/cli/commands/deployments.rb +26 -25
  272. data/lib/new_relic/cli/commands/install.rb +23 -23
  273. data/lib/new_relic/collection_helper.rb +2 -2
  274. data/lib/new_relic/constants.rb +10 -8
  275. data/lib/new_relic/control/class_methods.rb +4 -10
  276. data/lib/new_relic/control/frameworks/rails.rb +44 -20
  277. data/lib/new_relic/control/frameworks/roda.rb +20 -0
  278. data/lib/new_relic/control/instance_methods.rb +6 -6
  279. data/lib/new_relic/control/instrumentation.rb +1 -15
  280. data/lib/new_relic/control/private_instance_methods.rb +1 -1
  281. data/lib/new_relic/dependency_detection.rb +20 -18
  282. data/lib/new_relic/environment_report.rb +4 -4
  283. data/lib/new_relic/helper.rb +2 -1
  284. data/lib/new_relic/language_support.rb +10 -1
  285. data/lib/new_relic/latest_changes.rb +6 -6
  286. data/lib/new_relic/local_environment.rb +0 -10
  287. data/lib/new_relic/noticed_error.rb +25 -20
  288. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  289. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  290. data/lib/new_relic/rack/browser_monitoring.rb +21 -17
  291. data/lib/new_relic/recipes/capistrano3.rb +1 -1
  292. data/lib/new_relic/recipes/capistrano_legacy.rb +6 -6
  293. data/lib/new_relic/recipes/helpers/send_deployment.rb +5 -5
  294. data/lib/new_relic/supportability_helper.rb +4 -1
  295. data/lib/new_relic/traced_thread.rb +2 -3
  296. data/lib/new_relic/version.rb +2 -2
  297. data/lib/newrelic_rpm.rb +4 -4
  298. data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +6 -6
  299. data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +4 -4
  300. data/lib/tasks/bump_version.rake +21 -0
  301. data/lib/tasks/config.rake +13 -12
  302. data/lib/tasks/coverage_report.rake +4 -4
  303. data/lib/tasks/helpers/config.html.erb +93 -0
  304. data/lib/tasks/helpers/format.rb +19 -15
  305. data/lib/tasks/helpers/newrelicyml.rb +144 -0
  306. data/lib/tasks/helpers/version_bump.rb +62 -0
  307. data/lib/tasks/install.rake +4 -4
  308. data/lib/tasks/instrumentation_generator/instrumentation.thor +16 -19
  309. data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
  310. data/lib/tasks/instrumentation_generator/templates/chain.tt +1 -1
  311. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +1 -1
  312. data/lib/tasks/newrelic.rb +1 -0
  313. data/lib/tasks/newrelicyml.rake +13 -0
  314. data/lib/tasks/tests.rake +77 -6
  315. data/newrelic.yml +393 -274
  316. data/newrelic_rpm.gemspec +41 -30
  317. data/test/agent_helper.rb +25 -24
  318. metadata +172 -35
  319. data/.gitignore +0 -42
  320. data/.project +0 -23
  321. data/.rubocop.yml +0 -1946
  322. data/.rubocop_todo.yml +0 -62
  323. data/.simplecov +0 -15
  324. data/.snyk +0 -11
  325. data/.yardopts +0 -27
  326. data/Brewfile +0 -12
  327. data/DOCKER.md +0 -167
  328. data/Dockerfile +0 -10
  329. data/Guardfile +0 -26
  330. data/config/database.yml +0 -5
  331. data/config.dot +0 -278
  332. data/docker-compose.yml +0 -107
  333. data/lefthook.yml +0 -9
  334. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
  335. data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
  336. data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
  337. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
  338. data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
  339. data/lib/new_relic/agent/range_extensions.rb +0 -27
  340. data/lib/tasks/helpers/removers.rb +0 -33
  341. data/lib/tasks/multiverse.rake +0 -6
  342. data/lib/tasks/multiverse.rb +0 -77
data/docker-compose.yml DELETED
@@ -1,107 +0,0 @@
1
- version: "3.9"
2
- services:
3
- elasticsearch7:
4
- image: elasticsearch:7.16.2
5
- ports:
6
- - "9200:9200"
7
- environment:
8
- - discovery.type=single-node
9
- - bootstrap.memory_lock=true
10
- - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
11
- mem_limit: 1g
12
- elasticsearch8:
13
- image: elasticsearch:8.4.2
14
- ports:
15
- - "9250:9250"
16
- environment:
17
- - discovery.type=single-node
18
- - xpack.security.enabled=false
19
- - http.port=9250
20
- - bootstrap.memory_lock=true
21
- - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
22
- mem_limit: 1g
23
- mysql:
24
- image: mysql:5.7
25
- restart: always
26
- environment:
27
- MYSQL_ROOT_PASSWORD: mysql_root_password
28
- MYSQL_DATABASE: app
29
- expose:
30
- - "3306"
31
- volumes:
32
- - mysql:/var/lib/mysql
33
- rabbitmq:
34
- image: rabbitmq:3.9.12
35
- restart: always
36
- environment:
37
- RABBITMQ_NODENAME: rabbit
38
- expose:
39
- - "5672"
40
- - "15672"
41
- - "25672"
42
- - "4369"
43
- memcached:
44
- image: memcached:1.6.12
45
- restart: always
46
- expose:
47
- - "11211"
48
- mongodb:
49
- image: mongo:5.0.4
50
- restart: always
51
- volumes:
52
- - /data/db
53
- expose:
54
- - "27017"
55
- postgres:
56
- image: postgres:14.2
57
- restart: always
58
- environment:
59
- POSTGRES_USER: admin
60
- POSTGRES_PASSWORD: postgres_password
61
- volumes:
62
- - postgres:/var/lib/postgresql/data
63
- expose:
64
- - "5432"
65
- redis:
66
- image: redis:6.2.6
67
- restart: always
68
- volumes:
69
- - /var/lib/redis
70
- expose:
71
- - "6379"
72
- app:
73
- build:
74
- context: .
75
- args:
76
- - ruby_version=${RUBY_VERSION:-3.1}
77
- image: newrelic_rpm
78
- tty: true
79
- stdin_open: true
80
- environment:
81
- MYSQL_USERNAME: root
82
- MYSQL_PASSWORD: mysql_root_password
83
- DATABASE_NAME: app
84
- MYSQL_HOST: mysql
85
- POSTGRES_USERNAME: admin
86
- POSTGRES_PASSWORD: postgres_password
87
- command: ["irb"]
88
- volumes:
89
- - ".:/usr/src/app"
90
- depends_on:
91
- - elasticsearch7
92
- - elasticsearch8
93
- - mysql
94
- - memcached
95
- - mongodb
96
- - postgres
97
- - rabbitmq
98
- - redis
99
- sysctls:
100
- - "net.ipv6.conf.all.disable_ipv6=0"
101
- volumes:
102
- mongodb:
103
- driver: local
104
- mysql:
105
- driver: local
106
- postgres:
107
- driver: local
data/lefthook.yml DELETED
@@ -1,9 +0,0 @@
1
- # Lefthook (https://github.com/evilmartians/lefthook) is a git hooks manager
2
- # Install it on your machine by running `gem install lefthook`
3
- pre-commit:
4
- parallel: true
5
- commands:
6
- rubocop:
7
- files: git diff --name-only --staged
8
- glob: "*.rb"
9
- run: rubocop --force-exclusion {files}
@@ -1,83 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- require 'new_relic/agent/database'
6
-
7
- module NewRelic
8
- module Instrumentation
9
- module ActsAsSolrInstrumentation
10
- module ParserMethodsInstrumentation
11
- def parse_query_with_newrelic(*args)
12
- self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
13
- begin
14
- parse_query_without_newrelic(*args)
15
- ensure
16
- return unless txn = ::NewRelic::Agent::Tracer.current_transaction
17
-
18
- txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
27
- DependencyDetection.defer do
28
- @name = :acts_as_solr
29
-
30
- depends_on do
31
- defined?(ActsAsSolr)
32
- end
33
-
34
- depends_on do
35
- defined?(ActsAsSolr::ParserMethods)
36
- end
37
-
38
- depends_on do
39
- defined?(ActsAsSolr::ClassMethods)
40
- end
41
-
42
- depends_on do
43
- defined?(ActsAsSolr::CommonMethods)
44
- end
45
-
46
- executes do
47
- NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
48
- deprecation_msg = 'The instrumentation for ActsAsSolr is deprecated. ' \
49
- 'It will be removed in version 9.0.0.' \
50
-
51
- NewRelic::Agent.logger.log_once(
52
- :warn,
53
- :deprecated_acts_as_solr,
54
- deprecation_msg
55
- )
56
- end
57
-
58
- executes do
59
- ActsAsSolr::ParserMethods.module_eval do
60
- include NewRelic::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
61
- alias :parse_query_without_newrelic :parse_query
62
- alias :parse_query :parse_query_with_newrelic
63
- end
64
- end
65
-
66
- executes do
67
- ActsAsSolr::ClassMethods.module_eval do
68
- %w[find_by_solr find_id_by_solr multi_solr_search count_by_solr].each do |method|
69
- add_method_tracer method, 'SolrClient/ActsAsSolr/query'
70
- end
71
- add_method_tracer :rebuild_solr_index, 'SolrClient/ActsAsSolr/index'
72
- end
73
- end
74
-
75
- executes do
76
- ActsAsSolr::CommonMethods.module_eval do
77
- add_method_tracer :solr_add, 'SolrClient/ActsAsSolr/add'
78
- add_method_tracer :solr_delete, 'SolrClient/ActsAsSolr/delete'
79
- add_method_tracer :solr_commit, 'SolrClient/ActsAsSolr/commit'
80
- add_method_tracer :solr_optimize, 'SolrClient/ActsAsSolr/optimize'
81
- end
82
- end
83
- end
@@ -1,33 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- DependencyDetection.defer do
6
- @name = :authlogic
7
-
8
- depends_on do
9
- defined?(Authlogic) &&
10
- defined?(Authlogic::Session) &&
11
- defined?(Authlogic::Session::Base)
12
- end
13
-
14
- executes do
15
- NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
16
- deprecation_msg = 'The instrumentation for Authlogic is deprecated. ' \
17
- 'It will be removed in version 9.0.0.' \
18
-
19
- NewRelic::Agent.logger.log_once(
20
- :warn,
21
- :deprecated_authlogic,
22
- deprecation_msg
23
- )
24
- end
25
-
26
- executes do
27
- Authlogic::Session::Base.class_eval do
28
- class << self
29
- add_method_tracer :find, 'Custom/Authlogic/find'
30
- end
31
- end
32
- end
33
- end
@@ -1,215 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- DependencyDetection.defer do
6
- named :data_mapper
7
-
8
- depends_on do
9
- defined?(DataMapper) &&
10
- defined?(DataMapper::Model) &&
11
- defined?(DataMapper::Resource) &&
12
- defined?(DataMapper::Collection)
13
- end
14
-
15
- executes do
16
- NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
17
- require 'new_relic/agent/datastores/metric_helper'
18
-
19
- deprecation_msg = 'The instrumentation for DataMapper is deprecated. ' \
20
- 'It will be removed in version 9.0.0.' \
21
- 'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks ' \
22
- 'to learn about supported gems.'
23
-
24
- NewRelic::Agent.logger.log_once(
25
- :warn,
26
- :deprecated_datamapper,
27
- deprecation_msg
28
- )
29
- end
30
-
31
- executes do
32
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :get)
33
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :first)
34
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :last)
35
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :all)
36
-
37
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create)
38
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create!)
39
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update)
40
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update!)
41
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy)
42
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy!)
43
-
44
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :aggregate)
45
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find)
46
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find_by_sql)
47
- end
48
-
49
- executes do
50
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update)
51
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update!)
52
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save)
53
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save!)
54
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy)
55
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy!)
56
- end
57
-
58
- executes do
59
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :get)
60
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :first)
61
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :last)
62
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :all)
63
-
64
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
65
-
66
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create)
67
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create!)
68
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update)
69
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update!)
70
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy)
71
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy!)
72
-
73
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :aggregate)
74
- end
75
-
76
- executes do
77
- # Catch direct SQL calls that bypass CRUD
78
- if defined?(DataMapper::Adapters::DataObjectsAdapter)
79
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :select, true)
80
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :execute, true)
81
- end
82
- end
83
-
84
- executes do
85
- # DM::Validations overrides Model#create, so we patch it here as well
86
- if defined?(DataMapper::Validations::ClassMethods)
87
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Validations::ClassMethods, :create)
88
- end
89
- end
90
-
91
- executes do
92
- # DM::Transaction calls commit() twice, so potentially shows up twice.
93
- if defined?(DataMapper::Transaction)
94
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Transaction, :commit, true)
95
- end
96
- end
97
-
98
- executes do
99
- if defined?(DataObjects::Connection)
100
- DataObjects::Connection.class_eval do
101
- include NewRelic::Agent::Instrumentation::DataMapperInstrumentation
102
- end
103
- end
104
- end
105
- end
106
-
107
- module NewRelic
108
- module Agent
109
- module DataMapperTracing
110
- def self.add_tracer(clazz, method_name, operation_only = false)
111
- clazz.class_eval do
112
- if method_defined?(method_name) || private_method_defined?(method_name)
113
- define_method("#{method_name}_with_newrelic",
114
- NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
115
-
116
- alias_method("#{method_name}_without_newrelic", method_name)
117
- alias_method(method_name, "#{method_name}_with_newrelic")
118
- end
119
- end
120
- end
121
-
122
- DATA_MAPPER = "DataMapper".freeze
123
- PASSWORD_REGEX = /&password=.*?(&|$)/
124
- AMPERSAND = '&'.freeze
125
- PASSWORD_PARAM = '&password='.freeze
126
-
127
- def self.method_body(clazz, method_name, operation_only)
128
- use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
129
- metric_operation = method_name.to_s.gsub(/[!?]/, "")
130
-
131
- proc do |*args, &blk|
132
- begin
133
- if operation_only
134
- # Used by direct SQL, like ::DataMapper::Adapters::DataObjectsAdapter#select
135
- name = nil
136
- elsif use_model_name
137
- # Used by ::DataMapper::Collection to get contained model name
138
- name = self.model.name
139
- elsif self.is_a?(Class)
140
- # Used by class-style access, like Model.first()
141
- name = self.name
142
- else
143
- # Used by instance-style access, like model.update(attr: "new")
144
- name = self.class.name
145
- end
146
-
147
- segment = NewRelic::Agent::Tracer.start_datastore_segment(
148
- product: DATA_MAPPER,
149
- operation: metric_operation,
150
- collection: name
151
- )
152
-
153
- begin
154
- NewRelic::Agent::Tracer.capture_segment_error(segment) do
155
- self.send("#{method_name}_without_newrelic", *args, &blk)
156
- end
157
- rescue ::DataObjects::ConnectionError => e
158
- raise
159
- rescue ::DataObjects::SQLError => e
160
- e.uri.gsub!(PASSWORD_REGEX, AMPERSAND) if e.uri.include?(PASSWORD_PARAM)
161
-
162
- strategy = NewRelic::Agent::Database.record_sql_method(:slow_sql)
163
- case strategy
164
- when :obfuscated
165
- adapter_name = if self.respond_to?(:options)
166
- self.options[:adapter]
167
- else
168
- if self.repository.adapter.respond_to?(:options)
169
- self.repository.adapter.options[:adapter]
170
- else
171
- # DataMapper < 0.10.0
172
- self.repository.adapter.uri.scheme
173
- end
174
- end
175
- statement = NewRelic::Agent::Database::Statement.new(e.query, :adapter => adapter_name)
176
- obfuscated_sql = NewRelic::Agent::Database.obfuscate_sql(statement)
177
- e.instance_variable_set(:@query, obfuscated_sql)
178
- when :off
179
- e.instance_variable_set(:@query, nil)
180
- end
181
-
182
- raise
183
- ensure
184
- ::NewRelic::Agent::Transaction::Segment.finish(segment)
185
- end
186
- end
187
- end
188
- end
189
- end
190
-
191
- module Instrumentation
192
- module DataMapperInstrumentation
193
- # Unlike in AR, log is called in DM after the query actually ran,
194
- # complete with metrics. Since DO has already calculated the
195
- # duration, there's nothing more to measure, so just record and log.
196
- #
197
- # We rely on the assumption that all possible entry points have been
198
- # hooked with tracers, ensuring that notice_sql attaches this SQL to
199
- # the proper call scope.
200
- def log(msg) # THREAD_LOCAL_ACCESS
201
- state = NewRelic::Agent::Tracer.state
202
- return unless state.is_execution_traced?
203
-
204
- txn = state.current_transaction
205
-
206
- if txn && txn.current_segment.respond_to?(:notice_sql)
207
- txn.current_segment.notice_sql(msg.query)
208
- end
209
- ensure
210
- super
211
- end
212
- end
213
- end
214
- end
215
- end
@@ -1,36 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- DependencyDetection.defer do
6
- @name = :rainbows
7
-
8
- depends_on do
9
- defined?(Rainbows) && defined?(Rainbows::HttpServer)
10
- end
11
-
12
- executes do
13
- NewRelic::Agent.logger.info('Installing Rainbows instrumentation')
14
- NewRelic::Agent.logger.info('Detected Rainbows, please see additional documentation: https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data')
15
-
16
- deprecation_msg = 'The dispatcher rainbows is deprecated. It will be removed ' \
17
- 'in version 9.0.0. Please use a supported dispatcher instead. ' \
18
- 'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks for options.'
19
-
20
- NewRelic::Agent.logger.log_once(
21
- :warn,
22
- :deprecated_rainbows_dispatcher,
23
- deprecation_msg
24
- )
25
- end
26
-
27
- executes do
28
- Rainbows::HttpServer.class_eval do
29
- old_worker_loop = instance_method(:worker_loop)
30
- define_method(:worker_loop) do |worker|
31
- NewRelic::Agent.after_fork(:force_reconnect => true)
32
- old_worker_loop.bind(self).call(worker)
33
- end
34
- end
35
- end
36
- end
@@ -1,41 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- DependencyDetection.defer do
6
- @name = :sunspot
7
-
8
- depends_on do
9
- defined?(Sunspot)
10
- end
11
-
12
- executes do
13
- NewRelic::Agent.logger.info('Installing Rails Sunspot instrumentation')
14
- deprecation_msg = 'The instrumentation for Sunspot is deprecated. ' \
15
- 'It will be removed in version 9.0.0.'
16
-
17
- NewRelic::Agent.logger.log_once(
18
- :warn,
19
- :deprecated_sunspot,
20
- deprecation_msg
21
- )
22
- end
23
-
24
- executes do
25
- Sunspot.module_eval do
26
- class << self
27
- %w[index index!].each do |method|
28
- add_method_tracer method, 'SolrClient/Sunspot/index'
29
- end
30
- add_method_tracer :commit, 'SolrClient/Sunspot/commit'
31
-
32
- %w[search more_like_this].each do |method|
33
- add_method_tracer method, 'SolrClient/Sunspot/query'
34
- end
35
- %w[remove remove! remove_by_id remove_by_id! remove_all remove_all!].each do |method|
36
- add_method_tracer method, 'SolrClient/Sunspot/delete'
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,27 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- module NewRelic
6
- module Agent
7
- module RangeExtensions
8
- module_function
9
-
10
- def intersects?(r1, r2)
11
- r1.begin > r2.begin ? r2.cover?(r1.begin) : r1.cover?(r2.begin)
12
- end
13
-
14
- # Computes the amount of overlap between range and an array of ranges.
15
- # For efficiency, it assumes that range intersects with each of the
16
- # ranges in the ranges array.
17
- def compute_overlap(range, ranges)
18
- ranges.inject(0) do |memo, other|
19
- next memo unless intersects?(range, other)
20
-
21
- memo += ([range.end, other.end].min) -
22
- ([range.begin, other.begin].max)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- module Removers
6
- def remove_local_multiverse_databases
7
- list_databases_command = %(echo "show databases" | mysql -u root)
8
- databases = `#{list_databases_command}`.chomp!.split("\n").select { |s| s.include?('multiverse') }
9
- databases.each do |database|
10
- puts "Dropping #{database}"
11
- `echo "drop database #{database}" | mysql -u root`
12
- end
13
- rescue => error
14
- puts "ERROR: Cannot get MySQL databases..."
15
- puts error.message
16
- end
17
-
18
- def remove_generated_gemfiles
19
- file_path = File.expand_path("test/multiverse/suites")
20
- Dir.glob(File.join(file_path, "**", "Gemfile*")).each do |fn|
21
- puts "Removing #{fn.gsub(file_path, '.../suites')}"
22
- FileUtils.rm(fn)
23
- end
24
- end
25
-
26
- def remove_generated_gemfile_lockfiles
27
- file_path = File.expand_path("test/environments")
28
- Dir.glob(File.join(file_path, "**", "Gemfile.lock")).each do |fn|
29
- puts "Removing #{fn.gsub(file_path, '.../environments')}"
30
- FileUtils.rm(fn)
31
- end
32
- end
33
- end
@@ -1,6 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
-
5
- # Guts of task are in a .rb file to allow requiring from external gems
6
- require "#{File.join(File.dirname(__FILE__))}/multiverse"
@@ -1,77 +0,0 @@
1
- # This file is distributed under New Relic's license terms.
2
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
- # frozen_string_literal: true
4
- #
5
- # Rake task for running Ruby agent multiverse tests. This file may be required
6
- # from third party gems. It is also used by the agent itself to run multiverse.
7
- #
8
- # Multiverse tests are grouped in (potentially multiverse) "suite" directories.
9
- # These suites are found by default under ./test/multiverse. That location can
10
- # be overridden with ENV['SUITES_DIRECTORY'].
11
- #
12
- # The first parameter to this task is a suite directory name to run. If
13
- # excluded, multiverse will run all suites it finds.
14
- #
15
- # Additional parameters are allowed to multiverse. Many parameters can be
16
- # combined.
17
- #
18
- # Some examples:
19
- #
20
- # # Runs ./test/multiverse/*
21
- # bundle exec rake test:multiverse
22
- #
23
- # # Runs ./test/multiverse/my_gem
24
- # bundle exec rake test:multiverse[my_gem]
25
- #
26
- # # With verbose logging and debugging via pry
27
- # bundle exec rake test:multiverse[my_gem,verbose,debug]
28
- #
29
- # # Runs only first set of gems defined in my_gem's Envfile
30
- # bundle exec rake test:multiverse[my_gem,env=0]
31
- #
32
- # # Runs tests matching the passed name (via Minitest's built-in filtering)
33
- # bundle exec rake test:multiverse[my_gem,name=MyGemTest]
34
- #
35
- # # Runs with a specific test seed
36
- # bundle exec rake test:multiverse[my_gem,seed=1337]
37
-
38
- require_relative 'helpers/removers'
39
- include Removers
40
-
41
- namespace :test do
42
- desc "Run functional test suite for New Relic"
43
- task :multiverse, [:suite, :param1, :param2, :param3, :param4] => ['multiverse:env'] do |_, args|
44
- Multiverse::Runner.run(args.suite, Multiverse::Runner.parse_args(args))
45
- end
46
-
47
- namespace :multiverse do
48
- task :env do
49
- # ENV['SUITES_DIRECTORY'] = File.expand_path('../../test/multiverse/suites', __FILE__)
50
- require File.expand_path('../../../test/multiverse/lib/multiverse', __FILE__)
51
- end
52
-
53
- task :clobber do
54
- remove_local_multiverse_databases
55
- remove_generated_gemfiles
56
- remove_generated_gemfile_lockfiles
57
- end
58
-
59
- desc "Clean cached gemfiles from Bundler.bundle_path"
60
- task :clean_gemfile_cache do
61
- glob = File.expand_path('multiverse-cache/Gemfile.*.lock', Bundler.bundle_path)
62
- File.delete(*Dir[glob])
63
- end
64
-
65
- desc "Test the multiverse testing framework by executing tests in test/multiverse/test. Get meta with it."
66
- task :self, [:suite, :mode] do |_, args|
67
- args.with_defaults(:suite => "", :mode => "")
68
- puts ("Testing the multiverse testing framework...")
69
- test_files = FileList['test/multiverse/test/*_test.rb']
70
- ruby test_files.join(" ")
71
- end
72
-
73
- task :prime, [:suite] => [:env] do |_, args|
74
- Multiverse::Runner.prime(args.suite, Multiverse::Runner.parse_args(args))
75
- end
76
- end
77
- end