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
@@ -44,7 +44,7 @@ module NewRelic
44
44
  require 'new_relic/agent/sql_sampler'
45
45
  require 'new_relic/agent/commands/thread_profiler_session'
46
46
  require 'new_relic/agent/error_collector'
47
- require 'new_relic/agent/error_filter'
47
+ require 'new_relic/agent/error_filter'
48
48
  require 'new_relic/agent/sampler'
49
49
  require 'new_relic/agent/database'
50
50
  require 'new_relic/agent/database_adapter'
@@ -111,19 +111,19 @@ module NewRelic
111
111
  @tracer_queue = []
112
112
 
113
113
  # The singleton Agent instance. Used internally.
114
- def agent #:nodoc:
114
+ def agent # :nodoc:
115
115
  return @agent if @agent
116
116
  NewRelic::Agent.logger.warn("Agent unavailable as it hasn't been started.")
117
117
  NewRelic::Agent.logger.warn(caller.join("\n"))
118
118
  nil
119
119
  end
120
120
 
121
- def agent=(new_instance)#:nodoc:
121
+ def agent=(new_instance) # :nodoc:
122
122
  @agent = new_instance
123
123
  add_deferred_method_tracers_now
124
124
  end
125
125
 
126
- alias instance agent #:nodoc:
126
+ alias instance agent # :nodoc:
127
127
 
128
128
  # Primary interface to logging is fronted by this accessor
129
129
  # Access via ::NewRelic::Agent.logger
@@ -187,7 +187,7 @@ module NewRelic
187
187
  # This method is safe to use from any thread.
188
188
  #
189
189
  # @api public
190
- def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
190
+ def record_metric(metric_name, value) # THREAD_LOCAL_ACCESS
191
191
  record_api_supportability_metric(:record_metric)
192
192
 
193
193
  return unless agent
@@ -217,14 +217,14 @@ module NewRelic
217
217
 
218
218
  SUPPORTABILITY_INCREMENT_METRIC = 'Supportability/API/increment_metric'.freeze
219
219
 
220
- def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
220
+ def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS
221
221
  return unless agent
222
222
  if amount == 1
223
223
  metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]
224
- agent.stats_engine.tl_record_unscoped_metrics(metrics) {|stats| stats.increment_count}
224
+ agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }
225
225
  else
226
- agent.stats_engine.tl_record_unscoped_metrics(metric_name) {|stats| stats.increment_count(amount)}
227
- agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) {|stats| stats.increment_count}
226
+ agent.stats_engine.tl_record_unscoped_metrics(metric_name) { |stats| stats.increment_count(amount) }
227
+ agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) { |stats| stats.increment_count }
228
228
  end
229
229
  end
230
230
 
@@ -281,7 +281,7 @@ module NewRelic
281
281
  #
282
282
  # @api public
283
283
  #
284
- def notice_error(exception, options={})
284
+ def notice_error(exception, options = {})
285
285
  record_api_supportability_metric(:notice_error)
286
286
 
287
287
  Transaction.notice_error(exception, options)
@@ -347,9 +347,9 @@ module NewRelic
347
347
  #
348
348
  # @api public
349
349
  #
350
- def manual_start(options={})
350
+ def manual_start(options = {})
351
351
  raise "Options must be a hash" unless Hash === options
352
- NewRelic::Control.instance.init_plugin({ :agent_enabled => true, :sync_startup => true }.merge(options))
352
+ NewRelic::Control.instance.init_plugin({:agent_enabled => true, :sync_startup => true}.merge(options))
353
353
  record_api_supportability_metric(:manual_start)
354
354
  end
355
355
 
@@ -378,7 +378,7 @@ module NewRelic
378
378
  #
379
379
  # @api public
380
380
  #
381
- def after_fork(options={})
381
+ def after_fork(options = {})
382
382
  record_api_supportability_metric(:after_fork)
383
383
  agent.after_fork(options) if agent
384
384
  end
@@ -390,7 +390,7 @@ module NewRelic
390
390
  #
391
391
  # @api public
392
392
  #
393
- def shutdown(options={})
393
+ def shutdown(options = {})
394
394
  record_api_supportability_metric(:shutdown)
395
395
  agent.shutdown if agent
396
396
  end
@@ -512,7 +512,7 @@ module NewRelic
512
512
  #
513
513
  def disable_transaction_tracing
514
514
  Deprecator.deprecate :disable_transaction_tracing,
515
- 'disable_all_tracing or ignore_transaction'
515
+ 'disable_all_tracing or ignore_transaction'
516
516
  record_api_supportability_metric(:disable_transaction_tracing)
517
517
  yield
518
518
  end
@@ -572,7 +572,7 @@ module NewRelic
572
572
  #
573
573
  # @api public
574
574
  #
575
- def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
575
+ def add_custom_attributes(params) # THREAD_LOCAL_ACCESS
576
576
  record_api_supportability_metric(:add_custom_attributes)
577
577
 
578
578
  if params.is_a? Hash
@@ -644,7 +644,7 @@ module NewRelic
644
644
  #
645
645
  # @api public
646
646
  #
647
- def set_transaction_name(name, options={})
647
+ def set_transaction_name(name, options = {})
648
648
  record_api_supportability_metric(:set_transaction_name)
649
649
  Transaction.set_overriding_transaction_name(name, options[:category])
650
650
  end
@@ -654,7 +654,7 @@ module NewRelic
654
654
  #
655
655
  # @api public
656
656
  #
657
- def get_transaction_name #THREAD_LOCAL_ACCESS
657
+ def get_transaction_name # THREAD_LOCAL_ACCESS
658
658
  record_api_supportability_metric(:get_transaction_name)
659
659
 
660
660
  txn = Transaction.tl_current
@@ -686,13 +686,13 @@ module NewRelic
686
686
  # Subscribe to events of +event_type+, calling the given +handler+
687
687
  # when one is sent.
688
688
  def subscribe(event_type, &handler)
689
- agent.events.subscribe( event_type, &handler )
689
+ agent.events.subscribe(event_type, &handler)
690
690
  end
691
691
 
692
692
  # Fire an event of the specified +event_type+, passing it an the given +args+
693
693
  # to any registered handlers.
694
694
  def notify(event_type, *args)
695
- agent.events.notify( event_type, *args )
695
+ agent.events.notify(event_type, *args)
696
696
  rescue
697
697
  NewRelic::Agent.logger.debug "Ignoring exception during %p event notification" % [event_type]
698
698
  end
@@ -743,7 +743,7 @@ module NewRelic
743
743
  metadata
744
744
  end
745
745
 
746
- #@!endgroup
746
+ # @!endgroup
747
747
 
748
748
  # @!group Manual browser monitoring configuration
749
749
 
@@ -763,7 +763,7 @@ module NewRelic
763
763
  #
764
764
  # @api public
765
765
  #
766
- def browser_timing_header(nonce=nil)
766
+ def browser_timing_header(nonce = nil)
767
767
  record_api_supportability_metric(:browser_timing_header)
768
768
 
769
769
  return "" unless agent
@@ -15,7 +15,7 @@ module NewRelic
15
15
  # Capture a failure to execute the command.
16
16
  class CommandFailure < StandardError
17
17
  attr_reader :options
18
- def initialize message, opt_parser=nil
18
+ def initialize message, opt_parser = nil
19
19
  super message
20
20
  @options = opt_parser
21
21
  end
@@ -32,13 +32,13 @@ module NewRelic
32
32
  def initialize(command_line_args)
33
33
  if Hash === command_line_args
34
34
  # command line args is an options hash
35
- command_line_args.each do | key, value |
35
+ command_line_args.each do |key, value|
36
36
  instance_variable_set "@#{key}", value.to_s if value
37
37
  end
38
38
  else
39
39
  # parse command line args. Throw an exception on a bad arg.
40
- @options = options do | opts |
41
- opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
40
+ @options = options do |opts|
41
+ opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
42
42
  end
43
43
  @leftover = @options.parse(command_line_args)
44
44
  end
@@ -55,8 +55,7 @@ module NewRelic
55
55
  Dir[cmds].each { |command| require command }
56
56
 
57
57
  def self.run
58
-
59
- @command_names = @commands.map{ |c| c.command }
58
+ @command_names = @commands.map { |c| c.command }
60
59
 
61
60
  extra = []
62
61
  options = ARGV.options do |opts|
@@ -65,7 +64,7 @@ module NewRelic
65
64
  $stdout.puts "warning: the 'newrelic_cmd' script has been renamed 'newrelic'"
66
65
  script_name = 'newrelic'
67
66
  end
68
- opts.banner = "Usage: #{script_name} [ #{ @command_names.join(" | ")} ] [options]"
67
+ opts.banner = "Usage: #{script_name} [ #{@command_names.join(" | ")} ] [options]"
69
68
  opts.separator "use '#{script_name} <command> -h' to see detailed command options"
70
69
  opts
71
70
  end
@@ -73,19 +72,18 @@ module NewRelic
73
72
  command = extra.shift
74
73
  # just make it a little easier on them
75
74
  command = 'deployments' if command =~ /deploy/
76
- if command.nil?
77
- STDERR.puts options
78
- elsif !@command_names.include?(command)
79
- STDERR.puts "Unrecognized command: #{command}"
80
- STDERR.puts options
81
- else
82
- command_class = @commands.find{ |c| c.command == command}
83
- command_class.new(extra).run
84
- end
75
+ if command.nil?
76
+ STDERR.puts options
77
+ elsif !@command_names.include?(command)
78
+ STDERR.puts "Unrecognized command: #{command}"
79
+ STDERR.puts options
80
+ else
81
+ command_class = @commands.find { |c| c.command == command }
82
+ command_class.new(extra).run
83
+ end
85
84
  rescue OptionParser::InvalidOption => e
86
85
  raise NewRelic::Cli::Command::CommandFailure, e.message
87
86
  end
88
87
  end
89
-
90
88
  end
91
89
  end
@@ -30,8 +30,8 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
30
30
  def initialize command_line_args
31
31
  @control = NewRelic::Control.instance
32
32
  @environment = nil
33
- @changelog = nil
34
- @user = nil
33
+ @changelog = nil
34
+ @user = nil
35
35
  super(command_line_args)
36
36
  @description ||= @leftover && @leftover.join(" ")
37
37
  @user ||= ENV['USER']
@@ -66,12 +66,12 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
66
66
  @description = nil if @description && @description.strip.empty?
67
67
  create_params = {}
68
68
  {
69
- :application_id => @appname,
70
- :host => NewRelic::Agent::Hostname.get,
71
- :description => @description,
72
- :user => @user,
73
- :revision => @revision,
74
- :changelog => @changelog
69
+ :application_id => @appname,
70
+ :host => NewRelic::Agent::Hostname.get,
71
+ :description => @description,
72
+ :user => @user,
73
+ :revision => @revision,
74
+ :changelog => @changelog
75
75
  }.each do |k, v|
76
76
  create_params["deployment[#{k}]"] = v unless v.nil? || v == ''
77
77
  end
@@ -90,9 +90,9 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
90
90
  response = http.request(request)
91
91
 
92
92
  if response.is_a? Net::HTTPSuccess
93
- info "Recorded deployment to '#{@appname}' (#{@description || Time.now })"
93
+ info "Recorded deployment to '#{@appname}' (#{@description || Time.now})"
94
94
  else
95
- err_string = REXML::Document.new(response.body).elements['errors/error'].map(&:to_s).join("; ") rescue response.message
95
+ err_string = REXML::Document.new(response.body).elements['errors/error'].map(&:to_s).join("; ") rescue response.message
96
96
  raise NewRelic::Cli::Command::CommandFailure, "Deployment not recorded: #{err_string}"
97
97
  end
98
98
  rescue SystemCallError, SocketError => e
@@ -111,26 +111,24 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
111
111
  private
112
112
 
113
113
  def options
114
- OptionParser.new %Q{Usage: #{$0} #{self.class.command} [OPTIONS] ["description"] }, 40 do |o|
114
+ OptionParser.new %Q(Usage: #{$0} #{self.class.command} [OPTIONS] ["description"] ), 40 do |o|
115
115
  o.separator "OPTIONS:"
116
116
  o.on("-a", "--appname=NAME", String,
117
- "Set the application name.",
118
- "Default is app_name setting in newrelic.yml") { | e | @appname = e }
117
+ "Set the application name.",
118
+ "Default is app_name setting in newrelic.yml") { |e| @appname = e }
119
119
  o.on("-e", "--environment=name", String,
120
- "Override the (RAILS|RUBY|RACK)_ENV setting",
121
- "currently: #{control.env}") { | e | @environment = e }
120
+ "Override the (RAILS|RUBY|RACK)_ENV setting",
121
+ "currently: #{control.env}") { |e| @environment = e }
122
122
  o.on("-u", "--user=USER", String,
123
- "Specify the user deploying, for information only",
124
- "Default: #{@user || '<none>'}") { | u | @user = u }
123
+ "Specify the user deploying, for information only",
124
+ "Default: #{@user || '<none>'}") { |u| @user = u }
125
125
  o.on("-r", "--revision=REV", String,
126
- "Specify the revision being deployed") { | r | @revision = r }
126
+ "Specify the revision being deployed") { |r| @revision = r }
127
127
  o.on("-l", "--license-key=KEY", String,
128
- "Specify the license key of the account for the app being deployed") { | l | @license_key = l }
128
+ "Specify the license key of the account for the app being deployed") { |l| @license_key = l }
129
129
  o.on("-c", "--changes",
130
- "Read in a change log from the standard input") { @changelog = STDIN.read }
130
+ "Read in a change log from the standard input") { @changelog = STDIN.read }
131
131
  yield o if block_given?
132
132
  end
133
133
  end
134
-
135
-
136
134
  end
@@ -7,7 +7,6 @@ require 'new_relic/version'
7
7
  require 'erb'
8
8
 
9
9
  class NewRelic::Cli::Install < NewRelic::Cli::Command
10
-
11
10
  NO_LICENSE_KEY = "<PASTE LICENSE KEY HERE>"
12
11
 
13
12
  def self.command; "install"; end
@@ -21,7 +20,7 @@ class NewRelic::Cli::Install < NewRelic::Cli::Command
21
20
  # Will throw CommandFailed exception if there's any error.
22
21
  #
23
22
  attr_reader :dest_dir, :license_key, :generated_for_user, :quiet, :src_file, :app_name
24
- def initialize command_line_args={}
23
+ def initialize command_line_args = {}
25
24
  @dest_dir = nil
26
25
  super command_line_args
27
26
  if @dest_dir.nil?
@@ -43,7 +42,7 @@ class NewRelic::Cli::Install < NewRelic::Cli::Command
43
42
  if File.exist?(dest_file) && !@force
44
43
  raise NewRelic::Cli::Command::CommandFailure, "newrelic.yml file already exists. Use --force flag to overwrite."
45
44
  end
46
- File.open(dest_file, 'w') { | out | out.puts(content) }
45
+ File.open(dest_file, 'w') { |out| out.puts(content) }
47
46
 
48
47
  puts <<-EOF unless quiet
49
48
 
@@ -60,11 +59,10 @@ you receive upon registration.
60
59
 
61
60
  Visit support.newrelic.com if you are experiencing installation issues.
62
61
  EOF
63
-
64
62
  end
65
63
 
66
64
  def content
67
- @src_file ||= File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","..","newrelic.yml"))
65
+ @src_file ||= File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", "newrelic.yml"))
68
66
  template = File.read(@src_file)
69
67
  ERB.new(template).result(binding)
70
68
  end
@@ -73,14 +71,12 @@ Visit support.newrelic.com if you are experiencing installation issues.
73
71
 
74
72
  def options
75
73
  OptionParser.new "Usage: #{$0} #{self.class.command} [ OPTIONS] 'application name'", 40 do |o|
76
- o.on("-f", "--force", "Overwrite newrelic.yml if it exists") { | e | @force = true }
74
+ o.on("-f", "--force", "Overwrite newrelic.yml if it exists") { |e| @force = true }
77
75
  o.on("-l", "--license_key=NAME", String,
78
- "Use the given license key") { | e | @license_key = e }
76
+ "Use the given license key") { |e| @license_key = e }
79
77
  o.on("-d", "--destdir=name", String,
80
- "Write the newrelic.yml to the given directory, default is '.'") { | e | @dest_dir = e }
78
+ "Write the newrelic.yml to the given directory, default is '.'") { |e| @dest_dir = e }
81
79
  yield o if block_given?
82
80
  end
83
81
  end
84
-
85
-
86
82
  end
@@ -5,7 +5,6 @@
5
5
 
6
6
  module NewRelic
7
7
  module Coerce
8
-
9
8
  module_function
10
9
 
11
10
  # We really don't want to send bad values to the collector, and it doesn't
@@ -15,14 +14,14 @@ module NewRelic
15
14
  # to provide documentation of expected types on to_collector_array methods,
16
15
  # and to log failures if totally invalid data gets into outgoing data
17
16
 
18
- def int(value, context=nil)
17
+ def int(value, context = nil)
19
18
  Integer(value)
20
19
  rescue => error
21
20
  log_failure(value, Integer, context, error)
22
21
  0
23
22
  end
24
23
 
25
- def int_or_nil(value, context=nil)
24
+ def int_or_nil(value, context = nil)
26
25
  return nil if value.nil?
27
26
  Integer(value)
28
27
  rescue => error
@@ -30,7 +29,7 @@ module NewRelic
30
29
  nil
31
30
  end
32
31
 
33
- def float(value, context=nil)
32
+ def float(value, context = nil)
34
33
  result = Float(value)
35
34
  raise "Value #{result.inspect} is not finite." unless result.finite?
36
35
  result
@@ -39,7 +38,7 @@ module NewRelic
39
38
  0.0
40
39
  end
41
40
 
42
- def string(value, context=nil)
41
+ def string(value, context = nil)
43
42
  return value if value.nil?
44
43
  String(value)
45
44
  rescue => error
@@ -54,8 +53,6 @@ module NewRelic
54
53
  when Float
55
54
  if val.finite?
56
55
  val
57
- else
58
- nil
59
56
  end
60
57
  when Symbol
61
58
  val.to_s
@@ -76,7 +73,7 @@ module NewRelic
76
73
  value.to_i
77
74
  end
78
75
 
79
- def float! value, precision=NewRelic::PRIORITY_PRECISION
76
+ def float! value, precision = NewRelic::PRIORITY_PRECISION
80
77
  return nil unless value_or_nil(value)
81
78
  value.to_f.round(precision)
82
79
  end
@@ -4,58 +4,59 @@
4
4
 
5
5
  module NewRelic
6
6
  module CollectionHelper
7
- DEFAULT_TRUNCATION_SIZE=16 * 1024
8
- DEFAULT_ARRAY_TRUNCATION_SIZE=128
9
- # Transform parameter hash into a hash whose values are strictly
10
- # strings
11
- def normalize_params(params)
12
- case params
13
- when Hash
14
- # optimize for empty hash since that is often what this is called with.
15
- return params if params.empty?
16
- new_params = {}
17
- params.each do | key, value |
18
- new_params[truncate(normalize_params(key),64)] = normalize_params(value)
19
- end
20
- new_params
21
- when Symbol, FalseClass, TrueClass, nil
22
- params
23
- when Numeric
24
- truncate(params.to_s)
25
- when String
26
- truncate(params)
27
- when Array
28
- params.first(DEFAULT_ARRAY_TRUNCATION_SIZE).map{|item| normalize_params(item)}
29
- else
30
- truncate(flatten(params))
7
+ DEFAULT_TRUNCATION_SIZE = 16 * 1024
8
+ DEFAULT_ARRAY_TRUNCATION_SIZE = 128
9
+ # Transform parameter hash into a hash whose values are strictly
10
+ # strings
11
+ def normalize_params(params)
12
+ case params
13
+ when Hash
14
+ # optimize for empty hash since that is often what this is called with.
15
+ return params if params.empty?
16
+ new_params = {}
17
+ params.each do |key, value|
18
+ new_params[truncate(normalize_params(key), 64)] = normalize_params(value)
19
+ end
20
+ new_params
21
+ when Symbol, FalseClass, TrueClass, nil
22
+ params
23
+ when Numeric
24
+ truncate(params.to_s)
25
+ when String
26
+ truncate(params)
27
+ when Array
28
+ params.first(DEFAULT_ARRAY_TRUNCATION_SIZE).map { |item| normalize_params(item) }
29
+ else
30
+ truncate(flatten(params))
31
+ end
31
32
  end
32
- end
33
33
 
34
- private
34
+ private
35
35
 
36
- # Convert any kind of object to a short string.
37
- def flatten(object)
38
- case object
39
- when nil then ''
40
- when object.instance_of?(String) then object
41
- when String then String.new(object) # convert string subclasses to strings
42
- else "#<#{object.class.to_s}>"
36
+ # Convert any kind of object to a short string.
37
+ def flatten(object)
38
+ case object
39
+ when nil then ''
40
+ when object.instance_of?(String) then object
41
+ when String then String.new(object) # convert string subclasses to strings
42
+ else "#<#{object.class.to_s}>"
43
+ end
43
44
  end
44
- end
45
- def truncate(string, len=DEFAULT_TRUNCATION_SIZE)
46
- case string
47
- when Symbol then string
48
- when nil then ""
49
- when String
50
- real_string = flatten(string)
51
- if real_string.size > len
52
- real_string = real_string.slice(0...len)
53
- real_string << "..."
45
+
46
+ def truncate(string, len = DEFAULT_TRUNCATION_SIZE)
47
+ case string
48
+ when Symbol then string
49
+ when nil then ""
50
+ when String
51
+ real_string = flatten(string)
52
+ if real_string.size > len
53
+ real_string = real_string.slice(0...len)
54
+ real_string << "..."
55
+ end
56
+ real_string
57
+ else
58
+ truncate(flatten(string), len)
54
59
  end
55
- real_string
56
- else
57
- truncate(flatten(string), len)
58
60
  end
59
61
  end
60
- end
61
62
  end
@@ -9,7 +9,7 @@ module NewRelic
9
9
  module ClassMethods
10
10
  # Access the Control singleton, lazy initialized. Default will instantiate a new
11
11
  # instance or pass false to defer
12
- def instance(create=true)
12
+ def instance(create = true)
13
13
  @instance ||= create && new_instance
14
14
  end
15
15
 
@@ -35,7 +35,7 @@ module NewRelic
35
35
 
36
36
  # nb this does not 'load test' the framework, it loads the 'test framework'
37
37
  def load_test_framework
38
- config = File.expand_path(File.join('..','..','..','..', "test","config","newrelic.yml"), __FILE__)
38
+ config = File.expand_path(File.join('..', '..', '..', '..', "test", "config", "newrelic.yml"), __FILE__)
39
39
  require "config/test_control"
40
40
  NewRelic::Control::Frameworks::Test.new(local_env, config)
41
41
  end
@@ -11,7 +11,7 @@ module NewRelic
11
11
  # out specifically because in this context we are not monitoring
12
12
  # the running process, but actually external things.
13
13
  class External < NewRelic::Control::Frameworks::Ruby
14
- def init_config(options={})
14
+ def init_config(options = {})
15
15
  super
16
16
  end
17
17
  end
@@ -10,9 +10,8 @@ module NewRelic
10
10
  # Rails specific configuration, instrumentation, environment values,
11
11
  # etc.
12
12
  class Rails < NewRelic::Control::Frameworks::Ruby
13
-
14
13
  def env
15
- @env ||= ( ENV['NEW_RELIC_ENV'] || RAILS_ENV.dup )
14
+ @env ||= (ENV['NEW_RELIC_ENV'] || RAILS_ENV.dup)
16
15
  end
17
16
 
18
17
  # Rails can return an empty string from this method, causing
@@ -43,7 +42,7 @@ module NewRelic
43
42
  # In versions of Rails prior to 2.0, the rails config was only available to
44
43
  # the init.rb, so it had to be passed on from there. This is a best effort to
45
44
  # find a config and use that.
46
- def init_config(options={})
45
+ def init_config(options = {})
47
46
  @config = options[:config]
48
47
  # Install the dependency detection,
49
48
  if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
@@ -63,8 +62,8 @@ module NewRelic
63
62
  end
64
63
  rescue => e
65
64
  ::NewRelic::Agent.logger.error("Failure during init_config for Rails. Is Rails required in a non-Rails app? Set NEW_RELIC_FRAMEWORK=ruby to avoid this message.",
66
- "The Ruby agent will continue running, but Rails-specific features may be missing.",
67
- e)
65
+ "The Ruby agent will continue running, but Rails-specific features may be missing.",
66
+ e)
68
67
  end
69
68
 
70
69
  def install_agent_hooks(config)
@@ -103,7 +102,7 @@ module NewRelic
103
102
  protected
104
103
 
105
104
  def rails_vendor_root
106
- File.join(root,'vendor','rails')
105
+ File.join(root, 'vendor', 'rails')
107
106
  end
108
107
 
109
108
  def install_shim
@@ -13,9 +13,8 @@ module NewRelic
13
13
  # NewRelic::Control::Frameworks::Rails class, where the two do
14
14
  # not differ
15
15
  class Rails3 < NewRelic::Control::Frameworks::Rails
16
-
17
16
  def env
18
- @env ||= ( ENV['NEW_RELIC_ENV'] || ::Rails.env.to_s )
17
+ @env ||= (ENV['NEW_RELIC_ENV'] || ::Rails.env.to_s)
19
18
  end
20
19
 
21
20
  def rails_root
@@ -23,7 +22,7 @@ module NewRelic
23
22
  end
24
23
 
25
24
  def vendor_root
26
- @vendor_root ||= File.join(root,'vendor','rails')
25
+ @vendor_root ||= File.join(root, 'vendor', 'rails')
27
26
  end
28
27
 
29
28
  def version
@@ -9,14 +9,14 @@ module NewRelic
9
9
  class Ruby < NewRelic::Control
10
10
  def env
11
11
  @env ||= ENV['NEW_RELIC_ENV'] || ENV['RUBY_ENV'] || ENV['RAILS_ENV'] ||
12
- ENV['APP_ENV'] || ENV['RACK_ENV'] || 'development'
12
+ ENV['APP_ENV'] || ENV['RACK_ENV'] || 'development'
13
13
  end
14
14
 
15
15
  def root
16
16
  @root ||= ENV['APP_ROOT'] || '.'
17
17
  end
18
18
 
19
- def init_config(options={})
19
+ def init_config(options = {})
20
20
  end
21
21
  end
22
22
  end