newrelic_rpm 8.2.0 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1936 -0
  3. data/CHANGELOG.md +17 -2
  4. data/CONTRIBUTING.md +14 -2
  5. data/Guardfile +8 -8
  6. data/Rakefile +5 -7
  7. data/bin/mongrel_rpm +8 -9
  8. data/bin/newrelic +1 -1
  9. data/bin/nrdebug +14 -14
  10. data/init.rb +0 -2
  11. data/lefthook.yml +9 -0
  12. data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
  13. data/lib/new_relic/agent/agent.rb +38 -40
  14. data/lib/new_relic/agent/agent_logger.rb +8 -9
  15. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  16. data/lib/new_relic/agent/attributes.rb +2 -2
  17. data/lib/new_relic/agent/autostart.rb +6 -7
  18. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  19. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  20. data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
  21. data/lib/new_relic/agent/configuration/default_source.rb +318 -324
  22. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  23. data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
  24. data/lib/new_relic/agent/configuration/event_harvest_config.rb +2 -4
  25. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  26. data/lib/new_relic/agent/configuration/manager.rb +57 -57
  27. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  28. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  29. data/lib/new_relic/agent/configuration/server_source.rb +10 -10
  30. data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
  31. data/lib/new_relic/agent/connect/request_builder.rb +13 -16
  32. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  33. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
  34. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  35. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  36. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  37. data/lib/new_relic/agent/database.rb +20 -24
  38. data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
  39. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  40. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  41. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  42. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  43. data/lib/new_relic/agent/datastores.rb +1 -3
  44. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
  45. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
  46. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
  47. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
  48. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
  49. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
  50. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +23 -23
  51. data/lib/new_relic/agent/distributed_tracing.rb +17 -18
  52. data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
  53. data/lib/new_relic/agent/error_collector.rb +17 -17
  54. data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
  55. data/lib/new_relic/agent/error_filter.rb +6 -8
  56. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
  57. data/lib/new_relic/agent/event_aggregator.rb +1 -1
  58. data/lib/new_relic/agent/event_buffer.rb +6 -7
  59. data/lib/new_relic/agent/event_listener.rb +0 -1
  60. data/lib/new_relic/agent/event_loop.rb +10 -10
  61. data/lib/new_relic/agent/external.rb +1 -2
  62. data/lib/new_relic/agent/guid_generator.rb +1 -3
  63. data/lib/new_relic/agent/harvester.rb +3 -4
  64. data/lib/new_relic/agent/heap.rb +1 -3
  65. data/lib/new_relic/agent/hostname.rb +3 -3
  66. data/lib/new_relic/agent/http_clients/abstract.rb +5 -7
  67. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
  68. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
  69. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
  70. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
  71. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +2 -3
  72. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
  73. data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
  74. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
  75. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +9 -10
  76. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  77. data/lib/new_relic/agent/instrumentation/active_job.rb +4 -3
  78. data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
  79. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
  80. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
  81. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
  82. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
  83. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
  84. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
  85. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  86. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
  87. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
  88. data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
  89. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  90. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
  91. data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
  92. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  93. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -6
  94. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
  95. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  96. data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
  97. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  98. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  99. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  100. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  101. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  102. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  103. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  104. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  105. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  106. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  107. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +0 -1
  108. data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
  109. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -1
  110. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +0 -1
  111. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -0
  112. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  113. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
  114. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
  115. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
  116. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
  117. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
  118. data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
  119. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
  120. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
  121. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
  122. data/lib/new_relic/agent/instrumentation/padrino.rb +0 -5
  123. data/lib/new_relic/agent/instrumentation/queue_time.rb +5 -5
  124. data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
  125. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
  126. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
  127. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
  128. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  129. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
  130. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
  131. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
  132. data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
  133. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
  134. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  135. data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
  136. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
  137. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
  138. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  139. data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
  140. data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
  141. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
  142. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
  143. data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
  144. data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
  145. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
  146. data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -4
  147. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
  148. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
  149. data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
  150. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +0 -1
  151. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
  152. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
  153. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
  154. data/lib/new_relic/agent/internal_agent_error.rb +1 -1
  155. data/lib/new_relic/agent/javascript_instrumentor.rb +28 -28
  156. data/lib/new_relic/agent/logging.rb +8 -4
  157. data/lib/new_relic/agent/memory_logger.rb +1 -1
  158. data/lib/new_relic/agent/messaging.rb +42 -43
  159. data/lib/new_relic/agent/method_tracer.rb +9 -12
  160. data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
  161. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +13 -12
  162. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
  163. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
  164. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
  165. data/lib/new_relic/agent/monitors.rb +1 -2
  166. data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
  167. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
  168. data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
  169. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
  170. data/lib/new_relic/agent/new_relic_service.rb +20 -20
  171. data/lib/new_relic/agent/noticible_error.rb +0 -2
  172. data/lib/new_relic/agent/null_logger.rb +6 -2
  173. data/lib/new_relic/agent/obfuscator.rb +6 -8
  174. data/lib/new_relic/agent/parameter_filtering.rb +3 -5
  175. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  176. data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
  177. data/lib/new_relic/agent/pipe_service.rb +1 -1
  178. data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
  179. data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
  180. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
  181. data/lib/new_relic/agent/rules_engine.rb +2 -2
  182. data/lib/new_relic/agent/sampler.rb +2 -3
  183. data/lib/new_relic/agent/sampler_collection.rb +2 -3
  184. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +3 -3
  185. data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
  186. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  187. data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
  188. data/lib/new_relic/agent/span_event_primitive.rb +39 -39
  189. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  190. data/lib/new_relic/agent/stats.rb +16 -16
  191. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  192. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  193. data/lib/new_relic/agent/stats_engine.rb +6 -6
  194. data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
  195. data/lib/new_relic/agent/system_info.rb +22 -20
  196. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  197. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  198. data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
  199. data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
  200. data/lib/new_relic/agent/tracer.rb +37 -43
  201. data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
  202. data/lib/new_relic/agent/transaction/datastore_segment.rb +5 -7
  203. data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -9
  204. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  205. data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -5
  206. data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
  207. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  208. data/lib/new_relic/agent/transaction/segment.rb +3 -3
  209. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  210. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  211. data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
  212. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  213. data/lib/new_relic/agent/transaction/tracing.rb +1 -3
  214. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  215. data/lib/new_relic/agent/transaction.rb +79 -81
  216. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
  217. data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
  218. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  219. data/lib/new_relic/agent/transaction_metrics.rb +3 -3
  220. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  221. data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
  222. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  223. data/lib/new_relic/agent/utilization_data.rb +3 -4
  224. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  225. data/lib/new_relic/agent/vm/snapshot.rb +3 -3
  226. data/lib/new_relic/agent/worker_loop.rb +3 -5
  227. data/lib/new_relic/agent.rb +22 -22
  228. data/lib/new_relic/cli/command.rb +15 -17
  229. data/lib/new_relic/cli/commands/deployments.rb +20 -22
  230. data/lib/new_relic/cli/commands/install.rb +6 -10
  231. data/lib/new_relic/coerce.rb +5 -8
  232. data/lib/new_relic/collection_helper.rb +48 -47
  233. data/lib/new_relic/control/class_methods.rb +2 -2
  234. data/lib/new_relic/control/frameworks/external.rb +1 -1
  235. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  236. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  237. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  238. data/lib/new_relic/control/instance_methods.rb +4 -5
  239. data/lib/new_relic/control/instrumentation.rb +4 -5
  240. data/lib/new_relic/control/server_methods.rb +2 -3
  241. data/lib/new_relic/control.rb +0 -1
  242. data/lib/new_relic/dependency_detection.rb +6 -8
  243. data/lib/new_relic/environment_report.rb +16 -18
  244. data/lib/new_relic/helper.rb +5 -5
  245. data/lib/new_relic/language_support.rb +1 -1
  246. data/lib/new_relic/latest_changes.rb +2 -2
  247. data/lib/new_relic/local_environment.rb +7 -7
  248. data/lib/new_relic/metric_data.rb +6 -7
  249. data/lib/new_relic/metric_spec.rb +3 -3
  250. data/lib/new_relic/noticed_error.rb +14 -15
  251. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  252. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  253. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  254. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  255. data/lib/new_relic/supportability_helper.rb +1 -2
  256. data/lib/new_relic/version.rb +3 -4
  257. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  258. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  259. data/lib/tasks/all.rb +1 -1
  260. data/lib/tasks/config.rake +21 -21
  261. data/lib/tasks/multiverse.rb +4 -6
  262. data/lib/tasks/tests.rake +3 -7
  263. data/newrelic_rpm.gemspec +13 -12
  264. data/recipes/newrelic.rb +1 -1
  265. data/test/agent_helper.rb +55 -55
  266. metadata +33 -4
@@ -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 = Process.clock_gettime(Process::CLOCK_REALTIME)
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
@@ -45,7 +45,7 @@ module NewRelic
45
45
  @last_fired_at = Process.clock_gettime(Process::CLOCK_REALTIME)
46
46
  end
47
47
 
48
- def due?(now=Process.clock_gettime(Process::CLOCK_REALTIME))
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
@@ -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,7 +18,7 @@ module NewRelic
18
18
  module External
19
19
  extend self
20
20
 
21
- NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
21
+ NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
22
22
  NON_HTTP_CAT_TXN_HEADER = 'NewRelicTransaction'.freeze
23
23
  NON_HTTP_CAT_SYNTHETICS_HEADER = 'NewRelicSynthetics'.freeze
24
24
  NON_HTTP_CAT_CONTENT_LENGTH = -1
@@ -105,7 +105,6 @@ module NewRelic
105
105
  def obfuscator
106
106
  CrossAppTracing.obfuscator
107
107
  end
108
-
109
108
  end
110
109
  end
111
110
  end
@@ -5,8 +5,7 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  module GuidGenerator
8
-
9
- HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
8
+ HEX_DIGITS = (0..15).map { |i| i.to_s(16) }
10
9
 
11
10
  module_function
12
11
 
@@ -22,7 +21,6 @@ module NewRelic
22
21
  end
23
22
  guid
24
23
  end
25
-
26
24
  end
27
25
  end
28
26
  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
@@ -19,11 +19,11 @@ module NewRelic
19
19
 
20
20
  # calling hostname with -f on some OS's (NetBSD, FreeBSD, Solaris)
21
21
  # produces invalid option error, but doesn't raise exception. Instead,
22
- # we get back empty string. So, solution here is to check for non-zero
22
+ # we get back empty string. So, solution here is to check for non-zero
23
23
  # exit status and retry the command without the -f flag.
24
24
  def self.get_fqdn
25
- fqdn = %x[hostname -f].chomp!
26
- fqdn = %x[hostname].chomp! unless $?.exitstatus.zero?
25
+ fqdn = %x(hostname -f).chomp!
26
+ fqdn = %x(hostname).chomp! unless $?.exitstatus.zero?
27
27
  fqdn
28
28
  rescue => e
29
29
  NewRelic::Agent.logger.debug "Unable to determine fqdn #{e}"
@@ -15,7 +15,6 @@ module NewRelic
15
15
  #
16
16
  # @api public
17
17
  class AbstractRequest
18
-
19
18
  def []
20
19
  raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
21
20
  end
@@ -41,13 +40,12 @@ module NewRelic
41
40
  end
42
41
  end
43
42
 
44
- # This class implements the adaptor pattern and is used internally provide
43
+ # This class implements the adaptor pattern and is used internally provide
45
44
  # uniform access to the underlying HTTP Client's response object
46
45
  # NOTE: response_object should be non-nil!
47
46
  class AbstractResponse # :nodoc:
48
-
49
47
  def initialize(wrapped_response)
50
- if wrapped_response.nil?
48
+ if wrapped_response.nil?
51
49
  raise ArgumentError, WHINY_NIL_ERROR % self.class
52
50
  end
53
51
  @wrapped_response = wrapped_response
@@ -57,13 +55,13 @@ module NewRelic
57
55
  !!status_code
58
56
  end
59
57
 
60
- # most HTTP client libraries report the HTTP status code as an integer, so
58
+ # most HTTP client libraries report the HTTP status code as an integer, so
61
59
  # we expect status_code to be set only if a non-zero value is present
62
60
  def status_code
63
61
  @status_code ||= get_status_code
64
62
  end
65
63
 
66
- private
64
+ private
67
65
 
68
66
  def get_status_code_using(method_name)
69
67
  return unless @wrapped_response.respond_to?(method_name)
@@ -71,7 +69,7 @@ module NewRelic
71
69
  code == 0 ? nil : code
72
70
  end
73
71
 
74
- # Override this method to memoize a non-zero Integer representation
72
+ # Override this method to memoize a non-zero Integer representation
75
73
  # of HTTP status code from the response object
76
74
  def get_status_code
77
75
  get_status_code_using :code
@@ -8,7 +8,6 @@ require_relative 'abstract'
8
8
  module NewRelic
9
9
  module Agent
10
10
  module HTTPClients
11
-
12
11
  class CurbRequest
13
12
  CURB = 'Curb'
14
13
  LHOST = 'host'
@@ -34,7 +33,7 @@ module NewRelic
34
33
  @curlobj._nr_http_verb
35
34
  end
36
35
 
37
- def []( key )
36
+ def [](key)
38
37
  @curlobj.headers[key]
39
38
  end
40
39
 
@@ -48,7 +47,6 @@ module NewRelic
48
47
  end
49
48
 
50
49
  class CurbResponse < AbstractResponse
51
-
52
50
  def initialize wrapped_response
53
51
  super wrapped_response
54
52
  @headers = {}
@@ -75,8 +73,6 @@ module NewRelic
75
73
  get_status_code_using :response_code
76
74
  end
77
75
  end
78
-
79
76
  end
80
-
81
77
  end
82
78
  end
@@ -31,8 +31,8 @@ module NewRelic
31
31
  private
32
32
 
33
33
  def get_attribute name
34
- if @wrapped_response.respond_to?(name)
35
- @wrapped_response.send(name)
34
+ if @wrapped_response.respond_to?(name)
35
+ @wrapped_response.send(name)
36
36
  else
37
37
  @wrapped_response[name]
38
38
  end
@@ -57,8 +57,8 @@ module NewRelic
57
57
 
58
58
  @method = @datum[:method].to_s.upcase
59
59
  @scheme = @datum[:scheme]
60
- @port = @datum[:port]
61
- @path = @datum[:path]
60
+ @port = @datum[:port]
61
+ @path = @datum[:path]
62
62
  end
63
63
 
64
64
  def type
@@ -10,7 +10,7 @@ module NewRelic
10
10
  module HTTPClients
11
11
  class HTTPResponse < AbstractResponse
12
12
  def [](key)
13
- _, value = @wrapped_response.headers.find{ |k, _| key.downcase == k.downcase }
13
+ _, value = @wrapped_response.headers.find { |k, _| key.downcase == k.downcase }
14
14
  value unless value.nil?
15
15
  end
16
16
 
@@ -21,8 +21,8 @@ module NewRelic
21
21
 
22
22
  class HTTPRequest < AbstractRequest
23
23
  HTTP_RB = 'http.rb'
24
- HOST = 'host'
25
- COLON = ':'
24
+ HOST = 'host'
25
+ COLON = ':'
26
26
 
27
27
  def initialize wrapped_request
28
28
  @wrapped_request = wrapped_request
@@ -9,9 +9,8 @@ module NewRelic
9
9
  module Agent
10
10
  module HTTPClients
11
11
  class HTTPClientResponse < AbstractResponse
12
-
13
12
  def [](key)
14
- @wrapped_response.headers.each do |k,v|
13
+ @wrapped_response.headers.each do |k, v|
15
14
  if key.downcase == k.downcase
16
15
  return v
17
16
  end
@@ -10,7 +10,6 @@ module NewRelic
10
10
  module Agent
11
11
  module HTTPClients
12
12
  class NetHTTPResponse < AbstractResponse
13
-
14
13
  def [](key)
15
14
  @wrapped_response[key]
16
15
  end
@@ -63,14 +62,14 @@ module NewRelic
63
62
  ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@request.path)
64
63
  else
65
64
  connection_address = @connection.address
66
- if (connection_address =~ Resolv::IPv6::Regex)
65
+ if connection_address =~ Resolv::IPv6::Regex
67
66
  connection_address = "[#{connection_address}]"
68
67
  end
69
68
 
70
69
  scheme = @connection.use_ssl? ? 'https' : 'http'
71
70
  ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(
72
71
  "#{scheme}://#{connection_address}:#{@connection.port}#{@request.path}"
73
- )
72
+ )
74
73
  end
75
74
  end
76
75
  end
@@ -9,7 +9,6 @@ module NewRelic
9
9
  module Agent
10
10
  module HTTPClients
11
11
  class TyphoeusHTTPResponse < AbstractResponse
12
-
13
12
  def [](key)
14
13
  unless headers.nil?
15
14
  result = headers[key]
@@ -22,7 +21,7 @@ module NewRelic
22
21
 
23
22
  def to_hash
24
23
  hash = {}
25
- headers.each do |(k,v)|
24
+ headers.each do |(k, v)|
26
25
  hash[k] = v
27
26
  end
28
27
  hash
@@ -41,7 +40,7 @@ module NewRelic
41
40
  @uri = case request.url
42
41
  when ::URI then request.url
43
42
  else NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(request.url)
44
- end
43
+ end
45
44
  end
46
45
 
47
46
  TYPHOEUS = "Typhoeus".freeze
@@ -14,7 +14,6 @@ module NewRelic
14
14
  module Agent
15
15
  module HTTPClients
16
16
  module URIUtil
17
-
18
17
  def self.obfuscated_uri(url)
19
18
  parse_and_normalize_url(url).tap do |obfuscated|
20
19
  obfuscated.user = nil
@@ -7,10 +7,9 @@ module NewRelic
7
7
  module Agent
8
8
  module Instrumentation
9
9
  class ActionCableSubscriber < NotificationsSubscriber
10
-
11
10
  PERFORM_ACTION = 'perform_action.action_cable'.freeze
12
11
 
13
- def start(name, id, payload) #THREAD_LOCAL_ACCESS
12
+ def start(name, id, payload) # THREAD_LOCAL_ACCESS
14
13
  return unless state.is_execution_traced?
15
14
 
16
15
  finishable = if name == PERFORM_ACTION
@@ -26,7 +25,7 @@ module NewRelic
26
25
  log_notification_error e, name, 'start'
27
26
  end
28
27
 
29
- def finish(name, id, payload) #THREAD_LOCAL_ACCESS
28
+ def finish(name, id, payload) # THREAD_LOCAL_ACCESS
30
29
  return unless state.is_execution_traced?
31
30
 
32
31
  if exception = exception_object(payload)
@@ -9,8 +9,7 @@ module NewRelic
9
9
  module Agent
10
10
  module Instrumentation
11
11
  class ActionControllerSubscriber < NotificationsSubscriber
12
-
13
- def start(name, id, payload) #THREAD_LOCAL_ACCESS
12
+ def start(name, id, payload) # THREAD_LOCAL_ACCESS
14
13
  # @req is a historically stable but not guaranteed Rails header property
15
14
  request = payload[:headers].instance_variable_get(:@req)
16
15
 
@@ -29,7 +28,7 @@ module NewRelic
29
28
  log_notification_error(e, name, 'start')
30
29
  end
31
30
 
32
- def finish(name, id, payload) #THREAD_LOCAL_ACCESS
31
+ def finish(name, id, payload) # THREAD_LOCAL_ACCESS
33
32
  finishable = pop_segment(id)
34
33
 
35
34
  if state.is_execution_traced? \
@@ -49,21 +48,21 @@ module NewRelic
49
48
 
50
49
  def start_transaction_or_segment(payload, request, controller_class)
51
50
  Tracer.start_transaction_or_segment(
52
- name: format_metric_name(payload[:action], controller_class),
53
- category: :controller,
54
- options: {
55
- request: request,
56
- filtered_params: NewRelic::Agent::ParameterFiltering.filter_using_rails(
51
+ name: format_metric_name(payload[:action], controller_class),
52
+ category: :controller,
53
+ options: {
54
+ request: request,
55
+ filtered_params: NewRelic::Agent::ParameterFiltering.filter_using_rails(
57
56
  payload[:params],
58
57
  Rails.application.config.filter_parameters
59
58
  ),
60
59
  apdex_start_time: queue_start(request),
61
- ignore_apdex: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
60
+ ignore_apdex: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
62
61
  ControllerInstrumentation::NR_IGNORE_APDEX_KEY,
63
62
  controller_class,
64
63
  payload[:action]
65
64
  ),
66
- ignore_enduser: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
65
+ ignore_enduser: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
67
66
  ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY,
68
67
  controller_class,
69
68
  payload[:action]
@@ -9,8 +9,7 @@ module NewRelic
9
9
  module Agent
10
10
  module Instrumentation
11
11
  class ActionViewSubscriber < NotificationsSubscriber
12
-
13
- def start(name, id, payload) #THREAD_LOCAL_ACCESS
12
+ def start(name, id, payload) # THREAD_LOCAL_ACCESS
14
13
  parent = segment_stack[id].last
15
14
  metric_name = format_metric_name(name, payload, parent)
16
15
 
@@ -58,15 +57,15 @@ module NewRelic
58
57
  || metric_name == "View/#{::NewRelic::Agent::UNKNOWN_METRIC}/Partial"
59
58
  end
60
59
 
61
- RENDER_TEMPLATE_EVENT_NAME = 'render_template.action_view'.freeze
62
- RENDER_PARTIAL_EVENT_NAME = 'render_partial.action_view'.freeze
60
+ RENDER_TEMPLATE_EVENT_NAME = 'render_template.action_view'.freeze
61
+ RENDER_PARTIAL_EVENT_NAME = 'render_partial.action_view'.freeze
63
62
  RENDER_COLLECTION_EVENT_NAME = 'render_collection.action_view'.freeze
64
63
 
65
64
  def metric_action(name)
66
65
  case name
67
66
  when /#{RENDER_TEMPLATE_EVENT_NAME}$/ then 'Rendering'
68
- when RENDER_PARTIAL_EVENT_NAME then 'Partial'
69
- when RENDER_COLLECTION_EVENT_NAME then 'Partial'
67
+ when RENDER_PARTIAL_EVENT_NAME then 'Partial'
68
+ when RENDER_COLLECTION_EVENT_NAME then 'Partial'
70
69
  end
71
70
  end
72
71
 
@@ -107,6 +106,5 @@ module NewRelic
107
106
  end
108
107
  end
109
108
  end
110
-
111
109
  end
112
110
  end
@@ -44,12 +44,13 @@ module NewRelic
44
44
 
45
45
  # Don't nest transactions if we're already in a web transaction.
46
46
  # Probably inline processing the job if that happens, so just trace.
47
- if txn && txn.recording_web_transaction?
47
+ if txn && txn.recording_web_transaction?
48
48
  run_in_trace(job, block, :Consume)
49
49
  elsif txn && !txn.recording_web_transaction?
50
50
  ::NewRelic::Agent::Transaction.set_default_transaction_name(
51
51
  transaction_name_suffix_for_job(job),
52
- transaction_category)
52
+ transaction_category
53
+ )
53
54
  block.call
54
55
  else
55
56
  run_in_transaction(job, block)
@@ -64,7 +65,7 @@ module NewRelic
64
65
 
65
66
  def self.run_in_transaction(job, block)
66
67
  ::NewRelic::Agent::Tracer.in_transaction(name: transaction_name_for_job(job),
67
- category: :other,
68
+ category: :other,
68
69
  &block)
69
70
  end
70
71
 
@@ -27,8 +27,8 @@ DependencyDetection.defer do
27
27
  [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update].each do |operation|
28
28
  if implemented_methods.include?(operation)
29
29
  add_method_tracer operation, [-> (*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
30
- -> (*) { "ActiveMerchant/gateway/#{gateway_name}" },
31
- -> (*) { "ActiveMerchant/operation/#{operation}" }]
30
+ -> (*) { "ActiveMerchant/gateway/#{gateway_name}" },
31
+ -> (*) { "ActiveMerchant/operation/#{operation}" }]
32
32
  end
33
33
  end
34
34
  end
@@ -11,7 +11,7 @@ module NewRelic
11
11
  EXPLAINER = lambda do |statement|
12
12
  connection = NewRelic::Agent::Database.get_connection(statement.config) do
13
13
  ::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
14
- statement.config)
14
+ statement.config)
15
15
  end
16
16
  if connection && connection.respond_to?(:execute)
17
17
  return connection.execute("EXPLAIN #{statement.sql}")
@@ -46,28 +46,29 @@ module NewRelic
46
46
  if RUBY_VERSION < "2.7.0"
47
47
  def log_with_newrelic_instrumentation(*args, &block)
48
48
  state = NewRelic::Agent::Tracer.state
49
-
49
+
50
50
  if !state.is_execution_traced?
51
51
  return log_without_newrelic_instrumentation(*args, &block)
52
52
  end
53
-
53
+
54
54
  sql, name, _ = args
55
-
55
+
56
56
  product, operation, collection = ActiveRecordHelper.product_operation_collection_for(
57
57
  NewRelic::Helper.correctly_encoded(name),
58
58
  NewRelic::Helper.correctly_encoded(sql),
59
- @config && @config[:adapter])
60
-
59
+ @config && @config[:adapter]
60
+ )
61
+
61
62
  host = nil
62
63
  port_path_or_id = nil
63
64
  database = nil
64
-
65
+
65
66
  if ActiveRecordHelper::InstanceIdentification.supported_adapter?(@config)
66
67
  host = ActiveRecordHelper::InstanceIdentification.host(@config)
67
68
  port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(@config)
68
69
  database = @config && @config[:database]
69
70
  end
70
-
71
+
71
72
  segment = NewRelic::Agent::Tracer.start_datastore_segment(
72
73
  product: product,
73
74
  operation: operation,
@@ -77,7 +78,7 @@ module NewRelic
77
78
  database_name: database
78
79
  )
79
80
  segment._notice_sql(sql, @config, EXPLAINER)
80
-
81
+
81
82
  begin
82
83
  NewRelic::Agent::Tracer.capture_segment_error segment do
83
84
  log_without_newrelic_instrumentation(*args, &block)
@@ -86,31 +87,32 @@ module NewRelic
86
87
  segment.finish if segment
87
88
  end
88
89
  end
89
- else
90
+ else
90
91
  def log_with_newrelic_instrumentation(*args, **kwargs, &block)
91
92
  state = NewRelic::Agent::Tracer.state
92
-
93
+
93
94
  if !state.is_execution_traced?
94
95
  return log_without_newrelic_instrumentation(*args, **kwargs, &block)
95
96
  end
96
-
97
+
97
98
  sql, name, _ = args
98
-
99
+
99
100
  product, operation, collection = ActiveRecordHelper.product_operation_collection_for(
100
101
  NewRelic::Helper.correctly_encoded(name),
101
102
  NewRelic::Helper.correctly_encoded(sql),
102
- @config && @config[:adapter])
103
-
103
+ @config && @config[:adapter]
104
+ )
105
+
104
106
  host = nil
105
107
  port_path_or_id = nil
106
108
  database = nil
107
-
109
+
108
110
  if ActiveRecordHelper::InstanceIdentification.supported_adapter?(@config)
109
111
  host = ActiveRecordHelper::InstanceIdentification.host(@config)
110
112
  port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(@config)
111
113
  database = @config && @config[:database]
112
114
  end
113
-
115
+
114
116
  segment = NewRelic::Agent::Tracer.start_datastore_segment(
115
117
  product: product,
116
118
  operation: operation,
@@ -120,7 +122,7 @@ module NewRelic
120
122
  database_name: database
121
123
  )
122
124
  segment._notice_sql(sql, @config, EXPLAINER)
123
-
125
+
124
126
  begin
125
127
  NewRelic::Agent::Tracer.capture_segment_error segment do
126
128
  log_without_newrelic_instrumentation(*args, **kwargs, &block)