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
@@ -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
@@ -3,23 +3,21 @@
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
  # frozen_string_literal: true
5
5
 
6
-
7
6
  module NewRelic
8
7
  module Agent
9
8
  module Instrumentation
10
9
  module DelayedJob
11
-
12
10
  def initialize_with_tracing
13
11
  yield
14
12
  worker_name = case
15
13
  when self.respond_to?(:name) then self.name
16
14
  when self.class.respond_to?(:default_name) then self.class.default_name
17
- end
15
+ end
18
16
  NewRelic::DelayedJobInjection.worker_name = worker_name
19
17
 
20
18
  # TODO: Refactor the last line of this condition so that it can be evaluated in both prepend and chain instrumentation
21
19
  if defined?(::Delayed::Job) && ::Delayed::Job.method_defined?(:invoke_job) &&
22
- !(::Delayed::Job.method_defined?(:invoke_job_without_new_relic))
20
+ !(::Delayed::Job.method_defined?(:invoke_job_without_new_relic))
23
21
 
24
22
  ::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation [part 2/2]'
25
23
  install_newrelic_job_tracer
@@ -45,9 +43,7 @@ module NewRelic
45
43
  yield
46
44
  end
47
45
  end
48
-
49
46
  end
50
47
  end
51
48
  end
52
49
  end
53
-
@@ -14,11 +14,11 @@ module NewRelic
14
14
  module Naming
15
15
  module_function
16
16
 
17
- CLASS_METHOD_DELIMITER = '.'.freeze
18
- INSTANCE_METHOD_DELIMITER = '#'.freeze
17
+ CLASS_METHOD_DELIMITER = '.'.freeze
18
+ INSTANCE_METHOD_DELIMITER = '#'.freeze
19
19
  LEGACY_DJ_FORMAT_DELIMITER = ';'.freeze
20
- LEGACY_DJ_FORMAT_PREFIX = 'LOAD'.freeze
21
- LEGACY_DJ_DEFAULT_CLASS = '(unknown class)'.freeze
20
+ LEGACY_DJ_FORMAT_PREFIX = 'LOAD'.freeze
21
+ LEGACY_DJ_DEFAULT_CLASS = '(unknown class)'.freeze
22
22
 
23
23
  def name_from_payload(payload_object)
24
24
  if payload_object.is_a? ::Delayed::PerformableMethod
@@ -11,7 +11,7 @@ module ::Excon
11
11
  @stack = stack
12
12
  end
13
13
 
14
- def request_call(datum) #THREAD_LOCAL_ACCESS
14
+ def request_call(datum) # THREAD_LOCAL_ACCESS
15
15
  begin
16
16
  # Only instrument this request if we haven't already done so, because
17
17
  # we can get request_call multiple times for requests marked as
@@ -45,7 +45,7 @@ module ::Excon
45
45
  @stack.error_call(datum)
46
46
  end
47
47
 
48
- def finish_trace(datum) #THREAD_LOCAL_ACCESS
48
+ def finish_trace(datum) # THREAD_LOCAL_ACCESS
49
49
  segment = datum[:connection] && datum[:connection].instance_variable_get(TRACE_DATA_IVAR)
50
50
  if segment
51
51
  begin
@@ -51,4 +51,3 @@ DependencyDetection.defer do
51
51
  end
52
52
  end
53
53
  end
54
-
@@ -14,7 +14,7 @@ module NewRelic::Agent::Instrumentation
14
14
  Grape::Instrumentation.capture_transaction env, self
15
15
  end
16
16
  end
17
-
17
+
18
18
  alias_method :call_without_new_relic, :call
19
19
  alias_method :call, :call_with_new_relic
20
20
  end
@@ -22,4 +22,3 @@ module NewRelic::Agent::Instrumentation
22
22
  end
23
23
  end
24
24
  end
25
-
@@ -7,7 +7,6 @@ require 'new_relic/agent/parameter_filtering'
7
7
  module NewRelic::Agent::Instrumentation
8
8
  module Grape
9
9
  module Instrumentation
10
-
11
10
  extend self
12
11
 
13
12
  # Since 1.2.0, the class `Grape::API` no longer refers to an API instance, rather, what used to be `Grape::API` is `Grape::API::Instance`
@@ -37,12 +36,12 @@ module NewRelic::Agent::Instrumentation
37
36
  end
38
37
  end
39
38
 
40
- API_ENDPOINT = 'api.endpoint'.freeze
41
- API_VERSION = 'api.version'.freeze
42
- FORMAT_REGEX = /\(\/?\.[\:\w]*\)/.freeze # either :format (< 0.12.0) or .ext (>= 0.12.0)
43
- VERSION_REGEX = /:version(\/|$)/.freeze
44
- MIN_VERSION = Gem::Version.new("0.2.0")
45
- PIPE_STRING = '|'.freeze
39
+ API_ENDPOINT = 'api.endpoint'.freeze
40
+ API_VERSION = 'api.version'.freeze
41
+ FORMAT_REGEX = /\(\/?\.[\:\w]*\)/.freeze # either :format (< 0.12.0) or .ext (>= 0.12.0)
42
+ VERSION_REGEX = /:version(\/|$)/.freeze
43
+ MIN_VERSION = Gem::Version.new("0.2.0")
44
+ PIPE_STRING = '|'.freeze
46
45
 
47
46
  def handle_transaction(endpoint, class_name, version)
48
47
  return unless endpoint && route = endpoint.route
@@ -11,7 +11,7 @@ DependencyDetection.defer do
11
11
  # not shipping yet, overloading the name interferes with the plugin.
12
12
  named :grape_instrumentation
13
13
  configure_with :grape
14
-
14
+
15
15
  depends_on do
16
16
  defined?(::Grape::VERSION) &&
17
17
  Gem::Version.new(::Grape::VERSION) >= ::NewRelic::Agent::Instrumentation::Grape::Instrumentation::MIN_VERSION
@@ -37,9 +37,8 @@ DependencyDetection.defer do
37
37
  if use_prepend?
38
38
  instrumented_class = ::NewRelic::Agent::Instrumentation::Grape::Instrumentation.instrumented_class
39
39
  prepend_instrument instrumented_class, ::NewRelic::Agent::Instrumentation::Grape::Prepend
40
- else
40
+ else
41
41
  chain_instrument ::NewRelic::Agent::Instrumentation::Grape::Chain
42
42
  end
43
43
  end
44
-
45
44
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module HTTPClient
7
- module Chain
7
+ module Chain
8
8
  def self.instrument!
9
9
  ::HTTPClient.class_eval do
10
10
  include NewRelic::Agent::Instrumentation::HTTPClient::Instrumentation
@@ -14,7 +14,7 @@ module NewRelic::Agent::Instrumentation
14
14
  do_get_block_without_newrelic(req, proxy, conn, &block)
15
15
  end
16
16
  end
17
-
17
+
18
18
  alias :do_get_block_without_newrelic :do_get_block
19
19
  alias :do_get_block :do_get_block_with_newrelic
20
20
  end
@@ -22,4 +22,3 @@ module NewRelic::Agent::Instrumentation
22
22
  end
23
23
  end
24
24
  end
25
-
@@ -35,4 +35,3 @@ module NewRelic::Agent::Instrumentation
35
35
  end
36
36
  end
37
37
  end
38
-
@@ -2,7 +2,6 @@
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 HTTPClient
8
7
  module Prepend
@@ -14,4 +13,3 @@ module NewRelic::Agent::Instrumentation
14
13
  end
15
14
  end
16
15
  end
17
-
@@ -12,11 +12,11 @@ module NewRelic::Agent::Instrumentation
12
12
  def perform_with_newrelic_trace(request, options)
13
13
  with_tracing(request) { perform_without_newrelic_trace(request, options) }
14
14
  end
15
-
15
+
16
16
  alias perform_without_newrelic_trace perform
17
17
  alias perform perform_with_newrelic_trace
18
18
  end
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -6,25 +6,25 @@ module NewRelic::Agent::Instrumentation
6
6
  module HTTPrb
7
7
  def with_tracing(request)
8
8
  wrapped_request = ::NewRelic::Agent::HTTPClients::HTTPRequest.new(request)
9
-
9
+
10
10
  begin
11
11
  segment = NewRelic::Agent::Tracer.start_external_request_segment(
12
12
  library: wrapped_request.type,
13
13
  uri: wrapped_request.uri,
14
14
  procedure: wrapped_request.method
15
15
  )
16
-
16
+
17
17
  segment.add_request_headers wrapped_request
18
-
18
+
19
19
  response = NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
20
-
20
+
21
21
  wrapped_response = ::NewRelic::Agent::HTTPClients::HTTPResponse.new response
22
22
  segment.process_response_headers wrapped_response
23
-
23
+
24
24
  response
25
25
  ensure
26
26
  segment.finish if segment
27
27
  end
28
28
  end
29
29
  end
30
- end
30
+ end