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
data/test/agent_helper.rb CHANGED
@@ -28,7 +28,7 @@ module MiniTest
28
28
  end
29
29
 
30
30
  class ArrayLogDevice
31
- def initialize array=[]
31
+ def initialize array = []
32
32
  @array = array
33
33
  end
34
34
  attr_reader :array
@@ -40,7 +40,7 @@ class ArrayLogDevice
40
40
  def close; end
41
41
  end
42
42
 
43
- def fake_guid length=16
43
+ def fake_guid length = 16
44
44
  NewRelic::Agent::GuidGenerator.generate_guid length
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ def assert_match matcher, obj, msg = nil
51
51
  assert matcher =~ obj, msg
52
52
  end
53
53
 
54
- def assert_between floor, ceiling, value, message="expected #{floor} <= #{value} <= #{ceiling}"
54
+ def assert_between floor, ceiling, value, message = "expected #{floor} <= #{value} <= #{ceiling}"
55
55
  assert((floor <= value && value <= ceiling), message)
56
56
  end
57
57
 
@@ -70,7 +70,7 @@ end
70
70
  def assert_has_traced_error error_class
71
71
  errors = harvest_error_traces!
72
72
  assert \
73
- errors.find {|e| e.exception_class_name == error_class.name} != nil, \
73
+ errors.find { |e| e.exception_class_name == error_class.name } != nil, \
74
74
  "Didn't find error of class #{error_class}"
75
75
  end
76
76
 
@@ -109,21 +109,21 @@ unless defined? assert_block
109
109
  end
110
110
 
111
111
  unless defined? assert_includes
112
- def assert_includes collection, member, msg=nil
112
+ def assert_includes collection, member, msg = nil
113
113
  msg = "Expected #{collection.inspect} to include #{member.inspect}"
114
- assert_block( msg ) { collection.include?(member) }
114
+ assert_block(msg) { collection.include?(member) }
115
115
  end
116
116
  end
117
117
 
118
118
  unless defined? assert_not_includes
119
- def assert_not_includes collection, member, msg=nil
119
+ def assert_not_includes collection, member, msg = nil
120
120
  msg = "Expected #{collection.inspect} not to include #{member.inspect}"
121
121
  assert !collection.include?(member), msg
122
122
  end
123
123
  end
124
124
 
125
125
  unless defined? assert_empty
126
- def assert_empty collection, msg=nil
126
+ def assert_empty collection, msg = nil
127
127
  assert collection.empty?, msg
128
128
  end
129
129
  end
@@ -160,7 +160,7 @@ end
160
160
  def assert_audit_log_contains_object audit_log_contents, o, format = :json
161
161
  case o
162
162
  when Hash
163
- o.each do |k,v|
163
+ o.each do |k, v|
164
164
  assert_audit_log_contains_object(audit_log_contents, v, format)
165
165
  assert_audit_log_contains_object(audit_log_contents, k, format)
166
166
  end
@@ -176,14 +176,14 @@ def assert_audit_log_contains_object audit_log_contents, o, format = :json
176
176
  end
177
177
 
178
178
  def compare_metrics expected, actual
179
- actual.delete_if {|a| a.include?('GC/Transaction/') }
179
+ actual.delete_if { |a| a.include?('GC/Transaction/') }
180
180
  assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}")
181
181
  end
182
182
 
183
183
  def metric_spec_from_specish specish
184
184
  spec = case specish
185
185
  when String then NewRelic::MetricSpec.new(specish)
186
- when Array then NewRelic::MetricSpec.new(*specish)
186
+ when Array then NewRelic::MetricSpec.new(*specish)
187
187
  end
188
188
  spec
189
189
  end
@@ -193,17 +193,17 @@ def _normalize_metric_expectations expectations
193
193
  when Array
194
194
  hash = {}
195
195
  # Just assert that the metric is present, nothing about the attributes
196
- expectations.each { |k| hash[k] = { } }
196
+ expectations.each { |k| hash[k] = {} }
197
197
  hash
198
198
  when String
199
- { expectations => {} }
199
+ {expectations => {}}
200
200
  else
201
201
  expectations
202
202
  end
203
203
  end
204
204
 
205
205
  def dump_stats stats
206
- str = " Call count: #{stats.call_count}\n"
206
+ str = " Call count: #{stats.call_count}\n"
207
207
  str << " Total call time: #{stats.total_call_time}\n"
208
208
  str << " Total exclusive time: #{stats.total_exclusive_time}\n"
209
209
  str << " Min call time: #{stats.min_call_time}\n"
@@ -259,7 +259,7 @@ end
259
259
  # the :ignore_filter option. This will allow you to specify a Regex that
260
260
  # allowlists broad swathes of metric territory (e.g. 'Supportability/').
261
261
  #
262
- def assert_metrics_recorded_exclusive expected, options={}
262
+ def assert_metrics_recorded_exclusive expected, options = {}
263
263
  expected = _normalize_metric_expectations(expected)
264
264
  assert_metrics_recorded(expected)
265
265
 
@@ -272,7 +272,7 @@ def assert_metrics_recorded_exclusive expected, options={}
272
272
  recorded_metrics.reject! { |m| m.name.match(options[:ignore_filter]) }
273
273
  end
274
274
 
275
- expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s) }
275
+ expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s) }
276
276
 
277
277
  unexpected_metrics = recorded_metrics - expected_metrics
278
278
  unexpected_metrics.reject! { |m| m.name =~ /GC\/Transaction/ }
@@ -320,7 +320,7 @@ def assert_no_metrics_match regex
320
320
  assert_equal(
321
321
  [],
322
322
  matching_metrics,
323
- "Found unexpected metrics:\n" + matching_metrics.map { |m| " '#{m}'"}.join("\n") + "\n\n"
323
+ "Found unexpected metrics:\n" + matching_metrics.map { |m| " '#{m}'" }.join("\n") + "\n\n"
324
324
  )
325
325
  end
326
326
 
@@ -333,12 +333,12 @@ def format_metric_spec_list specs
333
333
  "[\n #{spec_strings.join(",\n ")}\n]"
334
334
  end
335
335
 
336
- def assert_truthy expected, msg=nil
336
+ def assert_truthy expected, msg = nil
337
337
  msg ||= "Expected #{expected.inspect} to be truthy"
338
338
  assert !!expected, msg
339
339
  end
340
340
 
341
- def assert_falsy expected, msg=nil
341
+ def assert_falsy expected, msg = nil
342
342
  msg ||= "Expected #{expected.inspect} to be falsy"
343
343
  assert !expected, msg
344
344
  end
@@ -372,7 +372,7 @@ end
372
372
  # in_transaction('foobar', :category => :controller) { ... }
373
373
  #
374
374
  def in_transaction *args, &blk
375
- opts = (args.last && args.last.is_a?(Hash)) ? args.pop : {}
375
+ opts = args.last && args.last.is_a?(Hash) ? args.pop : {}
376
376
  category = (opts && opts.delete(:category)) || :other
377
377
 
378
378
  # At least one test passes `:transaction_name => nil`, so handle it gently
@@ -442,13 +442,13 @@ end
442
442
 
443
443
  # Convenience wrapper around in_transaction that sets the category so that it
444
444
  # looks like we are in a web transaction
445
- def in_web_transaction name='dummy'
445
+ def in_web_transaction name = 'dummy'
446
446
  in_transaction(name, :category => :controller, :request => stub(:path => '/')) do |txn|
447
447
  yield txn
448
448
  end
449
449
  end
450
450
 
451
- def in_background_transaction name='silly'
451
+ def in_background_transaction name = 'silly'
452
452
  in_transaction(name, :category => :task) do |txn|
453
453
  yield txn
454
454
  end
@@ -483,7 +483,7 @@ def last_sql_trace
483
483
  NewRelic::Agent.agent.sql_sampler.sql_traces.values.last
484
484
  end
485
485
 
486
- def find_last_transaction_node transaction_sample=nil
486
+ def find_last_transaction_node transaction_sample = nil
487
487
  if transaction_sample
488
488
  root_node = transaction_sample.root_node
489
489
  else
@@ -491,7 +491,7 @@ def find_last_transaction_node transaction_sample=nil
491
491
  end
492
492
 
493
493
  last_node = nil
494
- root_node.each_node {|s| last_node = s }
494
+ root_node.each_node { |s| last_node = s }
495
495
 
496
496
  return last_node
497
497
  end
@@ -531,7 +531,7 @@ def find_all_nodes_with_name_matching transaction_sample, regexes
531
531
  matching_nodes
532
532
  end
533
533
 
534
- def with_config config_hash, at_start=true
534
+ def with_config config_hash, at_start = true
535
535
  config = NewRelic::Agent::Configuration::DottedHash.new(config_hash, true)
536
536
  NewRelic::Agent.config.add_config_for_testing(config, at_start)
537
537
  NewRelic::Agent.instance.refresh_attribute_filter
@@ -543,7 +543,7 @@ def with_config config_hash, at_start=true
543
543
  end
544
544
  end
545
545
 
546
- def with_server_source config_hash, at_start=true
546
+ def with_server_source config_hash, at_start = true
547
547
  with_config config_hash, at_start do
548
548
  NewRelic::Agent.config.notify_server_source_added
549
549
  yield
@@ -582,7 +582,7 @@ unless Time.respond_to?(:__original_now)
582
582
  end
583
583
  end
584
584
 
585
- def nr_freeze_time now=Time.now
585
+ def nr_freeze_time now = Time.now
586
586
  Time.__frozen_now = now
587
587
  end
588
588
 
@@ -607,11 +607,11 @@ unless Process.respond_to?(:__original_clock_gettime)
607
607
  end
608
608
  end
609
609
 
610
- def advance_process_time(seconds, clock_id=Process::CLOCK_REALTIME)
610
+ def advance_process_time(seconds, clock_id = Process::CLOCK_REALTIME)
611
611
  Process.__frozen_clock_gettime = Process.clock_gettime(clock_id) + seconds
612
612
  end
613
613
 
614
- def nr_freeze_process_time(now=Process.clock_gettime(Process::CLOCK_REALTIME))
614
+ def nr_freeze_process_time(now = Process.clock_gettime(Process::CLOCK_REALTIME))
615
615
  Process.__frozen_clock_gettime = now
616
616
  end
617
617
 
@@ -619,7 +619,7 @@ def nr_unfreeze_process_time
619
619
  Process.__frozen_clock_gettime = nil
620
620
  end
621
621
 
622
- def with_constant_defined constant_symbol, implementation=Module.new
622
+ def with_constant_defined constant_symbol, implementation = Module.new
623
623
  const_path = constant_path(constant_symbol.to_s)
624
624
 
625
625
  if const_path
@@ -639,7 +639,7 @@ def with_constant_defined constant_symbol, implementation=Module.new
639
639
  end
640
640
  end
641
641
 
642
- def constant_path name, opts={}
642
+ def constant_path name, opts = {}
643
643
  allow_partial = opts[:allow_partial]
644
644
  path = [Object]
645
645
  parts = name.gsub(/^::/, '').split('::')
@@ -673,7 +673,7 @@ def with_debug_logging
673
673
  orig_logger = NewRelic::Agent.logger
674
674
  $stderr.puts '', '---', ''
675
675
  NewRelic::Agent.logger =
676
- NewRelic::Agent::AgentLogger.new('', Logger.new($stderr) )
676
+ NewRelic::Agent::AgentLogger.new('', Logger.new($stderr))
677
677
 
678
678
  with_config(:log_level => 'debug') do
679
679
  yield
@@ -682,11 +682,11 @@ ensure
682
682
  NewRelic::Agent.logger = orig_logger
683
683
  end
684
684
 
685
- def create_agent_command args={}
686
- NewRelic::Agent::Commands::AgentCommand.new([-1, { "name" => "command_name", "arguments" => args}])
685
+ def create_agent_command args = {}
686
+ NewRelic::Agent::Commands::AgentCommand.new([-1, {"name" => "command_name", "arguments" => args}])
687
687
  end
688
688
 
689
- def wait_for_backtrace_service_poll opts={}
689
+ def wait_for_backtrace_service_poll opts = {}
690
690
  defaults = {
691
691
  :timeout => 10.0,
692
692
  :service => NewRelic::Agent.agent.agent_command_router.backtrace_service,
@@ -703,18 +703,18 @@ def wait_for_backtrace_service_poll opts={}
703
703
  sleep(0.01)
704
704
  if Process.clock_gettime(Process::CLOCK_REALTIME) > deadline
705
705
  raise "Timed out waiting #{opts[:timeout]} s for backtrace service poll\n" +
706
- "Worker loop ran for #{opts[:service].worker_loop.iterations} iterations\n\n" +
707
- Thread.list.map { |t|
708
- "#{t.to_s}: newrelic_label: #{t[:newrelic_label].inspect}\n\n" +
709
- (t.backtrace || []).join("\n\t")
710
- }.join("\n\n")
706
+ "Worker loop ran for #{opts[:service].worker_loop.iterations} iterations\n\n" +
707
+ Thread.list.map { |t|
708
+ "#{t.to_s}: newrelic_label: #{t[:newrelic_label].inspect}\n\n" +
709
+ (t.backtrace || []).join("\n\t")
710
+ }.join("\n\n")
711
711
  end
712
712
  end
713
713
  end
714
714
 
715
- def with_array_logger level=:info
715
+ def with_array_logger level = :info
716
716
  orig_logger = NewRelic::Agent.logger
717
- config = { :log_level => level }
717
+ config = {:log_level => level}
718
718
  logdev = ArrayLogDevice.new
719
719
  override_logger = Logger.new(logdev)
720
720
 
@@ -749,7 +749,7 @@ class EnvUpdater
749
749
 
750
750
  # Will attempt the given block up to MAX_RETRIES before
751
751
  # surfacing the exception down the chain.
752
- def with_retry retry_limit=MAX_RETRIES
752
+ def with_retry retry_limit = MAX_RETRIES
753
753
  retries ||= 0
754
754
  sleep(retries)
755
755
  yield
@@ -761,7 +761,7 @@ class EnvUpdater
761
761
  def safe_update env
762
762
  with_retry do
763
763
  @mutex.synchronize do
764
- env.each{ |key, val| ENV[key] = val.to_s }
764
+ env.each { |key, val| ENV[key] = val.to_s }
765
765
  end
766
766
  end
767
767
  end
@@ -770,7 +770,7 @@ class EnvUpdater
770
770
  def safe_restore old_env
771
771
  with_retry do
772
772
  @mutex.synchronize do
773
- old_env.each{ |key, val| val ? ENV[key] = val : ENV.delete(key) }
773
+ old_env.each { |key, val| val ? ENV[key] = val : ENV.delete(key) }
774
774
  end
775
775
  end
776
776
  end
@@ -792,7 +792,7 @@ class EnvUpdater
792
792
  # runs given block, then restores ENV to original state before returning.
793
793
  def self.inject env, &block
794
794
  old_env = {}
795
- env.each{ |key, val| old_env[key] = ENV[key] }
795
+ env.each { |key, val| old_env[key] = ENV[key] }
796
796
  begin
797
797
  safe_update(env)
798
798
  yield
@@ -868,7 +868,7 @@ end
868
868
  def each_cross_agent_test options
869
869
  options = {:dir => nil, :pattern => "*"}.update(options)
870
870
  path = File.join [cross_agent_tests_dir, options[:dir], options[:pattern]].compact
871
- Dir.glob(path).each { |file| yield file}
871
+ Dir.glob(path).each { |file| yield file }
872
872
  end
873
873
 
874
874
  def assert_event_attributes event, test_name, expected_attributes, non_expected_attributes
@@ -904,7 +904,7 @@ def attributes_for sample, type
904
904
  end
905
905
 
906
906
  def uncache_trusted_account_key
907
- NewRelic::Agent::Transaction::TraceContext::AccountHelpers.instance_variable_set :@trace_state_entry_key, nil
907
+ NewRelic::Agent::Transaction::TraceContext::AccountHelpers.instance_variable_set :@trace_state_entry_key, nil
908
908
  end
909
909
 
910
910
  def reset_buffers_and_caches
@@ -930,7 +930,7 @@ end
930
930
  # http status code associated with it.
931
931
  # a "status_code" may be passed in the headers to alter the HTTP Status Code
932
932
  # that is wrapped in the response.
933
- def mock_http_response headers, wrap_it=true
933
+ def mock_http_response headers, wrap_it = true
934
934
  status_code = (headers.delete("status_code") || 200).to_i
935
935
  net_http_resp = Net::HTTPResponse.new(1.0, status_code, message_for_status_code(status_code))
936
936
  headers.each do |key, value|
@@ -952,7 +952,7 @@ end
952
952
  # selects the last segment with a noticed_error and checks
953
953
  # the expectations against it.
954
954
  def assert_segment_noticed_error txn, segment_name, error_classes, error_message
955
- error_segment = txn.segments.reverse.detect{|s| s.noticed_error}
955
+ error_segment = txn.segments.reverse.detect { |s| s.noticed_error }
956
956
  assert error_segment, "Expected at least one segment with a noticed_error"
957
957
 
958
958
  assert_match_or_equal segment_name, error_segment.name
@@ -969,7 +969,7 @@ def assert_transaction_noticed_error txn, error_classes
969
969
  end
970
970
 
971
971
  def refute_transaction_noticed_error txn, error_class
972
- error_segment = txn.segments.reverse.detect{|s| s.noticed_error}
972
+ error_segment = txn.segments.reverse.detect { |s| s.noticed_error }
973
973
  assert error_segment, "Expected at least one segment with a noticed_error"
974
974
  assert_empty txn.exceptions, "Expected transaction to NOT notice any segment errors"
975
975
  end
@@ -997,11 +997,11 @@ def assert_implements instance, method, *args
997
997
  end
998
998
  end
999
999
 
1000
- def defer_testing_to_min_supported_rails test_file, min_rails_version, supports_jruby=true
1000
+ def defer_testing_to_min_supported_rails test_file, min_rails_version, supports_jruby = true
1001
1001
  if defined?(::Rails) &&
1002
- defined?(::Rails::VERSION::STRING) &&
1003
- (::Rails::VERSION::STRING.to_f >= min_rails_version) &&
1004
- (supports_jruby || !NewRelic::LanguageSupport.jruby?)
1002
+ defined?(::Rails::VERSION::STRING) &&
1003
+ (::Rails::VERSION::STRING.to_f >= min_rails_version) &&
1004
+ (supports_jruby || !NewRelic::LanguageSupport.jruby?)
1005
1005
 
1006
1006
  yield
1007
1007
  else
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Aaron Huntsman
8
7
  - Tanna McClure
9
8
  - Kayla Reopelle
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2021-11-29 00:00:00.000000000 Z
12
+ date: 2022-01-10 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rake
@@ -180,6 +179,34 @@ dependencies:
180
179
  - - ">="
181
180
  - !ruby/object:Gem::Version
182
181
  version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: rubocop
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: rubocop-performance
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
183
210
  description: |
184
211
  New Relic is a performance management system, developed by New Relic,
185
212
  Inc (http://www.newrelic.com). New Relic provides you with deep
@@ -203,6 +230,7 @@ extra_rdoc_files:
203
230
  files:
204
231
  - ".gitignore"
205
232
  - ".project"
233
+ - ".rubocop.yml"
206
234
  - ".yardopts"
207
235
  - CHANGELOG.md
208
236
  - CONTRIBUTING.md
@@ -221,6 +249,7 @@ files:
221
249
  - config/database.yml
222
250
  - init.rb
223
251
  - install.rb
252
+ - lefthook.yml
224
253
  - lib/new_relic/agent.rb
225
254
  - lib/new_relic/agent/adaptive_sampler.rb
226
255
  - lib/new_relic/agent/agent.rb
@@ -565,7 +594,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
565
594
  requirements:
566
595
  - - ">="
567
596
  - !ruby/object:Gem::Version
568
- version: 2.0.0
597
+ version: 2.2.0
569
598
  required_rubygems_version: !ruby/object:Gem::Requirement
570
599
  requirements:
571
600
  - - ">"