ghazel-newrelic_rpm 3.4.0.2 → 3.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. data/.gitignore +21 -0
  2. data/.project +23 -0
  3. data/.travis.yml +9 -0
  4. data/CHANGELOG +180 -1
  5. data/GUIDELINES_FOR_CONTRIBUTING.md +73 -0
  6. data/Gemfile +16 -0
  7. data/InstallationNotes.md +15 -0
  8. data/LICENSE +1 -1
  9. data/{README.rdoc → README.md} +71 -55
  10. data/Rakefile +54 -0
  11. data/config.dot +290 -0
  12. data/config/database.yml +5 -0
  13. data/init.rb +38 -0
  14. data/lib/new_relic/agent.rb +9 -4
  15. data/lib/new_relic/agent/agent.rb +189 -230
  16. data/lib/new_relic/agent/beacon_configuration.rb +34 -48
  17. data/lib/new_relic/agent/browser_monitoring.rb +108 -61
  18. data/lib/new_relic/agent/busy_calculator.rb +12 -4
  19. data/lib/new_relic/agent/configuration.rb +49 -0
  20. data/lib/new_relic/agent/configuration/defaults.rb +89 -0
  21. data/lib/new_relic/agent/configuration/environment_source.rb +56 -0
  22. data/lib/new_relic/agent/configuration/manager.rb +116 -0
  23. data/lib/new_relic/agent/configuration/server_source.rb +27 -0
  24. data/lib/new_relic/agent/configuration/yaml_source.rb +61 -0
  25. data/lib/new_relic/agent/database.rb +37 -22
  26. data/lib/new_relic/agent/error_collector.rb +47 -43
  27. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -5
  28. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +27 -6
  29. data/lib/new_relic/agent/instrumentation/data_mapper.rb +2 -10
  30. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
  32. data/lib/new_relic/agent/instrumentation/metric_frame.rb +4 -14
  33. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +4 -18
  34. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +3 -3
  36. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
  37. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +5 -1
  38. data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
  39. data/lib/new_relic/agent/instrumentation/sinatra.rb +14 -10
  40. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +4 -3
  41. data/lib/new_relic/agent/method_tracer.rb +5 -1
  42. data/lib/new_relic/agent/new_relic_service.rb +231 -61
  43. data/lib/new_relic/agent/pipe_channel_manager.rb +37 -23
  44. data/lib/new_relic/agent/pipe_service.rb +5 -1
  45. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -5
  46. data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -2
  47. data/lib/new_relic/agent/sql_sampler.rb +44 -68
  48. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +40 -24
  49. data/lib/new_relic/agent/stats_engine/metric_stats.rb +89 -14
  50. data/lib/new_relic/agent/stats_engine/samplers.rb +7 -3
  51. data/lib/new_relic/agent/stats_engine/transactions.rb +19 -11
  52. data/lib/new_relic/agent/thread.rb +27 -0
  53. data/lib/new_relic/agent/thread_profiler.rb +295 -0
  54. data/lib/new_relic/agent/transaction_info.rb +24 -4
  55. data/lib/new_relic/agent/transaction_sample_builder.rb +11 -11
  56. data/lib/new_relic/agent/transaction_sampler.rb +51 -61
  57. data/lib/new_relic/agent/worker_loop.rb +29 -15
  58. data/lib/new_relic/collection_helper.rb +1 -1
  59. data/lib/new_relic/commands/deployments.rb +19 -10
  60. data/lib/new_relic/control.rb +0 -1
  61. data/lib/new_relic/control/class_methods.rb +2 -3
  62. data/lib/new_relic/control/frameworks/rails.rb +24 -18
  63. data/lib/new_relic/control/frameworks/rails3.rb +18 -1
  64. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  65. data/lib/new_relic/control/instance_methods.rb +36 -53
  66. data/lib/new_relic/control/logging_methods.rb +5 -23
  67. data/lib/new_relic/control/server_methods.rb +11 -13
  68. data/lib/new_relic/delayed_job_injection.rb +1 -1
  69. data/lib/new_relic/helper.rb +13 -0
  70. data/lib/new_relic/language_support.rb +19 -22
  71. data/lib/new_relic/local_environment.rb +2 -3
  72. data/lib/new_relic/metric_data.rb +10 -2
  73. data/lib/new_relic/metric_spec.rb +6 -2
  74. data/lib/new_relic/noticed_error.rb +24 -9
  75. data/lib/new_relic/rack.rb +4 -0
  76. data/lib/new_relic/rack/browser_monitoring.rb +28 -10
  77. data/lib/new_relic/rack/developer_mode.rb +3 -0
  78. data/lib/new_relic/rack/error_collector.rb +56 -0
  79. data/lib/new_relic/transaction_sample.rb +23 -13
  80. data/lib/new_relic/transaction_sample/segment.rb +13 -15
  81. data/lib/new_relic/version.rb +3 -3
  82. data/lib/tasks/tests.rake +8 -8
  83. data/newrelic.yml +15 -32
  84. data/newrelic_rpm.gemspec +158 -38
  85. data/newrelic_rpm.gemspec.erb +55 -0
  86. data/test/config/newrelic.yml +3 -2
  87. data/test/intentional_fail.rb +10 -0
  88. data/test/multiverse/.gitignore +10 -0
  89. data/test/multiverse/README.md +90 -0
  90. data/test/multiverse/Rakefile +17 -0
  91. data/test/multiverse/lib/multiverse/color.rb +13 -0
  92. data/test/multiverse/lib/multiverse/envfile.rb +66 -0
  93. data/test/multiverse/lib/multiverse/environment.rb +16 -0
  94. data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
  95. data/test/multiverse/lib/multiverse/runner.rb +44 -0
  96. data/test/multiverse/lib/multiverse/suite.rb +162 -0
  97. data/test/multiverse/script/run_one +3 -0
  98. data/test/multiverse/script/runner +9 -0
  99. data/test/multiverse/suites/active_record/Envfile +13 -0
  100. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
  101. data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
  102. data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
  103. data/test/multiverse/suites/agent_only/Envfile +3 -0
  104. data/test/multiverse/suites/agent_only/config/newrelic.yml +22 -0
  105. data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
  106. data/test/multiverse/suites/agent_only/marshaling_test.rb +109 -0
  107. data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
  108. data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
  109. data/test/multiverse/suites/agent_only/service_timeout_test.rb +29 -0
  110. data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
  111. data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
  112. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +80 -0
  113. data/test/multiverse/suites/datamapper/Envfile +8 -0
  114. data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
  115. data/test/multiverse/suites/datamapper/encoding_test.rb +36 -0
  116. data/test/multiverse/suites/monitor_mode_false/Envfile +2 -0
  117. data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +25 -0
  118. data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +29 -0
  119. data/test/multiverse/suites/no_load/Envfile +2 -0
  120. data/test/multiverse/suites/no_load/config/newrelic.yml +23 -0
  121. data/test/multiverse/suites/no_load/start_up_test.rb +14 -0
  122. data/test/multiverse/suites/rails_3_error_tracing/Envfile +15 -0
  123. data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +165 -0
  124. data/test/multiverse/suites/rails_3_error_tracing/error_tracing_test.rb +236 -0
  125. data/test/multiverse/suites/rails_3_gc/Envfile +8 -0
  126. data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +167 -0
  127. data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +92 -0
  128. data/test/multiverse/suites/rails_3_queue_time/Envfile +15 -0
  129. data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +165 -0
  130. data/test/multiverse/suites/rails_3_queue_time/queue_time_test.rb +75 -0
  131. data/test/multiverse/suites/rails_3_views/.gitignore +3 -0
  132. data/test/multiverse/suites/rails_3_views/Envfile +16 -0
  133. data/test/multiverse/suites/rails_3_views/app/views/foos/_foo.html.haml +1 -0
  134. data/test/multiverse/suites/rails_3_views/app/views/test/_a_partial.html.erb +1 -0
  135. data/test/multiverse/suites/rails_3_views/app/views/test/_mid_partial.html.erb +1 -0
  136. data/test/multiverse/suites/rails_3_views/app/views/test/_top_partial.html.erb +3 -0
  137. data/test/multiverse/suites/rails_3_views/app/views/test/deep_partial.html.erb +3 -0
  138. data/test/multiverse/suites/rails_3_views/app/views/test/haml_view.html.haml +6 -0
  139. data/test/multiverse/suites/rails_3_views/app/views/test/index.html.erb +4 -0
  140. data/test/multiverse/suites/rails_3_views/config/newrelic.yml +164 -0
  141. data/test/multiverse/suites/rails_3_views/view_instrumentation_test.rb +245 -0
  142. data/test/multiverse/suites/resque/Envfile +21 -0
  143. data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
  144. data/test/multiverse/suites/resque/dump.rdb +0 -0
  145. data/test/multiverse/suites/resque/instrumentation_test.rb +73 -0
  146. data/test/multiverse/suites/rum_auto_instrumentation/Envfile +4 -0
  147. data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +24 -0
  148. data/test/multiverse/suites/rum_auto_instrumentation/problem_response.html +422 -0
  149. data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +5000 -0
  150. data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +115 -0
  151. data/test/multiverse/suites/sinatra/Envfile +13 -0
  152. data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
  153. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +76 -0
  154. data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
  155. data/test/multiverse/test/multiverse_test.rb +55 -0
  156. data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
  157. data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
  158. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
  159. data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
  160. data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
  161. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
  162. data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
  163. data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
  164. data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
  165. data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
  166. data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
  167. data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
  168. data/test/new_relic/agent/agent/connect_test.rb +134 -164
  169. data/test/new_relic/agent/agent/start_test.rb +111 -81
  170. data/test/new_relic/agent/agent/start_worker_thread_test.rb +6 -33
  171. data/test/new_relic/agent/agent_test.rb +88 -9
  172. data/test/new_relic/agent/agent_test_controller.rb +1 -1
  173. data/test/new_relic/agent/agent_test_controller_test.rb +42 -10
  174. data/test/new_relic/agent/beacon_configuration_test.rb +63 -67
  175. data/test/new_relic/agent/browser_monitoring_test.rb +150 -79
  176. data/test/new_relic/agent/configuration/environment_source_test.rb +74 -0
  177. data/test/new_relic/agent/configuration/manager_test.rb +149 -0
  178. data/test/new_relic/agent/configuration/server_source_test.rb +45 -0
  179. data/test/new_relic/agent/configuration/yaml_source_test.rb +56 -0
  180. data/test/new_relic/agent/error_collector/notice_error_test.rb +63 -50
  181. data/test/new_relic/agent/error_collector_test.rb +22 -12
  182. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +21 -11
  183. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +6 -0
  184. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
  185. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +5 -5
  186. data/test/new_relic/agent/method_tracer_test.rb +6 -6
  187. data/test/new_relic/agent/mock_scope_listener.rb +3 -0
  188. data/test/new_relic/agent/new_relic_service_test.rb +208 -23
  189. data/test/new_relic/agent/pipe_channel_manager_test.rb +34 -17
  190. data/test/new_relic/agent/rpm_agent_test.rb +27 -23
  191. data/test/new_relic/agent/sql_sampler_test.rb +81 -56
  192. data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +3 -20
  193. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +12 -1
  194. data/test/new_relic/agent/stats_engine_test.rb +17 -8
  195. data/test/new_relic/agent/thread_profiler_test.rb +536 -0
  196. data/test/new_relic/agent/thread_test.rb +76 -0
  197. data/test/new_relic/agent/threaded_test.rb +65 -0
  198. data/test/new_relic/agent/transaction_info_test.rb +45 -4
  199. data/test/new_relic/agent/transaction_sample_builder_test.rb +8 -6
  200. data/test/new_relic/agent/transaction_sampler_test.rb +193 -204
  201. data/test/new_relic/agent/worker_loop_test.rb +20 -0
  202. data/test/new_relic/agent_test.rb +69 -41
  203. data/test/new_relic/collection_helper_test.rb +7 -8
  204. data/test/new_relic/command/deployments_test.rb +18 -2
  205. data/test/new_relic/control/frameworks/rails_test.rb +26 -0
  206. data/test/new_relic/control/logging_methods_test.rb +78 -52
  207. data/test/new_relic/control_test.rb +91 -129
  208. data/test/new_relic/fake_collector.rb +103 -31
  209. data/test/new_relic/fake_service.rb +8 -2
  210. data/test/new_relic/load_test.rb +13 -0
  211. data/test/new_relic/local_environment_test.rb +7 -10
  212. data/test/new_relic/metric_data_test.rb +45 -16
  213. data/test/new_relic/noticed_error_test.rb +14 -0
  214. data/test/new_relic/rack/browser_monitoring_test.rb +15 -9
  215. data/test/new_relic/rack/developer_mode_test.rb +13 -7
  216. data/test/new_relic/rack/error_collector_test.rb +74 -0
  217. data/test/new_relic/transaction_sample/segment_test.rb +23 -4
  218. data/test/new_relic/transaction_sample_test.rb +47 -2
  219. data/test/script/build_test_gem.sh +9 -3
  220. data/test/script/ci.sh +48 -21
  221. data/test/script/ci_multiverse_runner.sh +11 -11
  222. data/test/test_helper.rb +37 -18
  223. data/ui/helpers/developer_mode_helper.rb +21 -11
  224. data/ui/views/layouts/newrelic_default.rhtml +1 -0
  225. data/ui/views/newrelic/show_sample.rhtml +1 -1
  226. data/ui/views/newrelic/threads.rhtml +2 -10
  227. data/vendor/gems/metric_parser-0.1.0.pre1/.specification +116 -0
  228. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +7 -0
  229. metadata +132 -58
  230. data/lib/new_relic/control/configuration.rb +0 -206
  231. data/test/new_relic/control/configuration_test.rb +0 -77
@@ -0,0 +1,33 @@
1
+ # https://newrelic.atlassian.net/browse/RUBY-669
2
+
3
+ class PipeManagerTest < Test::Unit::TestCase
4
+ def setup
5
+ @listener = NewRelic::Agent::PipeChannelManager.listener
6
+ end
7
+
8
+ def teardown
9
+ @listener.stop
10
+ end
11
+
12
+ def test_old_pipes_are_cleaned_up_after_timeout
13
+ @listener.timeout = 1
14
+ NewRelic::Agent::PipeChannelManager.register_report_channel(:timeout_test)
15
+ sleep 2
16
+ @listener.start
17
+ sleep 0.5 # give the thread some time to start, and clean things up
18
+ assert_nil NewRelic::Agent::PipeChannelManager.channels[:timeout_test]
19
+ end
20
+
21
+ def test_pipes_are_regularly_checked_for_freshness
22
+ @listener.select_timeout = 1
23
+ @listener.timeout = 2
24
+ NewRelic::Agent::PipeChannelManager.register_report_channel(:select_test)
25
+
26
+ sleep 1.5
27
+ @listener.start
28
+ assert NewRelic::Agent::PipeChannelManager.channels[:select_test]
29
+
30
+ sleep 1.5
31
+ assert_nil NewRelic::Agent::PipeChannelManager.channels[:select_test]
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'socket'
2
+
3
+ class ServiceTimeoutTest < Test::Unit::TestCase
4
+ def setup
5
+ hk = TCPServer.new('127.0.0.1',8081)
6
+
7
+ Thread.new {
8
+ client = hk.accept
9
+ what = client.gets
10
+ sleep 4
11
+ client.close
12
+ Thread.exit
13
+ }
14
+ end
15
+
16
+ def test_service_timeout
17
+ server = NewRelic::Control::Server.new('localhost', 8081,'127.0.0.1')
18
+ NewRelic::Agent.config.apply_config(:timeout => 2)
19
+
20
+ service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
21
+
22
+ assert_raise Timeout::Error do
23
+ service.send('send_request',
24
+ :uri => '/agent_listener/8/bd0e1d52adade840f7ca727d29a86249e89a6f1c/get_redirect_host',
25
+ :encoding => 'UTF-8', :collector => server, :data => 'blah')
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,30 @@
1
+
2
+ require 'test/unit'
3
+ require 'newrelic_rpm'
4
+ require 'new_relic/agent/method_tracer'
5
+
6
+
7
+ class MethodInterrobangTest < Test::Unit::TestCase
8
+ include NewRelic::Agent::MethodTracer
9
+
10
+ def interrogate?
11
+ "say what?"
12
+ end
13
+
14
+ def mutate!
15
+ "oh yeah!"
16
+ end
17
+
18
+ add_method_tracer :interrogate?
19
+ add_method_tracer :mutate!
20
+
21
+ def test_alias_method_ending_in_question_mark
22
+ assert_respond_to self,:interrogate?
23
+ assert_equal "say what?", interrogate?
24
+ end
25
+
26
+ def test_aliase_method_ending_in_exclamation_makr
27
+ assert_respond_to self,:mutate!
28
+ assert_equal "oh yeah!",mutate!
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+
2
+ require 'test/unit'
3
+ require 'newrelic_rpm'
4
+ require 'new_relic/agent/instrumentation/controller_instrumentation'
5
+
6
+
7
+ class TransactionInterrobangTest < Test::Unit::TestCase
8
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
+
10
+ def interrogate?
11
+ "say what?"
12
+ end
13
+
14
+ def mutate!
15
+ "oh yeah!"
16
+ end
17
+
18
+ add_transaction_tracer :interrogate?
19
+ add_transaction_tracer :mutate!
20
+
21
+ def test_alias_method_ending_in_question_mark
22
+ assert_respond_to self,:interrogate?
23
+ assert_respond_to self, :interrogate_with_newrelic_transaction_trace?
24
+ assert_equal "say what?", interrogate?
25
+ end
26
+
27
+ def test_aliase_method_ending_in_exclamation_makr
28
+ assert_respond_to self,:mutate!
29
+ assert_respond_to self, :mutate_with_newrelic_transaction_trace!
30
+ assert_equal "oh yeah!",mutate!
31
+ end
32
+ end
@@ -0,0 +1,80 @@
1
+ # https://newrelic.atlassian.net/wiki/display/eng/Agent+Thread+Profiling
2
+ # https://newrelic.atlassian.net/browse/RUBY-917
3
+
4
+ if RUBY_VERSION >= '1.9'
5
+ class ThreadProfilingTest < Test::Unit::TestCase
6
+ def setup
7
+ NewRelic::Agent.manual_start(:'thread_profiler.enabled' => true)
8
+
9
+ @agent = NewRelic::Agent.instance
10
+ @thread_profiler = @agent.thread_profiler
11
+
12
+ $collector ||= NewRelic::FakeCollector.new
13
+ $collector.reset
14
+ $collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
15
+ $collector.mock['get_agent_commands'] = [200, {'return_value' => START_COMMAND}]
16
+ $collector.mock['agent_command_results'] = [200, {'return_value' => []}]
17
+ $collector.run
18
+ end
19
+
20
+ def teardown
21
+ $collector.reset
22
+ end
23
+
24
+ START_COMMAND = [[666,{
25
+ "name" => "start_profiler",
26
+ "arguments" => {
27
+ "profile_id" => -1,
28
+ "sample_period" => 0.01,
29
+ "duration" => 0.5,
30
+ "only_runnable_threads" => false,
31
+ "only_request_threads" => false,
32
+ "profile_agent_code" => false
33
+ }
34
+ }]]
35
+
36
+ STOP_COMMAND = [[666,{
37
+ "name" => "stop_profiler",
38
+ "arguments" => {
39
+ "profile_id" => -1,
40
+ "report_data" => true
41
+ }
42
+ }]]
43
+
44
+ # These are potentially fragile for being timing based
45
+ # START_COMMAND with 0.01 sampling and 0.5 duration expects to get
46
+ # roughly 50 polling cycles in. We check signficiantly less than that.
47
+
48
+ # STOP_COMMAND when immediately issued after a START_COMMAND is expected
49
+ # go only let a few cycles through, so we check less than 10
50
+
51
+ def test_thread_profiling
52
+ @agent.send(:check_for_agent_commands)
53
+ sleep(1)
54
+ NewRelic::Agent.shutdown
55
+
56
+ profile_data = $collector.calls_for('profile_data')[0]
57
+ assert_equal(666, profile_data[0])
58
+
59
+ poll_count = profile_data[1][0][3]
60
+ assert poll_count > 25, "Expected poll_count > 25, but was #{poll_count}"
61
+ end
62
+
63
+ def test_thread_profiling_can_stop
64
+ @agent.send(:check_for_agent_commands)
65
+
66
+ $collector.mock['get_agent_commands'] = [200, {'return_value' => STOP_COMMAND}]
67
+ @agent.send(:check_for_agent_commands)
68
+
69
+ sleep(0.1)
70
+ NewRelic::Agent.shutdown
71
+
72
+ profile_data = $collector.calls_for('profile_data')[0]
73
+ assert_equal(666, profile_data[0])
74
+
75
+ poll_count = profile_data[1][0][3]
76
+ assert poll_count < 10, "Expected poll_count < 10, but was #{poll_count}"
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,8 @@
1
+ suite_condition("Datamapper not supported in 1.8.6") do
2
+ RUBY_VERSION != '1.8.6'
3
+ end
4
+
5
+ gemfile <<-RB
6
+ gem 'datamapper'
7
+ RB
8
+
@@ -0,0 +1,22 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ capture_source: true
5
+ enabled: true
6
+ apdex_t: 0.5
7
+ ssl: false
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
+ port: 30303
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
+ log_level: debug
22
+ log_file_path: agent.log
@@ -0,0 +1,36 @@
1
+ # https://support.newrelic.com/tickets/2101
2
+ # https://github.com/newrelic/rpm/pull/42
3
+ # https://github.com/newrelic/rpm/pull/45
4
+ require 'test/unit'
5
+ require 'new_relic/agent/instrumentation/data_mapper'
6
+
7
+ class DatabaseAdapter
8
+ # we patch in here
9
+ def log(*args)
10
+ end
11
+ include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
12
+ end
13
+
14
+ class EncodingTest < Test::Unit::TestCase
15
+ # datamapper wants a msg object
16
+ MSG = Object.new
17
+ def MSG.query
18
+ # Contains invalid UTF8 Byte
19
+ q = "select ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000"
20
+ if RUBY_VERSION >= '1.9'
21
+ # Force the query to an invalid encoding
22
+ q.force_encoding 'UTF-8'
23
+ end
24
+ q
25
+ end
26
+ def MSG.duration; 1.0; end
27
+
28
+ def test_should_not_bomb_out_if_a_query_is_in_an_invalid_encoding
29
+ if RUBY_VERSION >= '1.9'
30
+ assert_equal false, MSG.query.valid_encoding?
31
+ end
32
+ db = DatabaseAdapter.new
33
+ db.send(:log, MSG)
34
+ end
35
+ end
36
+
@@ -0,0 +1,2 @@
1
+ self.newrelic_gemfile_options=(':require => false')
2
+
@@ -0,0 +1,25 @@
1
+ development:
2
+ browser_monitoring:
3
+ auto_instrument: true
4
+ error_collector:
5
+ capture_source: true
6
+ enabled: true
7
+ apdex_t: 0.5
8
+ ssl: false
9
+ monitor_mode: false
10
+ license_key: bootstrap_newrelic_admin_license_key_000
11
+ developer_mode: false
12
+ app_name: test
13
+ host: staging-collector.newrelic.com
14
+ api_host: 127.0.0.1
15
+ port: 80
16
+ transaction_tracer:
17
+ record_sql: obfuscated
18
+ enabled: true
19
+ stack_trace_threshold: 0.5
20
+ transaction_threshold: 1.0
21
+ capture_params: false
22
+ log_level: debug
23
+ disable_serialization: false
24
+ log_file_name: mon_mode_false_newrelic.log
25
+ agent_enabled: false
@@ -0,0 +1,29 @@
1
+ require 'resolv'
2
+
3
+ class NoDnsResolv < Test::Unit::TestCase
4
+ def test_should_no_resolve_hostname_when_agent_is_disabled
5
+ Resolv.class_eval do
6
+
7
+ if RUBY_VERSION == '1.9.2'
8
+ class_variable_set(:@@getaddress_called,false)
9
+ else
10
+ @@getaddress_called = false
11
+ end
12
+
13
+ def self.getaddress(host)
14
+ @@getaddress_called = true
15
+ puts "address for #{host} requested"
16
+ "127.0.0.1"
17
+ end
18
+
19
+ def self.getaddress_called?
20
+ @@getaddress_called
21
+ end
22
+ end
23
+
24
+ require 'newrelic_rpm'
25
+
26
+ assert(!Resolv.getaddress_called?,
27
+ 'called Resolv.getaddress when we should not have')
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ self.newrelic_gemfile_options=(':require => false')
2
+
@@ -0,0 +1,23 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ capture_source: true
5
+ enabled: true
6
+ apdex_t: 0.5
7
+ ssl: false
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
+ port: 30303
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
+ log_level: debug
22
+ #log_file_path: STDOUT
23
+ disable_serialization: false
@@ -0,0 +1,14 @@
1
+ # RUBY-839 make sure there is no STDOUT chatter
2
+ require 'open3'
3
+
4
+ class StartUpTest < Test::Unit::TestCase
5
+ def test_should_not_print_to_stdout_when_logging_available
6
+ ruby = 'require "newrelic_rpm"; NewRelic::Agent.manual_start; NewRelic::Agent.shutdown'
7
+ cmd = "bundle exec ruby -e '#{ruby}'"
8
+
9
+ sin, sout, serr = Open3.popen3(cmd)
10
+
11
+ jruby_noise = "JRuby limited openssl loaded. http://jruby.org/openssl\ngem install jruby-openssl for full support.\n"
12
+ assert_equal '', (sout.read + serr.read).sub(jruby_noise, '')
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ suite_condition("Rails 3 does not support 1.8.6") do
2
+ RUBY_VERSION != '1.8.6'
3
+ end
4
+
5
+ gemfile <<-RB
6
+ gem 'rails', '~>3.2.0'
7
+ RB
8
+
9
+ gemfile <<-RB
10
+ gem 'rails', '~>3.1.0'
11
+ RB
12
+
13
+ gemfile <<-RB
14
+ gem 'rails', '~>3.0.0'
15
+ RB
@@ -0,0 +1,165 @@
1
+ #
2
+ # This file configures the NewRelic RPM Agent, NewRelic RPM monitors Rails
3
+ # applications with deep visibility and low overhead. For more information,
4
+ # visit www.newrelic.com.
5
+ #
6
+ #
7
+ #
8
+ # here are the settings that are common to all environments
9
+ common: &default_settings
10
+
11
+ # ============================== LICENSE KEY ===============================
12
+ # You must specify the licence key associated with your New Relic account.
13
+ # This key binds your Agent's data to your account in the New Relic RPM service.
14
+
15
+ #license_key: 'bootstrap_newrelic_admin_license_key_000'
16
+ #host: localhost
17
+ #port: 3000
18
+
19
+ license_key: 'bd0e1d52adade840f7ca727d29a86249e89a6f1c'
20
+ host: localhost
21
+
22
+ # Agent Enabled
23
+ # Use this setting to force the agent to run or not run.
24
+ # Default is 'auto' which means the agent will install and run only if a
25
+ # valid dispatcher such as Mongrel is running. This prevents it from running
26
+ # with Rake or the console. Set to false to completely turn the agent off
27
+ # regardless of the other settings. Valid values are true, false and auto.
28
+ # agent_enabled: auto
29
+
30
+ # Application Name
31
+ # Set this to be the name of your application as you'd like it show up in RPM.
32
+ # RPM will then auto-map instances of your application into a RPM "application"
33
+ # on your home dashboard page. This setting does not prevent you from manually
34
+ # defining applications.
35
+ app_name: Rails 3 view test ap
36
+
37
+ # When 'enabled' is turned on, the agent collects performance data by inserting lightweight
38
+ # tracers on key methods inside the rails framework and asynchronously aggregating
39
+ # and reporting this performance data to the NewRelic RPM service at newrelic.com.
40
+ enabled: false
41
+
42
+ # The newrelic agent generates its own log file to keep its logging information
43
+ # separate from that of your application. Specify its log level here.
44
+ log_level: debug
45
+
46
+ # The newrelic agent communicates with the RPM service via http by default.
47
+ # If you want to communicate via https to increase security, then turn on
48
+ # SSL by setting this value to true. Note, this will result in increased
49
+ # CPU overhead to perform the encryption involved in SSL communication, but this
50
+ # work is done asynchronously to the threads that process your application code, so
51
+ # it should not impact response times.
52
+ ssl: false
53
+
54
+ # Set your application's Apdex threshold value with the 'apdex_t' setting, in seconds. The
55
+ # apdex_t value determines the buckets used to compute your overall Apdex score. Requests
56
+ # that take less than apdex_t seconds to process will be classified as Satisfying transactions;
57
+ # more than apdex_t seconds as Tolerating transactions; and more than four times the apdex_t
58
+ # value as Frustrating transactions. For more
59
+ # about the Apdex standard, see http://support.newrelic.com/faqs/general/apdex
60
+ apdex_t: 1.0
61
+
62
+
63
+ # Proxy settings for connecting to the RPM server.
64
+ #
65
+ # If a proxy is used, the host setting is required. Other settings are optional. Default
66
+ # port is 8080.
67
+ #
68
+ # proxy_host: hostname
69
+ # proxy_port: 8080
70
+ # proxy_user:
71
+ # proxy_pass:
72
+
73
+
74
+ # Tells transaction tracer and error collector (when enabled) whether or not to capture HTTP params.
75
+ # When true, the RoR filter_parameter_logging mechanism is used so that sensitive parameters are not recorded
76
+ capture_params: true
77
+
78
+
79
+ # Transaction tracer captures deep information about slow
80
+ # transactions and sends this to the RPM service once a minute. Included in the
81
+ # transaction is the exact call sequence of the transactions including any SQL statements
82
+ # issued.
83
+ transaction_tracer:
84
+
85
+ # Transaction tracer is enabled by default. Set this to false to turn it off. This feature
86
+ # is only available at the Silver and above product levels.
87
+ enabled: true
88
+
89
+ # Threshold in seconds for when to collect a transaction trace. When the response time of
90
+ # a controller action exceeds this threshold, a transaction trace will be recorded and sent
91
+ # to RPM. Valid values are any float value, or (default) "apdex_f", which will use the
92
+ # threshold for an dissatisfying Apdex controller action - four times the Apdex T value.
93
+ transaction_threshold: apdex_f
94
+
95
+ # When transaction tracer is on, SQL statements can optionally be recorded. The recorder
96
+ # has three modes, "off" which sends no SQL, "raw" which sends the SQL statement in its
97
+ # original form, and "obfuscated", which strips out numeric and string literals
98
+ record_sql: obfuscated
99
+
100
+ # Threshold in seconds for when to collect stack trace for a SQL call. In other words,
101
+ # when SQL statements exceed this threshold, then capture and send to RPM the current
102
+ # stack trace. This is helpful for pinpointing where long SQL calls originate from
103
+ stack_trace_threshold: 0.500
104
+
105
+ # Error collector captures information about uncaught exceptions and sends them to RPM for
106
+ # viewing
107
+ error_collector:
108
+
109
+ # Error collector is enabled by default. Set this to false to turn it off. This feature
110
+ # is only available at the Silver and above product levels
111
+ enabled: true
112
+
113
+ # Tells error collector whether or not to capture a source snippet around the place of the
114
+ # error when errors are View related.
115
+ capture_source: true
116
+
117
+ # To stop specific errors from reporting to RPM, set this property to comma separated
118
+ # values
119
+ #
120
+ #ignore_errors: ActionController::RoutingError, ...
121
+ ignore_errors: IgnoredError
122
+
123
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers won't run. Useful when you
124
+ # are using the agent to monitor an external resource
125
+ # disable_samplers: true
126
+
127
+ # override default settings based on your application's environment
128
+
129
+ # NOTE if your application has other named environments, you should
130
+ # provide newrelic conifguration settings for these enviromnents here.
131
+
132
+ development:
133
+ <<: *default_settings
134
+ # turn off communication to RPM service in development mode.
135
+ # NOTE: for initial evaluation purposes, you may want to temporarily turn
136
+ # the agent on in development mode.
137
+ enabled: true
138
+
139
+ # When running in Developer Mode, the New Relic Agent will present
140
+ # performance information on the last 100 transactions you have
141
+ # executed since starting the mongrel. to view this data, go to
142
+ # http://localhost:3000/newrelic
143
+ developer: true
144
+
145
+ test:
146
+ <<: *default_settings
147
+ # it almost never makes sense to turn on the agent when running unit, functional or
148
+ # integration tests or the like.
149
+ enabled: true
150
+ log_level: debug
151
+
152
+ # Turn on the agent in production for 24x7 monitoring. NewRelic testing shows
153
+ # an average performance impact of < 5 ms per transaction, you you can leave this on
154
+ # all the time without incurring any user-visible performance degredation.
155
+ production:
156
+ <<: *default_settings
157
+ enabled: true
158
+
159
+ # many applications have a staging environment which behaves identically to production.
160
+ # Support for that environment is provided here. By default, the staging environment has
161
+ # the agent turned on.
162
+ staging:
163
+ <<: *default_settings
164
+ enabled: true
165
+ app_name: My Application (Staging)