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
@@ -19,6 +19,10 @@ class LoggingTest < Minitest::Test
19
19
  NewRelic::Agent.stubs(:logger).returns(NewRelic::Agent::MemoryLogger.new)
20
20
  end
21
21
 
22
+ def teardown
23
+ NewRelic::Agent.config.reset_to_defaults
24
+ end
25
+
22
26
  def test_logs_app_name
23
27
  running_agent_writes_to_log(
24
28
  {:app_name => "My App"},
@@ -50,17 +54,17 @@ class LoggingTest < Minitest::Test
50
54
  {:'transaction_tracer.record_sql' => 'obfuscated'},
51
55
  "Agent is configured to send raw SQL to the service") do
52
56
 
53
- NewRelic::Agent.config.apply_config(:'transaction_tracer.record_sql' => 'raw')
57
+ NewRelic::Agent.config.add_config_for_testing(:'transaction_tracer.record_sql' => 'raw')
54
58
  end
55
59
 
56
60
  end
57
61
 
58
62
  def test_logs_ssl_warning
59
63
  running_agent_writes_to_log(
60
- {:ssl => true},
64
+ {},
61
65
  "Agent is configured not to use SSL when communicating with New Relic's servers") do
62
-
63
- NewRelic::Agent.config.apply_config(:ssl => false)
66
+ NewRelic::Agent.config.add_config_for_testing(:ssl => true )
67
+ NewRelic::Agent.config.add_config_for_testing(:ssl => false)
64
68
  end
65
69
  end
66
70
 
@@ -69,7 +73,7 @@ class LoggingTest < Minitest::Test
69
73
  {:'error_collector.enabled' => false},
70
74
  "Errors will be sent") do
71
75
 
72
- NewRelic::Agent.config.apply_config(:'error_collector.enabled' => true)
76
+ NewRelic::Agent.config.add_config_for_testing(:'error_collector.enabled' => true)
73
77
  end
74
78
  end
75
79
 
@@ -78,7 +82,7 @@ class LoggingTest < Minitest::Test
78
82
  {:'error_collector.enabled' => true},
79
83
  "Errors will not be sent") do
80
84
 
81
- NewRelic::Agent.config.apply_config(:'error_collector.enabled' => false)
85
+ NewRelic::Agent.config.add_config_for_testing(:'error_collector.enabled' => false)
82
86
  end
83
87
  end
84
88
 
@@ -17,14 +17,15 @@ class MarshalingTest < Minitest::Test
17
17
  def test_transaction_trace_marshaling
18
18
  # create fake transaction trace
19
19
  time = freeze_time
20
+ state = NewRelic::Agent::TransactionState.tl_get
20
21
  sampler = agent.transaction_sampler
21
- sampler.on_start_transaction time, nil, {}
22
- sampler.notice_push_frame "a"
23
- sampler.notice_push_frame "ab"
22
+ sampler.on_start_transaction(state, time, nil)
23
+ sampler.notice_push_frame(state, "a")
24
+ sampler.notice_push_frame(state, "ab")
24
25
  advance_time 1
25
- sampler.notice_pop_frame "ab"
26
- sampler.notice_pop_frame "a"
27
- sampler.on_finishing_transaction(OpenStruct.new(:name => 'path',
26
+ sampler.notice_pop_frame(state, "ab")
27
+ sampler.notice_pop_frame(state, "a")
28
+ sampler.on_finishing_transaction(state, OpenStruct.new(:name => 'path',
28
29
  :custom_parameters => {}))
29
30
 
30
31
  expected_sample = sampler.last_sample
@@ -68,11 +69,12 @@ class MarshalingTest < Minitest::Test
68
69
  end
69
70
 
70
71
  def test_sql_trace_data_marshalling
71
- agent.sql_sampler.on_start_transaction(nil)
72
+ state = NewRelic::Agent::TransactionState.tl_get
73
+ agent.sql_sampler.on_start_transaction(state, nil)
72
74
  agent.sql_sampler.notice_sql("select * from test",
73
75
  "Database/test/select",
74
- nil, 1.5)
75
- agent.sql_sampler.on_finishing_transaction('txn')
76
+ nil, 1.5, state)
77
+ agent.sql_sampler.on_finishing_transaction(state, 'txn')
76
78
 
77
79
  agent.service.connect
78
80
  agent.send(:harvest_and_send_slowest_sql)
@@ -14,7 +14,7 @@ DependencyDetection.items.each do |item|
14
14
  enable_everyone["disable_#{item.name}".to_sym] = false
15
15
  end
16
16
  end
17
- NewRelic::Agent.config.apply_config(enable_everyone)
17
+ NewRelic::Agent.config.add_config_for_testing(enable_everyone)
18
18
 
19
19
  # Run dependency detection again!
20
20
  DependencyDetection.detect!
@@ -19,9 +19,13 @@ class ServiceTimeoutTest < Minitest::Test
19
19
  }
20
20
  end
21
21
 
22
+ def teardown
23
+ NewRelic::Agent.config.reset_to_defaults
24
+ end
25
+
22
26
  def test_service_timeout
23
27
  server = NewRelic::Control::Server.new('localhost',@port,'127.0.0.1')
24
- NewRelic::Agent.config.apply_config(:timeout => 0.1)
28
+ NewRelic::Agent.config.add_config_for_testing(:timeout => 0.1)
25
29
 
26
30
  service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
27
31
 
@@ -23,9 +23,10 @@ class TransactionIgnoringTest < Minitest::Test
23
23
 
24
24
  def trigger_transaction_with_slow_sql(txn_name)
25
25
  TestWidget.new.run_transaction(txn_name) do
26
+ state = NewRelic::Agent::TransactionState.tl_get
26
27
  NewRelic::Agent.instance.sql_sampler.notice_sql("select * from test",
27
28
  "Database/test/select",
28
- nil, 1.5)
29
+ nil, 1.5, state)
29
30
  end
30
31
  end
31
32
 
@@ -32,7 +32,7 @@ class XraySessionsTest < Minitest::Test
32
32
  end
33
33
 
34
34
  def test_tags_transaction_traces_with_xray_id
35
- session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
35
+ session = build_xray_session('key_transaction_name' => 'Controller/Middleware/Rack/A')
36
36
  with_xray_sessions(session) do
37
37
  5.times { get '/?transaction_name=A' }
38
38
  trigger_harvest
@@ -43,12 +43,12 @@ class XraySessionsTest < Minitest::Test
43
43
 
44
44
  traces = posts.first.samples
45
45
  assert_equal(5, traces.size)
46
- assert traces.all? { |t| t.metric_name == 'Controller/Rack/A' }
46
+ assert traces.all? { |t| t.metric_name == 'Controller/Middleware/Rack/A' }
47
47
  assert traces.all? { |t| t.xray_id == session['x_ray_id'] }
48
48
  end
49
49
 
50
50
  def test_does_not_collect_traces_for_non_xrayed_transactions
51
- session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
51
+ session = build_xray_session('key_transaction_name' => 'Controller/Middleware/Rack/A')
52
52
  with_xray_sessions(session) do
53
53
  get '/?transaction_name=OtherThing'
54
54
  get '/?transaction_name=A'
@@ -63,8 +63,8 @@ class XraySessionsTest < Minitest::Test
63
63
  end
64
64
 
65
65
  def test_gathers_transaction_traces_from_multiple_concurrent_xray_sessions
66
- sessionA = build_xray_session('x_ray_id' => 12, 'key_transaction_name' => 'Controller/Rack/A')
67
- sessionB = build_xray_session('x_ray_id' => 13, 'key_transaction_name' => 'Controller/Rack/B')
66
+ sessionA = build_xray_session('x_ray_id' => 12, 'key_transaction_name' => 'Controller/Middleware/Rack/A')
67
+ sessionB = build_xray_session('x_ray_id' => 13, 'key_transaction_name' => 'Controller/Middleware/Rack/B')
68
68
 
69
69
  with_xray_sessions(sessionA, sessionB) do
70
70
  2.times do
@@ -80,14 +80,14 @@ class XraySessionsTest < Minitest::Test
80
80
  traces = posts.first.samples
81
81
  assert_equal(4, traces.size)
82
82
 
83
- tracesA = traces.select { |t| t.metric_name == 'Controller/Rack/A' }
84
- tracesB = traces.select { |t| t.metric_name == 'Controller/Rack/B' }
83
+ tracesA = traces.select { |t| t.metric_name == 'Controller/Middleware/Rack/A' }
84
+ tracesB = traces.select { |t| t.metric_name == 'Controller/Middleware/Rack/B' }
85
85
  assert_equal(2, tracesA.size, "Expected 2 traces for transaction A")
86
86
  assert_equal(2, tracesB.size, "Expected 2 traces for transaction B")
87
87
  end
88
88
 
89
89
  def test_gathers_thread_profiles
90
- session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
90
+ session = build_xray_session('key_transaction_name' => 'Controller/Middleware/Rack/A')
91
91
  with_xray_sessions(session) do
92
92
  wait_for_backtrace_service_poll
93
93
  get '/?transaction_name=A&sleep=1'
@@ -115,7 +115,7 @@ class XraySessionsTest < Minitest::Test
115
115
  defaults = {
116
116
  "x_ray_id" => next_xray_session_id,
117
117
  "xray_session_name" => "Test XRay Session",
118
- "key_transaction_name" => "Controller/Rack/Transaction",
118
+ "key_transaction_name" => "Controller/Middleware/Rack/Transaction",
119
119
  "requested_trace_count" => 10,
120
120
  "duration" => 100,
121
121
  "sample_period" => 0.1,
@@ -0,0 +1,26 @@
1
+ # Load DSL and Setup Up Stages
2
+ require 'capistrano/setup'
3
+
4
+ # Includes default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ # Includes tasks from other gems included in your Gemfile
8
+ #
9
+ # For documentation on these, see for example:
10
+ #
11
+ # https://github.com/capistrano/rvm
12
+ # https://github.com/capistrano/rbenv
13
+ # https://github.com/capistrano/chruby
14
+ # https://github.com/capistrano/bundler
15
+ # https://github.com/capistrano/rails
16
+ #
17
+ # require 'capistrano/rvm'
18
+ # require 'capistrano/rbenv'
19
+ # require 'capistrano/chruby'
20
+ # require 'capistrano/bundler'
21
+ # require 'capistrano/rails/assets'
22
+ # require 'capistrano/rails/migrations'
23
+ require 'new_relic/recipes'
24
+
25
+ # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
26
+ Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@@ -0,0 +1,18 @@
1
+ suite_condition("Capistrano 3 not supported in 1.8.7") do
2
+ RUBY_VERSION != '1.8.7'
3
+ end
4
+
5
+ gemfile <<-RB
6
+ gem 'capistrano', '~>3.2.1'
7
+ gem 'rack'
8
+ RB
9
+
10
+ gemfile <<-RB
11
+ gem 'capistrano', '~>3.1.0'
12
+ gem 'rack'
13
+ RB
14
+
15
+ gemfile <<-RB
16
+ gem 'capistrano', '~>3.0.1'
17
+ gem 'rack'
18
+ RB
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ set :application, 'test'
6
+
7
+ # Since Capistrano 3 doesn't allow settings direct from command-line, add any
8
+ # settings we want to conditionally toggle from tests in the following manner.
9
+ set :newrelic_user, ENV["NEWRELIC_USER"] if ENV["NEWRELIC_USER"]
10
+ set :newrelic_appname, ENV["NEWRELIC_APPNAME"] if ENV["NEWRELIC_APPNAME"]
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ role :app, %w{deploy@example.com}
6
+ role :web, %w{deploy@example.com}
7
+ role :db, %w{deploy@example.com}
8
+
9
+ server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
@@ -0,0 +1,21 @@
1
+ ---
2
+ production:
3
+ error_collector:
4
+ enabled: true
5
+ apdex_t: 0.5
6
+ ssl: false
7
+ agent_enabled: true
8
+ monitor_mode: true
9
+ license_key: bootstrap_newrelic_admin_license_key_000
10
+ developer_mode: false
11
+ app_name: test
12
+ host: 127.0.0.1
13
+ api_host: 127.0.0.1
14
+ api_port: <%= ENV["FAKE_RPM_SITE_PORT"] %>
15
+ transaction_tracer:
16
+ record_sql: obfuscated
17
+ enabled: true
18
+ stack_trace_threshold: 0.5
19
+ transaction_threshold: 1.0
20
+ capture_params: false
21
+ disable_serialization: false
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ require 'fake_rpm_site'
6
+ require 'multiverse_helpers'
7
+
8
+ class DeploymentTest < Minitest::Test
9
+ def setup
10
+ $rpm_site ||= NewRelic::FakeRpmSite.new
11
+ $rpm_site.reset
12
+ $rpm_site.run
13
+ end
14
+
15
+ def test_deploys_to_configured_application
16
+ cap_it
17
+ assert_deployment_value("application_id", "test")
18
+ end
19
+
20
+ def test_deploys_with_commandline_parameter
21
+ # Capistrano 3 doesn't provide built-in commandline params -> settings
22
+ # We wire our own up via ENV to test setting out setting custom values
23
+ env = {
24
+ 'NEWRELIC_USER' => "someone",
25
+ 'NEWRELIC_APPNAME' => "somewhere"
26
+ }
27
+
28
+ cap_it(env)
29
+
30
+ assert_deployment_value("user", "someone")
31
+ assert_deployment_value("application_id", "somewhere")
32
+ end
33
+
34
+ def assert_deployment_value(key, value)
35
+ assert_equal(1, $rpm_site.requests.count)
36
+ assert_equal(value, $rpm_site.requests.first["deployment"][key])
37
+ end
38
+
39
+ def cap_it(custom_env={})
40
+ cmd = "cap production newrelic:notice_deployment"
41
+ default_env = { 'FAKE_RPM_SITE_PORT' => $rpm_site.port.to_s }
42
+ output = with_environment(default_env.merge(custom_env)) do
43
+ `#{cmd}`
44
+ end
45
+ assert $?.success?, "cap command '#{cmd}' failed with output: #{output}"
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ require 'new_relic/recipes'
2
+
3
+ load 'deploy'
4
+ load 'config/deploy'
@@ -0,0 +1,4 @@
1
+ gemfile <<-RB
2
+ gem 'capistrano', '~>2.15.5'
3
+ gem 'rack'
4
+ RB
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ # # This file is distributed under New Relic's license terms.
3
+ # # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ require 'bundler/capistrano'
6
+
7
+ set :application, "new_relic_capistrano"
8
+ set :repository, "~/new_relic_capistrano"
9
+ set :current_path, ""
10
+ set :newrelic_license_key, "bootstrap_newrelic_admin_license_key_000"
11
+ set :newrelic_rails_env, "development"
12
+
13
+ set :scm, :none
14
+
15
+ role :web, "localhost"
16
+ role :app, "localhost"
17
+ role :db, "localhost"
18
+
19
+ set :use_sudo, false
@@ -0,0 +1,21 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ enabled: true
5
+ apdex_t: 0.5
6
+ ssl: false
7
+ agent_enabled: true
8
+ monitor_mode: true
9
+ license_key: bootstrap_newrelic_admin_license_key_000
10
+ developer_mode: false
11
+ app_name: test
12
+ host: 127.0.0.1
13
+ api_host: 127.0.0.1
14
+ api_port: <%= ENV["FAKE_RPM_SITE_PORT"] %>
15
+ transaction_tracer:
16
+ record_sql: obfuscated
17
+ enabled: true
18
+ stack_trace_threshold: 0.5
19
+ transaction_threshold: 1.0
20
+ capture_params: false
21
+ disable_serialization: false
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ require 'fake_rpm_site'
6
+ require 'multiverse_helpers'
7
+
8
+ class DeploymentTest < Minitest::Test
9
+ def setup
10
+ $rpm_site ||= NewRelic::FakeRpmSite.new
11
+ $rpm_site.reset
12
+ $rpm_site.run
13
+ end
14
+
15
+ def test_deploys_to_configured_application
16
+ cap_it
17
+ assert_deployment_value("application_id", "test")
18
+ end
19
+
20
+ def test_deploys_with_commandline_parameter
21
+ cap_it("-s newrelic_user=someone -s newrelic_appname=somewhere")
22
+ assert_deployment_value("user", "someone")
23
+ assert_deployment_value("application_id", "somewhere")
24
+ end
25
+
26
+ def assert_deployment_value(key, value)
27
+ assert_equal(1, $rpm_site.requests.count)
28
+ assert_equal(value, $rpm_site.requests.first["deployment"][key])
29
+ end
30
+
31
+ def cap_it(options="")
32
+ cmd = "cap newrelic:notice_deployment #{options}"
33
+ output = with_environment('FAKE_RPM_SITE_PORT' => $rpm_site.port.to_s) do
34
+ `#{cmd}`
35
+ end
36
+ assert $?.success?, "cap command '#{cmd}' failed with output: #{output}"
37
+ end
38
+ end
@@ -3,9 +3,12 @@ suite_condition("Curb is not useful on JRuby") do
3
3
  end
4
4
 
5
5
  gemfile <<-RB
6
- gem 'curb', '0.8.1'
6
+ gem 'curb', '~> 0.8.4'
7
7
  gem 'rack'
8
8
  gem 'json', :platforms => [:rbx, :mri_18]
9
+
10
+ # We try translating URIs through Addressable if it's there, so test with it.
11
+ gem 'addressable', :require => 'addressable/uri'
9
12
  RB
10
13
 
11
14
  gemfile <<-RB
@@ -13,3 +16,9 @@ gemfile <<-RB
13
16
  gem 'rack'
14
17
  gem 'json', :platforms => [:rbx, :mri_18]
15
18
  RB
19
+
20
+ gemfile <<-RB
21
+ gem 'curb', '0.8.1'
22
+ gem 'rack'
23
+ gem 'json', :platforms => [:rbx, :mri_18]
24
+ RB