newrelic_rpm 3.8.1.221 → 3.9.0.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +1 -0
  3. data/.yardopts +2 -0
  4. data/CHANGELOG +95 -0
  5. data/README.md +9 -3
  6. data/Rakefile +6 -0
  7. data/lib/new_relic/agent.rb +37 -52
  8. data/lib/new_relic/agent/agent.rb +32 -64
  9. data/lib/new_relic/agent/agent_logger.rb +3 -2
  10. data/lib/new_relic/agent/audit_logger.rb +2 -1
  11. data/lib/new_relic/agent/busy_calculator.rb +10 -8
  12. data/lib/new_relic/agent/configuration.rb +0 -13
  13. data/lib/new_relic/agent/configuration/default_source.rb +27 -20
  14. data/lib/new_relic/agent/configuration/manager.rb +101 -27
  15. data/lib/new_relic/agent/cross_app_monitor.rb +43 -50
  16. data/lib/new_relic/agent/cross_app_tracing.rb +13 -12
  17. data/lib/new_relic/agent/error_collector.rb +31 -35
  18. data/lib/new_relic/agent/harvester.rb +5 -1
  19. data/lib/new_relic/agent/hostname.rb +17 -0
  20. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
  21. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
  22. data/lib/new_relic/agent/http_clients/uri_util.rb +13 -0
  23. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +18 -32
  24. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +15 -15
  25. data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
  26. data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
  27. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -2
  28. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +18 -20
  29. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +79 -93
  30. data/lib/new_relic/agent/instrumentation/curb.rb +3 -3
  31. data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -4
  32. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +96 -0
  33. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +69 -0
  34. data/lib/new_relic/agent/instrumentation/net.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/queue_time.rb +21 -13
  36. data/lib/new_relic/agent/instrumentation/rack.rb +85 -74
  37. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -1
  38. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +39 -0
  39. data/lib/new_relic/agent/instrumentation/rubyprof.rb +3 -3
  40. data/lib/new_relic/agent/instrumentation/sidekiq.rb +28 -5
  41. data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -4
  42. data/lib/new_relic/agent/instrumentation/typhoeus.rb +4 -2
  43. data/lib/new_relic/agent/javascript_instrumentor.rb +34 -30
  44. data/lib/new_relic/agent/memory_logger.rb +12 -12
  45. data/lib/new_relic/agent/method_tracer.rb +34 -74
  46. data/lib/new_relic/agent/new_relic_service.rb +1 -1
  47. data/lib/new_relic/agent/pipe_channel_manager.rb +3 -3
  48. data/lib/new_relic/agent/request_sampler.rb +10 -11
  49. data/lib/new_relic/agent/samplers/vm_sampler.rb +6 -6
  50. data/lib/new_relic/agent/shim_agent.rb +2 -1
  51. data/lib/new_relic/agent/sql_sampler.rb +52 -27
  52. data/lib/new_relic/agent/stats.rb +24 -10
  53. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +5 -17
  54. data/lib/new_relic/agent/stats_engine/metric_stats.rb +106 -58
  55. data/lib/new_relic/agent/stats_engine/stats_hash.rb +20 -24
  56. data/lib/new_relic/agent/supported_versions.rb +3 -1
  57. data/lib/new_relic/agent/threading/agent_thread.rb +42 -11
  58. data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
  59. data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
  60. data/lib/new_relic/agent/traced_method_stack.rb +28 -18
  61. data/lib/new_relic/agent/transaction.rb +249 -196
  62. data/lib/new_relic/agent/transaction_metrics.rb +57 -0
  63. data/lib/new_relic/agent/transaction_sample_builder.rb +10 -7
  64. data/lib/new_relic/agent/transaction_sampler.rb +81 -45
  65. data/lib/new_relic/agent/transaction_state.rb +38 -49
  66. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +15 -18
  67. data/lib/new_relic/agent/vm/rubinius_vm.rb +4 -2
  68. data/lib/new_relic/cli/commands/deployments.rb +3 -2
  69. data/lib/new_relic/control/frameworks/ruby.rb +2 -3
  70. data/lib/new_relic/control/frameworks/sinatra.rb +0 -7
  71. data/lib/new_relic/control/instance_methods.rb +3 -5
  72. data/lib/new_relic/json_wrapper.rb +2 -0
  73. data/lib/new_relic/language_support.rb +1 -1
  74. data/lib/new_relic/local_environment.rb +0 -16
  75. data/lib/new_relic/metric_spec.rb +10 -38
  76. data/lib/new_relic/noticed_error.rb +16 -11
  77. data/lib/new_relic/rack/agent_hooks.rb +4 -10
  78. data/lib/new_relic/rack/agent_middleware.rb +31 -0
  79. data/lib/new_relic/rack/browser_monitoring.rb +7 -13
  80. data/lib/new_relic/rack/developer_mode.rb +16 -59
  81. data/lib/new_relic/rack/error_collector.rb +16 -54
  82. data/lib/new_relic/recipes.rb +8 -101
  83. data/lib/new_relic/recipes/capistrano3.rb +66 -0
  84. data/lib/new_relic/recipes/capistrano_legacy.rb +98 -0
  85. data/lib/new_relic/transaction_sample.rb +6 -54
  86. data/lib/new_relic/transaction_sample/composite_segment.rb +1 -1
  87. data/lib/new_relic/transaction_sample/segment.rb +12 -4
  88. data/lib/new_relic/transaction_sample/summary_segment.rb +1 -1
  89. data/lib/new_relic/version.rb +2 -2
  90. data/lib/newrelic_rpm.rb +1 -1
  91. data/lib/sequel/extensions/newrelic_instrumentation.rb +19 -19
  92. data/lib/tasks/tests.rake +20 -1
  93. data/lib/tasks/versions.html.erb +0 -4
  94. data/lib/tasks/versions.rake +4 -3
  95. data/newrelic.yml +4 -12
  96. data/newrelic_rpm.gemspec +1 -1
  97. data/test/agent_helper.rb +146 -44
  98. data/test/config/newrelic.yml +0 -1
  99. data/test/environments/norails/Gemfile +1 -1
  100. data/test/environments/rails21/Gemfile +1 -1
  101. data/test/environments/rails22/Gemfile +1 -1
  102. data/test/environments/rails23/Gemfile +1 -1
  103. data/test/environments/rails30/Gemfile +1 -1
  104. data/test/environments/rails31/Gemfile +1 -1
  105. data/test/environments/rails32/Gemfile +1 -1
  106. data/test/environments/rails40/Gemfile +1 -1
  107. data/test/environments/rails41/Gemfile +1 -1
  108. data/test/multiverse/lib/multiverse/runner.rb +13 -1
  109. data/test/multiverse/lib/multiverse/suite.rb +26 -9
  110. data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
  111. data/test/multiverse/suites/activemerchant/Envfile +18 -1
  112. data/test/multiverse/suites/agent_only/audit_log_test.rb +4 -3
  113. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +35 -0
  114. data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
  115. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -0
  116. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +3 -2
  117. data/test/multiverse/suites/agent_only/exclusive_time_test.rb +178 -0
  118. data/test/multiverse/suites/agent_only/logging_test.rb +10 -6
  119. data/test/multiverse/suites/agent_only/marshaling_test.rb +11 -9
  120. data/test/multiverse/suites/agent_only/script/loading.rb +1 -1
  121. data/test/multiverse/suites/agent_only/service_timeout_test.rb +5 -1
  122. data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +2 -1
  123. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +9 -9
  124. data/test/multiverse/suites/capistrano/Capfile +26 -0
  125. data/test/multiverse/suites/capistrano/Envfile +18 -0
  126. data/test/multiverse/suites/capistrano/config/deploy.rb +10 -0
  127. data/test/multiverse/suites/capistrano/config/deploy/production.rb +9 -0
  128. data/test/multiverse/suites/capistrano/config/newrelic.yml +21 -0
  129. data/test/multiverse/suites/capistrano/deployment_test.rb +47 -0
  130. data/test/multiverse/suites/capistrano2/Capfile +4 -0
  131. data/test/multiverse/suites/capistrano2/Envfile +4 -0
  132. data/test/multiverse/suites/capistrano2/config/deploy.rb +19 -0
  133. data/test/multiverse/suites/capistrano2/config/newrelic.yml +21 -0
  134. data/test/multiverse/suites/capistrano2/deployment_test.rb +38 -0
  135. data/test/multiverse/suites/curb/Envfile +10 -1
  136. data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
  137. data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
  138. data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
  139. data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
  140. data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
  141. data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
  142. data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
  143. data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
  144. data/test/multiverse/suites/rack/Envfile +25 -0
  145. data/test/multiverse/suites/rack/example_app.rb +50 -0
  146. data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +66 -0
  147. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +143 -0
  148. data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +45 -0
  149. data/test/multiverse/suites/rack/url_map_test.rb +120 -0
  150. data/test/multiverse/suites/rails/Envfile +10 -0
  151. data/test/multiverse/suites/rails/app.rb +28 -63
  152. data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -4
  153. data/test/multiverse/suites/rails/config/newrelic.yml +1 -2
  154. data/test/multiverse/suites/rails/dummy.txt +1 -0
  155. data/test/multiverse/suites/rails/error_tracing_test.rb +46 -31
  156. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +0 -1
  157. data/test/multiverse/suites/rails/ignore_test.rb +9 -3
  158. data/test/multiverse/suites/rails/middleware_instrumentation_test.rb +41 -0
  159. data/test/multiverse/suites/rails/middlewares.rb +19 -0
  160. data/test/multiverse/suites/rails/parameter_capture_test.rb +169 -0
  161. data/test/multiverse/suites/rails/queue_time_test.rb +14 -4
  162. data/test/multiverse/suites/rails/rails2_app/app/controllers/application.rb +7 -0
  163. data/test/multiverse/suites/rails/rails2_app/config/boot.rb +127 -0
  164. data/test/multiverse/suites/rails/rails2_app/config/database.yml +18 -0
  165. data/test/multiverse/suites/rails/rails2_app/config/environment.rb +16 -0
  166. data/test/multiverse/suites/rails/rails2_app/config/environments/development.rb +10 -0
  167. data/test/multiverse/suites/rails/rails2_app/config/initializers/load_newrelic_rpm.rb +9 -0
  168. data/test/multiverse/suites/rails/rails2_app/config/preinitializer.rb +25 -0
  169. data/test/multiverse/suites/rails/rails2_app/config/routes.rb +18 -0
  170. data/test/multiverse/suites/rails/rails2_app/db/schema.rb +5 -0
  171. data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +76 -0
  172. data/test/multiverse/suites/rails/request_statistics_test.rb +2 -4
  173. data/test/multiverse/suites/rails/transaction_ignoring_test.rb +3 -5
  174. data/test/multiverse/suites/rails/view_instrumentation_test.rb +73 -42
  175. data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
  176. data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
  177. data/test/multiverse/suites/sidekiq/Envfile +4 -0
  178. data/test/multiverse/suites/sidekiq/after_suite.rb +7 -0
  179. data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
  180. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +55 -34
  181. data/test/multiverse/suites/sidekiq/sidekiq_server.rb +30 -0
  182. data/test/multiverse/suites/sidekiq/test_worker.rb +60 -0
  183. data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
  184. data/test/multiverse/suites/sinatra/ignoring_test.rb +33 -11
  185. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +3 -1
  186. data/test/multiverse/suites/typhoeus/Envfile +9 -0
  187. data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
  188. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +10 -0
  189. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
  190. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
  191. data/test/new_relic/agent/agent/connect_test.rb +3 -10
  192. data/test/new_relic/agent/agent_logger_test.rb +24 -6
  193. data/test/new_relic/agent/agent_test.rb +7 -8
  194. data/test/new_relic/agent/agent_test_controller.rb +2 -2
  195. data/test/new_relic/agent/audit_logger_test.rb +5 -1
  196. data/test/new_relic/agent/busy_calculator_test.rb +1 -1
  197. data/test/new_relic/agent/configuration/manager_test.rb +68 -69
  198. data/test/new_relic/agent/cross_app_monitor_test.rb +32 -14
  199. data/test/new_relic/agent/cross_app_tracing_test.rb +2 -2
  200. data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -33
  201. data/test/new_relic/agent/error_collector_test.rb +45 -14
  202. data/test/new_relic/agent/harvester_test.rb +9 -0
  203. data/test/new_relic/agent/hostname_test.rb +41 -0
  204. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +27 -19
  205. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
  206. data/test/new_relic/agent/instrumentation/active_record_test.rb +3 -3
  207. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +95 -14
  208. data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +189 -0
  209. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -2
  210. data/test/new_relic/agent/instrumentation/queue_time_test.rb +18 -1
  211. data/test/new_relic/agent/instrumentation/rack_test.rb +10 -1
  212. data/test/new_relic/agent/instrumentation/sinatra_test.rb +3 -1
  213. data/test/new_relic/agent/javascript_instrumentor_test.rb +28 -41
  214. data/test/new_relic/agent/memory_logger_test.rb +14 -0
  215. data/test/new_relic/agent/method_interrobang_test.rb +1 -1
  216. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -30
  217. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +5 -21
  218. data/test/new_relic/agent/method_tracer_test.rb +5 -4
  219. data/test/new_relic/agent/mock_scope_listener.rb +2 -2
  220. data/test/new_relic/agent/obfuscator_test.rb +1 -1
  221. data/test/new_relic/agent/pipe_channel_manager_test.rb +17 -5
  222. data/test/new_relic/agent/request_sampler_test.rb +16 -16
  223. data/test/new_relic/agent/rpm_agent_test.rb +23 -29
  224. data/test/new_relic/agent/sql_sampler_test.rb +39 -31
  225. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +189 -117
  226. data/test/new_relic/agent/stats_engine_test.rb +1 -1
  227. data/test/new_relic/agent/stats_hash_test.rb +28 -1
  228. data/test/new_relic/agent/stats_test.rb +1 -12
  229. data/test/new_relic/agent/threading/agent_thread_test.rb +23 -9
  230. data/test/new_relic/agent/threading/backtrace_service_test.rb +33 -32
  231. data/test/new_relic/agent/threading/fake_thread.rb +4 -8
  232. data/test/new_relic/agent/threading/threaded_test_case.rb +4 -14
  233. data/test/new_relic/agent/traced_method_stack_test.rb +43 -27
  234. data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
  235. data/test/new_relic/agent/transaction_metrics_test.rb +113 -0
  236. data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -61
  237. data/test/new_relic/agent/transaction_sampler_test.rb +176 -228
  238. data/test/new_relic/agent/transaction_state_test.rb +62 -26
  239. data/test/new_relic/agent/transaction_test.rb +198 -80
  240. data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +4 -4
  241. data/test/new_relic/agent/vm/rubinius_vm_test.rb +68 -0
  242. data/test/new_relic/agent_test.rb +31 -27
  243. data/test/new_relic/cli/commands/deployments_test.rb +7 -2
  244. data/test/new_relic/control/instance_methods_test.rb +4 -4
  245. data/test/new_relic/control_test.rb +28 -22
  246. data/test/new_relic/dependency_detection_test.rb +14 -0
  247. data/test/new_relic/fake_external_server.rb +1 -0
  248. data/test/new_relic/fake_rpm_site.rb +35 -0
  249. data/test/new_relic/http_client_test_cases.rb +12 -3
  250. data/test/new_relic/json_wrapper_test.rb +5 -0
  251. data/test/new_relic/language_support_test.rb +7 -0
  252. data/test/new_relic/license_test.rb +11 -5
  253. data/test/new_relic/local_environment_test.rb +0 -18
  254. data/test/new_relic/metric_data_test.rb +2 -2
  255. data/test/new_relic/metric_spec_test.rb +4 -23
  256. data/test/new_relic/multiverse_helpers.rb +1 -3
  257. data/test/new_relic/noticed_error_test.rb +6 -22
  258. data/test/new_relic/rack/agent_hooks_test.rb +5 -1
  259. data/test/new_relic/rack/agent_middleware_test.rb +32 -0
  260. data/test/new_relic/rack/browser_monitoring_test.rb +14 -1
  261. data/test/new_relic/rack/developer_mode_helper_test.rb +0 -8
  262. data/test/new_relic/rack/developer_mode_test.rb +1 -1
  263. data/test/new_relic/rack/error_collector_test.rb +6 -30
  264. data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -2
  265. data/test/new_relic/transaction_sample/segment_test.rb +47 -47
  266. data/test/new_relic/transaction_sample_test.rb +9 -8
  267. data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -8
  268. data/test/performance/script/runner +13 -0
  269. data/test/performance/suites/config.rb +5 -2
  270. data/test/performance/suites/rack_middleware.rb +84 -0
  271. data/test/performance/suites/rum_autoinsertion.rb +1 -1
  272. data/test/performance/suites/thread_profiling.rb +1 -1
  273. data/test/test_helper.rb +12 -10
  274. data/ui/helpers/developer_mode_helper.rb +3 -43
  275. data/ui/views/layouts/newrelic_default.rhtml +2 -2
  276. data/ui/views/newrelic/_sample.rhtml +2 -2
  277. data/ui/views/newrelic/_sql_row.rhtml +11 -11
  278. data/ui/views/newrelic/index.rhtml +21 -22
  279. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +15 -10
  280. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +2 -0
  281. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +34 -0
  282. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +24 -0
  283. metadata +108 -31
  284. metadata.gz.sig +0 -0
  285. data/lib/new_relic/rack/transaction_reset.rb +0 -20
  286. data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -42
  287. data/test/new_relic/rack/transaction_reset_test.rb +0 -35
  288. data/ui/views/newrelic/show_source.rhtml +0 -3
data.tar.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -23,3 +23,4 @@ lib/new_relic/build.rb
23
23
  .tm_properties
24
24
  .bundle
25
25
  .yardoc
26
+ artifacts/
data/.yardopts CHANGED
@@ -5,7 +5,9 @@ lib/new_relic/agent/method_tracer.rb
5
5
  lib/new_relic/agent/instrumentation/controller_instrumentation.rb
6
6
  lib/new_relic/agent/instrumentation/rack.rb
7
7
  lib/new_relic/agent/instrumentation/metric_frame.rb
8
+ lib/new_relic/agent/sql_sampler.rb
8
9
  lib/new_relic/agent/transaction.rb
10
+ lib/new_relic/agent/transaction_sampler.rb
9
11
  lib/new_relic/rack/developer_mode.rb
10
12
  lib/new_relic/rack/agent_hooks.rb
11
13
  lib/new_relic/rack/browser_monitoring.rb
data/CHANGELOG CHANGED
@@ -1,5 +1,100 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v3.9.0 ##
4
+
5
+ * Rack middleware instrumentation
6
+
7
+ The Ruby agent now automatically instruments Rack middlewares!
8
+
9
+ This means that the agent can now give you a more complete picture of your
10
+ application's response time, including time spent in middleware. It also means
11
+ that requests which previously weren't captured by the agent because they
12
+ never made it to the bottom of your middleware stack (usually a Rails or
13
+ Sinatra application) will now be captured.
14
+
15
+ After installing this version of the Ruby agent, you'll see a new 'Middleware'
16
+ band on your application's overview graph, and individual middlewares will
17
+ appear in transaction breakdown charts and transaction traces.
18
+
19
+ The agent can instrument middlewares that are added from a config.ru file via
20
+ Rack::Builder, or via Rails' middleware stack in Rails 3.0+.
21
+
22
+ This instrumentation may be disabled with the
23
+ disable_middlware_instrumentation configuration setting.
24
+
25
+ For more details, see the documentation for this feature:
26
+
27
+ - http://docs.newrelic.com/docs/ruby/rack-middlewares
28
+ - http://docs.newrelic.com/docs/ruby/middleware-upgrade-changes
29
+
30
+ * Capistrano 3.x support
31
+
32
+ Recording application deployments using Capistrano 3.x is now supported.
33
+
34
+ Many thanks to Jennifer Page for the contribution!
35
+
36
+ * Better support for Sidekiq's Delayed extensions
37
+
38
+ Sidekiq jobs executed via the Delayed extensions (e.g. the #delay method) will
39
+ now be named after the actual class that #delay was invoked against, and will
40
+ have their job arguments correctly captured if the sidekiq.capture_params
41
+ configuration setting is enabled.
42
+
43
+ Many thanks to printercu for the contribution!
44
+
45
+ * Improved Apdex calculation with ignored error classes
46
+
47
+ Previously, a transaction resulting in an exception that bubbled up to the top
48
+ level would always be counted as failing for the purposes of Apdex
49
+ calculations (unless the transaction name was ignored entirely). Now,
50
+ exceptions whose classes have been ignored by the
51
+ error_collector.ignore_errors configuration setting will not cause a
52
+ transaction to be automatically counted as failing.
53
+
54
+ * Allow URIs that are not parseable by stdlib's URI if addressable is present
55
+
56
+ There are some URIs that are valid by RFC 3986, but not parseable by Ruby's
57
+ stdlib URI class. The Ruby agent will now attempt to use the addressable gem
58
+ to parse URIs if it is present, allowing requests against these problematic
59
+ URIs to be instrumented.
60
+
61
+ Many thanks to Craig R Webster and Amir Yalon for their help with this issue!
62
+
63
+ * More robust error collection from Resque processes
64
+
65
+ Previously, traced errors where the exception class was defined in the Resque
66
+ worker but not in the Resque master process would not be correctly handled by
67
+ the agent. This has been fixed.
68
+
69
+ * Allow Sinatra apps to set the New Relic environment without setting RACK_ENV
70
+
71
+ The NEW_RELIC_ENV environment variable may now be used to specify the
72
+ environment the agent should use from its configuration file, independently of
73
+ RACK_ENV.
74
+
75
+ Many thanks to Mario Izquierdo for the contribution!
76
+
77
+ * Better error handling in Browser Application Monitoring injection
78
+
79
+ The agent middleware that injects the JavaScript code necessary for Browser
80
+ Application Monitoring now does a better job of catching errors that might
81
+ occur during the injection process.
82
+
83
+ * Allow disabling of Net::HTTP instrumentation
84
+
85
+ Most instrumentation in the Ruby agent can be disabled easily via a
86
+ configuration setting. Our Net::HTTP instrumentation was previously an
87
+ exception, but now it can also be disabled with the disable_net_http
88
+ configuration setting.
89
+
90
+ * Make Rails constant presence check more defensive
91
+
92
+ The Ruby agent now guards against the (rare) case where an application has a
93
+ Rails constant defined, but no Rails::VERSION constant (because Rails is not
94
+ actually present).
95
+
96
+ Many thanks to Vladimir Kiselev for the contribution!
97
+
3
98
  ## v3.8.1 ##
4
99
 
5
100
  * Better handling for Rack applications implemented as middlewares
data/README.md CHANGED
@@ -111,8 +111,8 @@ to your startup sequence and then manually start the agent using
111
111
 
112
112
  NewRelic::Agent.manual_start
113
113
 
114
- To instrument Rack based applications, refer to the docs in
115
- `NewRelic::Agent::Instrumentation::Rack`.
114
+ For information about instrumenting pure Rack applications, see our
115
+ [Rack middlewares documentation](http://docs.newrelic.com/docs/ruby/rack-middlewares).
116
116
 
117
117
  Refer to the [New Relic's Docs](http://newrelic.com/docs) for details on how to
118
118
  monitor other web frameworks, background jobs, and daemons.
@@ -120,7 +120,7 @@ monitor other web frameworks, background jobs, and daemons.
120
120
  The Ruby Agent provides an API that allows custom instrumentation of additional
121
121
  frameworks. You can find a list of community created intrumentation plugins
122
122
  (e.g. [newrelic-redis](https://github.com/evanphx/newrelic-redis)) in the
123
- [RPM Contrib README](https://github.com/newrelic/rpm_contrib/blob/master/README.md#new-relic-ruby-agent-plugins-seperate-projects).
123
+ [extends_newrelic_rpm project](https://github.com/newrelic/extends_newrelic_rpm).
124
124
 
125
125
  ## Developer Mode
126
126
 
@@ -171,6 +171,12 @@ analysis. To view this data, log in to http://rpm.newrelic.com.
171
171
  NOTE: You must have a valid account and license key to view this data
172
172
  online. Refer to instructions in *Getting Started*.
173
173
 
174
+ ## Recording Deploys
175
+
176
+ The Ruby Agent supports recording deployments in New Relic via a command line
177
+ tool or Capistrano recipes. For more information on these features see
178
+ [our deployment documentation](http://docs.newrelic.com/docs/ruby/recording-deployments-with-the-ruby-agent)
179
+ for more information.
174
180
 
175
181
  ## Support
176
182
 
data/Rakefile CHANGED
@@ -37,6 +37,12 @@ namespace :test do
37
37
  ruby test_files.join(" ")
38
38
  end
39
39
 
40
+ task 'multiverse:prime', [:suite] => [] do |t, args|
41
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'multiverse', 'lib', 'multiverse', 'environment'))
42
+ opts = Multiverse::Runner.parse_args(args)
43
+ Multiverse::Runner.prime(args.suite, opts)
44
+ end
45
+
40
46
  desc "Run agent performance tests"
41
47
  task :performance, [:suite, :name] => [] do |t, args|
42
48
  require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'performance', 'lib', 'performance'))
@@ -23,7 +23,7 @@ require 'new_relic/control'
23
23
  #
24
24
  # == Using with Rack/Metal
25
25
  #
26
- # To instrument Rack middlwares or Metal apps, refer to the docs in
26
+ # To instrument Rack middlewares or Metal apps, refer to the docs in
27
27
  # NewRelic::Agent::Instrumentation::Rack.
28
28
  #
29
29
  # == Ruby Agent API
@@ -118,8 +118,6 @@ module NewRelic
118
118
  require 'thread'
119
119
  require 'resolv'
120
120
 
121
- extend NewRelic::Agent::Configuration::Instance
122
-
123
121
  # An exception that is thrown by the server if the agent license is invalid.
124
122
  class LicenseException < StandardError; end
125
123
 
@@ -171,6 +169,19 @@ module NewRelic
171
169
  @logger = log
172
170
  end
173
171
 
172
+ # This needs to come after the definition of the logger method above, since
173
+ # instantiating the config writes to the Logger.
174
+
175
+ @config = NewRelic::Agent::Configuration::Manager.new
176
+
177
+ attr_reader :config
178
+
179
+ # For testing
180
+ # Important that we don't change the instance or we orphan callbacks
181
+ def reset_config
182
+ @config.reset_to_defaults
183
+ end
184
+
174
185
  # Record a value for the given metric name.
175
186
  #
176
187
  # This method should be used to record event-based metrics such as method
@@ -187,7 +198,7 @@ module NewRelic
187
198
  # This method is safe to use from any thread.
188
199
  #
189
200
  # @api public
190
- def record_metric(metric_name, value)
201
+ def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
191
202
  if value.is_a?(Hash)
192
203
  stats = NewRelic::Agent::Stats.new
193
204
 
@@ -199,7 +210,7 @@ module NewRelic
199
210
  stats.sum_of_squares = value[:sum_of_squares] if value[:sum_of_squares]
200
211
  value = stats
201
212
  end
202
- agent.stats_engine.record_metrics(metric_name, value)
213
+ agent.stats_engine.tl_record_unscoped_metrics(metric_name, value)
203
214
  end
204
215
 
205
216
  # Increment a simple counter metric.
@@ -210,8 +221,8 @@ module NewRelic
210
221
  # This method is safe to use from any thread.
211
222
  #
212
223
  # @api public
213
- def increment_metric(metric_name, amount=1)
214
- agent.stats_engine.record_metrics(metric_name) do |stats|
224
+ def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
225
+ agent.stats_engine.tl_record_unscoped_metrics(metric_name) do |stats|
215
226
  stats.increment_count(amount)
216
227
  end
217
228
  end
@@ -407,20 +418,20 @@ module NewRelic
407
418
  end
408
419
 
409
420
  # Check to see if we are capturing metrics currently on this thread.
410
- def is_execution_traced?
411
- NewRelic::Agent::TransactionState.get.is_traced?
421
+ def tl_is_execution_traced?
422
+ NewRelic::Agent::TransactionState.tl_get.is_execution_traced?
412
423
  end
413
424
 
414
425
  # helper method to check the thread local to determine whether the
415
426
  # transaction in progress is traced or not
416
- def is_transaction_traced?
417
- NewRelic::Agent::TransactionState.get.is_transaction_traced?
427
+ def tl_is_transaction_traced?
428
+ NewRelic::Agent::TransactionState.tl_get.is_transaction_traced?
418
429
  end
419
430
 
420
431
  # helper method to check the thread local to determine whether sql
421
432
  # is being recorded or not
422
- def is_sql_recorded?
423
- NewRelic::Agent::TransactionState.get.is_sql_recorded?
433
+ def tl_is_sql_recorded?
434
+ NewRelic::Agent::TransactionState.tl_get.is_sql_recorded?
424
435
  end
425
436
 
426
437
  # Set a filter to be applied to errors that the Ruby Agent will
@@ -467,9 +478,10 @@ module NewRelic
467
478
  #
468
479
  # @api public
469
480
  #
470
- def add_custom_parameters(params)
481
+ def add_custom_parameters(params) #THREAD_LOCAL_ACCESS
471
482
  if params.is_a? Hash
472
- Transaction.add_custom_parameters(params)
483
+ txn = Transaction.tl_current
484
+ txn.add_custom_parameters(params) if txn
473
485
  else
474
486
  ::NewRelic::Agent.logger.warn("Bad argument passed to #add_custom_parameters. Expected Hash but got #{params.class}")
475
487
  end
@@ -492,7 +504,7 @@ module NewRelic
492
504
  # * <tt>:category => :task</tt> indicates that this is a
493
505
  # background task and will show up in New Relic with other background
494
506
  # tasks instead of in the controllers list
495
- # * <tt>:category => :rack</tt> if you are instrumenting a rack
507
+ # * <tt>:category => :middleware</tt> if you are instrumenting a rack
496
508
  # middleware call. The <tt>:name</tt> is optional, useful if you
497
509
  # have more than one potential transaction in the #call.
498
510
  # * <tt>:category => :uri</tt> indicates that this is a
@@ -513,10 +525,11 @@ module NewRelic
513
525
  #
514
526
  # @api public
515
527
  #
516
- def get_transaction_name
517
- if Transaction.current
528
+ def get_transaction_name #THREAD_LOCAL_ACCESS
529
+ txn = Transaction.tl_current
530
+ if txn
518
531
  namer = Instrumentation::ControllerInstrumentation::TransactionNamer
519
- Transaction.current.best_name.sub(Regexp.new("\\A#{Regexp.escape(namer.category_name)}/"), '')
532
+ txn.best_name.sub(Regexp.new("\\A#{Regexp.escape(namer.prefix_for_category(txn))}"), '')
520
533
  end
521
534
  end
522
535
 
@@ -531,45 +544,17 @@ module NewRelic
531
544
  #
532
545
  # @api public
533
546
  #
534
- def with_database_metric_name(model, method, &block)
535
- if txn = Transaction.current
547
+ def with_database_metric_name(model, method, &block) #THREAD_LOCAL_ACCESS
548
+ if txn = Transaction.tl_current
536
549
  txn.with_database_metric_name(model, method, &block)
537
550
  else
538
551
  yield
539
552
  end
540
553
  end
541
554
 
542
- # Record a web transaction from an external source. This will
543
- # process the response time, error, and score an apdex value.
544
- #
545
- # First argument is a float value, time in seconds. Option
546
- # keys are strings.
547
- #
548
- # == Identifying the transaction
549
- # * <tt>'uri' => uri</tt> to record the value for a given web request.
550
- # If not provided, just record the aggregate dispatcher and apdex scores.
551
- # * <tt>'metric' => metric_name</tt> to record with a general metric name
552
- # like +OtherTransaction/Background/Class/method+. Ignored if +uri+ is
553
- # provided.
554
- #
555
- # == Error options
556
- # Provide one of the following:
557
- # * <tt>'is_error' => true</tt> if an unknown error occurred
558
- # * <tt>'error_message' => msg</tt> if an error message is available
559
- # * <tt>'exception' => exception</tt> if a ruby exception is recorded
560
- #
561
- # == Misc options
562
- # Additional information captured in errors
563
- # * <tt>'referer' => referer_url</tt>
564
- # * <tt>'request_params' => hash</tt> to record a set of name/value pairs as the
565
- # request parameters.
566
- # * <tt>'custom_params' => hash</tt> to record extra information in traced errors
567
- #
568
- # @api public
569
- # @deprecated
570
- #
571
- def record_transaction(response_sec, options = {})
572
- agent.record_transaction(response_sec, options)
555
+ # Remove after 5/9/15
556
+ def record_transaction(*args)
557
+ NewRelic::Agent.logger.warn('This method has been deprecated, please see https://docs.newrelic.com/docs/ruby/ruby-agent-api for current API documentation.')
573
558
  end
574
559
 
575
560
  # Subscribe to events of +event_type+, calling the given +handler+
@@ -11,6 +11,7 @@ require 'stringio'
11
11
  require 'new_relic/agent/sampled_buffer'
12
12
  require 'new_relic/agent/autostart'
13
13
  require 'new_relic/agent/harvester'
14
+ require 'new_relic/agent/hostname'
14
15
  require 'new_relic/agent/new_relic_service'
15
16
  require 'new_relic/agent/pipe_service'
16
17
  require 'new_relic/agent/configuration/manager'
@@ -32,14 +33,14 @@ module NewRelic
32
33
  # in realtime as the application runs, and periodically sends that
33
34
  # data to the NewRelic server.
34
35
  class Agent
35
- extend NewRelic::Agent::Configuration::Instance
36
+ def self.config
37
+ ::NewRelic::Agent.config
38
+ end
36
39
 
37
40
  def initialize
38
41
  # FIXME: temporary work around for RUBY-839
39
42
  # This should be handled with a configuration callback
40
- if Agent.config[:monitor_mode]
41
- @service = NewRelic::Agent::NewRelicService.new
42
- end
43
+ start_service_if_needed
43
44
 
44
45
  @events = NewRelic::Agent::EventListener.new
45
46
  @stats_engine = NewRelic::Agent::StatsEngine.new
@@ -112,42 +113,6 @@ module NewRelic
112
113
  # GC::Profiler.total_time is not monotonic so we wrap it.
113
114
  attr_reader :monotonic_gc_profiler
114
115
 
115
- # fakes out a transaction that did not happen in this process
116
- # by creating apdex, summary metrics, and recording statistics
117
- # for the transaction
118
- #
119
- # This method is *deprecated* - it may be removed in future
120
- # versions of the agent
121
- def record_transaction(duration_seconds, options={})
122
- is_error = options['is_error'] || options['error_message'] || options['exception']
123
- metric = options['metric']
124
- metric ||= options['uri'] # normalize this with url rules
125
- raise "metric or uri arguments required" unless metric
126
- metric_info = NewRelic::MetricParser::MetricParser.for_metric_named(metric)
127
-
128
- if metric_info.is_web_transaction?
129
- NewRelic::Agent::Transaction.record_apdex(metric_info, duration_seconds, duration_seconds, is_error)
130
- end
131
- metrics = metric_info.summary_metrics
132
-
133
- metrics << metric
134
- metrics.each do |name|
135
- NewRelic::Agent.record_metric(name, duration_seconds)
136
- end
137
-
138
- if is_error
139
- if options['exception']
140
- e = options['exception']
141
- elsif options['error_message']
142
- e = StandardError.new options['error_message']
143
- else
144
- e = StandardError.new 'Unknown Error'
145
- end
146
- error_collector.notice_error e, :uri => options['uri'], :metric => metric
147
- end
148
- # busy time ?
149
- end
150
-
151
116
  # This method should be called in a forked process after a fork.
152
117
  # It assumes the parent process initialized the agent, but does
153
118
  # not assume the agent started.
@@ -172,7 +137,7 @@ module NewRelic
172
137
  # we should be ready to run and shouldn't restarting if we can't.
173
138
  @harvester.mark_started
174
139
 
175
- Agent.config.apply_config(NewRelic::Agent::Configuration::ManualSource.new(options), 1)
140
+ Agent.config.replace_or_add_config(NewRelic::Agent::Configuration::ManualSource.new(options))
176
141
 
177
142
  if channel_id = options[:report_to_channel]
178
143
  @service = NewRelic::Agent::PipeService.new(channel_id)
@@ -223,10 +188,8 @@ module NewRelic
223
188
  end
224
189
 
225
190
  def revert_to_default_configuration
226
- NewRelic::Agent.config.remove_config do |config|
227
- config.class == NewRelic::Agent::Configuration::ManualSource ||
228
- config.class == NewRelic::Agent::Configuration::ServerSource
229
- end
191
+ NewRelic::Agent.config.remove_config_type(:manual)
192
+ NewRelic::Agent.config.remove_config_type(:server)
230
193
  end
231
194
 
232
195
  def stop_worker_loop
@@ -258,18 +221,20 @@ module NewRelic
258
221
  # Sets a thread local variable as to whether we should or
259
222
  # should not record sql in the current thread. Returns the
260
223
  # previous value, if there is one
261
- def set_record_sql(should_record)
262
- prev = TransactionState.get.record_sql
263
- TransactionState.get.record_sql = should_record
224
+ def set_record_sql(should_record) #THREAD_LOCAL_ACCESS
225
+ state = TransactionState.tl_get
226
+ prev = state.record_sql
227
+ state.record_sql = should_record
264
228
  prev.nil? || prev
265
229
  end
266
230
 
267
231
  # Sets a thread local variable as to whether we should or
268
232
  # should not record transaction traces in the current
269
233
  # thread. Returns the previous value, if there is one
270
- def set_record_tt(should_record)
271
- prev = TransactionState.get.record_tt
272
- TransactionState.get.record_tt = should_record
234
+ def set_record_tt(should_record) #THREAD_LOCAL_ACCESS
235
+ state = TransactionState.tl_get
236
+ prev = state.record_tt
237
+ state.record_tt = should_record
273
238
  prev.nil? || prev
274
239
  end
275
240
 
@@ -277,14 +242,14 @@ module NewRelic
277
242
  # thread. This uses a stack which allows us to disable tracing
278
243
  # children of a transaction without affecting the tracing of
279
244
  # the whole transaction
280
- def push_trace_execution_flag(should_trace=false)
281
- TransactionState.get.push_traced(should_trace)
245
+ def push_trace_execution_flag(should_trace=false) #THREAD_LOCAL_ACCESS
246
+ TransactionState.tl_get.push_traced(should_trace)
282
247
  end
283
248
 
284
249
  # Pop the current trace execution status. Restore trace execution status
285
250
  # to what it was before we pushed the current flag.
286
- def pop_trace_execution_flag
287
- TransactionState.get.pop_traced
251
+ def pop_trace_execution_flag #THREAD_LOCAL_ACCESS
252
+ TransactionState.tl_get.pop_traced
288
253
  end
289
254
 
290
255
  # Herein lies the corpse of the former 'start' method. May
@@ -385,6 +350,12 @@ module NewRelic
385
350
  end
386
351
  end
387
352
 
353
+ def start_service_if_needed
354
+ if Agent.config[:monitor_mode] && !@service
355
+ @service = NewRelic::Agent::NewRelicService.new
356
+ end
357
+ end
358
+
388
359
  # Classy logging of the agent version and the current pid,
389
360
  # so we can disambiguate processes in the log file and make
390
361
  # sure they're running a reasonable version
@@ -670,14 +641,13 @@ module NewRelic
670
641
  #
671
642
  # See #connect for a description of connection_options.
672
643
  def start_worker_thread(connection_options = {})
673
- disable = NewRelic::Agent.config[:disable_harvest_thread]
674
- if disable
644
+ if disable = NewRelic::Agent.config[:disable_harvest_thread]
675
645
  NewRelic::Agent.logger.info "Not starting Ruby Agent worker thread because :disable_harvest_thread is #{disable}"
676
646
  return
677
647
  end
678
648
 
679
649
  ::NewRelic::Agent.logger.debug "Creating Ruby Agent worker thread."
680
- @worker_thread = NewRelic::Agent::Threading::AgentThread.new('Worker Loop') do
650
+ @worker_thread = NewRelic::Agent::Threading::AgentThread.create('Worker Loop') do
681
651
  deferred_work!(connection_options)
682
652
  end
683
653
  end
@@ -826,7 +796,7 @@ module NewRelic
826
796
 
827
797
  ::NewRelic::Agent.logger.debug "Server provided config: #{config_data.inspect}"
828
798
  server_config = NewRelic::Agent::Configuration::ServerSource.new(config_data, Agent.config)
829
- Agent.config.replace_or_add_config(server_config, 1)
799
+ Agent.config.replace_or_add_config(server_config)
830
800
  log_connection!(config_data) if @service
831
801
 
832
802
  @transaction_rules = RulesEngine.from_specs(config_data['transaction_name_rules'])
@@ -908,7 +878,7 @@ module NewRelic
908
878
  handle_license_error(e)
909
879
  rescue NewRelic::Agent::UnrecoverableAgentException => e
910
880
  handle_unrecoverable_agent_error(e)
911
- rescue Timeout::Error, NewRelic::Agent::ServerConnectionException => e
881
+ rescue StandardError, Timeout::Error, NewRelic::Agent::ServerConnectionException => e
912
882
  log_error(e)
913
883
  if opts[:keep_retrying]
914
884
  note_connect_failure
@@ -918,13 +888,11 @@ module NewRelic
918
888
  else
919
889
  disconnect
920
890
  end
921
- rescue StandardError => e
922
- handle_other_error(e)
923
891
  end
924
892
 
925
893
  # Who am I? Well, this method can tell you your hostname.
926
894
  def determine_host
927
- Socket.gethostname
895
+ NewRelic::Agent::Hostname.get
928
896
  end
929
897
 
930
898
  def local_host
@@ -1053,7 +1021,7 @@ module NewRelic
1053
1021
  ensure
1054
1022
  NewRelic::Agent::Database.close_connections
1055
1023
  duration = (Time.now - now).to_f
1056
- @stats_engine.record_metrics('Supportability/Harvest', duration)
1024
+ NewRelic::Agent.record_metric('Supportability/Harvest', duration)
1057
1025
  end
1058
1026
 
1059
1027
  private :transmit_data_already_locked