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
@@ -22,23 +22,18 @@ module NewRelic
22
22
  @error_trace_aggregator = ErrorTraceAggregator.new(MAX_ERROR_QUEUE_LENGTH)
23
23
  @error_event_aggregator = ErrorEventAggregator.new events
24
24
 
25
- # lookup of exception class names to ignore. Hash for fast access
26
- @ignore = {}
27
-
28
- initialize_ignored_errors(Agent.config[:'error_collector.ignore_errors'])
29
-
30
- Agent.config.register_callback(:'error_collector.ignore_errors') do |ignore_errors|
31
- initialize_ignored_errors(ignore_errors)
25
+ @error_filter = NewRelic::Agent::ErrorFilter.new
26
+
27
+ %w[
28
+ ignore_errors ignore_classes ignore_messages ignore_status_codes
29
+ expected_classes expected_messages expected_status_codes
30
+ ].each do |w|
31
+ Agent.config.register_callback(:"error_collector.#{w}") do |value|
32
+ @error_filter.load_from_config(w, value)
33
+ end
32
34
  end
33
35
  end
34
36
 
35
- def initialize_ignored_errors(ignore_errors)
36
- @ignore.clear
37
- ignore_errors = ignore_errors.split(",") if ignore_errors.is_a? String
38
- ignore_errors.each { |error| error.strip! }
39
- ignore(ignore_errors)
40
- end
41
-
42
37
  def enabled?
43
38
  error_trace_aggregator.enabled? || error_event_aggregator.enabled?
44
39
  end
@@ -76,30 +71,39 @@ module NewRelic
76
71
  defined?(@ignore_filter) ? @ignore_filter : nil
77
72
  end
78
73
 
79
- # errors is an array of Exception Class Names
80
- #
81
74
  def ignore(errors)
82
- errors.each do |error|
83
- @ignore[error] = true
84
- ::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}'")
85
- end
75
+ @error_filter.ignore(errors)
76
+ end
77
+
78
+ def ignore?(ex, status_code = nil)
79
+ @error_filter.ignore?(ex, status_code)
80
+ end
81
+
82
+ def expect(errors)
83
+ @error_filter.expect(errors)
84
+ end
85
+
86
+ def expected?(ex, status_code = nil)
87
+ @error_filter.expected?(ex, status_code)
88
+ end
89
+
90
+ def load_error_filters
91
+ @error_filter.load_all
92
+ end
93
+
94
+ def reset_error_filters
95
+ @error_filter.reset
86
96
  end
87
97
 
88
98
  # Checks the provided error against the error filter, if there
89
99
  # is an error filter
90
- def filtered_by_error_filter?(error)
100
+ def ignored_by_filter_proc?(error)
91
101
  respond_to?(:ignore_filter_proc) && !ignore_filter_proc(error)
92
102
  end
93
103
 
94
- # Checks the array of error names and the error filter against
95
- # the provided error
96
- def filtered_error?(error)
97
- @ignore[error.class.name] || filtered_by_error_filter?(error)
98
- end
99
-
100
104
  # an error is ignored if it is nil or if it is filtered
101
- def error_is_ignored?(error)
102
- error && filtered_error?(error)
105
+ def error_is_ignored?(error, status_code = nil)
106
+ error && (@error_filter.ignore?(error, status_code) || ignored_by_filter_proc?(error))
103
107
  rescue => e
104
108
  NewRelic::Agent.logger.error("Error '#{error}' will NOT be ignored. Exception '#{e}' while determining whether to ignore or not.", e)
105
109
  false
@@ -161,10 +165,10 @@ module NewRelic
161
165
  end
162
166
 
163
167
  # Increments a statistic that tracks total error rate
164
- def increment_error_count!(state, exception, options={})
168
+ def increment_error_count!(state, exception, options = {})
165
169
  txn = state.current_transaction
166
170
 
167
- metric_names = aggregated_metric_names(txn)
171
+ metric_names = aggregated_metric_names(txn)
168
172
  blamed_metric = blamed_metric_name(txn, options)
169
173
  metric_names << blamed_metric if blamed_metric
170
174
 
@@ -174,11 +178,18 @@ module NewRelic
174
178
  end
175
179
  end
176
180
 
177
- def skip_notice_error?(exception)
181
+ def increment_expected_error_count!(state, exception)
182
+ stats_engine = NewRelic::Agent.agent.stats_engine
183
+ stats_engine.record_unscoped_metrics(state, ['ErrorsExpected/all']) do |stats|
184
+ stats.increment_count
185
+ end
186
+ end
187
+
188
+ def skip_notice_error?(exception, status_code = nil)
178
189
  disabled? ||
179
- error_is_ignored?(exception) ||
180
- exception.nil? ||
181
- exception_tagged_with?(EXCEPTION_TAG_IVAR, exception)
190
+ exception.nil? ||
191
+ exception_tagged_with?(EXCEPTION_TAG_IVAR, exception) ||
192
+ error_is_ignored?(exception, status_code)
182
193
  end
183
194
 
184
195
  # calls a method on an object, if it responds to it - used for
@@ -191,14 +202,14 @@ module NewRelic
191
202
  # extracts a stack trace from the exception for debugging purposes
192
203
  def extract_stack_trace(exception)
193
204
  actual_exception = if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR < 5
194
- sense_method(exception, :original_exception) || exception
195
- else
196
- exception
197
- end
205
+ sense_method(exception, :original_exception) || exception
206
+ else
207
+ exception
208
+ end
198
209
  sense_method(actual_exception, :backtrace) || '<no stack trace>'
199
210
  end
200
211
 
201
- def notice_segment_error(segment, exception, options={})
212
+ def notice_segment_error(segment, exception, options = {})
202
213
  return if skip_notice_error?(exception)
203
214
 
204
215
  segment.set_noticed_error create_noticed_error(exception, options)
@@ -209,14 +220,18 @@ module NewRelic
209
220
  end
210
221
 
211
222
  # See NewRelic::Agent.notice_error for options and commentary
212
- def notice_error(exception, options={}, span_id=nil)
213
- return if skip_notice_error?(exception)
223
+ def notice_error(exception, options = {}, span_id = nil)
224
+ state = ::NewRelic::Agent::Tracer.state
225
+ transaction = state.current_transaction
226
+ status_code = transaction ? transaction.http_response_code : nil
214
227
 
215
- tag_exception(exception)
228
+ return if skip_notice_error?(exception, status_code)
216
229
 
217
- state = ::NewRelic::Agent::Tracer.state
230
+ tag_exception(exception)
218
231
 
219
- unless options[:expected]
232
+ if options[:expected] || @error_filter.expected?(exception, status_code)
233
+ increment_expected_error_count!(state, exception)
234
+ else
220
235
  increment_error_count!(state, exception, options)
221
236
  end
222
237
 
@@ -224,7 +239,7 @@ module NewRelic
224
239
  error_trace_aggregator.add_to_error_queue(noticed_error)
225
240
  transaction = state.current_transaction
226
241
  payload = transaction ? transaction.payload : nil
227
- span_id ||= (transaction && transaction.current_segment) ? transaction.current_segment.guid : nil
242
+ span_id ||= transaction && transaction.current_segment ? transaction.current_segment.guid : nil
228
243
  error_event_aggregator.record(noticed_error, payload, span_id)
229
244
  exception
230
245
  rescue => e
@@ -232,7 +247,7 @@ module NewRelic
232
247
  nil
233
248
  end
234
249
 
235
- def truncate_trace(trace, keep_frames=nil)
250
+ def truncate_trace(trace, keep_frames = nil)
236
251
  keep_frames ||= Agent.config[:'error_collector.max_backtrace_frames']
237
252
  return trace if !keep_frames || trace.length < keep_frames || trace.length == 0
238
253
 
@@ -252,13 +267,13 @@ module NewRelic
252
267
  noticed_error = NewRelic::NoticedError.new(error_metric, exception)
253
268
  noticed_error.request_uri = options.delete(:uri) || NewRelic::EMPTY_STR
254
269
  noticed_error.request_port = options.delete(:port)
255
- noticed_error.attributes = options.delete(:attributes)
270
+ noticed_error.attributes = options.delete(:attributes)
256
271
 
257
- noticed_error.file_name = sense_method(exception, :file_name)
272
+ noticed_error.file_name = sense_method(exception, :file_name)
258
273
  noticed_error.line_number = sense_method(exception, :line_number)
259
274
  noticed_error.stack_trace = truncate_trace(extract_stack_trace(exception))
260
275
 
261
- noticed_error.expected = !! options.delete(:expected)
276
+ noticed_error.expected = !!options.delete(:expected) || expected?(exception)
262
277
 
263
278
  noticed_error.attributes_from_notice_error = options.delete(:custom_params) || {}
264
279
 
@@ -16,7 +16,7 @@ module NewRelic
16
16
  named :ErrorEventAggregator
17
17
  capacity_key :'error_collector.max_event_samples_stored'
18
18
  enabled_keys :'error_collector.enabled',
19
- :'error_collector.capture_events'
19
+ :'error_collector.capture_events'
20
20
  buffer_class PrioritySampledBuffer
21
21
 
22
22
  def record noticed_error, transaction_payload = nil, span_id = nil
@@ -0,0 +1,173 @@
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
+
5
+ module NewRelic
6
+ module Agent
7
+ # Handles loading of ignored and expected errors from the agent configuration, and
8
+ # determining at runtime whether an exception is ignored or expected.
9
+ class ErrorFilter
10
+ def initialize
11
+ reset
12
+ end
13
+
14
+ def reset
15
+ @ignore_classes, @expected_classes = [], []
16
+ @ignore_messages, @expected_messages = {}, {}
17
+ @ignore_status_codes, @expected_status_codes = [], []
18
+ end
19
+
20
+ def load_all
21
+ %i[
22
+ ignore_errors ignore_classes ignore_messages ignore_status_codes
23
+ expected_classes expected_messages expected_status_codes
24
+ ].each { |setting| load_from_config(setting) }
25
+ end
26
+
27
+ def load_from_config(setting, value = nil)
28
+ errors = nil
29
+ new_value = value || fetch_agent_config(setting.to_sym)
30
+
31
+ return if new_value.nil? || (new_value.respond_to?(:empty?) && new_value.empty?)
32
+
33
+ case setting.to_sym
34
+ when :ignore_errors, :ignore_classes
35
+ new_value = new_value.split(',').map!(&:strip) if new_value.is_a?(String)
36
+ errors = @ignore_classes = new_value
37
+ when :ignore_messages
38
+ errors = @ignore_messages = new_value || {}
39
+ when :ignore_status_codes
40
+ errors = @ignore_status_codes = parse_status_codes(new_value) || []
41
+ when :expected_classes
42
+ errors = @expected_classes = new_value || []
43
+ when :expected_messages
44
+ errors = @expected_messages = new_value || {}
45
+ when :expected_status_codes
46
+ errors = @expected_status_codes = parse_status_codes(new_value) || []
47
+ end
48
+ log_filter(setting, errors) if errors
49
+ end
50
+
51
+ def ignore?(ex, status_code = nil)
52
+ @ignore_classes.include?(ex.class.name) ||
53
+ (@ignore_messages.keys.include?(ex.class.name) &&
54
+ @ignore_messages[ex.class.name].any? { |m| ex.message.include?(m) }) ||
55
+ @ignore_status_codes.include?(status_code.to_i)
56
+ end
57
+
58
+ def expected?(ex, status_code = nil)
59
+ @expected_classes.include?(ex.class.name) ||
60
+ (@expected_messages.keys.include?(ex.class.name) &&
61
+ @expected_messages[ex.class.name].any? { |m| ex.message.include?(m) }) ||
62
+ @expected_status_codes.include?(status_code.to_i)
63
+ end
64
+
65
+ def fetch_agent_config(cfg)
66
+ NewRelic::Agent.config[:"error_collector.#{cfg}"]
67
+ end
68
+
69
+ # A generic method for adding ignore filters manually. This is kept for compatibility
70
+ # with the previous ErrorCollector#ignore method, and adds some flexibility for adding
71
+ # different ignore/expected error types by examining each argument.
72
+ def ignore(*args)
73
+ args.each do |errors|
74
+ case errors
75
+ when Array
76
+ errors.each { |e| ignore(e) }
77
+ when Integer
78
+ @ignore_status_codes << errors
79
+ when Hash
80
+ @ignore_messages.update(errors)
81
+ log_filter(:ignore_messages, errors)
82
+ when String
83
+ if errors.match(/^[\d\,\-]+$/)
84
+ @ignore_status_codes |= parse_status_codes(errors)
85
+ log_filter(:ignore_status_codes, errors)
86
+ else
87
+ new_ignore_classes = errors.split(',').map!(&:strip)
88
+ @ignore_classes |= new_ignore_classes
89
+ log_filter(:ignore_classes, new_ignore_classes)
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ # See #ignore above.
96
+ def expect(*args)
97
+ args.each do |errors|
98
+ case errors
99
+ when Array
100
+ errors.each { |e| expect(e) }
101
+ when Integer
102
+ @expected_status_codes << errors
103
+ when Hash
104
+ @expected_messages.update(errors)
105
+ log_filter(:expected_messages, errors)
106
+ when String
107
+ if errors.match(/^[\d\,\-]+$/)
108
+ @expected_status_codes |= parse_status_codes(errors)
109
+ log_filter(:expected_status_codes, errors)
110
+ else
111
+ new_expected_classes = errors.split(',').map!(&:strip)
112
+ @expected_classes |= new_expected_classes
113
+ log_filter(:expected_classes, new_expected_classes)
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ private
120
+
121
+ def log_filter(setting, errors)
122
+ case setting
123
+ when :ignore_errors, :ignore_classes
124
+ errors.each do |error|
125
+ ::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}'")
126
+ end
127
+ when :ignore_messages
128
+ errors.each do |error, messages|
129
+ ::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}' with messages: #{messages.join(',')}")
130
+ end
131
+ when :ignore_status_codes
132
+ ::NewRelic::Agent.logger.debug("Ignoring errors associated with status codes: #{errors}")
133
+ when :expected_classes
134
+ errors.each do |error|
135
+ ::NewRelic::Agent.logger.debug("Expecting errors of type '#{error}'")
136
+ end
137
+ when :expected_messages
138
+ errors.each do |error, messages|
139
+ ::NewRelic::Agent.logger.debug("Expecting errors of type '#{error}' with messages: #{messages.join(',')}")
140
+ end
141
+ when :expected_status_codes
142
+ ::NewRelic::Agent.logger.debug("Expecting errors associated with status codes: #{errors}")
143
+ end
144
+ end
145
+
146
+ def parse_status_codes(codes)
147
+ code_list = case codes
148
+ when String
149
+ codes.split(',')
150
+ when Integer
151
+ [codes]
152
+ else
153
+ codes
154
+ end
155
+ result = []
156
+ code_list.each do |code|
157
+ result << code && next if code.is_a?(Integer)
158
+ m = code.match(/(\d{3})(-\d{3})?/)
159
+ if m.nil? || m[1].nil?
160
+ ::NewRelic::Agent.logger.warn("Invalid HTTP status code: '#{code}'; ignoring config")
161
+ next
162
+ end
163
+ if m[2]
164
+ result += (m[1]..m[2].tr('-', '')).to_a.map(&:to_i)
165
+ else
166
+ result << m[1].to_i
167
+ end
168
+ end
169
+ result.uniq
170
+ end
171
+ end
172
+ end
173
+ end
@@ -54,7 +54,7 @@ module NewRelic
54
54
  # checks the size of the error queue to make sure we are under
55
55
  # the maximum limit, and logs a warning if we are over the limit.
56
56
  def over_queue_limit?(message)
57
- over_limit = (@errors.reject{|err| err.is_internal}.length >= @capacity)
57
+ over_limit = (@errors.reject { |err| err.is_internal }.length >= @capacity)
58
58
  if over_limit
59
59
  ::NewRelic::Agent.logger.warn("The error reporting queue has reached #{@capacity}. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: #{message}")
60
60
  end
@@ -25,7 +25,7 @@ module NewRelic
25
25
  @enabled_keys ||= []
26
26
  else
27
27
  @enabled_keys = Array(keys)
28
- @enabled_fn = ->(){ @enabled_keys.all? { |k| Agent.config[k] } }
28
+ @enabled_fn = ->() { @enabled_keys.all? { |k| Agent.config[k] } }
29
29
  end
30
30
  end
31
31
 
@@ -22,22 +22,22 @@ module NewRelic
22
22
 
23
23
  def initialize(capacity)
24
24
  @capacity = capacity
25
- @items = []
26
- @seen = 0
25
+ @items = []
26
+ @seen = 0
27
27
  end
28
28
 
29
29
  def reset!
30
30
  @items = []
31
- @seen = 0
31
+ @seen = 0
32
32
  end
33
33
 
34
34
  def capacity=(new_capacity)
35
35
  @capacity = new_capacity
36
36
  old_items = @items
37
- @items = []
38
- old_seen = @seen
37
+ @items = []
38
+ old_seen = @seen
39
39
  old_items.each { |i| append(i) }
40
- @seen = old_seen
40
+ @seen = old_seen
41
41
  end
42
42
 
43
43
  def append(x)
@@ -88,4 +88,3 @@ module NewRelic
88
88
  end
89
89
  end
90
90
  end
91
-
@@ -9,7 +9,6 @@ module NewRelic::Agent
9
9
  # While an EventListener could be used elsewhere, it's strongly expected
10
10
  # your eventing needs should be met by the agent's instance.
11
11
  class EventListener
12
-
13
12
  attr_accessor :runaway_threshold
14
13
 
15
14
  def initialize
@@ -10,11 +10,11 @@ module NewRelic
10
10
  class Timer
11
11
  attr_reader :next_fire_time, :event, :interval, :last_fired_at
12
12
 
13
- def initialize(interval, event, repeat=false)
14
- @interval = interval
15
- @event = event
16
- @repeat = repeat
17
- @started_at = Time.now
13
+ def initialize(interval, event, repeat = false)
14
+ @interval = interval
15
+ @event = event
16
+ @repeat = repeat
17
+ @started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
18
18
  @last_fired_at = nil
19
19
  reschedule
20
20
  end
@@ -32,7 +32,7 @@ module NewRelic
32
32
  end
33
33
 
34
34
  def calculate_next_fire_time
35
- now = Time.now
35
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
36
36
  return now if @interval == 0
37
37
  fire_time = @last_fired_at || now
38
38
  while fire_time <= now
@@ -42,10 +42,10 @@ module NewRelic
42
42
  end
43
43
 
44
44
  def set_fired_time
45
- @last_fired_at = Time.now
45
+ @last_fired_at = Process.clock_gettime(Process::CLOCK_REALTIME)
46
46
  end
47
47
 
48
- def due?(now=Time.now)
48
+ def due?(now = Process.clock_gettime(Process::CLOCK_REALTIME))
49
49
  now >= @next_fire_time
50
50
  end
51
51
 
@@ -57,10 +57,10 @@ module NewRelic
57
57
  def initialize
58
58
  @self_pipe_rd, @self_pipe_wr = IO.pipe
59
59
  @event_queue = Queue.new
60
- @stopped = false
61
- @timers = {}
60
+ @stopped = false
61
+ @timers = {}
62
62
 
63
- @subscriptions = Hash.new { |h,k| h[k] = [] }
63
+ @subscriptions = Hash.new { |h, k| h[k] = [] }
64
64
  @subscriptions[:__add_timer] << Proc.new { |t| set_timer(t) }
65
65
  @subscriptions[:__add_event] << Proc.new { |e, blk| @subscriptions[e] << blk }
66
66
  end
@@ -69,7 +69,7 @@ module NewRelic
69
69
  existing_timer = @timers[timer.event]
70
70
 
71
71
  if existing_timer
72
- elapsed_interval = Time.now - existing_timer.last_interval_start
72
+ elapsed_interval = Process.clock_gettime(Process::CLOCK_REALTIME) - existing_timer.last_interval_start
73
73
  timer.advance(elapsed_interval)
74
74
  end
75
75
 
@@ -80,7 +80,7 @@ module NewRelic
80
80
 
81
81
  def next_timeout
82
82
  return nil if @timers.empty?
83
- timeout = @timers.values.map(&:next_fire_time).min - Time.now
83
+ timeout = @timers.values.map(&:next_fire_time).min - Process.clock_gettime(Process::CLOCK_REALTIME)
84
84
  timeout < 0 ? 0 : timeout
85
85
  end
86
86
 
@@ -100,7 +100,7 @@ module NewRelic
100
100
  end
101
101
  end
102
102
 
103
- def run_once(nonblock=false)
103
+ def run_once(nonblock = false)
104
104
  wait_to_run(nonblock)
105
105
 
106
106
  prune_timers
@@ -18,39 +18,7 @@ module NewRelic
18
18
  module External
19
19
  extend self
20
20
 
21
- # This method creates and starts an external request segment using the
22
- # given library, URI, and procedure. This is used to time external calls
23
- # made over HTTP.
24
- #
25
- # @param [String] library a string of the class name of the library used to
26
- # make the external call, for example, 'Net::HTTP'.
27
- #
28
- # @param [String, URI] uri indicates the URI to which the
29
- # external request is being made. The URI should begin with the protocol,
30
- # for example, 'https://github.com'.
31
- #
32
- # @param [String] procedure the HTTP method being used for the external
33
- # request as a string, for example, 'GET'.
34
- #
35
- # @api public
36
- def start_segment(library: nil, uri: nil, procedure: nil)
37
- Deprecator.deprecate 'External.start_segment',
38
- 'Tracer#start_external_request_segment'
39
-
40
- raise ArgumentError, 'Argument `library` is required' if library.nil?
41
- raise ArgumentError, 'Argument `uri` is required' if uri.nil?
42
- raise ArgumentError, 'Argument `procedure` is required' if procedure.nil?
43
-
44
- ::NewRelic::Agent.record_api_supportability_metric(:start_segment)
45
-
46
- ::NewRelic::Agent::Tracer.start_external_request_segment(
47
- library: library,
48
- uri: uri,
49
- procedure: procedure
50
- )
51
- end
52
-
53
- NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
21
+ NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
54
22
  NON_HTTP_CAT_TXN_HEADER = 'NewRelicTransaction'.freeze
55
23
  NON_HTTP_CAT_SYNTHETICS_HEADER = 'NewRelicSynthetics'.freeze
56
24
  NON_HTTP_CAT_CONTENT_LENGTH = -1
@@ -137,7 +105,6 @@ module NewRelic
137
105
  def obfuscator
138
106
  CrossAppTracing.obfuscator
139
107
  end
140
-
141
108
  end
142
109
  end
143
110
  end
@@ -5,9 +5,6 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  module GuidGenerator
8
-
9
- HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
10
-
11
8
  module_function
12
9
 
13
10
  # This method intentionally does not use SecureRandom, because it relies
@@ -16,13 +13,9 @@ module NewRelic
16
13
  # The guids generated by this method may not be _secure_, but they are
17
14
  # random enough for our purposes.
18
15
  def generate_guid length = 16
19
- guid = ''
20
- length.times do |a|
21
- guid << HEX_DIGITS[rand(16)]
22
- end
23
- guid
16
+ guid = rand(16**length).to_s(16)
17
+ guid.length < length ? guid.rjust(length, "0") : guid
24
18
  end
25
-
26
19
  end
27
20
  end
28
21
  end
@@ -5,11 +5,10 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  class Harvester
8
-
9
8
  attr_accessor :starting_pid
10
9
 
11
10
  # Inject target for after_fork call to avoid spawning thread in tests
12
- def initialize(events, after_forker=NewRelic::Agent)
11
+ def initialize(events, after_forker = NewRelic::Agent)
13
12
  # We intentionally don't set our pid as started at this point.
14
13
  # Startup routines must call mark_started when they consider us set!
15
14
  @starting_pid = nil
@@ -22,8 +21,8 @@ module NewRelic
22
21
 
23
22
  def on_transaction(*_)
24
23
  return unless restart_in_children_enabled? &&
25
- needs_restart? &&
26
- harvest_thread_enabled?
24
+ needs_restart? &&
25
+ harvest_thread_enabled?
27
26
 
28
27
  restart_harvest_thread
29
28
  end
@@ -18,7 +18,6 @@ module NewRelic
18
18
  #
19
19
 
20
20
  class Heap
21
-
22
21
  # @param [Array] items an optional array of items to intialize the heap
23
22
  #
24
23
  # @param [Callable] priority_fn an optional priority function used to
@@ -27,7 +26,7 @@ module NewRelic
27
26
  def initialize(items = nil, &priority_fn)
28
27
  @items = []
29
28
  @priority_fn = priority_fn || ->(x) { x }
30
- items.each{ |item| push(item) } if items
29
+ items.each { |item| push(item) } if items
31
30
  end
32
31
 
33
32
  def [](index)
@@ -135,6 +134,5 @@ module NewRelic
135
134
  @items[i], @items[j] = @items[j], @items[i]
136
135
  end
137
136
  end
138
-
139
137
  end
140
138
  end