newrelic_rpm 2.9.9 → 2.10.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of newrelic_rpm might be problematic. Click here for more details.

Files changed (120) hide show
  1. data/CHANGELOG +117 -49
  2. data/bin/mongrel_rpm +2 -2
  3. data/install.rb +42 -33
  4. data/lib/new_relic/agent.rb +149 -39
  5. data/lib/new_relic/agent/agent.rb +139 -122
  6. data/lib/new_relic/agent/busy_calculator.rb +91 -0
  7. data/lib/new_relic/agent/collection_helper.rb +11 -2
  8. data/lib/new_relic/agent/error_collector.rb +33 -27
  9. data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +30 -26
  10. data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -0
  11. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +316 -105
  12. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +22 -0
  13. data/lib/new_relic/agent/instrumentation/memcache.rb +18 -12
  14. data/lib/new_relic/agent/instrumentation/merb/errors.rb +2 -1
  15. data/lib/new_relic/agent/instrumentation/metric_frame.rb +258 -0
  16. data/lib/new_relic/agent/instrumentation/net.rb +7 -11
  17. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +1 -1
  18. data/lib/new_relic/agent/instrumentation/rack.rb +109 -0
  19. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +6 -5
  20. data/lib/new_relic/agent/instrumentation/rails/errors.rb +7 -7
  21. data/lib/new_relic/agent/instrumentation/sinatra.rb +46 -0
  22. data/lib/new_relic/agent/method_tracer.rb +305 -150
  23. data/lib/new_relic/agent/sampler.rb +34 -0
  24. data/lib/new_relic/agent/samplers/cpu_sampler.rb +11 -1
  25. data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +37 -0
  26. data/lib/new_relic/agent/samplers/memory_sampler.rb +22 -10
  27. data/lib/new_relic/agent/samplers/object_sampler.rb +24 -0
  28. data/lib/new_relic/agent/shim_agent.rb +10 -0
  29. data/lib/new_relic/agent/stats_engine.rb +16 -278
  30. data/lib/new_relic/agent/stats_engine/metric_stats.rb +118 -0
  31. data/lib/new_relic/agent/stats_engine/samplers.rb +81 -0
  32. data/lib/new_relic/agent/stats_engine/transactions.rb +149 -0
  33. data/lib/new_relic/agent/transaction_sampler.rb +73 -67
  34. data/lib/new_relic/agent/worker_loop.rb +69 -68
  35. data/lib/new_relic/commands/deployments.rb +4 -6
  36. data/lib/new_relic/control.rb +121 -60
  37. data/lib/new_relic/control/external.rb +13 -0
  38. data/lib/new_relic/control/merb.rb +2 -0
  39. data/lib/new_relic/control/rails.rb +16 -6
  40. data/lib/new_relic/control/ruby.rb +8 -5
  41. data/lib/new_relic/control/sinatra.rb +18 -0
  42. data/lib/new_relic/delayed_job_injection.rb +25 -0
  43. data/lib/new_relic/histogram.rb +89 -0
  44. data/lib/new_relic/local_environment.rb +64 -30
  45. data/lib/new_relic/metric_data.rb +15 -6
  46. data/lib/new_relic/metric_parser.rb +14 -1
  47. data/lib/new_relic/metric_parser/active_record.rb +14 -0
  48. data/lib/new_relic/metric_parser/controller.rb +5 -2
  49. data/lib/new_relic/metric_parser/external.rb +50 -0
  50. data/lib/new_relic/metric_parser/other_transaction.rb +15 -0
  51. data/lib/new_relic/metric_parser/web_frontend.rb +14 -0
  52. data/lib/new_relic/metric_spec.rb +39 -20
  53. data/lib/new_relic/metrics.rb +9 -7
  54. data/lib/new_relic/noticed_error.rb +6 -8
  55. data/lib/new_relic/rack/metric_app.rb +5 -4
  56. data/lib/new_relic/rack/{newrelic.ru → mongrel_rpm.ru} +4 -4
  57. data/lib/new_relic/rack/newrelic.yml +1 -0
  58. data/lib/new_relic/{rack.rb → rack_app.rb} +0 -0
  59. data/lib/new_relic/recipes.rb +1 -1
  60. data/lib/new_relic/stats.rb +40 -26
  61. data/lib/new_relic/transaction_analysis.rb +5 -2
  62. data/lib/new_relic/transaction_sample.rb +134 -55
  63. data/lib/new_relic/version.rb +27 -20
  64. data/lib/new_relic_api.rb +67 -47
  65. data/lib/newrelic_rpm.rb +5 -5
  66. data/lib/tasks/tests.rake +2 -0
  67. data/newrelic.yml +69 -29
  68. data/test/active_record_fixtures.rb +2 -2
  69. data/test/config/newrelic.yml +4 -7
  70. data/test/config/test_control.rb +1 -2
  71. data/test/new_relic/agent/active_record_instrumentation_test.rb +115 -31
  72. data/test/new_relic/agent/agent_controller_test.rb +274 -0
  73. data/test/new_relic/agent/agent_test_controller.rb +42 -6
  74. data/test/new_relic/agent/busy_calculator_test.rb +79 -0
  75. data/test/new_relic/agent/collection_helper_test.rb +10 -3
  76. data/test/new_relic/agent/error_collector_test.rb +35 -17
  77. data/test/new_relic/agent/method_tracer_test.rb +60 -20
  78. data/test/new_relic/agent/metric_data_test.rb +2 -2
  79. data/test/new_relic/agent/metric_frame_test.rb +51 -0
  80. data/test/new_relic/agent/net_instrumentation_test.rb +77 -0
  81. data/test/new_relic/agent/{agent_test.rb → rpm_agent_test.rb} +26 -5
  82. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +79 -0
  83. data/test/new_relic/{samplers_test.rb → agent/stats_engine/samplers_test.rb} +23 -22
  84. data/test/new_relic/agent/{stats_engine_test.rb → stats_engine/stats_engine_test.rb} +19 -101
  85. data/test/new_relic/agent/task_instrumentation_test.rb +176 -0
  86. data/test/new_relic/agent/transaction_sample_builder_test.rb +2 -2
  87. data/test/new_relic/agent/transaction_sample_test.rb +53 -38
  88. data/test/new_relic/agent/transaction_sampler_test.rb +101 -33
  89. data/test/new_relic/agent/worker_loop_test.rb +16 -14
  90. data/test/new_relic/control_test.rb +26 -13
  91. data/test/new_relic/metric_parser_test.rb +31 -1
  92. data/test/new_relic/metric_spec_test.rb +2 -2
  93. data/test/new_relic/stats_test.rb +0 -8
  94. data/test/new_relic/version_number_test.rb +31 -1
  95. data/test/test_helper.rb +37 -1
  96. data/ui/controllers/newrelic_controller.rb +19 -11
  97. data/ui/helpers/google_pie_chart.rb +5 -11
  98. data/ui/helpers/newrelic_helper.rb +40 -35
  99. data/ui/views/layouts/newrelic_default.rhtml +7 -7
  100. data/ui/views/newrelic/_sample.rhtml +5 -1
  101. data/ui/views/newrelic/images/new-relic-rpm-desktop.gif +0 -0
  102. data/ui/views/newrelic/images/textmate.png +0 -0
  103. data/ui/views/newrelic/index.rhtml +13 -1
  104. data/ui/views/newrelic/show_sample.rhtml +5 -2
  105. data/ui/views/newrelic/stylesheets/style.css +54 -3
  106. metadata +65 -145
  107. data/Manifest +0 -143
  108. data/Rakefile +0 -22
  109. data/init.rb +0 -38
  110. data/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb +0 -127
  111. data/lib/new_relic/agent/instrumentation/error_instrumentation.rb +0 -14
  112. data/lib/new_relic/agent/instrumentation/merb/dispatcher.rb +0 -13
  113. data/lib/new_relic/agent/instrumentation/rails/dispatcher.rb +0 -38
  114. data/lib/new_relic/agent/patch_const_missing.rb +0 -125
  115. data/lib/new_relic/agent/samplers/mongrel_sampler.rb +0 -22
  116. data/lib/new_relic/metric_parser/database.rb +0 -23
  117. data/newrelic_rpm.gemspec +0 -35
  118. data/test/new_relic/agent/classloader_patch_test.rb +0 -56
  119. data/test/new_relic/agent/controller_test.rb +0 -107
  120. data/test/new_relic/agent/dispatcher_instrumentation_test.rb +0 -70
@@ -1,22 +0,0 @@
1
- module NewRelic::Agent::Samplers
2
- # NewRelic Instrumentation for Mongrel - tracks the queue length of the mongrel server.
3
- class MongrelSampler < NewRelic::Agent::Sampler
4
- def initialize
5
- super :mongrel
6
- end
7
- def queue_stats
8
- stats_engine.get_stats("Mongrel/Queue Length", false)
9
- end
10
- def poll
11
- mongrel = NewRelic::Control.instance.local_env.mongrel
12
- if mongrel
13
- # The mongrel workers list includes workers actively processing requests
14
- # so you need to subtract what appears to be the active workers from the total
15
- # number of workers to get the queue size.
16
- qsize = mongrel.workers.list.length - NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
17
- qsize = 0 if qsize < 0
18
- queue_stats.record_data_point qsize
19
- end
20
- end
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- class NewRelic::MetricParser::Database < NewRelic::MetricParser
2
- def is_database?; true; end
3
-
4
- def database
5
- segments[1]
6
- end
7
-
8
- def active_record_class
9
- segments[2].split(' ').first
10
- end
11
-
12
- def operation
13
- op = segments.last
14
- op_split = op.split(' ')
15
-
16
- return op if op == 'Join Table Columns'
17
- op_split.last
18
- end
19
-
20
- def developer_name
21
- (segments[2]) ? "#{segments[1]} - #{segments[2]}" : "#{segments[1]} - unknown"
22
- end
23
- end
@@ -1,35 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{newrelic_rpm}
5
- s.version = "2.9.9"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Bill Kayser"]
9
- s.date = %q{2009-12-14}
10
- s.description = %q{New Relic Ruby Performance Monitoring Agent}
11
- s.email = %q{bkayser@newrelic.com}
12
- s.executables = ["mongrel_rpm", "newrelic_cmd"]
13
- s.extra_rdoc_files = ["bin/mongrel_rpm", "bin/newrelic_cmd", "CHANGELOG", "lib/new_relic/agent/agent.rb", "lib/new_relic/agent/chained_call.rb", "lib/new_relic/agent/collection_helper.rb", "lib/new_relic/agent/error_collector.rb", "lib/new_relic/agent/instrumentation/active_merchant.rb", "lib/new_relic/agent/instrumentation/active_record_instrumentation.rb", "lib/new_relic/agent/instrumentation/controller_instrumentation.rb", "lib/new_relic/agent/instrumentation/data_mapper.rb", "lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb", "lib/new_relic/agent/instrumentation/error_instrumentation.rb", "lib/new_relic/agent/instrumentation/memcache.rb", "lib/new_relic/agent/instrumentation/merb/controller.rb", "lib/new_relic/agent/instrumentation/merb/dispatcher.rb", "lib/new_relic/agent/instrumentation/merb/errors.rb", "lib/new_relic/agent/instrumentation/net.rb", "lib/new_relic/agent/instrumentation/passenger_instrumentation.rb", "lib/new_relic/agent/instrumentation/rails/action_controller.rb", "lib/new_relic/agent/instrumentation/rails/action_web_service.rb", "lib/new_relic/agent/instrumentation/rails/dispatcher.rb", "lib/new_relic/agent/instrumentation/rails/errors.rb", "lib/new_relic/agent/method_tracer.rb", "lib/new_relic/agent/patch_const_missing.rb", "lib/new_relic/agent/sampler.rb", "lib/new_relic/agent/samplers/cpu_sampler.rb", "lib/new_relic/agent/samplers/memory_sampler.rb", "lib/new_relic/agent/samplers/mongrel_sampler.rb", "lib/new_relic/agent/shim_agent.rb", "lib/new_relic/agent/stats_engine.rb", "lib/new_relic/agent/transaction_sampler.rb", "lib/new_relic/agent/worker_loop.rb", "lib/new_relic/agent.rb", "lib/new_relic/commands/deployments.rb", "lib/new_relic/commands/new_relic_commands.rb", "lib/new_relic/control/merb.rb", "lib/new_relic/control/rails.rb", "lib/new_relic/control/ruby.rb", "lib/new_relic/control.rb", "lib/new_relic/local_environment.rb", "lib/new_relic/merbtasks.rb", "lib/new_relic/metric_data.rb", "lib/new_relic/metric_parser/action_mailer.rb", "lib/new_relic/metric_parser/active_merchant.rb", "lib/new_relic/metric_parser/active_record.rb", "lib/new_relic/metric_parser/controller.rb", "lib/new_relic/metric_parser/controller_cpu.rb", "lib/new_relic/metric_parser/database.rb", "lib/new_relic/metric_parser/errors.rb", "lib/new_relic/metric_parser/mem_cache.rb", "lib/new_relic/metric_parser/view.rb", "lib/new_relic/metric_parser/web_service.rb", "lib/new_relic/metric_parser.rb", "lib/new_relic/metric_spec.rb", "lib/new_relic/metrics.rb", "lib/new_relic/noticed_error.rb", "lib/new_relic/rack/metric_app.rb", "lib/new_relic/rack/newrelic.ru", "lib/new_relic/rack/newrelic.yml", "lib/new_relic/rack.rb", "lib/new_relic/recipes.rb", "lib/new_relic/stats.rb", "lib/new_relic/transaction_analysis.rb", "lib/new_relic/transaction_sample.rb", "lib/new_relic/version.rb", "lib/new_relic_api.rb", "lib/newrelic_rpm.rb", "lib/tasks/all.rb", "lib/tasks/install.rake", "lib/tasks/tests.rake", "LICENSE", "README.md"]
14
- s.files = ["bin/mongrel_rpm", "bin/newrelic_cmd", "cert/cacert.pem", "CHANGELOG", "init.rb", "install.rb", "lib/new_relic/agent/agent.rb", "lib/new_relic/agent/chained_call.rb", "lib/new_relic/agent/collection_helper.rb", "lib/new_relic/agent/error_collector.rb", "lib/new_relic/agent/instrumentation/active_merchant.rb", "lib/new_relic/agent/instrumentation/active_record_instrumentation.rb", "lib/new_relic/agent/instrumentation/controller_instrumentation.rb", "lib/new_relic/agent/instrumentation/data_mapper.rb", "lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb", "lib/new_relic/agent/instrumentation/error_instrumentation.rb", "lib/new_relic/agent/instrumentation/memcache.rb", "lib/new_relic/agent/instrumentation/merb/controller.rb", "lib/new_relic/agent/instrumentation/merb/dispatcher.rb", "lib/new_relic/agent/instrumentation/merb/errors.rb", "lib/new_relic/agent/instrumentation/net.rb", "lib/new_relic/agent/instrumentation/passenger_instrumentation.rb", "lib/new_relic/agent/instrumentation/rails/action_controller.rb", "lib/new_relic/agent/instrumentation/rails/action_web_service.rb", "lib/new_relic/agent/instrumentation/rails/dispatcher.rb", "lib/new_relic/agent/instrumentation/rails/errors.rb", "lib/new_relic/agent/method_tracer.rb", "lib/new_relic/agent/patch_const_missing.rb", "lib/new_relic/agent/sampler.rb", "lib/new_relic/agent/samplers/cpu_sampler.rb", "lib/new_relic/agent/samplers/memory_sampler.rb", "lib/new_relic/agent/samplers/mongrel_sampler.rb", "lib/new_relic/agent/shim_agent.rb", "lib/new_relic/agent/stats_engine.rb", "lib/new_relic/agent/transaction_sampler.rb", "lib/new_relic/agent/worker_loop.rb", "lib/new_relic/agent.rb", "lib/new_relic/commands/deployments.rb", "lib/new_relic/commands/new_relic_commands.rb", "lib/new_relic/control/merb.rb", "lib/new_relic/control/rails.rb", "lib/new_relic/control/ruby.rb", "lib/new_relic/control.rb", "lib/new_relic/local_environment.rb", "lib/new_relic/merbtasks.rb", "lib/new_relic/metric_data.rb", "lib/new_relic/metric_parser/action_mailer.rb", "lib/new_relic/metric_parser/active_merchant.rb", "lib/new_relic/metric_parser/active_record.rb", "lib/new_relic/metric_parser/controller.rb", "lib/new_relic/metric_parser/controller_cpu.rb", "lib/new_relic/metric_parser/database.rb", "lib/new_relic/metric_parser/errors.rb", "lib/new_relic/metric_parser/mem_cache.rb", "lib/new_relic/metric_parser/view.rb", "lib/new_relic/metric_parser/web_service.rb", "lib/new_relic/metric_parser.rb", "lib/new_relic/metric_spec.rb", "lib/new_relic/metrics.rb", "lib/new_relic/noticed_error.rb", "lib/new_relic/rack/metric_app.rb", "lib/new_relic/rack/newrelic.ru", "lib/new_relic/rack/newrelic.yml", "lib/new_relic/rack.rb", "lib/new_relic/recipes.rb", "lib/new_relic/stats.rb", "lib/new_relic/transaction_analysis.rb", "lib/new_relic/transaction_sample.rb", "lib/new_relic/version.rb", "lib/new_relic_api.rb", "lib/newrelic_rpm.rb", "lib/tasks/all.rb", "lib/tasks/install.rake", "lib/tasks/tests.rake", "LICENSE", "newrelic.yml", "Rakefile", "README.md", "recipes/newrelic.rb", "test/active_record_fixtures.rb", "test/config/newrelic.yml", "test/config/test_control.rb", "test/new_relic/agent/active_record_instrumentation_test.rb", "test/new_relic/agent/agent_test.rb", "test/new_relic/agent/agent_test_controller.rb", "test/new_relic/agent/classloader_patch_test.rb", "test/new_relic/agent/collection_helper_test.rb", "test/new_relic/agent/controller_test.rb", "test/new_relic/agent/dispatcher_instrumentation_test.rb", "test/new_relic/agent/error_collector_test.rb", "test/new_relic/agent/method_tracer_test.rb", "test/new_relic/agent/metric_data_test.rb", "test/new_relic/agent/mock_ar_connection.rb", "test/new_relic/agent/mock_scope_listener.rb", "test/new_relic/agent/stats_engine_test.rb", "test/new_relic/agent/testable_agent.rb", "test/new_relic/agent/transaction_sample_builder_test.rb", "test/new_relic/agent/transaction_sample_test.rb", "test/new_relic/agent/transaction_sampler_test.rb", "test/new_relic/agent/worker_loop_test.rb", "test/new_relic/control_test.rb", "test/new_relic/deployments_api_test.rb", "test/new_relic/environment_test.rb", "test/new_relic/metric_parser_test.rb", "test/new_relic/metric_spec_test.rb", "test/new_relic/samplers_test.rb", "test/new_relic/shim_agent_test.rb", "test/new_relic/stats_test.rb", "test/new_relic/version_number_test.rb", "test/test_helper.rb", "test/ui/newrelic_controller_test.rb", "test/ui/newrelic_helper_test.rb", "ui/controllers/newrelic_controller.rb", "ui/helpers/google_pie_chart.rb", "ui/helpers/newrelic_helper.rb", "ui/views/layouts/newrelic_default.rhtml", "ui/views/newrelic/_explain_plans.rhtml", "ui/views/newrelic/_sample.rhtml", "ui/views/newrelic/_segment.rhtml", "ui/views/newrelic/_segment_limit_message.rhtml", "ui/views/newrelic/_segment_row.rhtml", "ui/views/newrelic/_show_sample_detail.rhtml", "ui/views/newrelic/_show_sample_sql.rhtml", "ui/views/newrelic/_show_sample_summary.rhtml", "ui/views/newrelic/_sql_row.rhtml", "ui/views/newrelic/_stack_trace.rhtml", "ui/views/newrelic/_table.rhtml", "ui/views/newrelic/explain_sql.rhtml", "ui/views/newrelic/images/arrow-close.png", "ui/views/newrelic/images/arrow-open.png", "ui/views/newrelic/images/blue_bar.gif", "ui/views/newrelic/images/file_icon.png", "ui/views/newrelic/images/gray_bar.gif", "ui/views/newrelic/images/new_relic_rpm_desktop.gif", "ui/views/newrelic/index.rhtml", "ui/views/newrelic/javascript/prototype-scriptaculous.js", "ui/views/newrelic/javascript/transaction_sample.js", "ui/views/newrelic/sample_not_found.rhtml", "ui/views/newrelic/show_sample.rhtml", "ui/views/newrelic/show_source.rhtml", "ui/views/newrelic/stylesheets/style.css", "ui/views/newrelic/threads.rhtml", "Manifest", "newrelic_rpm.gemspec"]
15
- s.homepage = %q{http://www.newrelic.com}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Newrelic_rpm", "--main", "README.md"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{newrelic}
19
- s.rubygems_version = %q{1.3.5}
20
- s.summary = %q{New Relic Ruby Performance Monitoring Agent}
21
- s.test_files = ["test/config/test_control.rb", "test/new_relic/agent/active_record_instrumentation_test.rb", "test/new_relic/agent/agent_test.rb", "test/new_relic/agent/classloader_patch_test.rb", "test/new_relic/agent/collection_helper_test.rb", "test/new_relic/agent/controller_test.rb", "test/new_relic/agent/dispatcher_instrumentation_test.rb", "test/new_relic/agent/error_collector_test.rb", "test/new_relic/agent/method_tracer_test.rb", "test/new_relic/agent/metric_data_test.rb", "test/new_relic/agent/stats_engine_test.rb", "test/new_relic/agent/transaction_sample_builder_test.rb", "test/new_relic/agent/transaction_sample_test.rb", "test/new_relic/agent/transaction_sampler_test.rb", "test/new_relic/agent/worker_loop_test.rb", "test/new_relic/control_test.rb", "test/new_relic/deployments_api_test.rb", "test/new_relic/environment_test.rb", "test/new_relic/metric_parser_test.rb", "test/new_relic/metric_spec_test.rb", "test/new_relic/samplers_test.rb", "test/new_relic/shim_agent_test.rb", "test/new_relic/stats_test.rb", "test/new_relic/version_number_test.rb", "test/test_helper.rb", "test/ui/newrelic_controller_test.rb", "test/ui/newrelic_helper_test.rb"]
22
-
23
- if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
- s.specification_version = 3
26
-
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<echoe>, [">= 0"])
29
- else
30
- s.add_dependency(%q<echoe>, [">= 0"])
31
- end
32
- else
33
- s.add_dependency(%q<echoe>, [">= 0"])
34
- end
35
- end
@@ -1,56 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
2
-
3
- class ClassLoaderPatchTest < ActiveSupport::TestCase
4
-
5
- def test_const_undefined
6
- require 'new_relic/agent/patch_const_missing'
7
- ClassLoadingWatcher.background_thread = Thread.current
8
-
9
- # try loading some non-existent class
10
- NewRelic::Control.instance.log.expects(:error).at_least_once.with{|args| args =~ /Agent background thread.*:FooBar/}
11
- NewRelic::Control.instance.log.expects(:error).with{|args| args =~ /Agent background thread.*:FooBaz/}.never
12
-
13
- ClassLoadingWatcher.enable_warning
14
- assert_raise NameError do
15
- FooBar::Bat
16
- end
17
-
18
- ClassLoadingWatcher.disable_warning
19
- assert_raise NameError do
20
- FooBaz::Bat
21
- end
22
- end
23
-
24
- def test_require
25
- require 'new_relic/agent/patch_const_missing'
26
- ClassLoadingWatcher.background_thread = Thread.current
27
-
28
- # try loading some non-existent class
29
- NewRelic::Control.instance.log.expects(:error).at_least_once.with{|args| args =~ /Agent background thread.*rational/}
30
- NewRelic::Control.instance.log.expects(:error).with{|args| args =~ /Agent background thread.*pstore/}.never
31
-
32
- ClassLoadingWatcher.enable_warning
33
- require('rational') # standard library probably not loaded yet
34
-
35
- ClassLoadingWatcher.disable_warning
36
-
37
- require 'pstore' # standard library probably not loaded yet
38
- end
39
-
40
- def test_load
41
- require 'new_relic/agent/patch_const_missing'
42
- ClassLoadingWatcher.background_thread = Thread.current
43
-
44
- # try loading some non-existent class
45
- NewRelic::Control.instance.log.expects(:error).with{|args| args =~ /Agent background thread.*tsort/}.at_least_once
46
- NewRelic::Control.instance.log.expects(:error).with{|args| args =~ /Agent background thread.*getoptlong/}.never
47
-
48
- ClassLoadingWatcher.enable_warning
49
-
50
- load 'tsort.rb' # standard library probably not loaded yet
51
-
52
- ClassLoadingWatcher.disable_warning
53
-
54
- load 'getoptlong.rb' # standard library probably not loaded yet
55
- end
56
- end
@@ -1,107 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
2
- require 'action_controller/base'
3
-
4
- class AgentControllerTest < ActionController::TestCase
5
-
6
- self.controller_class = NewRelic::Agent::AgentTestController
7
-
8
- attr_accessor :agent
9
-
10
- # Normally you can do this with #setup but for some reason in rails 2.0.2
11
- # setup is not called.
12
- def initialize name
13
- super name
14
- Thread.current[:controller_ignored] = nil
15
- NewRelic::Agent.manual_start
16
- @agent = NewRelic::Agent.instance
17
- # @agent.instrument_app
18
- agent.transaction_sampler.harvest
19
- NewRelic::Agent::AgentTestController.class_eval do
20
- newrelic_ignore :only => [:action_to_ignore, :entry_action, :base_action]
21
- newrelic_ignore_apdex :only => :action_to_ignore_apdex
22
- end
23
- end
24
-
25
- def teardown
26
- Thread.current[:controller_ignored] = nil
27
- super
28
- end
29
-
30
- def test_metric__ignore
31
- engine = @agent.stats_engine
32
- get :action_to_ignore
33
- assert_equal true, Thread.current[:controller_ignored]
34
- end
35
- def test_metric__ignore_base
36
- engine = @agent.stats_engine
37
- get :base_action
38
- assert_equal true, Thread.current[:controller_ignored]
39
- end
40
- def test_metric__no_ignore
41
- engine = @agent.stats_engine
42
- path = 'new_relic/agent/agent_test/index'
43
- cpu_stats = engine.get_stats_no_scope("ControllerCPU/#{path}")
44
- index_stats = engine.get_stats_no_scope("Controller/#{path}")
45
- index_apdex_stats = engine.get_custom_stats("Apdex/#{path}", NewRelic::ApdexStats)
46
- assert_difference 'index_stats.call_count' do
47
- assert_difference 'index_apdex_stats.call_count' do
48
- assert_difference 'cpu_stats.call_count' do
49
- get :index
50
- end
51
- end
52
- end
53
- assert_nil Thread.current[:controller_ignored]
54
- end
55
- def test_metric__ignore_apdex
56
- engine = @agent.stats_engine
57
- path = 'new_relic/agent/agent_test/action_to_ignore_apdex'
58
- cpu_stats = engine.get_stats_no_scope("ControllerCPU/#{path}")
59
- index_stats = engine.get_stats_no_scope("Controller/#{path}")
60
- index_apdex_stats = engine.get_custom_stats("Apdex/#{path}", NewRelic::ApdexStats)
61
- assert_difference 'index_stats.call_count' do
62
- assert_no_difference 'index_apdex_stats.call_count' do
63
- assert_difference 'cpu_stats.call_count' do
64
- get :action_to_ignore_apdex
65
- end
66
- end
67
- end
68
- assert_nil Thread.current[:controller_ignored]
69
-
70
- end
71
- def test_metric__dispatched
72
- engine = @agent.stats_engine
73
- get :entry_action
74
- assert_nil Thread.current[:controller_ignored]
75
- assert_nil engine.lookup_stat('Controller/agent_test/entry_action')
76
- assert_equal 1, engine.lookup_stat('Controller/new_relic/agent/agent_test/internal_action').call_count
77
- end
78
- def test_action_instrumentation
79
- begin
80
- get :index, :foo => 'bar'
81
- assert_match /bar/, @response.body
82
- #rescue ActionController::RoutingError
83
- # you might get here if you don't have the default route installed.
84
- end
85
- end
86
-
87
- def test_controller_params
88
-
89
- assert agent.transaction_sampler
90
-
91
- num_samples = NewRelic::Agent.instance.transaction_sampler.samples.length
92
-
93
- assert_equal "[FILTERED]", @controller._filter_parameters({'social_security_number' => 'test'})['social_security_number']
94
-
95
- get :index, 'social_security_number' => "001-555-1212"
96
-
97
- samples = agent.transaction_sampler.samples
98
-
99
- agent.transaction_sampler.expects(:notice_transaction).never
100
-
101
- assert_equal num_samples + 1, samples.length
102
-
103
- assert_equal "[FILTERED]", samples.last.params[:request_params]["social_security_number"]
104
-
105
- end
106
-
107
- end
@@ -1,70 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
2
-
3
- class NewRelic::Agent::DispatcherInstrumentationTest < Test::Unit::TestCase
4
-
5
- class FunnyDispatcher
6
- include NewRelic::Agent::Instrumentation::DispatcherInstrumentation
7
- def newrelic_response_code; end
8
- end
9
- def setup
10
- @instance_busy = NewRelic::Agent.agent.stats_engine.get_stats('Instance/Busy')
11
- @dispatch_stat = NewRelic::Agent.agent.stats_engine.get_stats 'Rails/HTTP Dispatch'
12
- @mongrel_queue_stat = NewRelic::Agent.agent.stats_engine.get_stats 'WebFrontend/Mongrel/Average Queue Time'
13
-
14
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
15
- @instance_busy.reset
16
- @dispatch_stat.reset
17
- @mongrel_queue_stat.reset
18
-
19
- end
20
-
21
- def test_normal_call
22
- d = FunnyDispatcher.new
23
- assert_equal 0, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
24
- d.newrelic_dispatcher_start
25
- sleep 1.0
26
- assert_equal 1, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
27
- d.newrelic_dispatcher_finish
28
- assert_equal 0, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
29
- assert_nil Thread.current[:newrelic_t0]
30
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
31
-
32
- assert_equal 1, @instance_busy.call_count
33
- assert_equal 1, @dispatch_stat.call_count
34
- assert_equal 0, @mongrel_queue_stat.call_count
35
- assert @dispatch_stat.total_call_time >= 1.0, "Total call time must be at least one second"
36
- assert @instance_busy.total_call_time > 0.9 && @instance_busy.total_call_time <= 1.0, "instance busy = #{@instance_busy.inspect}"
37
- end
38
- def test_ignore_zero_counts
39
- assert_equal 0, @instance_busy.call_count, "Problem with test--instance busy not starting off at zero."
40
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
41
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
42
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
43
- assert_equal 0, @instance_busy.call_count
44
- end
45
- def test_recursive_call
46
- d0 = FunnyDispatcher.new
47
- d1 = FunnyDispatcher.new
48
-
49
- assert_equal 0, @instance_busy.call_count, "Problem with test--instance busy not starting off at zero."
50
-
51
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
52
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
53
- assert_equal 0, @instance_busy.call_count
54
-
55
- assert_equal 0, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
56
- d0.newrelic_dispatcher_start
57
- assert_equal 1, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
58
- d1.newrelic_dispatcher_start
59
- assert_equal 2, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
60
- sleep 1
61
- d0.newrelic_dispatcher_finish
62
- assert_equal 1, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
63
- d1.newrelic_dispatcher_finish
64
- assert_equal 0, NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
65
- assert_nil Thread.current[:newrelic_t0]
66
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
67
- assert_equal 1, @instance_busy.call_count
68
- assert @instance_busy.total_call_time.between?(1.8, 2.1), "Should be about 200%: #{@instance_busy.total_call_time}"
69
- end
70
- end