newrelic_rpm 7.2.0 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +1936 -0
  4. data/CHANGELOG.md +182 -9
  5. data/CONTRIBUTING.md +14 -2
  6. data/Guardfile +8 -8
  7. data/README.md +5 -1
  8. data/Rakefile +5 -7
  9. data/bin/mongrel_rpm +8 -9
  10. data/bin/newrelic +1 -1
  11. data/bin/nrdebug +14 -14
  12. data/init.rb +0 -2
  13. data/lefthook.yml +9 -0
  14. data/lib/new_relic/agent/adaptive_sampler.rb +9 -5
  15. data/lib/new_relic/agent/agent.rb +44 -46
  16. data/lib/new_relic/agent/agent_logger.rb +8 -9
  17. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  18. data/lib/new_relic/agent/attributes.rb +2 -2
  19. data/lib/new_relic/agent/autostart.rb +6 -7
  20. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  21. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  22. data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -6
  23. data/lib/new_relic/agent/configuration/default_source.rb +352 -336
  24. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  25. data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
  26. data/lib/new_relic/agent/configuration/event_harvest_config.rb +30 -16
  27. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  28. data/lib/new_relic/agent/configuration/manager.rb +57 -58
  29. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  30. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  31. data/lib/new_relic/agent/configuration/server_source.rb +12 -11
  32. data/lib/new_relic/agent/configuration/yaml_source.rb +26 -5
  33. data/lib/new_relic/agent/connect/request_builder.rb +13 -16
  34. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  35. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -9
  36. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  37. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  38. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  39. data/lib/new_relic/agent/database.rb +25 -26
  40. data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
  41. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  42. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  43. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  44. data/lib/new_relic/agent/datastores/mongo.rb +5 -10
  45. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  46. data/lib/new_relic/agent/datastores.rb +7 -9
  47. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +9 -9
  48. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +21 -16
  49. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -12
  50. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +42 -43
  51. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
  52. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
  53. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +25 -25
  54. data/lib/new_relic/agent/distributed_tracing.rb +17 -18
  55. data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
  56. data/lib/new_relic/agent/error_collector.rb +17 -17
  57. data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
  58. data/lib/new_relic/agent/error_filter.rb +16 -10
  59. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
  60. data/lib/new_relic/agent/event_aggregator.rb +1 -1
  61. data/lib/new_relic/agent/event_buffer.rb +6 -7
  62. data/lib/new_relic/agent/event_listener.rb +0 -1
  63. data/lib/new_relic/agent/event_loop.rb +14 -14
  64. data/lib/new_relic/agent/external.rb +1 -34
  65. data/lib/new_relic/agent/guid_generator.rb +1 -3
  66. data/lib/new_relic/agent/harvester.rb +3 -4
  67. data/lib/new_relic/agent/heap.rb +1 -3
  68. data/lib/new_relic/agent/hostname.rb +3 -3
  69. data/lib/new_relic/agent/http_clients/abstract.rb +7 -9
  70. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
  71. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
  72. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
  73. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
  74. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +8 -3
  75. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
  76. data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
  77. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
  78. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -11
  79. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  80. data/lib/new_relic/agent/instrumentation/active_job.rb +4 -3
  81. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
  82. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
  83. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
  84. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
  85. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
  86. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
  87. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
  88. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  89. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +8 -9
  90. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +42 -42
  91. data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
  92. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  93. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
  94. data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
  95. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  96. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
  97. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
  98. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  99. data/lib/new_relic/agent/instrumentation/excon.rb +3 -23
  100. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  101. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  102. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  103. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  104. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  105. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  106. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  107. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  108. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  109. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  110. data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
  111. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
  112. data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
  113. data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
  114. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
  115. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
  116. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
  117. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  118. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
  119. data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
  120. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
  121. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
  122. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
  123. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
  124. data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
  125. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
  126. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
  127. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
  128. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +2 -2
  129. data/lib/new_relic/agent/instrumentation/padrino.rb +2 -5
  130. data/lib/new_relic/agent/instrumentation/queue_time.rb +8 -8
  131. data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
  132. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
  133. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
  134. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
  135. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  136. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +11 -47
  137. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
  138. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
  139. data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
  140. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
  141. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  142. data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
  143. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
  144. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
  145. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  146. data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
  147. data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
  148. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
  149. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
  150. data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
  151. data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
  152. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
  153. data/lib/new_relic/agent/instrumentation/sidekiq.rb +7 -1
  154. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
  155. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
  156. data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
  157. data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
  158. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +40 -0
  159. data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
  160. data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
  161. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
  162. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
  163. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
  164. data/lib/new_relic/agent/internal_agent_error.rb +1 -1
  165. data/lib/new_relic/agent/javascript_instrumentor.rb +30 -30
  166. data/lib/new_relic/agent/logging.rb +11 -8
  167. data/lib/new_relic/agent/memory_logger.rb +1 -1
  168. data/lib/new_relic/agent/messaging.rb +46 -61
  169. data/lib/new_relic/agent/method_tracer.rb +139 -143
  170. data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
  171. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +21 -13
  172. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
  173. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
  174. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
  175. data/lib/new_relic/agent/monitors.rb +1 -2
  176. data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
  177. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
  178. data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
  179. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
  180. data/lib/new_relic/agent/new_relic_service.rb +34 -41
  181. data/lib/new_relic/agent/noticible_error.rb +0 -2
  182. data/lib/new_relic/agent/null_logger.rb +6 -2
  183. data/lib/new_relic/agent/obfuscator.rb +6 -8
  184. data/lib/new_relic/agent/parameter_filtering.rb +3 -5
  185. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  186. data/lib/new_relic/agent/pipe_channel_manager.rb +15 -12
  187. data/lib/new_relic/agent/pipe_service.rb +2 -2
  188. data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
  189. data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
  190. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
  191. data/lib/new_relic/agent/rules_engine.rb +2 -2
  192. data/lib/new_relic/agent/sampler.rb +2 -3
  193. data/lib/new_relic/agent/sampler_collection.rb +2 -3
  194. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  195. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +10 -7
  196. data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
  197. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  198. data/lib/new_relic/agent/span_event_aggregator.rb +10 -10
  199. data/lib/new_relic/agent/span_event_primitive.rb +39 -39
  200. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  201. data/lib/new_relic/agent/stats.rb +16 -16
  202. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  203. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  204. data/lib/new_relic/agent/stats_engine.rb +7 -7
  205. data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
  206. data/lib/new_relic/agent/system_info.rb +22 -20
  207. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  208. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  209. data/lib/new_relic/agent/threading/backtrace_service.rb +12 -13
  210. data/lib/new_relic/agent/threading/thread_profile.rb +16 -19
  211. data/lib/new_relic/agent/tracer.rb +43 -71
  212. data/lib/new_relic/agent/transaction/abstract_segment.rb +9 -9
  213. data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
  214. data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
  215. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  216. data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
  217. data/lib/new_relic/agent/transaction/message_broker_segment.rb +24 -30
  218. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  219. data/lib/new_relic/agent/transaction/segment.rb +6 -3
  220. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  221. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  222. data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
  223. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  224. data/lib/new_relic/agent/transaction/tracing.rb +1 -3
  225. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  226. data/lib/new_relic/agent/transaction.rb +85 -108
  227. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
  228. data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
  229. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  230. data/lib/new_relic/agent/transaction_metrics.rb +3 -3
  231. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  232. data/lib/new_relic/agent/transaction_time_aggregator.rb +11 -11
  233. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  234. data/lib/new_relic/agent/utilization_data.rb +3 -4
  235. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  236. data/lib/new_relic/agent/vm/snapshot.rb +4 -4
  237. data/lib/new_relic/agent/worker_loop.rb +8 -10
  238. data/lib/new_relic/agent.rb +27 -27
  239. data/lib/new_relic/cli/command.rb +15 -17
  240. data/lib/new_relic/cli/commands/deployments.rb +21 -23
  241. data/lib/new_relic/cli/commands/install.rb +6 -10
  242. data/lib/new_relic/coerce.rb +5 -8
  243. data/lib/new_relic/collection_helper.rb +48 -47
  244. data/lib/new_relic/constants.rb +0 -4
  245. data/lib/new_relic/control/class_methods.rb +2 -2
  246. data/lib/new_relic/control/frameworks/external.rb +1 -1
  247. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  248. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  249. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  250. data/lib/new_relic/control/instance_methods.rb +4 -5
  251. data/lib/new_relic/control/instrumentation.rb +4 -5
  252. data/lib/new_relic/control/server_methods.rb +2 -3
  253. data/lib/new_relic/control.rb +0 -1
  254. data/lib/new_relic/dependency_detection.rb +6 -8
  255. data/lib/new_relic/environment_report.rb +16 -18
  256. data/lib/new_relic/helper.rb +5 -5
  257. data/lib/new_relic/language_support.rb +1 -1
  258. data/lib/new_relic/latest_changes.rb +2 -2
  259. data/lib/new_relic/local_environment.rb +7 -7
  260. data/lib/new_relic/metric_data.rb +6 -7
  261. data/lib/new_relic/metric_spec.rb +3 -3
  262. data/lib/new_relic/noticed_error.rb +16 -17
  263. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  264. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  265. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  266. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  267. data/lib/new_relic/supportability_helper.rb +1 -2
  268. data/lib/new_relic/version.rb +4 -5
  269. data/lib/newrelic_rpm.rb +10 -34
  270. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  271. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  272. data/lib/tasks/all.rb +2 -2
  273. data/lib/tasks/config.rake +21 -21
  274. data/lib/tasks/multiverse.rb +4 -6
  275. data/lib/tasks/tests.rake +3 -7
  276. data/newrelic.yml +580 -3
  277. data/newrelic_rpm.gemspec +13 -12
  278. data/recipes/newrelic.rb +1 -1
  279. data/test/agent_helper.rb +80 -55
  280. metadata +42 -13
  281. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
  282. data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
  283. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
  284. data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
  285. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
  286. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
  287. data/lib/new_relic/agent/supported_versions.rb +0 -275
  288. data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -7,12 +7,12 @@ module NewRelic
7
7
  module VM
8
8
  class Snapshot
9
9
  attr_accessor :gc_total_time, :gc_runs, :major_gc_count, :minor_gc_count,
10
- :total_allocated_object, :heap_live, :heap_free,
11
- :method_cache_invalidations, :constant_cache_invalidations,
12
- :thread_count, :taken_at
10
+ :total_allocated_object, :heap_live, :heap_free,
11
+ :method_cache_invalidations, :constant_cache_invalidations,
12
+ :thread_count, :taken_at
13
13
 
14
14
  def initialize
15
- @taken_at = Time.now.to_f
15
+ @taken_at = Process.clock_gettime(Process::CLOCK_REALTIME)
16
16
  end
17
17
  end
18
18
  end
@@ -6,19 +6,17 @@ require 'thread'
6
6
 
7
7
  module NewRelic
8
8
  module Agent
9
-
10
9
  # A worker loop executes a set of registered tasks on a single thread.
11
10
  # A task is a proc or block with a specified call period in seconds.
12
11
  class WorkerLoop
13
-
14
12
  attr_accessor :period, :propagate_errors
15
13
  attr_reader :iterations
16
14
 
17
15
  # Optional argument :duration (in seconds) for how long the worker loop runs
18
16
  # or :limit (integer) for max number of iterations
19
- def initialize(opts={})
17
+ def initialize(opts = {})
20
18
  @should_run = true
21
- @next_invocation_time = Time.now
19
+ @next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
22
20
  @period = 60.0
23
21
  @duration = opts[:duration]
24
22
  @limit = opts[:limit]
@@ -34,7 +32,7 @@ module NewRelic
34
32
  @should_run = true
35
33
  @iterations = 0
36
34
 
37
- now = Time.now
35
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
38
36
  @deadline = now + @duration if @duration
39
37
  @next_invocation_time = (now + @period)
40
38
  end
@@ -42,9 +40,9 @@ module NewRelic
42
40
  # Run infinitely, calling the registered tasks at their specified
43
41
  # call periods. The caller is responsible for creating the thread
44
42
  # that runs this worker loop. This will run the task immediately.
45
- def run(period=nil, &block)
43
+ def run(period = nil, &block)
46
44
  setup(period, block)
47
- while keep_running? do
45
+ while keep_running?
48
46
  sleep_time = schedule_next_invocation
49
47
  sleep(sleep_time) if sleep_time > 0
50
48
  run_task if keep_running?
@@ -53,11 +51,11 @@ module NewRelic
53
51
  end
54
52
 
55
53
  def schedule_next_invocation
56
- now = Time.now
54
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
57
55
  while @next_invocation_time <= now && @period > 0
58
56
  @next_invocation_time += @period
59
57
  end
60
- @next_invocation_time - Time.now
58
+ @next_invocation_time - Process.clock_gettime(Process::CLOCK_REALTIME)
61
59
  end
62
60
 
63
61
  # a simple accessor for @should_run
@@ -66,7 +64,7 @@ module NewRelic
66
64
  end
67
65
 
68
66
  def under_duration?
69
- !@deadline || Time.now < @deadline
67
+ !@deadline || Process.clock_gettime(Process::CLOCK_REALTIME) < @deadline
70
68
  end
71
69
 
72
70
  def under_limit?
@@ -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
@@ -139,20 +139,20 @@ module NewRelic
139
139
  # is initialized; these methods enable us to defer these calls
140
140
  # until we have started up and can process them.
141
141
  #
142
- def add_or_defer_method_tracer(receiver, method_name, metric_name_code, options)
142
+ def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
143
143
  @tracer_lock.synchronize do
144
144
  if @agent
145
- receiver.send(:_add_method_tracer_now, method_name, metric_name_code, options)
145
+ receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
146
146
  else
147
- @tracer_queue << [receiver, method_name, metric_name_code, options]
147
+ @tracer_queue << [receiver, method_name, metric_name, options]
148
148
  end
149
149
  end
150
150
  end
151
151
 
152
152
  def add_deferred_method_tracers_now
153
153
  @tracer_lock.synchronize do
154
- @tracer_queue.each do |receiver, method_name, metric_name_code, options|
155
- receiver.send(:_add_method_tracer_now, method_name, metric_name_code, options)
154
+ @tracer_queue.each do |receiver, method_name, metric_name, options|
155
+ receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
156
156
  end
157
157
 
158
158
  @tracer_queue = []
@@ -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
@@ -10,7 +10,7 @@ require 'net/http'
10
10
  require 'new_relic/agent/hostname'
11
11
 
12
12
  # We need to use the Control object but we don't want to load
13
- # the rails/merb environment. The defined? clause is so that
13
+ # the rails environment. The defined? clause is so that
14
14
  # it won't load it twice, something it does when run inside a test
15
15
  require 'new_relic/control' unless defined? NewRelic::Control
16
16
 
@@ -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|MERB|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
@@ -28,10 +28,6 @@ module NewRelic
28
28
  TRACEPARENT_KEY = "traceparent"
29
29
  TRACESTATE_KEY = "tracestate"
30
30
 
31
- # Right now, old and new Rubies are the same. Intention is to use "(...)" for
32
- # Ruby 2.7+ for argument delegation, but doing so is a breaking API change.
33
- ARGS_FOR_RUBY_VERSION = RUBY_VERSION < "2.7.0" ? "*args, &block" : "*args, &block"
34
-
35
31
  HTTP_TRACEPARENT_KEY = "HTTP_#{TRACEPARENT_KEY.upcase}"
36
32
  HTTP_TRACESTATE_KEY = "HTTP_#{TRACESTATE_KEY.upcase}"
37
33
  HTTP_NEWRELIC_KEY = "HTTP_#{NEWRELIC_KEY.upcase}"