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
@@ -2,16 +2,15 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
-
6
5
  module NewRelic::Agent::Instrumentation
7
6
  module Resque
8
- module Chain
7
+ module Chain
9
8
  def self.instrument!
10
9
  ::Resque::Job.class_eval do
11
10
  include NewRelic::Agent::Instrumentation::Resque
12
11
 
13
12
  alias_method :perform_without_instrumentation, :perform
14
-
13
+
15
14
  def perform
16
15
  with_tracing { perform_without_instrumentation }
17
16
  end
@@ -16,4 +16,4 @@ module NewRelic
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -12,12 +12,13 @@ module NewRelic::Agent::Instrumentation
12
12
  perform_action_with_newrelic_trace(
13
13
  :name => 'perform',
14
14
  :class_name => self.payload_class,
15
- :category => 'OtherTransaction/ResqueJob') do
16
-
15
+ :category => 'OtherTransaction/ResqueJob'
16
+ ) do
17
17
  NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(
18
18
  args,
19
19
  :'job.resque.args',
20
- NewRelic::Agent::AttributeFilter::DST_NONE)
20
+ NewRelic::Agent::AttributeFilter::DST_NONE
21
+ )
21
22
 
22
23
  yield
23
24
  end
@@ -30,6 +31,5 @@ module NewRelic::Agent::Instrumentation
30
31
  end
31
32
  end
32
33
  end
33
-
34
34
  end
35
35
  end
@@ -2,10 +2,9 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
-
6
5
  module NewRelic::Agent::Instrumentation
7
6
  module Resque
8
- module Prepend
7
+ module Prepend
9
8
  include NewRelic::Agent::Instrumentation::Resque
10
9
 
11
10
  def perform
@@ -39,9 +39,9 @@ DependencyDetection.defer do
39
39
 
40
40
  if NewRelic::Agent::Instrumentation::Resque::Helper.resque_fork_per_job?
41
41
  ::Resque.before_first_fork do
42
- NewRelic::Agent.manual_start(:dispatcher => :resque,
43
- :sync_startup => true,
44
- :start_channel_listener => true)
42
+ NewRelic::Agent.manual_start(:dispatcher => :resque,
43
+ :sync_startup => true,
44
+ :start_channel_listener => true)
45
45
  end
46
46
 
47
47
  ::Resque.before_fork do |job|
@@ -52,13 +52,13 @@ DependencyDetection.defer do
52
52
  # Only suppress reporting Instance/Busy for forked children
53
53
  # Traced errors UI relies on having the parent process report that metric
54
54
  NewRelic::Agent.after_fork(:report_to_channel => job.object_id,
55
- :report_instance_busy => false)
55
+ :report_instance_busy => false)
56
56
  end
57
57
  else
58
58
  ::Resque.before_first_fork do
59
- NewRelic::Agent.manual_start(:dispatcher => :resque,
60
- :sync_startup => true,
61
- :start_channel_listener => false)
59
+ NewRelic::Agent.manual_start(:dispatcher => :resque,
60
+ :sync_startup => true,
61
+ :start_channel_listener => false)
62
62
  end
63
63
  end
64
64
  end
@@ -12,13 +12,13 @@ DependencyDetection.defer do
12
12
 
13
13
  depends_on do
14
14
  !NewRelic::Agent.config[:disable_sequel_instrumentation] &&
15
- !NewRelic::Agent.config[:disable_database_instrumentation]
15
+ !NewRelic::Agent.config[:disable_database_instrumentation]
16
16
  end
17
17
 
18
18
  def supported_sequel_version?
19
- Sequel.const_defined?( :MAJOR ) &&
20
- ( Sequel::MAJOR > 3 ||
21
- Sequel::MAJOR == 3 && Sequel::MINOR >= 37 )
19
+ Sequel.const_defined?(:MAJOR) &&
20
+ (Sequel::MAJOR > 3 ||
21
+ Sequel::MAJOR == 3 && Sequel::MINOR >= 37)
22
22
  end
23
23
 
24
24
  executes do
@@ -26,15 +26,15 @@ DependencyDetection.defer do
26
26
 
27
27
  ::NewRelic::Agent.logger.info 'Installing Sequel instrumentation'
28
28
 
29
- if Sequel::Database.respond_to?( :extension )
29
+ if Sequel::Database.respond_to?(:extension)
30
30
  Sequel::Database.extension :newrelic_instrumentation
31
31
  else
32
- NewRelic::Agent.logger.info "Detected Sequel version %s." % [ Sequel::VERSION ]
32
+ NewRelic::Agent.logger.info "Detected Sequel version %s." % [Sequel::VERSION]
33
33
  NewRelic::Agent.logger.info "Please see additional documentation: " +
34
34
  "https://newrelic.com/docs/ruby/sequel-instrumentation"
35
35
  end
36
36
 
37
- Sequel.synchronize{Sequel::DATABASES.dup}.each do |db|
37
+ Sequel.synchronize { Sequel::DATABASES.dup }.each do |db|
38
38
  db.extension :newrelic_instrumentation
39
39
  end
40
40
 
@@ -44,7 +44,5 @@ DependencyDetection.defer do
44
44
  NewRelic::Agent.logger.info "Sequel instrumentation requires at least version 3.37.0."
45
45
 
46
46
  end
47
-
48
47
  end
49
-
50
48
  end
@@ -33,4 +33,4 @@ module NewRelic
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -44,6 +44,7 @@ DependencyDetection.defer do
44
44
  }
45
45
  end
46
46
  end
47
+
47
48
  class Client
48
49
  def call(_worker_class, job, *_)
49
50
  job[NewRelic::NEWRELIC_KEY] ||= distributed_tracing_headers if ::NewRelic::Agent.config[:'distributed_tracing.enabled']
@@ -61,10 +62,10 @@ DependencyDetection.defer do
61
62
  class Sidekiq::Extensions::DelayedClass
62
63
  def newrelic_trace_args(msg, queue)
63
64
  (target, method_name, _args) = if YAML.respond_to?(:unsafe_load)
64
- YAML.unsafe_load(msg['args'][0])
65
- else
66
- YAML.load(msg['args'][0])
67
- end
65
+ YAML.unsafe_load(msg['args'][0])
66
+ else
67
+ YAML.load(msg['args'][0])
68
+ end
68
69
 
69
70
  {
70
71
  :name => method_name,
@@ -5,7 +5,6 @@
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module Sinatra
7
7
  module Ignorer
8
-
9
8
  def self.should_ignore?(app, type)
10
9
  return false if !app.settings.respond_to?(:newrelic_ignores)
11
10
 
@@ -70,7 +70,8 @@ module NewRelic::Agent::Instrumentation
70
70
  begin
71
71
  if txn_name = TransactionNamer.transaction_name_for_route(env, request)
72
72
  ::NewRelic::Agent::Transaction.set_default_transaction_name(
73
- "#{self.class.name}/#{txn_name}", :sinatra)
73
+ "#{self.class.name}/#{txn_name}", :sinatra
74
+ )
74
75
  end
75
76
  rescue => e
76
77
  ::NewRelic::Agent.logger.debug("Failed during route_eval to set transaction name", e)
@@ -93,8 +94,8 @@ module NewRelic::Agent::Instrumentation
93
94
 
94
95
  name = TransactionNamer.initial_transaction_name(request)
95
96
  perform_action_with_newrelic_trace(:category => :sinatra,
96
- :name => name,
97
- :params => filtered_params) do
97
+ :name => name,
98
+ :params => filtered_params) do
98
99
  begin
99
100
  yield
100
101
  ensure
@@ -16,7 +16,7 @@ DependencyDetection.defer do
16
16
  executes do
17
17
  ::Sunspot.module_eval do
18
18
  class << self
19
- %w(index index!).each do |method|
19
+ %w[index index!].each do |method|
20
20
  add_method_tracer method, 'SolrClient/Sunspot/index'
21
21
  end
22
22
  add_method_tracer :commit, 'SolrClient/Sunspot/commit'
@@ -6,7 +6,6 @@ module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
8
  module Tilt
9
-
10
9
  def metric_name(klass, file)
11
10
  "View/#{klass}/#{file}/Rendering"
12
11
  end
@@ -4,19 +4,19 @@
4
4
 
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module Typhoeus
7
- module Chain
7
+ module Chain
8
8
  def self.instrument!
9
- ::Typhoeus::Hydra.class_eval do
9
+ ::Typhoeus::Hydra.class_eval do
10
10
  include NewRelic::Agent::Instrumentation::Typhoeus
11
11
 
12
12
  def run_with_newrelic(*args)
13
13
  with_tracing { run_without_newrelic(*args) }
14
14
  end
15
-
15
+
16
16
  alias run_without_newrelic run
17
17
  alias run run_with_newrelic
18
18
  end
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -6,8 +6,7 @@ module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
8
  module Typhoeus
9
-
10
- HYDRA_SEGMENT_NAME = "External/Multiple/Typhoeus::Hydra/run"
9
+ HYDRA_SEGMENT_NAME = "External/Multiple/Typhoeus::Hydra/run"
11
10
  NOTICIBLE_ERROR_CLASS = "Typhoeus::Errors::TyphoeusError"
12
11
 
13
12
  EARLIEST_VERSION = Gem::Version.new("0.5.3")
@@ -27,7 +26,7 @@ module NewRelic
27
26
  response.return_message
28
27
  else
29
28
  # 0.5.4 seems to have lost xxxx_message methods altogether.
30
- "timeout"
29
+ "timeout"
31
30
  end
32
31
  end
33
32
 
@@ -68,11 +67,10 @@ module NewRelic
68
67
  if request.response.code == 0
69
68
  segment.notice_error NoticibleError.new NOTICIBLE_ERROR_CLASS, response_message(request.response)
70
69
  end
71
-
70
+
72
71
  segment.finish if segment
73
72
  end
74
73
  request.on_complete.unshift(callback)
75
-
76
74
  rescue => e
77
75
  NewRelic::Agent.logger.error("Exception during trace setup for Typhoeus request", e)
78
76
  end
@@ -11,4 +11,4 @@ module NewRelic::Agent::Instrumentation
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -10,7 +10,7 @@
10
10
  module NewRelic
11
11
  module Agent
12
12
  class InternalAgentError < StandardError
13
- def initialize(msg=nil)
13
+ def initialize(msg = nil)
14
14
  super("Ruby agent internal error. Please contact support referencing this error.\n #{msg}")
15
15
  end
16
16
  end
@@ -19,8 +19,8 @@ module NewRelic
19
19
 
20
20
  def log_configuration
21
21
  NewRelic::Agent.logger.debug("JS agent loader requested: #{NewRelic::Agent.config[:'browser_monitoring.loader']}",
22
- "JS agent loader debug: #{NewRelic::Agent.config[:'browser_monitoring.debug']}",
23
- "JS agent loader version: #{NewRelic::Agent.config[:'browser_monitoring.loader_version']}")
22
+ "JS agent loader debug: #{NewRelic::Agent.config[:'browser_monitoring.debug']}",
23
+ "JS agent loader version: #{NewRelic::Agent.config[:'browser_monitoring.loader_version']}")
24
24
 
25
25
  if !NewRelic::Agent.config[:'rum.enabled']
26
26
  NewRelic::Agent.logger.debug("Real User Monitoring is disabled for this agent. Edit your configuration to change this.")
@@ -38,19 +38,19 @@ module NewRelic
38
38
  def js_enabled_and_ready?
39
39
  if !enabled?
40
40
  ::NewRelic::Agent.logger.log_once(:debug, :js_agent_disabled,
41
- "JS agent instrumentation is disabled.")
41
+ "JS agent instrumentation is disabled.")
42
42
  false
43
43
  elsif missing_config?(:js_agent_loader)
44
44
  ::NewRelic::Agent.logger.log_once(:debug, :missing_js_agent_loader,
45
- "Missing :js_agent_loader. Skipping browser instrumentation.")
45
+ "Missing :js_agent_loader. Skipping browser instrumentation.")
46
46
  false
47
47
  elsif missing_config?(:beacon)
48
48
  ::NewRelic::Agent.logger.log_once(:debug, :missing_beacon,
49
- "Beacon configuration not received (yet?). Skipping browser instrumentation.")
49
+ "Beacon configuration not received (yet?). Skipping browser instrumentation.")
50
50
  false
51
51
  elsif missing_config?(:browser_key)
52
52
  ::NewRelic::Agent.logger.log_once(:debug, :missing_browser_key,
53
- "Browser key is not set. Skipping browser instrumentation.")
53
+ "Browser key is not set. Skipping browser instrumentation.")
54
54
  false
55
55
  else
56
56
  true
@@ -83,7 +83,7 @@ module NewRelic
83
83
  value.nil? || value.empty?
84
84
  end
85
85
 
86
- def browser_timing_header(nonce=nil) #THREAD_LOCAL_ACCESS
86
+ def browser_timing_header(nonce = nil) # THREAD_LOCAL_ACCESS
87
87
  return '' unless js_enabled_and_ready? # fast exit
88
88
 
89
89
  state = NewRelic::Agent::Tracer.state
@@ -99,11 +99,11 @@ module NewRelic
99
99
  ''
100
100
  end
101
101
 
102
- def browser_timing_loader(nonce=nil)
102
+ def browser_timing_loader(nonce = nil)
103
103
  html_safe_if_needed("\n<script type=\"text/javascript\"#{create_nonce(nonce)}>#{Agent.config[:js_agent_loader]}</script>")
104
104
  end
105
105
 
106
- def browser_timing_config(state, nonce=nil)
106
+ def browser_timing_config(state, nonce = nil)
107
107
  txn = state.current_transaction
108
108
  return '' if txn.nil?
109
109
 
@@ -116,44 +116,44 @@ module NewRelic
116
116
  ''
117
117
  end
118
118
 
119
- def create_nonce(nonce=nil)
119
+ def create_nonce(nonce = nil)
120
120
  return '' unless nonce
121
121
  " nonce=\"#{nonce.to_s}\""
122
122
  end
123
123
 
124
- BEACON_KEY = "beacon".freeze
125
- ERROR_BEACON_KEY = "errorBeacon".freeze
126
- LICENSE_KEY_KEY = "licenseKey".freeze
127
- APPLICATIONID_KEY = "applicationID".freeze
124
+ BEACON_KEY = "beacon".freeze
125
+ ERROR_BEACON_KEY = "errorBeacon".freeze
126
+ LICENSE_KEY_KEY = "licenseKey".freeze
127
+ APPLICATIONID_KEY = "applicationID".freeze
128
128
  TRANSACTION_NAME_KEY = "transactionName".freeze
129
- QUEUE_TIME_KEY = "queueTime".freeze
129
+ QUEUE_TIME_KEY = "queueTime".freeze
130
130
  APPLICATION_TIME_KEY = "applicationTime".freeze
131
- AGENT_KEY = "agent".freeze
132
- SSL_FOR_HTTP_KEY = "sslForHttp".freeze
133
- ATTS_KEY = "atts".freeze
134
- ATTS_USER_SUBKEY = "u".freeze
135
- ATTS_AGENT_SUBKEY = "a".freeze
131
+ AGENT_KEY = "agent".freeze
132
+ SSL_FOR_HTTP_KEY = "sslForHttp".freeze
133
+ ATTS_KEY = "atts".freeze
134
+ ATTS_USER_SUBKEY = "u".freeze
135
+ ATTS_AGENT_SUBKEY = "a".freeze
136
136
 
137
137
  # NOTE: Internal prototyping may override this, so leave name stable!
138
138
  def data_for_js_agent(transaction)
139
139
  queue_time_in_seconds = [transaction.queue_time, 0.0].max
140
140
  start_time_in_seconds = [transaction.start_time, 0.0].max
141
- app_time_in_seconds = Process.clock_gettime(Process::CLOCK_REALTIME) - start_time_in_seconds
141
+ app_time_in_seconds = Process.clock_gettime(Process::CLOCK_REALTIME) - start_time_in_seconds
142
142
 
143
143
  queue_time_in_millis = (1000.0 * queue_time_in_seconds).round
144
- app_time_in_millis = (1000.0 * app_time_in_seconds).round
144
+ app_time_in_millis = (1000.0 * app_time_in_seconds).round
145
145
 
146
146
  transaction_name = transaction.best_name || ::NewRelic::Agent::UNKNOWN_METRIC
147
147
 
148
148
  data = {
149
- BEACON_KEY => NewRelic::Agent.config[:beacon],
150
- ERROR_BEACON_KEY => NewRelic::Agent.config[:error_beacon],
151
- LICENSE_KEY_KEY => NewRelic::Agent.config[:browser_key],
152
- APPLICATIONID_KEY => NewRelic::Agent.config[:application_id],
149
+ BEACON_KEY => NewRelic::Agent.config[:beacon],
150
+ ERROR_BEACON_KEY => NewRelic::Agent.config[:error_beacon],
151
+ LICENSE_KEY_KEY => NewRelic::Agent.config[:browser_key],
152
+ APPLICATIONID_KEY => NewRelic::Agent.config[:application_id],
153
153
  TRANSACTION_NAME_KEY => obfuscator.obfuscate(transaction_name),
154
- QUEUE_TIME_KEY => queue_time_in_millis,
154
+ QUEUE_TIME_KEY => queue_time_in_millis,
155
155
  APPLICATION_TIME_KEY => app_time_in_millis,
156
- AGENT_KEY => NewRelic::Agent.config[:js_agent_file]
156
+ AGENT_KEY => NewRelic::Agent.config[:js_agent_file]
157
157
  }
158
158
 
159
159
  add_ssl_for_http(data)
@@ -8,7 +8,6 @@ require 'new_relic/agent/hostname'
8
8
  module NewRelic
9
9
  module Agent
10
10
  module Logging
11
-
12
11
  # This class can be used as the formatter for an existing logger. It
13
12
  # decorates log messages with trace and entity metadata, and formats each
14
13
  # log messages as a JSON object.
@@ -89,7 +88,14 @@ module NewRelic
89
88
 
90
89
  def escape(message)
91
90
  message = message.to_s unless message.is_a?(String)
92
- message = message.scrub(REPLACEMENT_CHAR) unless message.valid_encoding?
91
+ unless message.encoding == Encoding::UTF_8 && message.valid_encoding?
92
+ message = message.encode(
93
+ Encoding::UTF_8,
94
+ invalid: :replace,
95
+ undef: :replace,
96
+ replace: REPLACEMENT_CHAR
97
+ )
98
+ end
93
99
  message.to_json
94
100
  end
95
101
 
@@ -98,7 +104,6 @@ module NewRelic
98
104
  end
99
105
  end
100
106
 
101
-
102
107
  # This logger decorates logs with trace and entity metadata, and emits log
103
108
  # messages formatted as JSON objects. It extends the Logger class from
104
109
  # the Ruby standard library, and accepts the same constructor parameters.
@@ -115,7 +120,6 @@ module NewRelic
115
120
  #
116
121
  # @api public
117
122
  class DecoratingLogger < (defined?(::ActiveSupport) && defined?(::ActiveSupport::Logger) ? ::ActiveSupport::Logger : ::Logger)
118
-
119
123
  alias :write :info
120
124
 
121
125
  # Positional and Keyword arguments are separated beginning with Ruby 2.7
@@ -44,7 +44,7 @@ module NewRelic
44
44
  messages << [:debug, msgs, blk]
45
45
  end
46
46
 
47
- def log_exception(level, e, backtrace_level=level)
47
+ def log_exception(level, e, backtrace_level = level)
48
48
  messages << [:log_exception, [level, e, backtrace_level]]
49
49
  end
50
50
 
@@ -18,8 +18,8 @@ module NewRelic
18
18
  RABBITMQ_TRANSPORT_TYPE = "RabbitMQ"
19
19
 
20
20
  ATTR_DESTINATION = AttributeFilter::DST_TRANSACTION_EVENTS |
21
- AttributeFilter::DST_TRANSACTION_TRACER |
22
- AttributeFilter::DST_ERROR_COLLECTOR
21
+ AttributeFilter::DST_TRANSACTION_TRACER |
22
+ AttributeFilter::DST_ERROR_COLLECTOR
23
23
 
24
24
  # Start a MessageBroker segment configured to trace a messaging action.
25
25
  # Finishing this segment will handle timing and recording of the proper
@@ -53,12 +53,12 @@ module NewRelic
53
53
  # @api public
54
54
  #
55
55
  def start_message_broker_segment(action: nil,
56
- library: nil,
57
- destination_type: nil,
58
- destination_name: nil,
59
- headers: nil,
60
- parameters: nil,
61
- start_time: nil)
56
+ library: nil,
57
+ destination_type: nil,
58
+ destination_name: nil,
59
+ headers: nil,
60
+ parameters: nil,
61
+ start_time: nil)
62
62
 
63
63
  Tracer.start_message_broker_segment(
64
64
  action: action,
@@ -111,14 +111,14 @@ module NewRelic
111
111
  # @api public
112
112
  #
113
113
  def wrap_message_broker_consume_transaction(library:,
114
- destination_type:,
115
- destination_name:,
116
- headers: nil,
117
- routing_key: nil,
118
- queue_name: nil,
119
- exchange_type: nil,
120
- reply_to: nil,
121
- correlation_id: nil)
114
+ destination_type:,
115
+ destination_name:,
116
+ headers: nil,
117
+ routing_key: nil,
118
+ queue_name: nil,
119
+ exchange_type: nil,
120
+ reply_to: nil,
121
+ correlation_id: nil)
122
122
 
123
123
  state = Tracer.state
124
124
  return yield if state.current_transaction
@@ -181,12 +181,12 @@ module NewRelic
181
181
  # @api public
182
182
  #
183
183
  def start_amqp_publish_segment(library:,
184
- destination_name:,
185
- headers: nil,
186
- routing_key: nil,
187
- reply_to: nil,
188
- correlation_id: nil,
189
- exchange_type: nil)
184
+ destination_name:,
185
+ headers: nil,
186
+ routing_key: nil,
187
+ reply_to: nil,
188
+ correlation_id: nil,
189
+ exchange_type: nil)
190
190
 
191
191
  raise ArgumentError, 'missing required argument: headers' if headers.nil? && CrossAppTracing.cross_app_enabled?
192
192
 
@@ -240,12 +240,12 @@ module NewRelic
240
240
  # @api public
241
241
  #
242
242
  def start_amqp_consume_segment(library:,
243
- destination_name:,
244
- delivery_info:,
245
- message_properties:,
246
- exchange_type: nil,
247
- queue_name: nil,
248
- start_time: nil)
243
+ destination_name:,
244
+ delivery_info:,
245
+ message_properties:,
246
+ exchange_type: nil,
247
+ queue_name: nil,
248
+ start_time: nil)
249
249
 
250
250
  segment = Tracer.start_message_broker_segment(
251
251
  action: :consume,
@@ -301,22 +301,22 @@ module NewRelic
301
301
  # @api public
302
302
  #
303
303
  def wrap_amqp_consume_transaction library: nil,
304
- destination_name: nil,
305
- delivery_info: nil,
306
- message_properties: nil,
307
- exchange_type: nil,
308
- queue_name: nil,
309
- &block
304
+ destination_name: nil,
305
+ delivery_info: nil,
306
+ message_properties: nil,
307
+ exchange_type: nil,
308
+ queue_name: nil,
309
+ &block
310
310
 
311
311
  wrap_message_broker_consume_transaction library: library,
312
- destination_type: :exchange,
313
- destination_name: Instrumentation::Bunny.exchange_name(destination_name),
314
- routing_key: delivery_info[:routing_key],
315
- reply_to: message_properties[:reply_to],
316
- queue_name: queue_name,
317
- exchange_type: exchange_type,
318
- headers: message_properties[:headers],
319
- correlation_id: message_properties[:correlation_id],
312
+ destination_type: :exchange,
313
+ destination_name: Instrumentation::Bunny.exchange_name(destination_name),
314
+ routing_key: delivery_info[:routing_key],
315
+ reply_to: message_properties[:reply_to],
316
+ queue_name: queue_name,
317
+ exchange_type: exchange_type,
318
+ headers: message_properties[:headers],
319
+ correlation_id: message_properties[:correlation_id],
320
320
  &block
321
321
  end
322
322
 
@@ -352,7 +352,6 @@ module NewRelic
352
352
 
353
353
  transaction_name
354
354
  end
355
-
356
355
  end
357
356
  end
358
357
  end