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
@@ -3,7 +3,6 @@ development:
3
3
  browser_monitoring:
4
4
  auto_instrument: true
5
5
  error_collector:
6
- capture_source: true
7
6
  enabled: true
8
7
  apdex_t: 0.5
9
8
  ssl: false
@@ -3,7 +3,6 @@ development:
3
3
  browser_monitoring:
4
4
  auto_instrument: true
5
5
  error_collector:
6
- capture_source: true
7
6
  enabled: true
8
7
  apdex_t: 0.5
9
8
  ssl: false
@@ -26,7 +26,7 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
26
26
 
27
27
  @test_config = { :developer_mode => true }
28
28
  NewRelic::Agent.reset_config
29
- NewRelic::Agent.config.apply_config(@test_config)
29
+ NewRelic::Agent.config.add_config_for_testing(@test_config)
30
30
  end
31
31
 
32
32
  def teardown
@@ -190,7 +190,7 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
190
190
 
191
191
  def test_connect_gets_config
192
192
  NewRelic::Agent.manual_start
193
- NewRelic::Agent::Agent.instance.service = default_service(
193
+ NewRelic::Agent.instance.service = default_service(
194
194
  :connect => {'agent_run_id' => 23, 'config' => 'a lot'})
195
195
 
196
196
  response = NewRelic::Agent.agent.connect_to_server
@@ -268,20 +268,13 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
268
268
  finish_setup(:boo => "boo")
269
269
  finish_setup(:hoo => true)
270
270
 
271
- assert_equal 1, server_layers.length
272
-
273
271
  assert NewRelic::Agent.config[:hoo]
274
272
  assert_nil NewRelic::Agent.config[:boo]
275
273
  end
276
274
 
277
- def server_layers
278
- stack = NewRelic::Agent.config.config_stack
279
- stack.select{|layer| layer.class == NewRelic::Agent::Configuration::ServerSource}
280
- end
281
-
282
275
  def test_logging_collector_messages
283
276
  NewRelic::Agent.manual_start
284
- NewRelic::Agent::Agent.instance.service = default_service(
277
+ NewRelic::Agent.instance.service = default_service(
285
278
  :connect => {
286
279
  'messages' => [{ 'message' => 'beep boop', 'level' => 'INFO' },
287
280
  { 'message' => 'ha cha cha', 'level' => 'WARN' }]
@@ -25,11 +25,17 @@ class AgentLoggerTest < Minitest::Test
25
25
  LEVELS = [:fatal, :error, :warn, :info, :debug]
26
26
 
27
27
  def setup
28
- NewRelic::Agent.config.apply_config(:log_file_path => "log/",
29
- :log_file_name => "testlog.log",
30
- :log_level => :info)
28
+ NewRelic::Agent.config.add_config_for_testing(
29
+ :log_file_path => "log/",
30
+ :log_file_name => "testlog.log",
31
+ :log_level => :info)
31
32
  end
32
33
 
34
+ def teardown
35
+ NewRelic::Agent.config.reset_to_defaults
36
+ end
37
+
38
+
33
39
  #
34
40
  # Tests
35
41
  #
@@ -97,10 +103,22 @@ class AgentLoggerTest < Minitest::Test
97
103
  end
98
104
  end
99
105
 
106
+ def test_consider_null_logger_a_startup_logger
107
+ with_config(:agent_enabled => false) do
108
+ logger = NewRelic::Agent::AgentLogger.new
109
+ assert logger.is_startup_logger?
110
+ end
111
+ end
112
+
113
+ def test_consider_any_other_logger_not_a_startup_logger
114
+ logger = NewRelic::Agent::AgentLogger.new
115
+ refute logger.is_startup_logger?
116
+ end
117
+
100
118
  def test_does_not_touch_dev_null
101
119
  Logger.expects(:new).with('/dev/null').never
102
120
  with_config(:agent_enabled => false) do
103
- logger = NewRelic::Agent::AgentLogger.new
121
+ NewRelic::Agent::AgentLogger.new
104
122
  end
105
123
  end
106
124
 
@@ -120,7 +138,7 @@ class AgentLoggerTest < Minitest::Test
120
138
  override_logger = Logger.new( $stderr )
121
139
  override_logger.level = Logger::FATAL
122
140
 
123
- logger = NewRelic::Agent::AgentLogger.new("", override_logger)
141
+ NewRelic::Agent::AgentLogger.new("", override_logger)
124
142
 
125
143
  assert_equal Logger::DEBUG, override_logger.level
126
144
  end
@@ -156,7 +174,7 @@ class AgentLoggerTest < Minitest::Test
156
174
  ::NewRelic::Agent::StartupLogger.instance.send(level, "boo!")
157
175
  end
158
176
 
159
- logger = create_basic_logger
177
+ create_basic_logger
160
178
 
161
179
  assert_logged(/FATAL/,
162
180
  /ERROR/,
@@ -17,11 +17,11 @@ module NewRelic
17
17
  @agent.stubs(:start_worker_thread)
18
18
 
19
19
  @config = { :license_key => "a" * 40 }
20
- NewRelic::Agent.config.apply_config(@config)
20
+ NewRelic::Agent.config.add_config_for_testing(@config)
21
21
  end
22
22
 
23
23
  def teardown
24
- NewRelic::Agent.config.remove_config(@config)
24
+ NewRelic::Agent.config.reset_to_defaults
25
25
  end
26
26
 
27
27
  def test_after_fork_reporting_to_channel
@@ -106,7 +106,7 @@ module NewRelic
106
106
 
107
107
  def test_transmit_data_should_transmit
108
108
  @agent.service.expects(:metric_data).at_least_once
109
- @agent.stats_engine.record_metrics(['foo'], 12)
109
+ @agent.stats_engine.tl_record_unscoped_metrics(['foo'], 12)
110
110
  @agent.instance_eval { transmit_data }
111
111
  end
112
112
 
@@ -545,19 +545,18 @@ module NewRelic
545
545
 
546
546
  def test_revert_to_default_configuration_removes_manual_and_server_source
547
547
  manual_source = NewRelic::Agent::Configuration::ManualSource.new(:manual => "source")
548
- Agent.config.apply_config(manual_source)
548
+ Agent.config.replace_or_add_config(manual_source)
549
549
 
550
550
  server_config = NewRelic::Agent::Configuration::ServerSource.new({})
551
- Agent.config.apply_config(server_config, 1)
552
-
553
- config_classes = NewRelic::Agent.config.config_stack.map(&:class)
551
+ Agent.config.replace_or_add_config(server_config)
554
552
 
553
+ config_classes = NewRelic::Agent.config.config_classes_for_testing
555
554
  assert_includes config_classes, NewRelic::Agent::Configuration::ManualSource
556
555
  assert_includes config_classes, NewRelic::Agent::Configuration::ServerSource
557
556
 
558
557
  @agent.revert_to_default_configuration
559
558
 
560
- config_classes = NewRelic::Agent.config.config_stack.map(&:class)
559
+ config_classes = NewRelic::Agent.config.config_classes_for_testing
561
560
  assert !config_classes.include?(NewRelic::Agent::Configuration::ManualSource)
562
561
  assert !config_classes.include?(NewRelic::Agent::Configuration::ServerSource)
563
562
  end
@@ -53,7 +53,7 @@ class NewRelic::Agent::AgentTestController < NewRelic::Agent::SuperclassControll
53
53
  raise "error in action"
54
54
  end
55
55
  def entry_action
56
- perform_action_with_newrelic_trace('internal_action') do
56
+ perform_action_with_newrelic_trace(:name => 'internal_action') do
57
57
  internal_action
58
58
  end
59
59
  end
@@ -71,7 +71,7 @@ class NewRelic::Agent::AgentTestController < NewRelic::Agent::SuperclassControll
71
71
  @@headers_to_add = nil
72
72
  end
73
73
 
74
- def newrelic_request_headers
74
+ def newrelic_request_headers(_)
75
75
  @@headers_to_add ||= {}
76
76
  end
77
77
 
@@ -8,7 +8,7 @@ require 'new_relic/agent/null_logger'
8
8
 
9
9
  class AuditLoggerTest < Minitest::Test
10
10
  def setup
11
- NewRelic::Agent.config.apply_config(:'audit_log.enabled' => true)
11
+ NewRelic::Agent.config.add_config_for_testing(:'audit_log.enabled' => true)
12
12
 
13
13
  @uri = "http://really.notreal"
14
14
  @marshaller = NewRelic::Agent::NewRelicService::Marshaller.new
@@ -21,6 +21,10 @@ class AuditLoggerTest < Minitest::Test
21
21
  }
22
22
  end
23
23
 
24
+ def teardown
25
+ NewRelic::Agent.config.reset_to_defaults
26
+ end
27
+
24
28
  def setup_fake_logger
25
29
  @fakelog = StringIO.new
26
30
  @logger = NewRelic::Agent::AuditLogger.new
@@ -91,7 +91,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
91
91
  end
92
92
 
93
93
  def test_finishing_without_starting_doesnt_raise
94
- NewRelic::Agent::TransactionState.clear
94
+ NewRelic::Agent::TransactionState.tl_clear_for_testing
95
95
  NewRelic::Agent::BusyCalculator.dispatcher_finish
96
96
  end
97
97
 
@@ -15,12 +15,15 @@ module NewRelic::Agent::Configuration
15
15
  @manager = NewRelic::Agent.config
16
16
  end
17
17
 
18
+ def teardown
19
+ @manager.reset_to_defaults
20
+ end
21
+
18
22
  def test_should_use_indifferent_access
19
23
  config = NewRelic::Agent::Configuration::DottedHash.new('string' => 'string', :symbol => 'symbol')
20
- @manager.apply_config(config)
24
+ @manager.add_config_for_testing(config)
21
25
  assert_equal 'string', @manager[:string]
22
26
  assert_equal 'symbol', @manager['symbol']
23
- @manager.remove_config(config)
24
27
  end
25
28
 
26
29
  def test_should_apply_config_sources_in_order
@@ -29,35 +32,40 @@ module NewRelic::Agent::Configuration
29
32
  :bar => 'default bar',
30
33
  :baz => 'default baz'
31
34
  }
32
- @manager.apply_config(config0)
35
+ @manager.add_config_for_testing(config0)
33
36
  config1 = { :foo => 'real foo' }
34
- @manager.apply_config(config1)
37
+ @manager.add_config_for_testing(config1)
35
38
  config2 = { :foo => 'wrong foo', :bar => 'real bar' }
36
- @manager.apply_config(config2, 1)
39
+ @manager.add_config_for_testing(config2, 1)
37
40
 
38
- assert_equal 'real foo', @manager['foo']
39
- assert_equal 'real bar', @manager['bar']
41
+ assert_equal 'real foo' , @manager['foo']
42
+ assert_equal 'real bar' , @manager['bar']
40
43
  assert_equal 'default baz', @manager['baz']
44
+ end
41
45
 
42
- @manager.remove_config(config0)
43
- @manager.remove_config(config1)
44
- @manager.remove_config(config2)
46
+ def test_sources_applied_in_correct_order
47
+ # in order of precedence
48
+ server_source = ServerSource.new(:foo => 'foo' )
49
+ manual_source = ManualSource.new(:foo => 'bad' , :bar => 'bar')
50
+
51
+ # load them out of order, just to prove that load order
52
+ # doesn't determine precedence
53
+ @manager.replace_or_add_config(manual_source)
54
+ @manager.replace_or_add_config(server_source)
55
+
56
+ assert_equal 'foo', @manager['foo']
57
+ assert_equal 'bar', @manager['bar']
45
58
  end
46
59
 
47
60
  def test_identifying_config_source
48
61
  hash_source = {:foo => 'foo', :bar => 'default'}
49
- @manager.apply_config(hash_source)
50
- test_source = TestSource.new
51
- test_source[:bar] = 'bar'
52
- test_source[:baz] = 'baz'
53
- @manager.apply_config(test_source)
62
+ @manager.add_config_for_testing(hash_source, 3)
63
+ test_source = ManualSource.new(:bar => 'bar', :baz => 'baz')
64
+ @manager.replace_or_add_config(test_source)
54
65
 
55
66
  refute_equal test_source, @manager.source(:foo)
56
67
  assert_equal test_source, @manager.source(:bar)
57
68
  assert_equal test_source, @manager.source(:baz)
58
-
59
- @manager.remove_config(hash_source)
60
- @manager.remove_config(test_source)
61
69
  end
62
70
 
63
71
  def test_callable_value_for_config_should_return_computed_value
@@ -66,13 +74,11 @@ module NewRelic::Agent::Configuration
66
74
  :simple_value => Proc.new { '666' },
67
75
  :reference => Proc.new { self['foo'] }
68
76
  }
69
- @manager.apply_config(source)
77
+ @manager.add_config_for_testing(source)
70
78
 
71
79
  assert_equal 'bar', @manager[:foo]
72
80
  assert_equal '666', @manager[:simple_value]
73
81
  assert_equal 'bar', @manager[:reference]
74
-
75
- @manager.remove_config(source)
76
82
  end
77
83
 
78
84
  def test_manager_resolves_nested_procs_from_default_source
@@ -81,18 +87,16 @@ module NewRelic::Agent::Configuration
81
87
  :bar => Proc.new { self[:baz] },
82
88
  :baz => Proc.new { 'Russian Nesting Dolls!' }
83
89
  }
84
- @manager.apply_config(source)
90
+ @manager.add_config_for_testing(source)
85
91
 
86
92
  source.keys.each do |key|
87
93
  assert_equal 'Russian Nesting Dolls!', @manager[key]
88
94
  end
89
-
90
- @manager.remove_config(source)
91
95
  end
92
96
 
93
97
  def test_should_not_apply_removed_sources
94
- test_source = TestSource.new
95
- @manager.apply_config(test_source)
98
+ test_source = { :test_config_accessor => true }
99
+ @manager.add_config_for_testing(test_source)
96
100
  @manager.remove_config(test_source)
97
101
 
98
102
  assert_equal nil, @manager['test_config_accessor']
@@ -101,7 +105,7 @@ module NewRelic::Agent::Configuration
101
105
  def test_should_read_license_key_from_env
102
106
  ENV['NEWRELIC_LICENSE_KEY'] = 'right'
103
107
  manager = NewRelic::Agent::Configuration::Manager.new
104
- manager.apply_config({:license_key => 'wrong'}, 1)
108
+ manager.add_config_for_testing({:license_key => 'wrong'}, 1)
105
109
 
106
110
  assert_equal 'right', manager['license_key']
107
111
  ensure
@@ -109,10 +113,12 @@ module NewRelic::Agent::Configuration
109
113
  end
110
114
 
111
115
  def test_config_values_should_be_memoized
112
- @manager.apply_config(:setting => 'correct value')
116
+ @manager.add_config_for_testing(:setting => 'correct value')
113
117
  assert_equal 'correct value', @manager[:setting]
114
118
 
115
- @manager.config_stack.unshift(:setting => 'wrong value')
119
+ @manager.instance_variable_get(:@configs_for_testing).
120
+ unshift(:setting => 'wrong value')
121
+
116
122
  assert_equal 'correct value', @manager[:setting]
117
123
  end
118
124
 
@@ -122,12 +128,12 @@ module NewRelic::Agent::Configuration
122
128
  end
123
129
 
124
130
  def test_to_collector_hash
125
- @manager.instance_variable_set(:@config_stack, [])
126
- @manager.apply_config(:eins => Proc.new { self[:one] })
127
- @manager.apply_config(:one => 1)
128
- @manager.apply_config(:two => 2)
129
- @manager.apply_config(:nested => {:madness => 'test'})
130
- @manager.apply_config(:'nested.madness' => 'test')
131
+ @manager.delete_all_configs_for_testing
132
+ @manager.add_config_for_testing(:eins => Proc.new { self[:one] })
133
+ @manager.add_config_for_testing(:one => 1)
134
+ @manager.add_config_for_testing(:two => 2)
135
+ @manager.add_config_for_testing(:nested => {:madness => 'test'})
136
+ @manager.add_config_for_testing(:'nested.madness' => 'test')
131
137
 
132
138
  assert_equal({ :eins => 1, :one => 1, :two => 2, :'nested.madness' => 'test' },
133
139
  @manager.to_collector_hash)
@@ -135,8 +141,8 @@ module NewRelic::Agent::Configuration
135
141
 
136
142
  # Necessary to keep the pruby marshaller happy
137
143
  def test_to_collector_hash_returns_bare_hash
138
- @manager.instance_variable_set(:@config_stack, [])
139
- @manager.apply_config(:eins => Proc.new { self[:one] })
144
+ @manager.delete_all_configs_for_testing
145
+ @manager.add_config_for_testing(:eins => Proc.new { self[:one] })
140
146
 
141
147
  assert_equal(::Hash, @manager.to_collector_hash.class)
142
148
  end
@@ -144,7 +150,7 @@ module NewRelic::Agent::Configuration
144
150
  def test_config_masks
145
151
  NewRelic::Agent::Configuration::MASK_DEFAULTS[:boo] = Proc.new { true }
146
152
 
147
- @manager.apply_config(:boo => 1)
153
+ @manager.add_config_for_testing(:boo => 1)
148
154
 
149
155
  assert_equal false, @manager.to_collector_hash.has_key?(:boo)
150
156
  end
@@ -152,7 +158,7 @@ module NewRelic::Agent::Configuration
152
158
  def test_config_masks_conditionally
153
159
  NewRelic::Agent::Configuration::MASK_DEFAULTS[:boo] = Proc.new { false }
154
160
 
155
- @manager.apply_config(:boo => 1)
161
+ @manager.add_config_for_testing(:boo => 1)
156
162
 
157
163
  assert @manager.to_collector_hash.has_key?(:boo)
158
164
  end
@@ -170,54 +176,53 @@ module NewRelic::Agent::Configuration
170
176
 
171
177
  def test_replacing_a_layer_by_class
172
178
  old_config = NewRelic::Agent::Configuration::ManualSource.new(:test => 'wrong')
173
- @manager.apply_config(old_config, 1)
179
+ @manager.replace_or_add_config(old_config)
174
180
  new_config = NewRelic::Agent::Configuration::ManualSource.new(:test => 'right')
175
181
  @manager.replace_or_add_config(new_config)
176
182
 
177
183
  assert_equal 'right', @manager[:test]
178
- assert_equal 3, @manager.config_stack.size
179
- assert_equal 1, @manager.config_stack.map{|s| s.class} \
180
- .index(NewRelic::Agent::Configuration::ManualSource)
184
+ assert_equal 3, @manager.num_configs_for_testing
181
185
  end
182
186
 
183
187
  def test_registering_a_callback
184
188
  observed_value = 'old'
185
- @manager.apply_config(:test => 'original')
189
+ @manager.add_config_for_testing(:test => 'original')
186
190
 
187
191
  @manager.register_callback(:test) do |value|
188
192
  observed_value = value
189
193
  end
190
194
  assert_equal 'original', observed_value
191
195
 
192
- @manager.apply_config(:test => 'new')
196
+ @manager.add_config_for_testing(:test => 'new')
193
197
  assert_equal 'new', observed_value
194
198
  end
195
199
 
196
200
  def test_callback_not_called_if_no_change
197
- @manager.apply_config(:test => true, :other => false)
201
+ state = nil
202
+ @manager.add_config_for_testing(:test => true, :other => false)
198
203
  @manager.register_callback(:test) do |value|
199
204
  state = 'wrong'
200
205
  end
201
206
  state = 'right'
202
207
  config = {:test => true}
203
- @manager.apply_config(config)
208
+ @manager.add_config_for_testing(config)
204
209
  @manager.remove_config(config)
205
210
 
206
211
  assert_equal 'right', state
207
212
  end
208
213
 
209
214
  def test_finished_configuring
210
- @manager.apply_config(:layer => "yo")
215
+ @manager.add_config_for_testing(:layer => "yo")
211
216
  assert_equal false, @manager.finished_configuring?
212
217
 
213
- @manager.apply_config(ServerSource.new({}))
218
+ @manager.replace_or_add_config(ServerSource.new({}))
214
219
  assert_equal true, @manager.finished_configuring?
215
220
  end
216
221
 
217
222
  def test_notifies_finished_configuring
218
223
  called = false
219
224
  NewRelic::Agent.instance.events.subscribe(:finished_configuring) { called = true }
220
- @manager.apply_config(ServerSource.new({}))
225
+ @manager.replace_or_add_config(ServerSource.new({}))
221
226
 
222
227
  assert_equal true, called
223
228
  end
@@ -226,27 +231,27 @@ module NewRelic::Agent::Configuration
226
231
  called = false
227
232
  NewRelic::Agent.instance.events.subscribe(:finished_configuring) { called = true }
228
233
 
229
- @manager.apply_config(:fake => "config")
230
- @manager.apply_config(ManualSource.new(:manual => true))
231
- @manager.apply_config(YamlSource.new("", "test"))
234
+ @manager.add_config_for_testing(:fake => "config")
235
+ @manager.replace_or_add_config(ManualSource.new(:manual => true))
236
+ @manager.replace_or_add_config(YamlSource.new("", "test"))
232
237
 
233
238
  assert_equal false, called
234
239
  end
235
240
 
236
241
  def test_high_security_enables_strip_exception_messages
237
- @manager.apply_config(:high_security => true)
242
+ @manager.add_config_for_testing(:high_security => true)
238
243
 
239
244
  assert_truthy @manager[:'strip_exception_messages.enabled']
240
245
  end
241
246
 
242
247
  def test_stripped_exceptions_whitelist_contains_only_valid_exception_classes
243
- @manager.apply_config(:'strip_exception_messages.whitelist' => 'LocalJumpError, NonExistentException')
248
+ @manager.add_config_for_testing(:'strip_exception_messages.whitelist' => 'LocalJumpError, NonExistentException')
244
249
  assert_equal [LocalJumpError], @manager.stripped_exceptions_whitelist
245
250
  end
246
251
 
247
252
  def test_should_log_when_applying
248
253
  log = with_array_logger(:debug) do
249
- @manager.apply_config(:test => "asdf")
254
+ @manager.add_config_for_testing(:test => "asdf")
250
255
  end
251
256
 
252
257
  log_lines = log.array
@@ -255,7 +260,7 @@ module NewRelic::Agent::Configuration
255
260
 
256
261
  def test_should_log_when_removing
257
262
  config = { :test => "asdf" }
258
- @manager.apply_config(config)
263
+ @manager.add_config_for_testing(config)
259
264
 
260
265
  log = with_array_logger(:debug) do
261
266
  @manager.remove_config(config)
@@ -265,18 +270,12 @@ module NewRelic::Agent::Configuration
265
270
  refute_match(/DEBUG.*asdf/, log_lines[0])
266
271
  end
267
272
 
268
- def test_config_stack_index_for
269
- assert_equal 0, @manager.config_stack_index_for(EnvironmentSource)
270
- assert_equal 1, @manager.config_stack_index_for(DefaultSource)
271
- assert_equal nil, @manager.config_stack_index_for(ManualSource)
272
- assert_equal nil, @manager.config_stack_index_for(ServerSource)
273
- assert_equal nil, @manager.config_stack_index_for(YamlSource)
274
- end
275
-
276
- class TestSource < ::Hash
277
- def test_config_accessor
278
- 'some value'
279
- end
273
+ def test_config_is_correctly_initialized
274
+ assert @manager.config_classes_for_testing.include?(EnvironmentSource)
275
+ assert @manager.config_classes_for_testing.include?(DefaultSource)
276
+ refute @manager.config_classes_for_testing.include?(ManualSource)
277
+ refute @manager.config_classes_for_testing.include?(ServerSource)
278
+ refute @manager.config_classes_for_testing.include?(YamlSource)
280
279
  end
281
280
  end
282
281
  end