newrelic_rpm 7.0.0 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rubocop.yml +1941 -0
  4. data/.yardopts +1 -0
  5. data/Brewfile +10 -0
  6. data/CHANGELOG.md +431 -1
  7. data/CONTRIBUTING.md +32 -5
  8. data/DOCKER.md +167 -0
  9. data/Dockerfile +10 -0
  10. data/Guardfile +8 -8
  11. data/LICENSE +0 -6
  12. data/README.md +20 -18
  13. data/Rakefile +39 -29
  14. data/THIRD_PARTY_NOTICES.md +14 -199
  15. data/bin/mongrel_rpm +8 -9
  16. data/bin/newrelic +1 -1
  17. data/bin/nrdebug +14 -14
  18. data/docker-compose.yml +85 -0
  19. data/init.rb +0 -2
  20. data/lefthook.yml +9 -0
  21. data/lib/new_relic/agent/adaptive_sampler.rb +9 -5
  22. data/lib/new_relic/agent/agent.rb +72 -49
  23. data/lib/new_relic/agent/agent_logger.rb +15 -9
  24. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  25. data/lib/new_relic/agent/attributes.rb +2 -2
  26. data/lib/new_relic/agent/audit_logger.rb +4 -0
  27. data/lib/new_relic/agent/autostart.rb +19 -17
  28. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  29. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  30. data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -6
  31. data/lib/new_relic/agent/configuration/default_source.rb +731 -476
  32. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  33. data/lib/new_relic/agent/configuration/environment_source.rb +5 -4
  34. data/lib/new_relic/agent/configuration/event_harvest_config.rb +39 -16
  35. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  36. data/lib/new_relic/agent/configuration/manager.rb +74 -64
  37. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  38. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  39. data/lib/new_relic/agent/configuration/server_source.rb +14 -12
  40. data/lib/new_relic/agent/configuration/yaml_source.rb +26 -5
  41. data/lib/new_relic/agent/connect/request_builder.rb +14 -15
  42. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  43. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -9
  44. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  45. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  46. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  47. data/lib/new_relic/agent/database.rb +30 -31
  48. data/lib/new_relic/agent/datastores/metric_helper.rb +13 -11
  49. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  50. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  51. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  52. data/lib/new_relic/agent/datastores/mongo.rb +5 -10
  53. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  54. data/lib/new_relic/agent/datastores.rb +7 -9
  55. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +9 -9
  56. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +21 -16
  57. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -12
  58. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +42 -43
  59. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
  60. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
  61. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +25 -25
  62. data/lib/new_relic/agent/distributed_tracing.rb +17 -18
  63. data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
  64. data/lib/new_relic/agent/error_collector.rb +65 -50
  65. data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
  66. data/lib/new_relic/agent/error_filter.rb +173 -0
  67. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
  68. data/lib/new_relic/agent/event_aggregator.rb +1 -1
  69. data/lib/new_relic/agent/event_buffer.rb +6 -7
  70. data/lib/new_relic/agent/event_listener.rb +0 -1
  71. data/lib/new_relic/agent/event_loop.rb +14 -14
  72. data/lib/new_relic/agent/external.rb +1 -34
  73. data/lib/new_relic/agent/guid_generator.rb +2 -9
  74. data/lib/new_relic/agent/harvester.rb +3 -4
  75. data/lib/new_relic/agent/heap.rb +1 -3
  76. data/lib/new_relic/agent/hostname.rb +16 -10
  77. data/lib/new_relic/agent/http_clients/abstract.rb +7 -9
  78. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
  79. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
  80. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
  81. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
  82. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +8 -3
  83. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
  84. data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
  85. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
  86. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +28 -26
  87. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  88. data/lib/new_relic/agent/instrumentation/active_job.rb +12 -5
  89. data/lib/new_relic/agent/instrumentation/active_merchant.rb +17 -3
  90. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
  91. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +56 -46
  92. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
  93. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
  94. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +22 -16
  95. data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
  96. data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +23 -0
  97. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +20 -0
  98. data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +12 -0
  99. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +24 -0
  100. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +18 -9
  101. data/lib/new_relic/agent/instrumentation/authlogic.rb +10 -0
  102. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  103. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +8 -9
  104. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +52 -46
  105. data/lib/new_relic/agent/instrumentation/curb/chain.rb +20 -21
  106. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  107. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +10 -11
  108. data/lib/new_relic/agent/instrumentation/data_mapper.rb +22 -10
  109. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  110. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
  111. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +23 -4
  112. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  113. data/lib/new_relic/agent/instrumentation/excon.rb +3 -23
  114. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  115. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  116. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  117. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  118. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  119. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  120. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  121. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  122. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  123. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  124. data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
  125. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
  126. data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
  127. data/lib/new_relic/agent/instrumentation/logger.rb +26 -0
  128. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
  129. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
  130. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
  131. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  132. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +5 -6
  133. data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
  134. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
  135. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
  136. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
  137. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
  138. data/lib/new_relic/agent/instrumentation/net_http.rb +7 -2
  139. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
  140. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
  141. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
  142. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +2 -2
  143. data/lib/new_relic/agent/instrumentation/padrino.rb +2 -5
  144. data/lib/new_relic/agent/instrumentation/queue_time.rb +8 -8
  145. data/lib/new_relic/agent/instrumentation/rack/chain.rb +8 -7
  146. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +2 -1
  147. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
  148. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -2
  149. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  150. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +11 -47
  151. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
  152. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
  153. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +11 -0
  154. data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
  155. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
  156. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  157. data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
  158. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
  159. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
  160. data/lib/new_relic/agent/instrumentation/redis.rb +5 -1
  161. data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
  162. data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
  163. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +9 -7
  164. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
  165. data/lib/new_relic/agent/instrumentation/resque.rb +17 -8
  166. data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
  167. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
  168. data/lib/new_relic/agent/instrumentation/sidekiq.rb +22 -1
  169. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
  170. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +12 -5
  171. data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -11
  172. data/lib/new_relic/agent/instrumentation/sunspot.rb +11 -1
  173. data/lib/new_relic/agent/instrumentation/thread/chain.rb +24 -0
  174. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +27 -0
  175. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +22 -0
  176. data/lib/new_relic/agent/instrumentation/thread.rb +20 -0
  177. data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
  178. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +40 -0
  179. data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
  180. data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
  181. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
  182. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
  183. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
  184. data/lib/new_relic/agent/internal_agent_error.rb +1 -1
  185. data/lib/new_relic/agent/javascript_instrumentor.rb +38 -33
  186. data/lib/new_relic/agent/linking_metadata.rb +45 -0
  187. data/lib/new_relic/agent/local_log_decorator.rb +37 -0
  188. data/lib/new_relic/agent/log_event_aggregator.rb +234 -0
  189. data/lib/new_relic/agent/log_priority.rb +20 -0
  190. data/lib/new_relic/agent/logging.rb +11 -8
  191. data/lib/new_relic/agent/memory_logger.rb +1 -1
  192. data/lib/new_relic/agent/messaging.rb +46 -62
  193. data/lib/new_relic/agent/method_tracer.rb +145 -144
  194. data/lib/new_relic/agent/method_tracer_helpers.rb +82 -2
  195. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +21 -13
  196. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
  197. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
  198. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
  199. data/lib/new_relic/agent/monitors.rb +1 -2
  200. data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
  201. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
  202. data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
  203. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
  204. data/lib/new_relic/agent/new_relic_service.rb +61 -53
  205. data/lib/new_relic/agent/noticible_error.rb +0 -2
  206. data/lib/new_relic/agent/null_logger.rb +6 -2
  207. data/lib/new_relic/agent/obfuscator.rb +6 -8
  208. data/lib/new_relic/agent/parameter_filtering.rb +16 -8
  209. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  210. data/lib/new_relic/agent/pipe_channel_manager.rb +15 -12
  211. data/lib/new_relic/agent/pipe_service.rb +6 -3
  212. data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
  213. data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
  214. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
  215. data/lib/new_relic/agent/rules_engine.rb +2 -2
  216. data/lib/new_relic/agent/sampler.rb +2 -3
  217. data/lib/new_relic/agent/sampler_collection.rb +2 -3
  218. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  219. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +10 -7
  220. data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -3
  221. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  222. data/lib/new_relic/agent/span_event_aggregator.rb +10 -10
  223. data/lib/new_relic/agent/span_event_primitive.rb +48 -45
  224. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  225. data/lib/new_relic/agent/stats.rb +62 -37
  226. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  227. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  228. data/lib/new_relic/agent/stats_engine.rb +7 -7
  229. data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -2
  230. data/lib/new_relic/agent/system_info.rb +22 -20
  231. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  232. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  233. data/lib/new_relic/agent/threading/backtrace_service.rb +12 -13
  234. data/lib/new_relic/agent/threading/thread_profile.rb +16 -19
  235. data/lib/new_relic/agent/tracer.rb +57 -72
  236. data/lib/new_relic/agent/transaction/abstract_segment.rb +38 -10
  237. data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
  238. data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
  239. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  240. data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
  241. data/lib/new_relic/agent/transaction/message_broker_segment.rb +24 -30
  242. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  243. data/lib/new_relic/agent/transaction/segment.rb +6 -3
  244. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  245. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  246. data/lib/new_relic/agent/transaction/trace_context.rb +14 -16
  247. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  248. data/lib/new_relic/agent/transaction/tracing.rb +9 -6
  249. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  250. data/lib/new_relic/agent/transaction.rb +132 -119
  251. data/lib/new_relic/agent/transaction_error_primitive.rb +18 -16
  252. data/lib/new_relic/agent/transaction_event_aggregator.rb +7 -8
  253. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  254. data/lib/new_relic/agent/transaction_event_recorder.rb +1 -1
  255. data/lib/new_relic/agent/transaction_metrics.rb +8 -7
  256. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  257. data/lib/new_relic/agent/transaction_time_aggregator.rb +11 -11
  258. data/lib/new_relic/agent/utilization/aws.rb +32 -2
  259. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  260. data/lib/new_relic/agent/utilization/vendor.rb +15 -2
  261. data/lib/new_relic/agent/utilization_data.rb +3 -4
  262. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  263. data/lib/new_relic/agent/vm/mri_vm.rb +13 -1
  264. data/lib/new_relic/agent/vm/snapshot.rb +4 -4
  265. data/lib/new_relic/agent/worker_loop.rb +8 -10
  266. data/lib/new_relic/agent.rb +36 -41
  267. data/lib/new_relic/cli/command.rb +15 -17
  268. data/lib/new_relic/cli/commands/deployments.rb +21 -23
  269. data/lib/new_relic/cli/commands/install.rb +6 -10
  270. data/lib/new_relic/coerce.rb +5 -8
  271. data/lib/new_relic/collection_helper.rb +48 -47
  272. data/lib/new_relic/constants.rb +0 -4
  273. data/lib/new_relic/control/class_methods.rb +2 -2
  274. data/lib/new_relic/control/frameworks/external.rb +1 -1
  275. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  276. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  277. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  278. data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
  279. data/lib/new_relic/control/instance_methods.rb +4 -5
  280. data/lib/new_relic/control/instrumentation.rb +35 -5
  281. data/lib/new_relic/control/server_methods.rb +2 -3
  282. data/lib/new_relic/control.rb +0 -1
  283. data/lib/new_relic/dependency_detection.rb +7 -9
  284. data/lib/new_relic/environment_report.rb +16 -18
  285. data/lib/new_relic/helper.rb +45 -5
  286. data/lib/new_relic/language_support.rb +20 -2
  287. data/lib/new_relic/latest_changes.rb +2 -2
  288. data/lib/new_relic/local_environment.rb +9 -7
  289. data/lib/new_relic/metric_data.rb +6 -7
  290. data/lib/new_relic/metric_spec.rb +3 -3
  291. data/lib/new_relic/noticed_error.rb +18 -19
  292. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  293. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  294. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  295. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  296. data/lib/new_relic/supportability_helper.rb +2 -2
  297. data/lib/new_relic/traced_thread.rb +35 -0
  298. data/lib/new_relic/version.rb +5 -16
  299. data/lib/newrelic_rpm.rb +10 -34
  300. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  301. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  302. data/lib/tasks/all.rb +2 -2
  303. data/lib/tasks/config.html.erb +14 -25
  304. data/lib/tasks/config.rake +36 -27
  305. data/lib/tasks/multiverse.rb +4 -6
  306. data/lib/tasks/tests.rake +3 -7
  307. data/newrelic.yml +610 -3
  308. data/newrelic_rpm.gemspec +14 -14
  309. data/recipes/newrelic.rb +1 -1
  310. data/test/agent_helper.rb +98 -59
  311. metadata +69 -20
  312. data/ROADMAP.md +0 -24
  313. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
  314. data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
  315. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
  316. data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
  317. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
  318. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
  319. data/lib/new_relic/agent/supported_versions.rb +0 -275
  320. data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -13,7 +13,6 @@ module NewRelic
13
13
  # Additional logic can be registered by using the EnvironmentReport.report_on
14
14
  # hook.
15
15
  class EnvironmentReport
16
-
17
16
  # This is the main interface for registering logic that should be included
18
17
  # in the Environment Report. For example:
19
18
  #
@@ -57,23 +56,23 @@ module NewRelic
57
56
  end
58
57
  end
59
58
  end
60
- report_on('Plugin List' ) { ::Rails.configuration.plugins.to_a }
61
- report_on('Ruby version' ) { RUBY_VERSION }
62
- report_on('Ruby description' ) { RUBY_DESCRIPTION }
63
- report_on('Ruby platform' ) { RUBY_PLATFORM }
64
- report_on('Ruby patchlevel' ) { RUBY_PATCHLEVEL.to_s }
65
- report_on('JRuby version' ) { JRUBY_VERSION }
66
- report_on('Java VM version' ) { ENV_JAVA['java.vm.version'] }
59
+ report_on('Plugin List') { ::Rails.configuration.plugins.to_a }
60
+ report_on('Ruby version') { RUBY_VERSION }
61
+ report_on('Ruby description') { RUBY_DESCRIPTION }
62
+ report_on('Ruby platform') { RUBY_PLATFORM }
63
+ report_on('Ruby patchlevel') { RUBY_PATCHLEVEL.to_s }
64
+ report_on('JRuby version') { JRUBY_VERSION }
65
+ report_on('Java VM version') { ENV_JAVA['java.vm.version'] }
67
66
  report_on('Logical Processors') { ::NewRelic::Agent::SystemInfo.num_logical_processors }
68
- report_on('Physical Cores' ) { ::NewRelic::Agent::SystemInfo.num_physical_cores }
69
- report_on('Arch' ) { ::NewRelic::Agent::SystemInfo.processor_arch }
70
- report_on('OS version' ) { ::NewRelic::Agent::SystemInfo.os_version }
71
- report_on('OS' ) { ::NewRelic::Agent::SystemInfo.ruby_os_identifier }
72
- report_on('Database adapter' ) { ::NewRelic::Agent::DatabaseAdapter.value }
73
- report_on('Framework' ) { Agent.config[:framework].to_s }
74
- report_on('Dispatcher' ) { Agent.config[:dispatcher].to_s }
75
- report_on('Environment' ) { NewRelic::Control.instance.env }
76
- report_on('Rails version' ) { ::Rails::VERSION::STRING }
67
+ report_on('Physical Cores') { ::NewRelic::Agent::SystemInfo.num_physical_cores }
68
+ report_on('Arch') { ::NewRelic::Agent::SystemInfo.processor_arch }
69
+ report_on('OS version') { ::NewRelic::Agent::SystemInfo.os_version }
70
+ report_on('OS') { ::NewRelic::Agent::SystemInfo.ruby_os_identifier }
71
+ report_on('Database adapter') { ::NewRelic::Agent::DatabaseAdapter.value }
72
+ report_on('Framework') { Agent.config[:framework].to_s }
73
+ report_on('Dispatcher') { Agent.config[:dispatcher].to_s }
74
+ report_on('Environment') { NewRelic::Control.instance.env }
75
+ report_on('Rails version') { ::Rails::VERSION::STRING }
77
76
  report_on('Rails threadsafe') do
78
77
  ::Rails.configuration.action_controller.allow_concurrency
79
78
  end
@@ -88,7 +87,6 @@ module NewRelic
88
87
  # end reporting logic
89
88
  ####################################
90
89
 
91
-
92
90
  attr_reader :data
93
91
  # Generate the report based on the class level logic.
94
92
  def initialize
@@ -3,8 +3,12 @@
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
5
  require 'new_relic/language_support'
6
+ require 'open3'
6
7
 
7
8
  module NewRelic
9
+ class CommandExecutableNotFoundError < StandardError; end
10
+ class CommandRunFailedError < StandardError; end
11
+
8
12
  # A singleton for shared generic helper methods
9
13
  module Helper
10
14
  extend self
@@ -19,9 +23,9 @@ module NewRelic
19
23
  end
20
24
 
21
25
  def instance_method_visibility(klass, method_name)
22
- if klass.private_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
26
+ if klass.private_instance_methods.map { |s| s.to_sym }.include? method_name.to_sym
23
27
  :private
24
- elsif klass.protected_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
28
+ elsif klass.protected_instance_methods.map { |s| s.to_sym }.include? method_name.to_sym
25
29
  :protected
26
30
  else
27
31
  :public
@@ -31,14 +35,50 @@ module NewRelic
31
35
  def instance_methods_include?(klass, method_name)
32
36
  method_name_sym = method_name.to_sym
33
37
  (
34
- klass.instance_methods.map{ |s| s.to_sym }.include?(method_name_sym) ||
35
- klass.protected_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym) ||
36
- klass.private_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym)
38
+ klass.instance_methods.map { |s| s.to_sym }.include?(method_name_sym) ||
39
+ klass.protected_instance_methods.map { |s| s.to_sym }.include?(method_name_sym) ||
40
+ klass.private_instance_methods.map { |s| s.to_sym }.include?(method_name_sym)
37
41
  )
38
42
  end
39
43
 
40
44
  def time_to_millis(time)
41
45
  (time.to_f * 1000).round
42
46
  end
47
+
48
+ def run_command(command)
49
+ executable = command.split(' ').first
50
+ unless executable_in_path?(executable)
51
+ raise NewRelic::CommandExecutableNotFoundError.new("Executable not found: '#{executable}'")
52
+ end
53
+
54
+ exception = nil
55
+ begin
56
+ output, status = Open3.capture2e(command)
57
+ rescue => exception
58
+ end
59
+
60
+ if exception || !status.success?
61
+ message = exception ? "#{exception.class} - #{exception.message}" : output
62
+ raise NewRelic::CommandRunFailedError.new("Failed to run command '#{command}': #{message}")
63
+ end
64
+
65
+ output.chomp
66
+ end
67
+
68
+ # TODO: Open3 defers the actual excecution of a binary to Process.spawn,
69
+ # which will raise an Errno::ENOENT exception for a file that
70
+ # cannot be found. We might want to take the time to evaluate
71
+ # relying on that Process.spawn behavior instead of checking for
72
+ # existence ourselves. We'd need to see what it does, how efficient
73
+ # it is, if it differs in functionality between Ruby versions and
74
+ # operating systems, etc.
75
+ def executable_in_path?(executable)
76
+ return false unless ENV['PATH']
77
+
78
+ ENV['PATH'].split(File::PATH_SEPARATOR).any? do |bin_path|
79
+ executable_path = File.join(bin_path, executable)
80
+ File.exist?(executable_path) && File.file?(executable_path) && File.executable?(executable_path)
81
+ end
82
+ end
43
83
  end
44
84
  end
@@ -22,7 +22,8 @@ module NewRelic
22
22
  end
23
23
 
24
24
  def object_space_usable?
25
- if defined?(::JRuby) && JRuby.respond_to?(:runtime)
25
+ if jruby?
26
+ require 'jruby'
26
27
  JRuby.runtime.is_object_space_enabled
27
28
  else
28
29
  defined?(::ObjectSpace)
@@ -33,8 +34,25 @@ module NewRelic
33
34
  RUBY_ENGINE == 'jruby'
34
35
  end
35
36
 
37
+ # TODO: OLD RUBIES - RUBY_VERSION < 2.6
38
+ #
39
+ # Ruby 2.6 introduced an improved version of `Object.const_get` that
40
+ # respects the full namespace of the input and doesn't just grab the first
41
+ # constant matching the string to the right of the last '::'.
42
+ # Once we drop support for Ruby 2.5 and below, the only value this custom
43
+ # method will provide beyond `Object.const_get` itself is to automatically
44
+ # catch NameError.
45
+ #
46
+ # see: https://github.com/rails/rails/commit/7057ccf6565c1cb5354c1906880119276a9d15c0
47
+ #
48
+ # With Ruby 2.6+, this method can be defined like so:
49
+ # def constantize(constant_as_string_or_symbol)
50
+ # Object.const_get(constant_as_string_or_symbol)
51
+ # rescue NameError
52
+ # end
53
+ #
36
54
  def constantize(const_name)
37
- const_name.to_s.sub(/\A::/,'').split('::').inject(Object) do |namespace, name|
55
+ const_name.to_s.sub(/\A::/, '').split('::').inject(Object) do |namespace, name|
38
56
  begin
39
57
  result = namespace.const_get(name)
40
58
 
@@ -13,7 +13,7 @@ module NewRelic
13
13
  changes.
14
14
  EOS
15
15
 
16
- def self.read(changelog=default_changelog)
16
+ def self.read(changelog = default_changelog)
17
17
  changes = extract_latest_changes(File.read(changelog))
18
18
  changes << FOOTER
19
19
 
@@ -24,7 +24,7 @@ EOS
24
24
  # precise version number included in the line in parens. For example:
25
25
  #
26
26
  # * This is a patch item (3.7.1.188)
27
- def self.read_patch(patch_level, changelog=default_changelog)
27
+ def self.read_patch(patch_level, changelog = default_changelog)
28
28
  latest = extract_latest_changes(File.read(changelog))
29
29
  changes = ["## v#{patch_level}", ""]
30
30
 
@@ -36,7 +36,7 @@ module NewRelic
36
36
  def initialize
37
37
  # Extend self with any any submodules of LocalEnvironment. These can override
38
38
  # the discover methods to discover new framworks and dispatchers.
39
- NewRelic::LocalEnvironment.constants.each do | const |
39
+ NewRelic::LocalEnvironment.constants.each do |const|
40
40
  mod = NewRelic::LocalEnvironment.const_get const
41
41
  self.extend mod if mod.instance_of? Module
42
42
  end
@@ -76,14 +76,15 @@ module NewRelic
76
76
  rainbows
77
77
  unicorn
78
78
  ]
79
+ # TODO: MAJOR VERSION - remove rainbows
79
80
  while dispatchers.any? && @discovered_dispatcher.nil?
80
- send 'check_for_'+(dispatchers.shift)
81
+ send 'check_for_' + (dispatchers.shift)
81
82
  end
82
83
  end
83
84
 
84
85
  def check_for_torquebox
85
86
  return unless defined?(::JRuby) &&
86
- ( org.torquebox::TorqueBox rescue nil)
87
+ (org.torquebox::TorqueBox rescue nil)
87
88
  @discovered_dispatcher = :torquebox
88
89
  end
89
90
 
@@ -127,6 +128,7 @@ module NewRelic
127
128
  end
128
129
  end
129
130
 
131
+ # TODO: MAJOR VERSION - remove this method
130
132
  def check_for_rainbows
131
133
  if (defined?(::Rainbows) && defined?(::Rainbows::HttpServer)) && NewRelic::LanguageSupport.object_space_usable?
132
134
  v = find_class_in_object_space(::Rainbows::HttpServer)
@@ -147,9 +149,9 @@ module NewRelic
147
149
  end
148
150
 
149
151
  def check_for_resque
150
- has_queue = ENV['QUEUE'] || ENV['QUEUES']
151
- resque_rake = executable == 'rake' && ARGV.include?('resque:work')
152
- resque_pool_rake = executable == 'rake' && ARGV.include?('resque:pool')
152
+ has_queue = ENV['QUEUE'] || ENV['QUEUES']
153
+ resque_rake = executable == 'rake' && ARGV.include?('resque:work')
154
+ resque_pool_rake = executable == 'rake' && ARGV.include?('resque:pool')
153
155
  resque_pool_executable = executable == 'resque-pool' && defined?(::Resque::Pool)
154
156
 
155
157
  using_resque = defined?(::Resque) &&
@@ -192,6 +194,7 @@ module NewRelic
192
194
  end
193
195
 
194
196
  public
197
+
195
198
  # outputs a human-readable description
196
199
  def to_s
197
200
  s = "LocalEnvironment["
@@ -202,6 +205,5 @@ module NewRelic
202
205
  def executable
203
206
  File.basename($0)
204
207
  end
205
-
206
208
  end
207
209
  end
@@ -18,7 +18,7 @@ module NewRelic
18
18
  end
19
19
 
20
20
  def eql?(o)
21
- (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats)
21
+ (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats)
22
22
  end
23
23
 
24
24
  def original_spec
@@ -37,7 +37,7 @@ module NewRelic
37
37
  end
38
38
 
39
39
  def to_json(*a)
40
- %Q[{"metric_spec":#{metric_spec.to_json},"stats":{"total_exclusive_time":#{stats.total_exclusive_time},"min_call_time":#{stats.min_call_time},"call_count":#{stats.call_count},"sum_of_squares":#{stats.sum_of_squares},"total_call_time":#{stats.total_call_time},"max_call_time":#{stats.max_call_time}}}]
40
+ %Q({"metric_spec":#{metric_spec.to_json},"stats":{"total_exclusive_time":#{stats.total_exclusive_time},"min_call_time":#{stats.min_call_time},"call_count":#{stats.call_count},"sum_of_squares":#{stats.sum_of_squares},"total_call_time":#{stats.total_call_time},"max_call_time":#{stats.max_call_time}}})
41
41
  end
42
42
 
43
43
  def to_s
@@ -50,9 +50,9 @@ module NewRelic
50
50
 
51
51
  include NewRelic::Coerce
52
52
 
53
- def to_collector_array(encoder=nil)
54
- stat_key = { 'name' => metric_spec.name, 'scope' => metric_spec.scope }
55
- [ stat_key,
53
+ def to_collector_array(encoder = nil)
54
+ stat_key = {'name' => metric_spec.name, 'scope' => metric_spec.scope}
55
+ [stat_key,
56
56
  [
57
57
  int(stats.call_count, stat_key),
58
58
  float(stats.total_call_time, stat_key),
@@ -60,8 +60,7 @@ module NewRelic
60
60
  float(stats.min_call_time, stat_key),
61
61
  float(stats.max_call_time, stat_key),
62
62
  float(stats.sum_of_squares, stat_key)
63
- ]
64
- ]
63
+ ]]
65
64
  end
66
65
  end
67
66
  end
@@ -5,14 +5,14 @@
5
5
  # this struct uniquely defines a metric, optionally inside
6
6
  # the call scope of another metric
7
7
  class NewRelic::MetricSpec
8
- attr_reader :name, :scope
8
+ attr_reader :name, :scope
9
9
 
10
10
  # the maximum length of a metric name or metric scope
11
11
  MAX_LENGTH = 255
12
12
  LENGTH_RANGE = (0...MAX_LENGTH)
13
13
  EMPTY_SCOPE = ''.freeze
14
14
 
15
- def initialize(metric_name='', metric_scope=nil)
15
+ def initialize(metric_name = '', metric_scope = nil)
16
16
  if metric_name.to_s.length > MAX_LENGTH
17
17
  @name = metric_name.to_s[LENGTH_RANGE]
18
18
  else
@@ -53,7 +53,7 @@ class NewRelic::MetricSpec
53
53
 
54
54
  def to_json(*a)
55
55
  {'name' => name,
56
- 'scope' => scope}.to_json(*a)
56
+ 'scope' => scope}.to_json(*a)
57
57
  end
58
58
 
59
59
  def <=>(o)
@@ -12,11 +12,11 @@ class NewRelic::NoticedError
12
12
  extend NewRelic::CollectionHelper
13
13
 
14
14
  attr_accessor :path, :timestamp, :message, :exception_class_name,
15
- :request_uri, :request_port, :file_name, :line_number,
16
- :stack_trace, :attributes_from_notice_error, :attributes,
17
- :expected
15
+ :request_uri, :request_port, :file_name, :line_number,
16
+ :stack_trace, :attributes_from_notice_error, :attributes,
17
+ :expected
18
18
 
19
- attr_reader :exception_id, :is_internal
19
+ attr_reader :exception_id, :is_internal
20
20
 
21
21
  STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE = "Message removed by New Relic 'strip_exception_messages' setting"
22
22
  UNKNOWN_ERROR_CLASS_NAME = 'Error'
@@ -28,12 +28,12 @@ class NewRelic::NoticedError
28
28
 
29
29
  DESTINATION = NewRelic::Agent::AttributeFilter::DST_ERROR_COLLECTOR
30
30
 
31
- ERROR_PREFIX_KEY = 'error'
32
- ERROR_MESSAGE_KEY = "#{ERROR_PREFIX_KEY}.message"
33
- ERROR_CLASS_KEY = "#{ERROR_PREFIX_KEY}.class"
31
+ ERROR_PREFIX_KEY = 'error'
32
+ ERROR_MESSAGE_KEY = "#{ERROR_PREFIX_KEY}.message"
33
+ ERROR_CLASS_KEY = "#{ERROR_PREFIX_KEY}.class"
34
34
  ERROR_EXPECTED_KEY = "#{ERROR_PREFIX_KEY}.expected"
35
35
 
36
- def initialize(path, exception, timestamp = Time.now)
36
+ def initialize(path, exception, timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), expected = false)
37
37
  @exception_id = exception.object_id
38
38
  @path = path
39
39
 
@@ -51,14 +51,14 @@ class NewRelic::NoticedError
51
51
 
52
52
  # replace error message if enabled
53
53
  if NewRelic::Agent.config[:'strip_exception_messages.enabled'] &&
54
- !self.class.passes_message_allowlist(exception.class)
54
+ !self.class.passes_message_allowlist(exception.class)
55
55
  @message = STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE
56
56
  end
57
57
 
58
58
  @attributes_from_notice_error = nil
59
59
  @attributes = nil
60
60
  @timestamp = timestamp
61
- @expected = false
61
+ @expected = expected
62
62
  end
63
63
 
64
64
  def ==(other)
@@ -77,12 +77,12 @@ class NewRelic::NoticedError
77
77
 
78
78
  include NewRelic::Coerce
79
79
 
80
- def to_collector_array(encoder=nil)
81
- [ NewRelic::Helper.time_to_millis(timestamp),
80
+ def to_collector_array(encoder = nil)
81
+ [NewRelic::Helper.time_to_millis(timestamp),
82
82
  string(path),
83
83
  string(message),
84
84
  string(exception_class_name),
85
- processed_attributes ]
85
+ processed_attributes]
86
86
  end
87
87
 
88
88
  # Note that we process attributes lazily and store the result. This is because
@@ -101,10 +101,10 @@ class NewRelic::NoticedError
101
101
 
102
102
  def base_parameters
103
103
  params = {}
104
- params[:file_name] = file_name if file_name
105
- params[:line_number] = line_number if line_number
106
- params[:stack_trace] = stack_trace if stack_trace
107
- params[:'error.expected'] = expected
104
+ params[:file_name] = file_name if file_name
105
+ params[:line_number] = line_number if line_number
106
+ params[:stack_trace] = stack_trace if stack_trace
107
+ params[ERROR_EXPECTED_KEY.to_sym] = expected
108
108
  params
109
109
  end
110
110
 
@@ -139,7 +139,7 @@ class NewRelic::NoticedError
139
139
  ERROR_MESSAGE_KEY => string(message),
140
140
  ERROR_CLASS_KEY => string(exception_class_name)
141
141
  })
142
-
142
+
143
143
  @attributes_from_notice_error[ERROR_EXPECTED_KEY] = true if expected
144
144
  end
145
145
 
@@ -200,5 +200,4 @@ class NewRelic::NoticedError
200
200
  @message = exception.to_s
201
201
  end
202
202
  end
203
-
204
203
  end
@@ -13,10 +13,10 @@ module NewRelic
13
13
 
14
14
  attr_reader :transaction_options, :category, :target
15
15
 
16
- def initialize(app, options={})
16
+ def initialize(app, options = {})
17
17
  @app = app
18
18
  @category = :middleware
19
- @target = self
19
+ @target = self
20
20
  @transaction_options = {
21
21
  :transaction_name => build_transaction_name
22
22
  }
@@ -19,15 +19,15 @@ module NewRelic::Rack
19
19
  # examine in order to look for a RUM insertion point.
20
20
  SCAN_LIMIT = 50_000
21
21
 
22
- CONTENT_TYPE = 'Content-Type'.freeze
22
+ CONTENT_TYPE = 'Content-Type'.freeze
23
23
  CONTENT_DISPOSITION = 'Content-Disposition'.freeze
24
- CONTENT_LENGTH = 'Content-Length'.freeze
25
- ATTACHMENT = 'attachment'.freeze
26
- TEXT_HTML = 'text/html'.freeze
24
+ CONTENT_LENGTH = 'Content-Length'.freeze
25
+ ATTACHMENT = 'attachment'.freeze
26
+ TEXT_HTML = 'text/html'.freeze
27
27
 
28
- BODY_START = "<body".freeze
29
- HEAD_START = "<head".freeze
30
- GT = ">".freeze
28
+ BODY_START = "<body".freeze
29
+ HEAD_START = "<head".freeze
30
+ GT = ">".freeze
31
31
 
32
32
  def traced_call(env)
33
33
  result = @app.call(env)
@@ -79,7 +79,7 @@ module NewRelic::Rack
79
79
  env['action_controller.instance'].class.included_modules.include?(ActionController::Live)
80
80
  end
81
81
 
82
- CHARSET_RE = /<\s*meta[^>]+charset\s*=[^>]*>/im.freeze
82
+ CHARSET_RE = /<\s*meta[^>]+charset\s*=[^>]*>/im.freeze
83
83
  X_UA_COMPATIBLE_RE = /<\s*meta[^>]+http-equiv\s*=\s*['"]x-ua-compatible['"][^>]*>/im.freeze
84
84
 
85
85
  def autoinstrument_source(response, headers, js_to_inject)
@@ -123,7 +123,7 @@ module NewRelic::Rack
123
123
 
124
124
  def gather_source(response)
125
125
  source = nil
126
- response.each {|fragment| source ? (source << fragment.to_s) : (source = fragment.to_s)}
126
+ response.each { |fragment| source ? (source << fragment.to_s) : (source = fragment.to_s) }
127
127
  source
128
128
  end
129
129
 
@@ -5,7 +5,6 @@
5
5
  require 'capistrano/framework'
6
6
 
7
7
  namespace :newrelic do
8
-
9
8
  # notifies New Relic of a deployment
10
9
  desc "Record a deployment in New Relic (newrelic.com)"
11
10
  task :notice_deployment do
@@ -23,15 +22,15 @@ namespace :newrelic do
23
22
  def send_deployment_notification_to_newrelic
24
23
  environment = fetch(:newrelic_rails_env, fetch(:rack_env, fetch(:rails_env, fetch(:stage, "production"))))
25
24
 
26
- require 'new_relic/cli/command.rb'
25
+ require 'new_relic/cli/command'
27
26
 
28
27
  begin
29
28
  # allow overrides to be defined for revision, description, changelog, appname, and user
30
- rev = fetch(:newrelic_revision)
29
+ rev = fetch(:newrelic_revision)
31
30
  description = fetch(:newrelic_desc)
32
- changelog = fetch(:newrelic_changelog)
33
- appname = fetch(:newrelic_appname)
34
- user = fetch(:newrelic_user)
31
+ changelog = fetch(:newrelic_changelog)
32
+ appname = fetch(:newrelic_appname)
33
+ user = fetch(:newrelic_user)
35
34
  license_key = fetch(:newrelic_license_key)
36
35
 
37
36
  has_scm_from_plugin = respond_to?(:scm_plugin_installed?) && scm_plugin_installed?
@@ -39,17 +38,17 @@ namespace :newrelic do
39
38
 
40
39
  if has_scm_from_plugin || has_scm_from_config
41
40
  changelog ||= lookup_changelog
42
- rev ||= fetch(:current_revision)
41
+ rev ||= fetch(:current_revision)
43
42
  end
44
43
 
45
44
  new_revision = rev
46
45
  deploy_options = {
47
46
  :environment => environment,
48
- :revision => new_revision,
49
- :changelog => changelog,
47
+ :revision => new_revision,
48
+ :changelog => changelog,
50
49
  :description => description,
51
- :appname => appname,
52
- :user => user,
50
+ :appname => appname,
51
+ :user => user,
53
52
  :license_key => license_key
54
53
  }
55
54
 
@@ -57,7 +56,6 @@ namespace :newrelic do
57
56
  deployment = NewRelic::Cli::Deployments.new deploy_options
58
57
  deployment.run
59
58
  info "Uploaded deployment information to New Relic"
60
-
61
59
  rescue NewRelic::Cli::Command::CommandFailure => e
62
60
  info e.message
63
61
  rescue => e
@@ -74,7 +72,7 @@ namespace :newrelic do
74
72
 
75
73
  if Rake::Task.task_defined?("git:check")
76
74
  log_command = "git --no-pager log --no-color --pretty=format:' * %an: %s' " +
77
- "--abbrev-commit --no-merges #{previous_revision}..#{current_revision}"
75
+ "--abbrev-commit --no-merges #{previous_revision}..#{current_revision}"
78
76
  `#{log_command}`
79
77
  end
80
78
  end
@@ -3,38 +3,36 @@
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
5
  make_notify_task = Proc.new do
6
-
7
6
  namespace :newrelic do
8
-
9
7
  # on all deployments, notify New Relic
10
8
  desc "Record a deployment in New Relic (newrelic.com)"
11
- task :notice_deployment, :roles => :app, :except => {:no_release => true } do
9
+ task :notice_deployment, :roles => :app, :except => {:no_release => true} do
12
10
  rails_env = fetch(:newrelic_rails_env, fetch(:rails_env, "production"))
13
11
 
14
12
  require 'new_relic/cli/command'
15
13
 
16
14
  begin
17
15
  # allow overrides to be defined for revision, description, changelog, appname, and user
18
- rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
19
- description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
20
- changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
21
- appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
22
- user = fetch(:newrelic_user) if exists?(:newrelic_user)
16
+ rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
17
+ description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
18
+ changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
19
+ appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
20
+ user = fetch(:newrelic_user) if exists?(:newrelic_user)
23
21
  license_key = fetch(:newrelic_license_key) if exists?(:newrelic_license_key)
24
22
 
25
23
  unless scm == :none
26
24
  changelog = lookup_changelog(changelog)
27
- rev = lookup_rev(rev)
25
+ rev = lookup_rev(rev)
28
26
  end
29
27
 
30
28
  new_revision = rev
31
29
  deploy_options = {
32
30
  :environment => rails_env,
33
- :revision => new_revision,
34
- :changelog => changelog,
31
+ :revision => new_revision,
32
+ :changelog => changelog,
35
33
  :description => description,
36
- :appname => appname,
37
- :user => user,
34
+ :appname => appname,
35
+ :user => user,
38
36
  :license_key => license_key
39
37
  }
40
38
 
@@ -42,7 +40,6 @@ make_notify_task = Proc.new do
42
40
  deployment = NewRelic::Cli::Deployments.new deploy_options
43
41
  deployment.run
44
42
  logger.info "Uploaded deployment information to New Relic"
45
-
46
43
  rescue NewRelic::Cli::Command::CommandFailure => e
47
44
  logger.info e.message
48
45
  rescue Capistrano::CommandError
@@ -4,7 +4,6 @@
4
4
 
5
5
  module NewRelic
6
6
  module SupportabilityHelper
7
-
8
7
  API_SUPPORTABILITY_PREFIX = 'Supportability/API/'.freeze
9
8
 
10
9
  # pre-instantiate these strings as they may be used multiple times per
@@ -51,10 +50,11 @@ module NewRelic
51
50
  :shutdown,
52
51
  :start_segment,
53
52
  :trace,
53
+ :traced_thread,
54
54
  :trace_execution_scoped,
55
55
  :trace_execution_unscoped,
56
56
  :wrap
57
- ].reduce({}) do |h,o|
57
+ ].reduce({}) do |h, o|
58
58
  h[o] = API_SUPPORTABILITY_PREFIX + o.to_s
59
59
  h
60
60
  end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
+ # frozen_string_literal: true
5
+
6
+ module NewRelic
7
+ #
8
+ # This class allows the current transaction to be passed to a Thread so that nested segments can be created from the operations performed within the Thread's block.
9
+ # To have the New Relic Ruby agent automatically trace all of your applications threads,
10
+ # enable the +instrumentation.thread.tracing+ configuration option in your newrelic.yml.
11
+ #
12
+ # Note: disabling the configuration option +instrumentation.thread+ while using this class can cause incorrectly nested spans.
13
+ #
14
+ # @api public
15
+ class TracedThread < Thread
16
+ #
17
+ # Creates a new Thread whose work will be traced by New Relic.
18
+ # Use this class as a replacement for the native Thread class.
19
+ # Example: Instead of using +Thread.new+, use:
20
+ #
21
+ # NewRelic::TracedThread.new { execute_some_code }
22
+ #
23
+ # @api public
24
+ def initialize(*args, &block)
25
+ NewRelic::Agent.record_api_supportability_metric(:traced_thread)
26
+ traced_block = create_traced_block(*args, &block)
27
+ super(*args, &traced_block)
28
+ end
29
+
30
+ def create_traced_block(*args, &block)
31
+ return block if NewRelic::Agent.config[:'instrumentation.thread.tracing'] # if this is on, don't double trace
32
+ NewRelic::Agent::Tracer.thread_block_with_current_transaction(*args, &block)
33
+ end
34
+ end
35
+ end