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
@@ -22,7 +22,6 @@ module NewRelic
22
22
  # @api public
23
23
  #
24
24
  module ControllerInstrumentation
25
-
26
25
  def self.included(clazz) # :nodoc:
27
26
  clazz.extend(ClassMethods)
28
27
  end
@@ -30,7 +29,9 @@ module NewRelic
30
29
  # This module is for importing stubs when the agent is disabled
31
30
  module ClassMethodsShim # :nodoc:
32
31
  def newrelic_ignore(*args); end
32
+
33
33
  def newrelic_ignore_apdex(*args); end
34
+
34
35
  def newrelic_ignore_enduser(*args); end
35
36
  end
36
37
 
@@ -38,14 +39,16 @@ module NewRelic
38
39
  def self.included(clazz)
39
40
  clazz.extend(ClassMethodsShim)
40
41
  end
42
+
41
43
  def new_relic_trace_controller_action(*args); yield; end
44
+
42
45
  def perform_action_with_newrelic_trace(*args); yield; end
43
46
  end
44
47
 
45
- NR_DO_NOT_TRACE_KEY = :'@do_not_trace'
46
- NR_IGNORE_APDEX_KEY = :'@ignore_apdex'
48
+ NR_DO_NOT_TRACE_KEY = :'@do_not_trace'
49
+ NR_IGNORE_APDEX_KEY = :'@ignore_apdex'
47
50
  NR_IGNORE_ENDUSER_KEY = :'@ignore_enduser'
48
- NR_DEFAULT_OPTIONS = {}.freeze
51
+ NR_DEFAULT_OPTIONS = {}.freeze
49
52
 
50
53
  # @api public
51
54
  module ClassMethods
@@ -54,31 +57,32 @@ module NewRelic
54
57
  #
55
58
  # @api public
56
59
  #
57
- def newrelic_ignore(specifiers={})
60
+ def newrelic_ignore(specifiers = {})
58
61
  NewRelic::Agent.record_api_supportability_metric(:newrelic_ignore)
59
62
  newrelic_ignore_aspect(NR_DO_NOT_TRACE_KEY, specifiers)
60
63
  end
64
+
61
65
  # Have NewRelic omit apdex measurements on the given actions. Typically used for
62
66
  # actions that are not user facing or that skew your overall apdex measurement.
63
67
  # Accepts :except and :only options, as with #newrelic_ignore.
64
68
  #
65
69
  # @api public
66
70
  #
67
- def newrelic_ignore_apdex(specifiers={})
71
+ def newrelic_ignore_apdex(specifiers = {})
68
72
  NewRelic::Agent.record_api_supportability_metric(:newrelic_ignore_apdex)
69
73
  newrelic_ignore_aspect(NR_IGNORE_APDEX_KEY, specifiers)
70
74
  end
71
75
 
72
76
  # @api public
73
- def newrelic_ignore_enduser(specifiers={})
77
+ def newrelic_ignore_enduser(specifiers = {})
74
78
  NewRelic::Agent.record_api_supportability_metric(:newrelic_ignore_enduser)
75
79
  newrelic_ignore_aspect(NR_IGNORE_ENDUSER_KEY, specifiers)
76
80
  end
77
81
 
78
- def newrelic_ignore_aspect(property, specifiers={}) # :nodoc:
82
+ def newrelic_ignore_aspect(property, specifiers = {}) # :nodoc:
79
83
  if specifiers.empty?
80
84
  self.newrelic_write_attr property, true
81
- elsif ! (Hash === specifiers)
85
+ elsif !(Hash === specifiers)
82
86
  ::NewRelic::Agent.logger.error "newrelic_#{property} takes an optional hash with :only and :except lists of actions (illegal argument type '#{specifiers.class}')"
83
87
  else
84
88
  # symbolize the incoming values
@@ -158,7 +162,7 @@ module NewRelic
158
162
  #
159
163
  # @api public
160
164
  #
161
- def add_transaction_tracer(method, options={})
165
+ def add_transaction_tracer(method, options = {})
162
166
  NewRelic::Agent.record_api_supportability_metric(:add_transaction_tracer)
163
167
 
164
168
  # The metric path:
@@ -202,54 +206,50 @@ module NewRelic
202
206
  elsif key == :params
203
207
  value.to_s
204
208
  else
205
- %Q["#{value.to_s}"]
209
+ %Q("#{value.to_s}")
206
210
  end
207
211
 
208
- %Q[:#{key} => #{value}]
212
+ %Q(:#{key} => #{value})
209
213
  end
210
214
  end
211
215
 
212
216
  def build_method_names(traced_method, punctuation)
213
- [ "#{traced_method.to_s}_with_newrelic_transaction_trace#{punctuation}",
214
- "#{traced_method.to_s}_without_newrelic_transaction_trace#{punctuation}" ]
217
+ ["#{traced_method.to_s}_with_newrelic_transaction_trace#{punctuation}",
218
+ "#{traced_method.to_s}_without_newrelic_transaction_trace#{punctuation}"]
215
219
  end
216
220
 
217
221
  def already_added_transaction_tracer?(target, with_method_name)
218
- if NewRelic::Helper.instance_methods_include?(target, with_method_name)
219
- true
220
- else
221
- false
222
- end
222
+ NewRelic::Helper.instance_methods_include?(target, with_method_name)
223
223
  end
224
224
  end
225
225
 
226
226
  # @!parse extend ClassMethods
227
227
 
228
228
  class TransactionNamer
229
- def self.name_for(txn, traced_obj, category, options={})
229
+ def self.name_for(txn, traced_obj, category, options = {})
230
230
  "#{prefix_for_category(txn, category)}#{path_name(traced_obj, options)}"
231
231
  end
232
232
 
233
233
  def self.prefix_for_category(txn, category = nil)
234
234
  category ||= (txn && txn.category)
235
235
  case category
236
- when :controller then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
237
- when :web then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
238
- when :task then ::NewRelic::Agent::Transaction::TASK_PREFIX
239
- when :background then ::NewRelic::Agent::Transaction::TASK_PREFIX
240
- when :rack then ::NewRelic::Agent::Transaction::RACK_PREFIX
241
- when :uri then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
242
- when :sinatra then ::NewRelic::Agent::Transaction::SINATRA_PREFIX
243
- when :middleware then ::NewRelic::Agent::Transaction::MIDDLEWARE_PREFIX
244
- when :grape then ::NewRelic::Agent::Transaction::GRAPE_PREFIX
245
- when :rake then ::NewRelic::Agent::Transaction::RAKE_PREFIX
246
- when :action_cable then ::NewRelic::Agent::Transaction::ACTION_CABLE_PREFIX
247
- when :message then ::NewRelic::Agent::Transaction::MESSAGE_PREFIX
236
+ when :controller then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
237
+ when :web then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
238
+ when :task then ::NewRelic::Agent::Transaction::TASK_PREFIX
239
+ when :background then ::NewRelic::Agent::Transaction::TASK_PREFIX
240
+ when :rack then ::NewRelic::Agent::Transaction::RACK_PREFIX
241
+ when :uri then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
242
+ when :sinatra then ::NewRelic::Agent::Transaction::SINATRA_PREFIX
243
+ when :middleware then ::NewRelic::Agent::Transaction::MIDDLEWARE_PREFIX
244
+ when :grape then ::NewRelic::Agent::Transaction::GRAPE_PREFIX
245
+ when :rake then ::NewRelic::Agent::Transaction::RAKE_PREFIX
246
+ when :action_cable then ::NewRelic::Agent::Transaction::ACTION_CABLE_PREFIX
247
+ when :message then ::NewRelic::Agent::Transaction::MESSAGE_PREFIX
248
248
  else "#{category.to_s}/" # for internal use only
249
249
  end
250
250
  end
251
251
 
252
- def self.path_name(traced_obj, options={})
252
+ def self.path_name(traced_obj, options = {})
253
253
  return options[:path] if options[:path]
254
254
 
255
255
  class_name = class_name(traced_obj, options)
@@ -266,9 +266,9 @@ module NewRelic
266
266
  end
267
267
  end
268
268
 
269
- def self.class_name(traced_obj, options={})
269
+ def self.class_name(traced_obj, options = {})
270
270
  return options[:class_name] if options[:class_name]
271
- if (traced_obj.is_a?(Class) || traced_obj.is_a?(Module))
271
+ if traced_obj.is_a?(Class) || traced_obj.is_a?(Module)
272
272
  traced_obj.name
273
273
  else
274
274
  traced_obj.class.name
@@ -345,7 +345,7 @@ module NewRelic
345
345
  #
346
346
  # @api public
347
347
  #
348
- def perform_action_with_newrelic_trace(*args, &block) #THREAD_LOCAL_ACCESS
348
+ def perform_action_with_newrelic_trace(*args, &block) # THREAD_LOCAL_ACCESS
349
349
  NewRelic::Agent.record_api_supportability_metric(:perform_action_with_newrelic_trace)
350
350
  state = NewRelic::Agent::Tracer.state
351
351
  request = newrelic_request(args)
@@ -363,8 +363,8 @@ module NewRelic
363
363
  # the *args method signature to ensure backwards compatibility.
364
364
 
365
365
  trace_options = args.last.is_a?(Hash) ? args.last : NR_DEFAULT_OPTIONS
366
- category = trace_options[:category] || :controller
367
- txn_options = create_transaction_options(trace_options, category, state, queue_start_time)
366
+ category = trace_options[:category] || :controller
367
+ txn_options = create_transaction_options(trace_options, category, state, queue_start_time)
368
368
 
369
369
  begin
370
370
  finishable = Tracer.start_transaction_or_segment(
@@ -379,7 +379,6 @@ module NewRelic
379
379
  NewRelic::Agent.notice_error(e)
380
380
  raise
381
381
  end
382
-
383
382
  ensure
384
383
  finishable.finish if finishable
385
384
  end
@@ -434,7 +433,7 @@ module NewRelic
434
433
 
435
434
  def create_transaction_options(trace_options, category, state, queue_start_time)
436
435
  txn_options = {}
437
- txn_options[:request] = trace_options[:request]
436
+ txn_options[:request] = trace_options[:request]
438
437
  txn_options[:request] ||= request if respond_to?(:request) rescue nil
439
438
  # params should have been filtered before calling perform_action_with_newrelic_trace
440
439
  txn_options[:filtered_params] = trace_options[:params]
@@ -457,7 +456,8 @@ module NewRelic
457
456
  NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
458
457
  key,
459
458
  self.class,
460
- name)
459
+ name
460
+ )
461
461
  end
462
462
 
463
463
  def detect_queue_start_time(request)
@@ -15,77 +15,76 @@ module NewRelic::Agent::Instrumentation
15
15
  def http_head_with_newrelic(*args, &blk)
16
16
  http_head_with_tracing { http_head_without_newrelic(*args, &blk) }
17
17
  end
18
-
18
+
19
19
  alias_method :http_head_without_newrelic, :http_head
20
20
  alias_method :http_head, :http_head_with_newrelic
21
-
21
+
22
22
  def http_post_with_newrelic(*args, &blk)
23
23
  http_post_with_tracing { http_post_without_newrelic(*args, &blk) }
24
24
  end
25
-
25
+
26
26
  alias_method :http_post_without_newrelic, :http_post
27
27
  alias_method :http_post, :http_post_with_newrelic
28
-
28
+
29
29
  def http_put_with_newrelic(*args, &blk)
30
30
  http_put_with_tracing { http_put_without_newrelic(*args, &blk) }
31
31
  end
32
-
32
+
33
33
  alias_method :http_put_without_newrelic, :http_put
34
34
  alias_method :http_put, :http_put_with_newrelic
35
-
35
+
36
36
  # Hook the #http method to set the verb.
37
37
  def http_with_newrelic verb
38
- http_with_tracing(verb) { http_without_newrelic( verb ) }
38
+ http_with_tracing(verb) { http_without_newrelic(verb) }
39
39
  end
40
-
40
+
41
41
  alias_method :http_without_newrelic, :http
42
42
  alias_method :http, :http_with_newrelic
43
-
43
+
44
44
  # Hook the #perform method to mark the request as non-parallel.
45
45
  def perform_with_newrelic
46
46
  perform_with_tracing { perform_without_newrelic }
47
47
  end
48
-
48
+
49
49
  alias_method :perform_without_newrelic, :perform
50
50
  alias_method :perform, :perform_with_newrelic
51
-
51
+
52
52
  # Record the HTTP verb for future #perform calls
53
53
  def method_with_newrelic verb
54
54
  method_with_tracing { method_without_newrelic(verb) }
55
55
  end
56
-
56
+
57
57
  alias_method :method_without_newrelic, :method
58
58
  alias_method :method, :method_with_newrelic
59
-
59
+
60
60
  # We override this method in order to ensure access to header_str even
61
61
  # though we use an on_header callback
62
62
  def header_str_with_newrelic
63
63
  header_str_with_tracing { header_str_without_newrelic }
64
64
  end
65
-
65
+
66
66
  alias_method :header_str_without_newrelic, :header_str
67
67
  alias_method :header_str, :header_str_with_newrelic
68
68
  end
69
69
 
70
- Curl::Multi.class_eval do
70
+ Curl::Multi.class_eval do
71
71
  include NewRelic::Agent::Instrumentation::Curb::Multi
72
-
72
+
73
73
  # Add CAT with callbacks if the request is serial
74
74
  def add_with_newrelic(curl)
75
75
  add_with_tracing(curl) { add_without_newrelic curl }
76
76
  end
77
-
77
+
78
78
  alias_method :add_without_newrelic, :add
79
79
  alias_method :add, :add_with_newrelic
80
-
80
+
81
81
  # Trace as an External/Multiple call if the first request isn't serial.
82
82
  def perform_with_newrelic(&blk)
83
83
  perform_with_tracing { perform_without_newrelic(&blk) }
84
84
  end
85
-
85
+
86
86
  alias_method :perform_without_newrelic, :perform
87
87
  alias_method :perform, :perform_with_newrelic
88
-
89
88
  end
90
89
  end
91
90
  end
@@ -9,51 +9,50 @@ module NewRelic
9
9
  module Curb
10
10
  module Easy
11
11
  attr_accessor :_nr_instrumented,
12
- :_nr_failure_instrumented,
13
- :_nr_http_verb,
14
- :_nr_header_str,
15
- :_nr_original_on_header,
16
- :_nr_original_on_complete,
17
- :_nr_original_on_failure,
18
- :_nr_serial
19
-
12
+ :_nr_failure_instrumented,
13
+ :_nr_http_verb,
14
+ :_nr_header_str,
15
+ :_nr_original_on_header,
16
+ :_nr_original_on_complete,
17
+ :_nr_original_on_failure,
18
+ :_nr_serial
19
+
20
20
  # We have to hook these three methods separately, as they don't use
21
21
  # Curl::Easy#http
22
22
  def http_head_with_tracing
23
23
  self._nr_http_verb = :HEAD
24
24
  yield
25
25
  end
26
-
26
+
27
27
  def http_post_with_tracing
28
28
  self._nr_http_verb = :POST
29
29
  yield
30
30
  end
31
-
32
-
31
+
33
32
  def http_put_with_tracing
34
33
  self._nr_http_verb = :PUT
35
34
  yield
36
35
  end
37
-
36
+
38
37
  # Hook the #http method to set the verb.
39
38
  def http_with_tracing verb
40
39
  self._nr_http_verb = verb.to_s.upcase
41
40
  yield
42
41
  end
43
-
42
+
44
43
  # Hook the #perform method to mark the request as non-parallel.
45
44
  def perform_with_tracing
46
45
  self._nr_http_verb ||= :GET
47
46
  self._nr_serial = true
48
47
  yield
49
48
  end
50
-
49
+
51
50
  # Record the HTTP verb for future #perform calls
52
51
  def method_with_tracing verb
53
52
  self._nr_http_verb = verb.upcase
54
53
  yield
55
54
  end
56
-
55
+
57
56
  # We override this method in order to ensure access to header_str even
58
57
  # though we use an on_header callback
59
58
  def header_str_with_tracing
@@ -65,9 +64,8 @@ module NewRelic
65
64
  yield
66
65
  end
67
66
  end
68
-
69
67
  end
70
- ####################################################
68
+ ####################################################
71
69
 
72
70
  module Multi
73
71
  include NewRelic::Agent::MethodTracer
@@ -77,14 +75,14 @@ module NewRelic
77
75
  if curl.respond_to?(:_nr_serial) && curl._nr_serial
78
76
  hook_pending_request(curl) if NewRelic::Agent::Tracer.tracing_enabled?
79
77
  end
80
-
78
+
81
79
  return yield
82
80
  end
83
81
 
84
82
  # Trace as an External/Multiple call if the first request isn't serial.
85
83
  def perform_with_tracing
86
84
  return yield if first_request_is_serial?
87
-
85
+
88
86
  trace_execution_scoped("External/Multiple/Curb::Multi/perform") do
89
87
  yield
90
88
  end
@@ -94,15 +92,15 @@ module NewRelic
94
92
  # and set up cross-application tracing if it's enabled.
95
93
  def hook_pending_request(request)
96
94
  wrapped_request, wrapped_response = wrap_request(request)
97
-
95
+
98
96
  segment = NewRelic::Agent::Tracer.start_external_request_segment(
99
97
  library: wrapped_request.type,
100
98
  uri: wrapped_request.uri,
101
99
  procedure: wrapped_request.method
102
100
  )
103
-
101
+
104
102
  segment.add_request_headers wrapped_request
105
-
103
+
106
104
  # install all callbacks
107
105
  unless request._nr_instrumented
108
106
  install_header_callback(request, wrapped_response)
@@ -113,8 +111,7 @@ module NewRelic
113
111
  rescue => err
114
112
  NewRelic::Agent.logger.error("Untrapped exception", err)
115
113
  end
116
-
117
-
114
+
118
115
  # Create request and response adapter objects for the specified +request+
119
116
  # NOTE: Although strange to wrap request and response at once, it works
120
117
  # because curb's callback mechanism updates the instantiated wrappers
@@ -123,7 +120,7 @@ module NewRelic
123
120
  return NewRelic::Agent::HTTPClients::CurbRequest.new(request),
124
121
  NewRelic::Agent::HTTPClients::CurbResponse.new(request)
125
122
  end
126
-
123
+
127
124
  # Install a callback that will record the response headers
128
125
  # to enable CAT linking
129
126
  def install_header_callback(request, wrapped_response)
@@ -139,7 +136,7 @@ module NewRelic
139
136
  end
140
137
  end
141
138
  end
142
-
139
+
143
140
  # Install a callback that will finish the trace.
144
141
  def install_completion_callback(request, wrapped_response, segment)
145
142
  original_callback = request.on_complete
@@ -156,7 +153,7 @@ module NewRelic
156
153
  end
157
154
  end
158
155
  end
159
-
156
+
160
157
  # Install a callback that will fire on failures
161
158
  # NOTE: on_failure is not always called, so we're not always
162
159
  # unhooking the callback. No harm/no foul in production, but
@@ -177,10 +174,10 @@ module NewRelic
177
174
  original_callback.call(failed_request, error) if original_callback
178
175
  remove_failure_callback(failed_request)
179
176
  end
180
- request._nr_failure_instrumented = true
177
+ request._nr_failure_instrumented = true
181
178
  end
182
179
  end
183
-
180
+
184
181
  # on_failure callbacks cannot be removed in the on_complete
185
182
  # callback where this method is invoked because on_complete
186
183
  # fires before the on_failure!
@@ -189,20 +186,20 @@ module NewRelic
189
186
  request.on_header(&request._nr_original_on_header)
190
187
  request._nr_instrumented = false
191
188
  end
192
-
193
- # We execute customer's on_failure callback (if any) and
194
- # uninstall our hook here since the on_complete callback
189
+
190
+ # We execute customer's on_failure callback (if any) and
191
+ # uninstall our hook here since the on_complete callback
195
192
  # fires before the on_failure callback.
196
193
  def remove_failure_callback(request)
197
194
  request.on_failure(&request._nr_original_on_failure)
198
195
  request._nr_failure_instrumented = false
199
196
  end
200
-
197
+
201
198
  private
202
-
199
+
203
200
  def first_request_is_serial?
204
201
  return false unless (first = self.requests.first)
205
-
202
+
206
203
  # Before curb 0.9.8, requests was an array of Curl::Easy
207
204
  # instances. Starting with 0.9.8, it's a Hash where the
208
205
  # values are Curl::Easy instances.
@@ -211,12 +208,11 @@ module NewRelic
211
208
  # We need to handle either case.
212
209
  #
213
210
  first = first[-1] if first.is_a?(Array)
214
-
211
+
215
212
  first.respond_to?(:_nr_serial) && first._nr_serial
216
213
  end
217
-
218
214
  end
219
215
  end
220
216
  end
221
217
  end
222
- end
218
+ end
@@ -5,8 +5,8 @@
5
5
 
6
6
  require_relative 'instrumentation'
7
7
 
8
- module NewRelic
9
- module Agent
8
+ module NewRelic
9
+ module Agent
10
10
  module Instrumentation
11
11
  module Curb
12
12
  module Easy
@@ -16,27 +16,27 @@ module NewRelic
16
16
  def http_head(*args, &blk)
17
17
  http_head_with_tracing { super }
18
18
  end
19
-
19
+
20
20
  def http_post(*args, &blk)
21
21
  http_post_with_tracing { super }
22
22
  end
23
-
23
+
24
24
  def http_put(*args, &blk)
25
25
  http_put_with_tracing { super }
26
26
  end
27
-
27
+
28
28
  def http verb
29
29
  http_with_tracing(verb) { super }
30
30
  end
31
-
31
+
32
32
  def perform
33
33
  perform_with_tracing { super }
34
34
  end
35
-
35
+
36
36
  def method verb
37
37
  method_with_tracing { super }
38
38
  end
39
-
39
+
40
40
  def header_str
41
41
  header_str_with_tracing { super }
42
42
  end
@@ -46,7 +46,7 @@ module NewRelic
46
46
  module Multi
47
47
  module Prepend
48
48
  include NewRelic::Agent::Instrumentation::Curb::Multi
49
-
49
+
50
50
  def add(curl)
51
51
  add_with_tracing(curl) { super }
52
52
  end
@@ -54,7 +54,6 @@ module NewRelic
54
54
  def perform(&blk)
55
55
  perform_with_tracing { super }
56
56
  end
57
-
58
57
  end
59
58
  end
60
59
  end
@@ -100,7 +100,7 @@ module NewRelic
100
100
  clazz.class_eval do
101
101
  if method_defined?(method_name) || private_method_defined?(method_name)
102
102
  define_method("#{method_name}_with_newrelic",
103
- NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
103
+ NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
104
104
 
105
105
  alias_method "#{method_name}_without_newrelic", method_name
106
106
  alias_method method_name, "#{method_name}_with_newrelic"
@@ -114,7 +114,7 @@ module NewRelic
114
114
  PASSWORD_PARAM = '&password='.freeze
115
115
 
116
116
  def self.method_body(clazz, method_name, operation_only)
117
- use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
117
+ use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
118
118
  metric_operation = method_name.to_s.gsub(/[!?]/, "")
119
119
 
120
120
  Proc.new do |*args, &blk|
@@ -152,15 +152,15 @@ module NewRelic
152
152
  case strategy
153
153
  when :obfuscated
154
154
  adapter_name = if self.respond_to?(:options)
155
- self.options[:adapter]
155
+ self.options[:adapter]
156
+ else
157
+ if self.repository.adapter.respond_to?(:options)
158
+ self.repository.adapter.options[:adapter]
156
159
  else
157
- if self.repository.adapter.respond_to?(:options)
158
- self.repository.adapter.options[:adapter]
159
- else
160
- # DataMapper < 0.10.0
161
- self.repository.adapter.uri.scheme
162
- end
160
+ # DataMapper < 0.10.0
161
+ self.repository.adapter.uri.scheme
163
162
  end
163
+ end
164
164
  statement = NewRelic::Agent::Database::Statement.new(e.query, :adapter => adapter_name)
165
165
  obfuscated_sql = NewRelic::Agent::Database.obfuscate_sql(statement)
166
166
  e.instance_variable_set(:@query, obfuscated_sql)
@@ -186,7 +186,7 @@ module NewRelic
186
186
  # We rely on the assumption that all possible entry points have been
187
187
  # hooked with tracers, ensuring that notice_sql attaches this SQL to
188
188
  # the proper call scope.
189
- def log(msg) #THREAD_LOCAL_ACCESS
189
+ def log(msg) # THREAD_LOCAL_ACCESS
190
190
  state = NewRelic::Agent::Tracer.state
191
191
  return unless state.is_execution_traced?
192
192
 
@@ -14,25 +14,23 @@ module NewRelic::Agent::Instrumentation
14
14
  def initialize_with_new_relic(*args)
15
15
  initialize_with_tracing { initialize_without_new_relic(*args) }
16
16
  end
17
-
17
+
18
18
  alias initialize_without_new_relic initialize
19
19
  alias initialize initialize_with_new_relic
20
-
21
-
20
+
22
21
  def install_newrelic_job_tracer
23
22
  Delayed::Job.class_eval do
24
23
  include NewRelic::Agent::Instrumentation::DelayedJobTracer
25
-
24
+
26
25
  alias_method :invoke_job_without_new_relic, :invoke_job
27
-
26
+
28
27
  def invoke_job(*args, &block)
29
28
  invoke_job_with_tracing { invoke_job_without_new_relic(*args, &block) }
30
29
  end
31
-
32
30
  end
33
31
  end
34
32
  end
35
33
  end
36
34
  end
37
35
  end
38
- end
36
+ end