newrelic_rpm 8.0.0 → 8.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.rubocop.yml +1936 -0
  4. data/Brewfile +10 -0
  5. data/CHANGELOG.md +96 -0
  6. data/CONTRIBUTING.md +15 -3
  7. data/Guardfile +8 -8
  8. data/README.md +3 -1
  9. data/Rakefile +7 -9
  10. data/bin/mongrel_rpm +8 -9
  11. data/bin/newrelic +1 -1
  12. data/bin/nrdebug +14 -14
  13. data/init.rb +0 -2
  14. data/lefthook.yml +9 -0
  15. data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
  16. data/lib/new_relic/agent/agent.rb +38 -40
  17. data/lib/new_relic/agent/agent_logger.rb +8 -9
  18. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  19. data/lib/new_relic/agent/attributes.rb +2 -2
  20. data/lib/new_relic/agent/autostart.rb +6 -7
  21. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  22. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  23. data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
  24. data/lib/new_relic/agent/configuration/default_source.rb +343 -337
  25. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  26. data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
  27. data/lib/new_relic/agent/configuration/event_harvest_config.rb +2 -4
  28. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  29. data/lib/new_relic/agent/configuration/manager.rb +57 -57
  30. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  31. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  32. data/lib/new_relic/agent/configuration/server_source.rb +10 -10
  33. data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
  34. data/lib/new_relic/agent/connect/request_builder.rb +13 -16
  35. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  36. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
  37. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  38. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  39. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  40. data/lib/new_relic/agent/database.rb +20 -24
  41. data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
  42. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  43. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  44. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  45. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  46. data/lib/new_relic/agent/datastores.rb +1 -3
  47. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
  48. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
  49. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
  50. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
  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 +24 -24
  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 +10 -10
  64. data/lib/new_relic/agent/external.rb +1 -2
  65. data/lib/new_relic/agent/guid_generator.rb +2 -9
  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 +5 -7
  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 +9 -10
  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 +2 -2
  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/active_storage.rb +1 -1
  88. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
  89. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  90. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
  91. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
  92. data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
  93. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  94. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
  95. data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
  96. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  97. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
  98. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
  99. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  100. data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
  101. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  102. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  103. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  104. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  105. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  106. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  107. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  108. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  109. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  110. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  111. data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
  112. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
  113. data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
  114. data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
  115. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
  116. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
  117. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
  118. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  119. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
  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 +5 -5
  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 +6 -6
  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 +5 -4
  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 +28 -28
  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 +42 -43
  169. data/lib/new_relic/agent/method_tracer.rb +17 -15
  170. data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
  171. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +19 -16
  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 +26 -33
  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 +15 -7
  185. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  186. data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
  187. data/lib/new_relic/agent/pipe_service.rb +1 -1
  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/delayed_job_sampler.rb +10 -7
  195. data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
  196. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  197. data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
  198. data/lib/new_relic/agent/span_event_primitive.rb +39 -39
  199. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  200. data/lib/new_relic/agent/stats.rb +16 -16
  201. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  202. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  203. data/lib/new_relic/agent/stats_engine.rb +6 -6
  204. data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
  205. data/lib/new_relic/agent/system_info.rb +22 -20
  206. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  207. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  208. data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
  209. data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
  210. data/lib/new_relic/agent/tracer.rb +37 -43
  211. data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
  212. data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
  213. data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
  214. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  215. data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
  216. data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
  217. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  218. data/lib/new_relic/agent/transaction/segment.rb +6 -3
  219. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  220. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  221. data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
  222. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  223. data/lib/new_relic/agent/transaction/tracing.rb +1 -3
  224. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  225. data/lib/new_relic/agent/transaction.rb +79 -81
  226. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
  227. data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
  228. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  229. data/lib/new_relic/agent/transaction_metrics.rb +3 -3
  230. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  231. data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
  232. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  233. data/lib/new_relic/agent/utilization_data.rb +3 -4
  234. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  235. data/lib/new_relic/agent/vm/snapshot.rb +3 -3
  236. data/lib/new_relic/agent/worker_loop.rb +3 -5
  237. data/lib/new_relic/agent.rb +22 -22
  238. data/lib/new_relic/cli/command.rb +15 -17
  239. data/lib/new_relic/cli/commands/deployments.rb +20 -22
  240. data/lib/new_relic/cli/commands/install.rb +6 -10
  241. data/lib/new_relic/coerce.rb +5 -8
  242. data/lib/new_relic/collection_helper.rb +48 -47
  243. data/lib/new_relic/control/class_methods.rb +2 -2
  244. data/lib/new_relic/control/frameworks/external.rb +1 -1
  245. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  246. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  247. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  248. data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
  249. data/lib/new_relic/control/instance_methods.rb +4 -5
  250. data/lib/new_relic/control/instrumentation.rb +4 -5
  251. data/lib/new_relic/control/server_methods.rb +2 -3
  252. data/lib/new_relic/control.rb +0 -1
  253. data/lib/new_relic/dependency_detection.rb +6 -8
  254. data/lib/new_relic/environment_report.rb +16 -18
  255. data/lib/new_relic/helper.rb +5 -5
  256. data/lib/new_relic/language_support.rb +1 -1
  257. data/lib/new_relic/latest_changes.rb +2 -2
  258. data/lib/new_relic/local_environment.rb +7 -7
  259. data/lib/new_relic/metric_data.rb +6 -7
  260. data/lib/new_relic/metric_spec.rb +3 -3
  261. data/lib/new_relic/noticed_error.rb +14 -15
  262. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  263. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  264. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  265. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  266. data/lib/new_relic/supportability_helper.rb +1 -2
  267. data/lib/new_relic/version.rb +3 -4
  268. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  269. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  270. data/lib/tasks/all.rb +1 -1
  271. data/lib/tasks/config.rake +21 -21
  272. data/lib/tasks/multiverse.rb +4 -6
  273. data/lib/tasks/tests.rake +3 -7
  274. data/newrelic.yml +8 -21
  275. data/newrelic_rpm.gemspec +13 -12
  276. data/recipes/newrelic.rb +1 -1
  277. data/test/agent_helper.rb +55 -55
  278. metadata +43 -7
  279. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
  280. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
  281. data/lib/new_relic/agent/supported_versions.rb +0 -275
data/test/agent_helper.rb CHANGED
@@ -28,7 +28,7 @@ module MiniTest
28
28
  end
29
29
 
30
30
  class ArrayLogDevice
31
- def initialize array=[]
31
+ def initialize array = []
32
32
  @array = array
33
33
  end
34
34
  attr_reader :array
@@ -40,7 +40,7 @@ class ArrayLogDevice
40
40
  def close; end
41
41
  end
42
42
 
43
- def fake_guid length=16
43
+ def fake_guid length = 16
44
44
  NewRelic::Agent::GuidGenerator.generate_guid length
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ def assert_match matcher, obj, msg = nil
51
51
  assert matcher =~ obj, msg
52
52
  end
53
53
 
54
- def assert_between floor, ceiling, value, message="expected #{floor} <= #{value} <= #{ceiling}"
54
+ def assert_between floor, ceiling, value, message = "expected #{floor} <= #{value} <= #{ceiling}"
55
55
  assert((floor <= value && value <= ceiling), message)
56
56
  end
57
57
 
@@ -70,7 +70,7 @@ end
70
70
  def assert_has_traced_error error_class
71
71
  errors = harvest_error_traces!
72
72
  assert \
73
- errors.find {|e| e.exception_class_name == error_class.name} != nil, \
73
+ errors.find { |e| e.exception_class_name == error_class.name } != nil, \
74
74
  "Didn't find error of class #{error_class}"
75
75
  end
76
76
 
@@ -109,21 +109,21 @@ unless defined? assert_block
109
109
  end
110
110
 
111
111
  unless defined? assert_includes
112
- def assert_includes collection, member, msg=nil
112
+ def assert_includes collection, member, msg = nil
113
113
  msg = "Expected #{collection.inspect} to include #{member.inspect}"
114
- assert_block( msg ) { collection.include?(member) }
114
+ assert_block(msg) { collection.include?(member) }
115
115
  end
116
116
  end
117
117
 
118
118
  unless defined? assert_not_includes
119
- def assert_not_includes collection, member, msg=nil
119
+ def assert_not_includes collection, member, msg = nil
120
120
  msg = "Expected #{collection.inspect} not to include #{member.inspect}"
121
121
  assert !collection.include?(member), msg
122
122
  end
123
123
  end
124
124
 
125
125
  unless defined? assert_empty
126
- def assert_empty collection, msg=nil
126
+ def assert_empty collection, msg = nil
127
127
  assert collection.empty?, msg
128
128
  end
129
129
  end
@@ -160,7 +160,7 @@ end
160
160
  def assert_audit_log_contains_object audit_log_contents, o, format = :json
161
161
  case o
162
162
  when Hash
163
- o.each do |k,v|
163
+ o.each do |k, v|
164
164
  assert_audit_log_contains_object(audit_log_contents, v, format)
165
165
  assert_audit_log_contains_object(audit_log_contents, k, format)
166
166
  end
@@ -176,14 +176,14 @@ def assert_audit_log_contains_object audit_log_contents, o, format = :json
176
176
  end
177
177
 
178
178
  def compare_metrics expected, actual
179
- actual.delete_if {|a| a.include?('GC/Transaction/') }
179
+ actual.delete_if { |a| a.include?('GC/Transaction/') }
180
180
  assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}")
181
181
  end
182
182
 
183
183
  def metric_spec_from_specish specish
184
184
  spec = case specish
185
185
  when String then NewRelic::MetricSpec.new(specish)
186
- when Array then NewRelic::MetricSpec.new(*specish)
186
+ when Array then NewRelic::MetricSpec.new(*specish)
187
187
  end
188
188
  spec
189
189
  end
@@ -193,17 +193,17 @@ def _normalize_metric_expectations expectations
193
193
  when Array
194
194
  hash = {}
195
195
  # Just assert that the metric is present, nothing about the attributes
196
- expectations.each { |k| hash[k] = { } }
196
+ expectations.each { |k| hash[k] = {} }
197
197
  hash
198
198
  when String
199
- { expectations => {} }
199
+ {expectations => {}}
200
200
  else
201
201
  expectations
202
202
  end
203
203
  end
204
204
 
205
205
  def dump_stats stats
206
- str = " Call count: #{stats.call_count}\n"
206
+ str = " Call count: #{stats.call_count}\n"
207
207
  str << " Total call time: #{stats.total_call_time}\n"
208
208
  str << " Total exclusive time: #{stats.total_exclusive_time}\n"
209
209
  str << " Min call time: #{stats.min_call_time}\n"
@@ -259,7 +259,7 @@ end
259
259
  # the :ignore_filter option. This will allow you to specify a Regex that
260
260
  # allowlists broad swathes of metric territory (e.g. 'Supportability/').
261
261
  #
262
- def assert_metrics_recorded_exclusive expected, options={}
262
+ def assert_metrics_recorded_exclusive expected, options = {}
263
263
  expected = _normalize_metric_expectations(expected)
264
264
  assert_metrics_recorded(expected)
265
265
 
@@ -272,7 +272,7 @@ def assert_metrics_recorded_exclusive expected, options={}
272
272
  recorded_metrics.reject! { |m| m.name.match(options[:ignore_filter]) }
273
273
  end
274
274
 
275
- expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s) }
275
+ expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s) }
276
276
 
277
277
  unexpected_metrics = recorded_metrics - expected_metrics
278
278
  unexpected_metrics.reject! { |m| m.name =~ /GC\/Transaction/ }
@@ -320,7 +320,7 @@ def assert_no_metrics_match regex
320
320
  assert_equal(
321
321
  [],
322
322
  matching_metrics,
323
- "Found unexpected metrics:\n" + matching_metrics.map { |m| " '#{m}'"}.join("\n") + "\n\n"
323
+ "Found unexpected metrics:\n" + matching_metrics.map { |m| " '#{m}'" }.join("\n") + "\n\n"
324
324
  )
325
325
  end
326
326
 
@@ -333,12 +333,12 @@ def format_metric_spec_list specs
333
333
  "[\n #{spec_strings.join(",\n ")}\n]"
334
334
  end
335
335
 
336
- def assert_truthy expected, msg=nil
336
+ def assert_truthy expected, msg = nil
337
337
  msg ||= "Expected #{expected.inspect} to be truthy"
338
338
  assert !!expected, msg
339
339
  end
340
340
 
341
- def assert_falsy expected, msg=nil
341
+ def assert_falsy expected, msg = nil
342
342
  msg ||= "Expected #{expected.inspect} to be falsy"
343
343
  assert !expected, msg
344
344
  end
@@ -372,7 +372,7 @@ end
372
372
  # in_transaction('foobar', :category => :controller) { ... }
373
373
  #
374
374
  def in_transaction *args, &blk
375
- opts = (args.last && args.last.is_a?(Hash)) ? args.pop : {}
375
+ opts = args.last && args.last.is_a?(Hash) ? args.pop : {}
376
376
  category = (opts && opts.delete(:category)) || :other
377
377
 
378
378
  # At least one test passes `:transaction_name => nil`, so handle it gently
@@ -442,13 +442,13 @@ end
442
442
 
443
443
  # Convenience wrapper around in_transaction that sets the category so that it
444
444
  # looks like we are in a web transaction
445
- def in_web_transaction name='dummy'
445
+ def in_web_transaction name = 'dummy'
446
446
  in_transaction(name, :category => :controller, :request => stub(:path => '/')) do |txn|
447
447
  yield txn
448
448
  end
449
449
  end
450
450
 
451
- def in_background_transaction name='silly'
451
+ def in_background_transaction name = 'silly'
452
452
  in_transaction(name, :category => :task) do |txn|
453
453
  yield txn
454
454
  end
@@ -483,7 +483,7 @@ def last_sql_trace
483
483
  NewRelic::Agent.agent.sql_sampler.sql_traces.values.last
484
484
  end
485
485
 
486
- def find_last_transaction_node transaction_sample=nil
486
+ def find_last_transaction_node transaction_sample = nil
487
487
  if transaction_sample
488
488
  root_node = transaction_sample.root_node
489
489
  else
@@ -491,7 +491,7 @@ def find_last_transaction_node transaction_sample=nil
491
491
  end
492
492
 
493
493
  last_node = nil
494
- root_node.each_node {|s| last_node = s }
494
+ root_node.each_node { |s| last_node = s }
495
495
 
496
496
  return last_node
497
497
  end
@@ -531,7 +531,7 @@ def find_all_nodes_with_name_matching transaction_sample, regexes
531
531
  matching_nodes
532
532
  end
533
533
 
534
- def with_config config_hash, at_start=true
534
+ def with_config config_hash, at_start = true
535
535
  config = NewRelic::Agent::Configuration::DottedHash.new(config_hash, true)
536
536
  NewRelic::Agent.config.add_config_for_testing(config, at_start)
537
537
  NewRelic::Agent.instance.refresh_attribute_filter
@@ -543,7 +543,7 @@ def with_config config_hash, at_start=true
543
543
  end
544
544
  end
545
545
 
546
- def with_server_source config_hash, at_start=true
546
+ def with_server_source config_hash, at_start = true
547
547
  with_config config_hash, at_start do
548
548
  NewRelic::Agent.config.notify_server_source_added
549
549
  yield
@@ -582,7 +582,7 @@ unless Time.respond_to?(:__original_now)
582
582
  end
583
583
  end
584
584
 
585
- def nr_freeze_time now=Time.now
585
+ def nr_freeze_time now = Time.now
586
586
  Time.__frozen_now = now
587
587
  end
588
588
 
@@ -607,11 +607,11 @@ unless Process.respond_to?(:__original_clock_gettime)
607
607
  end
608
608
  end
609
609
 
610
- def advance_process_time(seconds, clock_id=Process::CLOCK_REALTIME)
610
+ def advance_process_time(seconds, clock_id = Process::CLOCK_REALTIME)
611
611
  Process.__frozen_clock_gettime = Process.clock_gettime(clock_id) + seconds
612
612
  end
613
613
 
614
- def nr_freeze_process_time(now=Process.clock_gettime(Process::CLOCK_REALTIME))
614
+ def nr_freeze_process_time(now = Process.clock_gettime(Process::CLOCK_REALTIME))
615
615
  Process.__frozen_clock_gettime = now
616
616
  end
617
617
 
@@ -619,7 +619,7 @@ def nr_unfreeze_process_time
619
619
  Process.__frozen_clock_gettime = nil
620
620
  end
621
621
 
622
- def with_constant_defined constant_symbol, implementation=Module.new
622
+ def with_constant_defined constant_symbol, implementation = Module.new
623
623
  const_path = constant_path(constant_symbol.to_s)
624
624
 
625
625
  if const_path
@@ -639,7 +639,7 @@ def with_constant_defined constant_symbol, implementation=Module.new
639
639
  end
640
640
  end
641
641
 
642
- def constant_path name, opts={}
642
+ def constant_path name, opts = {}
643
643
  allow_partial = opts[:allow_partial]
644
644
  path = [Object]
645
645
  parts = name.gsub(/^::/, '').split('::')
@@ -673,7 +673,7 @@ def with_debug_logging
673
673
  orig_logger = NewRelic::Agent.logger
674
674
  $stderr.puts '', '---', ''
675
675
  NewRelic::Agent.logger =
676
- NewRelic::Agent::AgentLogger.new('', Logger.new($stderr) )
676
+ NewRelic::Agent::AgentLogger.new('', Logger.new($stderr))
677
677
 
678
678
  with_config(:log_level => 'debug') do
679
679
  yield
@@ -682,11 +682,11 @@ ensure
682
682
  NewRelic::Agent.logger = orig_logger
683
683
  end
684
684
 
685
- def create_agent_command args={}
686
- NewRelic::Agent::Commands::AgentCommand.new([-1, { "name" => "command_name", "arguments" => args}])
685
+ def create_agent_command args = {}
686
+ NewRelic::Agent::Commands::AgentCommand.new([-1, {"name" => "command_name", "arguments" => args}])
687
687
  end
688
688
 
689
- def wait_for_backtrace_service_poll opts={}
689
+ def wait_for_backtrace_service_poll opts = {}
690
690
  defaults = {
691
691
  :timeout => 10.0,
692
692
  :service => NewRelic::Agent.agent.agent_command_router.backtrace_service,
@@ -703,18 +703,18 @@ def wait_for_backtrace_service_poll opts={}
703
703
  sleep(0.01)
704
704
  if Process.clock_gettime(Process::CLOCK_REALTIME) > deadline
705
705
  raise "Timed out waiting #{opts[:timeout]} s for backtrace service poll\n" +
706
- "Worker loop ran for #{opts[:service].worker_loop.iterations} iterations\n\n" +
707
- Thread.list.map { |t|
708
- "#{t.to_s}: newrelic_label: #{t[:newrelic_label].inspect}\n\n" +
709
- (t.backtrace || []).join("\n\t")
710
- }.join("\n\n")
706
+ "Worker loop ran for #{opts[:service].worker_loop.iterations} iterations\n\n" +
707
+ Thread.list.map { |t|
708
+ "#{t.to_s}: newrelic_label: #{t[:newrelic_label].inspect}\n\n" +
709
+ (t.backtrace || []).join("\n\t")
710
+ }.join("\n\n")
711
711
  end
712
712
  end
713
713
  end
714
714
 
715
- def with_array_logger level=:info
715
+ def with_array_logger level = :info
716
716
  orig_logger = NewRelic::Agent.logger
717
- config = { :log_level => level }
717
+ config = {:log_level => level}
718
718
  logdev = ArrayLogDevice.new
719
719
  override_logger = Logger.new(logdev)
720
720
 
@@ -749,7 +749,7 @@ class EnvUpdater
749
749
 
750
750
  # Will attempt the given block up to MAX_RETRIES before
751
751
  # surfacing the exception down the chain.
752
- def with_retry retry_limit=MAX_RETRIES
752
+ def with_retry retry_limit = MAX_RETRIES
753
753
  retries ||= 0
754
754
  sleep(retries)
755
755
  yield
@@ -761,7 +761,7 @@ class EnvUpdater
761
761
  def safe_update env
762
762
  with_retry do
763
763
  @mutex.synchronize do
764
- env.each{ |key, val| ENV[key] = val.to_s }
764
+ env.each { |key, val| ENV[key] = val.to_s }
765
765
  end
766
766
  end
767
767
  end
@@ -770,7 +770,7 @@ class EnvUpdater
770
770
  def safe_restore old_env
771
771
  with_retry do
772
772
  @mutex.synchronize do
773
- old_env.each{ |key, val| val ? ENV[key] = val : ENV.delete(key) }
773
+ old_env.each { |key, val| val ? ENV[key] = val : ENV.delete(key) }
774
774
  end
775
775
  end
776
776
  end
@@ -792,7 +792,7 @@ class EnvUpdater
792
792
  # runs given block, then restores ENV to original state before returning.
793
793
  def self.inject env, &block
794
794
  old_env = {}
795
- env.each{ |key, val| old_env[key] = ENV[key] }
795
+ env.each { |key, val| old_env[key] = ENV[key] }
796
796
  begin
797
797
  safe_update(env)
798
798
  yield
@@ -868,7 +868,7 @@ end
868
868
  def each_cross_agent_test options
869
869
  options = {:dir => nil, :pattern => "*"}.update(options)
870
870
  path = File.join [cross_agent_tests_dir, options[:dir], options[:pattern]].compact
871
- Dir.glob(path).each { |file| yield file}
871
+ Dir.glob(path).each { |file| yield file }
872
872
  end
873
873
 
874
874
  def assert_event_attributes event, test_name, expected_attributes, non_expected_attributes
@@ -904,7 +904,7 @@ def attributes_for sample, type
904
904
  end
905
905
 
906
906
  def uncache_trusted_account_key
907
- NewRelic::Agent::Transaction::TraceContext::AccountHelpers.instance_variable_set :@trace_state_entry_key, nil
907
+ NewRelic::Agent::Transaction::TraceContext::AccountHelpers.instance_variable_set :@trace_state_entry_key, nil
908
908
  end
909
909
 
910
910
  def reset_buffers_and_caches
@@ -930,7 +930,7 @@ end
930
930
  # http status code associated with it.
931
931
  # a "status_code" may be passed in the headers to alter the HTTP Status Code
932
932
  # that is wrapped in the response.
933
- def mock_http_response headers, wrap_it=true
933
+ def mock_http_response headers, wrap_it = true
934
934
  status_code = (headers.delete("status_code") || 200).to_i
935
935
  net_http_resp = Net::HTTPResponse.new(1.0, status_code, message_for_status_code(status_code))
936
936
  headers.each do |key, value|
@@ -952,7 +952,7 @@ end
952
952
  # selects the last segment with a noticed_error and checks
953
953
  # the expectations against it.
954
954
  def assert_segment_noticed_error txn, segment_name, error_classes, error_message
955
- error_segment = txn.segments.reverse.detect{|s| s.noticed_error}
955
+ error_segment = txn.segments.reverse.detect { |s| s.noticed_error }
956
956
  assert error_segment, "Expected at least one segment with a noticed_error"
957
957
 
958
958
  assert_match_or_equal segment_name, error_segment.name
@@ -969,7 +969,7 @@ def assert_transaction_noticed_error txn, error_classes
969
969
  end
970
970
 
971
971
  def refute_transaction_noticed_error txn, error_class
972
- error_segment = txn.segments.reverse.detect{|s| s.noticed_error}
972
+ error_segment = txn.segments.reverse.detect { |s| s.noticed_error }
973
973
  assert error_segment, "Expected at least one segment with a noticed_error"
974
974
  assert_empty txn.exceptions, "Expected transaction to NOT notice any segment errors"
975
975
  end
@@ -997,11 +997,11 @@ def assert_implements instance, method, *args
997
997
  end
998
998
  end
999
999
 
1000
- def defer_testing_to_min_supported_rails test_file, min_rails_version, supports_jruby=true
1000
+ def defer_testing_to_min_supported_rails test_file, min_rails_version, supports_jruby = true
1001
1001
  if defined?(::Rails) &&
1002
- defined?(::Rails::VERSION::STRING) &&
1003
- (::Rails::VERSION::STRING.to_f >= min_rails_version) &&
1004
- (supports_jruby || !NewRelic::LanguageSupport.jruby?)
1002
+ defined?(::Rails::VERSION::STRING) &&
1003
+ (::Rails::VERSION::STRING.to_f >= min_rails_version) &&
1004
+ (supports_jruby || !NewRelic::LanguageSupport.jruby?)
1005
1005
 
1006
1006
  yield
1007
1007
  else
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - Aaron Huntsman
8
7
  - Tanna McClure
9
8
  - Kayla Reopelle
9
+ - James Bunch
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-22 00:00:00.000000000 Z
13
+ date: 2022-01-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -180,6 +180,34 @@ dependencies:
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
+ - !ruby/object:Gem::Dependency
184
+ name: rubocop
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ type: :development
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ - !ruby/object:Gem::Dependency
198
+ name: rubocop-performance
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ type: :development
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
183
211
  description: |
184
212
  New Relic is a performance management system, developed by New Relic,
185
213
  Inc (http://www.newrelic.com). New Relic provides you with deep
@@ -203,7 +231,9 @@ extra_rdoc_files:
203
231
  files:
204
232
  - ".gitignore"
205
233
  - ".project"
234
+ - ".rubocop.yml"
206
235
  - ".yardopts"
236
+ - Brewfile
207
237
  - CHANGELOG.md
208
238
  - CONTRIBUTING.md
209
239
  - Gemfile
@@ -221,6 +251,7 @@ files:
221
251
  - config/database.yml
222
252
  - init.rb
223
253
  - install.rb
254
+ - lefthook.yml
224
255
  - lib/new_relic/agent.rb
225
256
  - lib/new_relic/agent/adaptive_sampler.rb
226
257
  - lib/new_relic/agent/agent.rb
@@ -338,6 +369,10 @@ files:
338
369
  - lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
339
370
  - lib/new_relic/agent/instrumentation/httprb/prepend.rb
340
371
  - lib/new_relic/agent/instrumentation/ignore_actions.rb
372
+ - lib/new_relic/agent/instrumentation/logger.rb
373
+ - lib/new_relic/agent/instrumentation/logger/chain.rb
374
+ - lib/new_relic/agent/instrumentation/logger/instrumentation.rb
375
+ - lib/new_relic/agent/instrumentation/logger/prepend.rb
341
376
  - lib/new_relic/agent/instrumentation/memcache.rb
342
377
  - lib/new_relic/agent/instrumentation/memcache/chain.rb
343
378
  - lib/new_relic/agent/instrumentation/memcache/dalli.rb
@@ -364,8 +399,6 @@ files:
364
399
  - lib/new_relic/agent/instrumentation/rack/helpers.rb
365
400
  - lib/new_relic/agent/instrumentation/rack/instrumentation.rb
366
401
  - lib/new_relic/agent/instrumentation/rack/prepend.rb
367
- - lib/new_relic/agent/instrumentation/rails/action_controller.rb
368
- - lib/new_relic/agent/instrumentation/rails/action_web_service.rb
369
402
  - lib/new_relic/agent/instrumentation/rails3/action_controller.rb
370
403
  - lib/new_relic/agent/instrumentation/rails_middleware.rb
371
404
  - lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb
@@ -395,6 +428,10 @@ files:
395
428
  - lib/new_relic/agent/instrumentation/sinatra/prepend.rb
396
429
  - lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb
397
430
  - lib/new_relic/agent/instrumentation/sunspot.rb
431
+ - lib/new_relic/agent/instrumentation/tilt.rb
432
+ - lib/new_relic/agent/instrumentation/tilt/chain.rb
433
+ - lib/new_relic/agent/instrumentation/tilt/instrumentation.rb
434
+ - lib/new_relic/agent/instrumentation/tilt/prepend.rb
398
435
  - lib/new_relic/agent/instrumentation/typhoeus.rb
399
436
  - lib/new_relic/agent/instrumentation/typhoeus/chain.rb
400
437
  - lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb
@@ -444,7 +481,6 @@ files:
444
481
  - lib/new_relic/agent/stats_engine.rb
445
482
  - lib/new_relic/agent/stats_engine/gc_profiler.rb
446
483
  - lib/new_relic/agent/stats_engine/stats_hash.rb
447
- - lib/new_relic/agent/supported_versions.rb
448
484
  - lib/new_relic/agent/synthetics_event_aggregator.rb
449
485
  - lib/new_relic/agent/system_info.rb
450
486
  - lib/new_relic/agent/threading/agent_thread.rb
@@ -560,7 +596,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
560
596
  requirements:
561
597
  - - ">="
562
598
  - !ruby/object:Gem::Version
563
- version: 2.0.0
599
+ version: 2.2.0
564
600
  required_rubygems_version: !ruby/object:Gem::Requirement
565
601
  requirements:
566
602
  - - ">"
@@ -1,125 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
-
5
- require 'new_relic/agent/parameter_filtering'
6
-
7
- DependencyDetection.defer do
8
- @name = :rails21_view
9
-
10
- depends_on do
11
- !NewRelic::Agent.config[:disable_view_instrumentation] &&
12
- defined?(ActionController) && defined?(ActionController::Base) && defined?(ActionView::PartialTemplate) && defined?(ActionView::Template) &&
13
- defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.1\./ # Rails 2.1 &&
14
- end
15
-
16
- executes do
17
- ::NewRelic::Agent.logger.info 'Installing Rails 2.1 View instrumentation'
18
- end
19
-
20
- executes do
21
- ActionView::PartialTemplate.class_eval do
22
- include NewRelic::Agent::MethodTracer
23
- add_method_tracer :render, -> (*) { "View/#{path_without_extension[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Partial" }
24
- end
25
-
26
- # this is for template rendering, as opposed to partial rendering.
27
- ActionView::Template.class_eval do
28
- include NewRelic::Agent::MethodTracer
29
- add_method_tracer :render, -> (*) { "View/#{(path_without_extension || @view.controller.newrelic_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering" }
30
- end
31
- end
32
- end
33
-
34
- DependencyDetection.defer do
35
- @name = :old_rails_view
36
-
37
- depends_on do
38
- !NewRelic::Agent.config[:disable_view_instrumentation] &&
39
- defined?(ActionController) && defined?(ActionController::Base) &&
40
- defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
41
- end
42
-
43
- executes do
44
- ::NewRelic::Agent.logger.info 'Installing Rails 1.* - 2.0 View instrumentation'
45
- end
46
-
47
- executes do
48
- ActionController::Base.class_eval do
49
- include NewRelic::Agent::MethodTracer
50
- add_method_tracer :render, -> (*) { "View/#{newrelic_metric_path}/Rendering" }
51
- end
52
- end
53
- end
54
-
55
- DependencyDetection.defer do
56
- @name = :rails23_view
57
-
58
- depends_on do
59
- !NewRelic::Agent.config[:disable_view_instrumentation] &&
60
- defined?(ActionView) && defined?(ActionView::Template) && defined?(ActionView::RenderablePartial) &&
61
- defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
62
- end
63
-
64
- executes do
65
- ::NewRelic::Agent.logger.info 'Installing Rails 2.2 - 2.3 View instrumentation'
66
- end
67
-
68
- executes do
69
- ActionView::RenderablePartial.module_eval do
70
- include NewRelic::Agent::MethodTracer
71
- add_method_tracer :render_partial, -> (*) { "View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial" }
72
- end
73
-
74
- ActionView::Template.class_eval do
75
- include NewRelic::Agent::MethodTracer
76
- add_method_tracer :render, -> (*) { "View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering" }
77
- end
78
- end
79
- end
80
-
81
- DependencyDetection.defer do
82
- @name = :rails2_controller
83
-
84
- depends_on do
85
- defined?(ActionController) && defined?(ActionController::Base)
86
- end
87
-
88
- depends_on do
89
- defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR.to_i == 2
90
- end
91
-
92
- executes do
93
- ::NewRelic::Agent.logger.info 'Installing Rails 2 Controller instrumentation'
94
- end
95
-
96
- executes do
97
- ActionController::Base.class_eval do
98
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
99
-
100
- def perform_action_with_newrelic_trace_wrapper
101
- munged_params = (respond_to?(:filter_parameters)) ? filter_parameters(params) : params
102
- munged_params = NewRelic::Agent::ParameterFiltering.filter_rails_request_parameters(munged_params)
103
-
104
- perform_action_with_newrelic_trace(:params => munged_params) do
105
- perform_action_without_newrelic_trace
106
- end
107
- end
108
-
109
- alias_method :perform_action_without_newrelic_trace, :perform_action
110
- alias_method :perform_action, :perform_action_with_newrelic_trace_wrapper
111
- private :perform_action
112
-
113
- # determine the path that is used in the metric name for
114
- # the called controller action
115
- def newrelic_metric_path(action_name_override = nil)
116
- action_part = action_name_override || action_name
117
- if action_name_override || self.class.action_methods.include?(action_part)
118
- "#{self.class.controller_path}/#{action_part}"
119
- else
120
- "#{self.class.controller_path}/(other)"
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,46 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
-
5
- DependencyDetection.defer do
6
- @name = :rails_action_web_service
7
-
8
- depends_on do
9
- defined?(ActionWebService)
10
- end
11
-
12
- executes do
13
- ::NewRelic::Agent.logger.info 'Installing Rails ActionWebService instrumentation'
14
- end
15
-
16
- executes do
17
- # NewRelic Agent instrumentation for WebServices
18
-
19
- # Note Action Web Service is removed from default package in rails
20
- # 2.0, this is purely here as a service to our legacy customers.
21
-
22
- # instrumentation for Web Service martialing - XML RPC
23
- ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.class_eval do
24
- add_method_tracer :decode_request, "WebService/Xml Rpc/XML Decode"
25
- add_method_tracer :encode_request, "WebService/Xml Rpc/XML Encode"
26
- add_method_tracer :decode_response, "WebService/Xml Rpc/XML Decode"
27
- add_method_tracer :encode_response, "WebService/Xml Rpc/XML Encode"
28
- end
29
-
30
- # instrumentation for Web Service martialing - Soap
31
- ActionWebService::Protocol::Soap::SoapProtocol.class_eval do
32
- add_method_tracer :decode_request, "WebService/Soap/XML Decode"
33
- add_method_tracer :encode_request, "WebService/Soap/XML Encode"
34
- add_method_tracer :decode_response, "WebService/Soap/XML Decode"
35
- add_method_tracer :encode_response, "WebService/Soap/XML Encode"
36
- end
37
-
38
- if defined?(ActionController) && defined?(ActionController::Base)
39
- ActionController::Base.class_eval do
40
- if method_defined? :perform_invocation
41
- add_method_tracer :perform_invocation, -> (*args) { "WebService/#{controller_name}/#{args.first}" }
42
- end
43
- end
44
- end
45
- end
46
- end