newrelic_rpm 2.14.1 → 3.0.0.beta1

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 (123) hide show
  1. data/CHANGELOG +8 -0
  2. data/README.rdoc +2 -0
  3. data/install.rb +2 -2
  4. data/lib/new_relic/agent.rb +34 -1
  5. data/lib/new_relic/agent/agent.rb +34 -25
  6. data/lib/new_relic/agent/browser_monitoring.rb +111 -0
  7. data/lib/new_relic/agent/error_collector.rb +4 -4
  8. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
  9. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -7
  10. data/lib/new_relic/agent/instrumentation/data_mapper.rb +8 -8
  11. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
  12. data/lib/new_relic/agent/instrumentation/memcache.rb +1 -1
  13. data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
  14. data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
  15. data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -0
  16. data/lib/new_relic/agent/instrumentation/queue_time.rb +26 -26
  17. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
  18. data/lib/new_relic/agent/instrumentation/rails/errors.rb +1 -1
  19. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
  20. data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
  21. data/lib/new_relic/agent/method_tracer.rb +15 -15
  22. data/lib/new_relic/agent/shim_agent.rb +2 -0
  23. data/lib/new_relic/agent/stats_engine/metric_stats.rb +3 -3
  24. data/lib/new_relic/agent/stats_engine/samplers.rb +2 -2
  25. data/lib/new_relic/agent/stats_engine/transactions.rb +2 -1
  26. data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
  27. data/lib/new_relic/agent/transaction_sampler.rb +299 -251
  28. data/lib/new_relic/control.rb +2 -2
  29. data/lib/new_relic/control/class_methods.rb +0 -5
  30. data/lib/new_relic/control/configuration.rb +4 -3
  31. data/lib/new_relic/control/frameworks/rails.rb +9 -12
  32. data/lib/new_relic/control/instance_methods.rb +2 -2
  33. data/lib/new_relic/control/instrumentation.rb +1 -1
  34. data/lib/new_relic/control/server_methods.rb +2 -2
  35. data/lib/new_relic/delayed_job_injection.rb +1 -1
  36. data/lib/new_relic/local_environment.rb +7 -7
  37. data/lib/new_relic/rack/browser_monitoring.rb +61 -0
  38. data/lib/new_relic/stats.rb +6 -6
  39. data/lib/new_relic/version.rb +4 -4
  40. data/newrelic.yml +19 -0
  41. data/newrelic_rpm.gemspec +9 -4
  42. data/test/active_record_fixtures.rb +5 -5
  43. data/test/config/test_control.rb +3 -3
  44. data/test/new_relic/agent/agent/connect_test.rb +27 -6
  45. data/test/new_relic/agent/agent/start_test.rb +13 -13
  46. data/test/new_relic/agent/agent/start_worker_thread_test.rb +8 -8
  47. data/test/new_relic/agent/agent_test.rb +85 -0
  48. data/test/new_relic/agent/agent_test_controller.rb +9 -9
  49. data/test/new_relic/agent/agent_test_controller_test.rb +37 -37
  50. data/test/new_relic/agent/browser_monitoring_test.rb +124 -0
  51. data/test/new_relic/agent/busy_calculator_test.rb +7 -7
  52. data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -9
  53. data/test/new_relic/agent/error_collector_test.rb +54 -54
  54. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +69 -69
  55. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
  56. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +3 -3
  57. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +11 -11
  58. data/test/new_relic/agent/instrumentation/queue_time_test.rb +38 -35
  59. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +18 -18
  60. data/test/new_relic/agent/memcache_instrumentation_test.rb +12 -12
  61. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
  62. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +16 -15
  63. data/test/new_relic/agent/method_tracer_test.rb +60 -60
  64. data/test/new_relic/agent/mock_scope_listener.rb +8 -8
  65. data/test/new_relic/agent/rpm_agent_test.rb +26 -26
  66. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +17 -17
  67. data/test/new_relic/agent/stats_engine/samplers_test.rb +4 -4
  68. data/test/new_relic/agent/stats_engine/stats_engine_test.rb +51 -51
  69. data/test/new_relic/agent/transaction_sample_builder_test.rb +36 -36
  70. data/test/new_relic/agent/transaction_sampler_test.rb +727 -178
  71. data/test/new_relic/agent/worker_loop_test.rb +4 -4
  72. data/test/new_relic/collection_helper_test.rb +15 -15
  73. data/test/new_relic/command/deployments_test.rb +5 -5
  74. data/test/new_relic/control_test.rb +25 -25
  75. data/test/new_relic/local_environment_test.rb +11 -11
  76. data/test/new_relic/metric_spec_test.rb +21 -21
  77. data/test/new_relic/rack/episodes_test.rb +35 -35
  78. data/test/new_relic/stats_test.rb +61 -43
  79. data/test/new_relic/transaction_sample_subtest_test.rb +15 -15
  80. data/test/new_relic/transaction_sample_test.rb +25 -25
  81. data/test/new_relic/version_number_test.rb +11 -11
  82. data/test/test_contexts.rb +7 -7
  83. data/test/test_helper.rb +6 -6
  84. data/ui/helpers/developer_mode_helper.rb +67 -67
  85. data/ui/helpers/google_pie_chart.rb +4 -4
  86. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +4 -4
  87. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +3 -3
  88. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +7 -7
  89. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +1 -1
  90. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +9 -9
  91. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +1 -1
  92. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +8 -8
  93. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +9 -9
  94. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +4 -4
  95. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +2 -2
  96. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +8 -8
  97. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +3 -3
  98. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +6 -6
  99. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +3 -3
  100. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +2 -2
  101. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +6 -6
  102. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +2 -2
  103. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +1 -1
  104. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +4 -4
  105. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +3 -3
  106. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +4 -4
  107. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +1 -1
  108. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +1 -1
  109. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +21 -21
  110. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +2 -2
  111. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +6 -6
  112. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +2 -2
  113. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +1 -1
  114. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +1 -1
  115. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +3 -3
  116. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +1 -1
  117. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +8 -8
  118. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +3 -3
  119. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +3 -3
  120. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +5 -5
  121. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +20 -20
  122. metadata +15 -9
  123. data/lib/new_relic/agent/instrumentation/sequel.rb +0 -109
@@ -1,5 +1,5 @@
1
1
  ENV['SKIP_RAILS'] = 'true'
2
- require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
3
3
 
4
4
  class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
5
5
  def setup
@@ -9,7 +9,7 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
9
9
  @worker_loop.stubs(:log).returns(@logger)
10
10
  @test_start_time = Time.now
11
11
  end
12
-
12
+
13
13
  def test_add_task
14
14
  @x = false
15
15
  @worker_loop.run(0) do
@@ -18,7 +18,7 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
18
18
  end
19
19
  assert @x
20
20
  end
21
-
21
+
22
22
  def test_density
23
23
  # This shows how the tasks stay aligned with the period and don't drift.
24
24
  count = 0
@@ -46,7 +46,7 @@ class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
46
46
  assert done
47
47
  end
48
48
  class BadBoy < Exception; end
49
-
49
+
50
50
  def test_task_error__exception
51
51
  @logger.expects(:error).once
52
52
  @logger.expects(:debug).once
@@ -1,18 +1,18 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
2
2
  require 'ostruct'
3
3
  require 'active_record_fixtures' if defined?(::ActiveRecord)
4
4
 
5
5
  require 'new_relic/collection_helper'
6
6
  class NewRelic::CollectionHelperTest < Test::Unit::TestCase
7
-
7
+
8
8
  def setup
9
- NewRelic::Agent.manual_start
9
+ NewRelic::Agent.manual_start
10
10
  super
11
11
  end
12
12
  def teardown
13
13
  super
14
14
  end
15
-
15
+
16
16
  include NewRelic::CollectionHelper
17
17
  def test_string
18
18
  val = (('A'..'Z').to_a.join * 100).to_s
@@ -58,7 +58,7 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
58
58
  assert_equal Hash["ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF..." => (("0"*256) + "...")], normalize_params({ val => '0' * 512 })
59
59
  end
60
60
  class MyHash < Hash
61
-
61
+
62
62
  end
63
63
  # Test to ensure that hash subclasses are properly converted
64
64
  def test_hash_subclass
@@ -67,19 +67,19 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
67
67
  custom_params = { :one => {:hash => { :a => :b}, :myhash => h }}
68
68
  nh = normalize_params(custom_params)
69
69
  myhash = custom_params[:one][:myhash]
70
- assert_equal MyHash, myhash.class
70
+ assert_equal MyHash, myhash.class
71
71
  myhash = nh[:one][:myhash]
72
- assert_equal Hash, myhash.class
72
+ assert_equal Hash, myhash.class
73
73
  end
74
-
74
+
75
75
  class MyEnumerable
76
76
  include Enumerable
77
-
77
+
78
78
  def each
79
79
  yield "1"
80
80
  end
81
81
  end
82
-
82
+
83
83
  def test_enumerable
84
84
  e = MyEnumerable.new
85
85
  custom_params = { :one => {:hash => { :a => :b}, :myenum => e }}
@@ -87,25 +87,25 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
87
87
  myenum = nh[:one][:myenum]
88
88
  assert_match /MyEnumerable/, myenum
89
89
  end
90
-
90
+
91
91
  def test_stringio
92
92
  # Verify StringIO works like this normally:
93
93
  s = StringIO.new "start" + ("foo bar bat " * 1000)
94
94
  val = nil
95
- s.each { | entry | val = entry; break }
95
+ s.each { | entry | val = entry; break }
96
96
  assert_match /^startfoo bar/, val
97
97
 
98
98
  # make sure stringios aren't affected by calling normalize_params:
99
99
  s = StringIO.new "start" + ("foo bar bat " * 1000)
100
100
  v = normalize_params({ :foo => s.string })
101
- s.each { | entry | val = entry; break }
101
+ s.each { | entry | val = entry; break }
102
102
  assert_match /^startfoo bar/, val
103
103
  end
104
-
104
+
105
105
  def test_object
106
106
  assert_equal ["foo", '#<OpenStruct>'], normalize_params(['foo', OpenStruct.new('z'=>'q')])
107
107
  end
108
-
108
+
109
109
  def test_strip_backtrace
110
110
  begin
111
111
  ActiveRecordFixtures.setup
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
2
2
  require File.expand_path(File.join(File.dirname(__FILE__),'/../../../lib/new_relic/command'))
3
3
 
4
4
  class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
5
-
5
+
6
6
  def setup
7
7
  NewRelic::Command::Deployments.class_eval do
8
8
  attr_accessor :messages, :exit_status, :errors, :revision
@@ -40,7 +40,7 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
40
40
  @deployment.run
41
41
  @deployment = nil
42
42
  end
43
-
43
+
44
44
  def test_command_line_run
45
45
  mock_the_connection
46
46
  # @mock_response.expects(:body).returns("<xml>deployment</xml>")
@@ -49,11 +49,11 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
49
49
  assert_nil @deployment.errors
50
50
  assert_equal '3838', @deployment.revision
51
51
  @deployment.run
52
-
52
+
53
53
  # This should pass because it's a bogus deployment
54
54
  #assert_equal 1, @deployment.exit_status
55
55
  #assert_match /Unable to upload/, @deployment.errors
56
-
56
+
57
57
  @deployment = nil
58
58
  end
59
59
  private
@@ -64,5 +64,5 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
64
64
  mock_connection.expects(:request).returns(@mock_response)
65
65
  NewRelic::Control.instance.stubs(:http_connection).returns(mock_connection)
66
66
  end
67
-
67
+
68
68
  end
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
2
2
  class NewRelic::ControlTest < Test::Unit::TestCase
3
-
3
+
4
4
  attr_reader :c
5
-
5
+
6
6
  def setup
7
-
7
+
8
8
  NewRelic::Agent.manual_start(:dispatcher_instance_id => 'test')
9
9
  @c = NewRelic::Control.instance
10
10
  raise 'oh geez, wrong class' unless NewRelic::Control.instance.is_a?(::NewRelic::Control::Frameworks::Test)
@@ -17,7 +17,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
17
17
  assert @c.cert_file_path
18
18
  assert_equal File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'cert', 'cacert.pem')), @c.cert_file_path
19
19
  end
20
-
20
+
21
21
  def test_cert_file
22
22
  result = `openssl verify -CAfile #{@c.cert_file_path} #{@c.send(:newrelic_root)}/cert/site.pem`
23
23
  assert (result =~ /OK/), 'Should verify certificate: ' + result
@@ -26,7 +26,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
26
26
  def test_old_cert_file
27
27
  result = `openssl verify -CAfile #{@c.cert_file_path} #{@c.send(:newrelic_root)}/cert/oldsite.pem`
28
28
  assert (result =~ /OK/), 'Should verify the old certificate: ' + result
29
- end
29
+ end
30
30
 
31
31
  def test_monitor_mode
32
32
  assert ! @c.monitor_mode?
@@ -47,50 +47,50 @@ class NewRelic::ControlTest < Test::Unit::TestCase
47
47
  @c['enabled'] = false
48
48
  @c['monitor_mode'] = false
49
49
  end
50
-
50
+
51
51
  def test_test_config
52
52
  if defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3
53
53
  assert_equal :rails3, c.app
54
54
  elsif defined?(Rails)
55
- assert_equal :rails, c.app
55
+ assert_equal :rails, c.app
56
56
  else
57
57
  assert_equal :test, c.app
58
58
  end
59
59
  assert_equal :test, c.framework
60
60
  assert_match /test/i, c.dispatcher_instance_id
61
- assert_equal nil, c.dispatcher
61
+ assert("" == c.dispatcher.to_s)
62
62
  assert !c['enabled']
63
63
  assert_equal false, c['monitor_mode']
64
64
  c.local_env
65
65
  end
66
-
66
+
67
67
  def test_root
68
68
  assert File.directory?(NewRelic::Control.newrelic_root), NewRelic::Control.newrelic_root
69
69
  if defined?(Rails)
70
70
  assert File.directory?(File.join(NewRelic::Control.newrelic_root, "lib")), NewRelic::Control.newrelic_root + "/lib"
71
71
  end
72
72
  end
73
-
73
+
74
74
  def test_info
75
75
  props = NewRelic::Control.instance.local_env.snapshot
76
76
  if defined?(Rails)
77
77
  assert_match /jdbc|postgres|mysql|sqlite/, props.assoc('Database adapter').last, props.inspect
78
78
  end
79
79
  end
80
-
80
+
81
81
  def test_resolve_ip
82
82
  assert_equal nil, c.send(:convert_to_ip_address, 'localhost')
83
83
  assert_equal nil, c.send(:convert_to_ip_address, 'q1239988737.us')
84
84
  # This will fail if you don't have a valid, accessible, DNS server
85
85
  assert_equal '204.93.223.153', c.send(:convert_to_ip_address, 'collector.newrelic.com')
86
86
  end
87
-
87
+
88
88
  class FakeResolv
89
89
  def self.getaddress(host)
90
90
  raise 'deliberately broken'
91
91
  end
92
92
  end
93
-
93
+
94
94
  def test_resolve_ip_with_broken_dns
95
95
  # Here be dragons: disable the ruby DNS lookup methods we use so
96
96
  # that it will actually fail to resolve.
@@ -99,16 +99,16 @@ class NewRelic::ControlTest < Test::Unit::TestCase
99
99
  Object.instance_eval { remove_const :Resolv}
100
100
  Object.instance_eval {remove_const:'IPSocket' }
101
101
  assert_equal(nil, c.send(:convert_to_ip_address, 'collector.newrelic.com'), "DNS is down, should be no IP for server")
102
-
102
+
103
103
  Object.instance_eval {const_set('Resolv', old_resolv); const_set('IPSocket', old_ipsocket)}
104
104
  # these are here to make sure that the constant tomfoolery above
105
105
  # has not broket the system unduly
106
106
  assert_equal old_resolv, Resolv
107
107
  assert_equal old_ipsocket, IPSocket
108
108
  end
109
-
110
-
111
-
109
+
110
+
111
+
112
112
  def test_config_yaml_erb
113
113
  assert_equal 'heyheyhey', c['erb_value']
114
114
  assert_equal '', c['message']
@@ -118,12 +118,12 @@ class NewRelic::ControlTest < Test::Unit::TestCase
118
118
  def test_appnames
119
119
  assert_equal %w[a b c], NewRelic::Control.instance.app_names
120
120
  end
121
-
121
+
122
122
  def test_config_booleans
123
123
  assert_equal c['tval'], true
124
124
  assert_equal c['fval'], false
125
125
  assert_nil c['not_in_yaml_val']
126
- assert_equal c['yval'], true
126
+ assert_equal c['yval'], true
127
127
  assert_equal c['sval'], 'sure'
128
128
  end
129
129
  def test_config_apdex
@@ -137,20 +137,20 @@ class NewRelic::ControlTest < Test::Unit::TestCase
137
137
  NewRelic::Control.instance.setup_log
138
138
  assert_match /newrelic_agent.log$/, c.instance_variable_get('@log_file')
139
139
  end
140
-
140
+
141
141
  def test_transaction_threshold__apdex
142
142
  forced_start
143
143
  assert_equal 'Apdex_f', c['transaction_tracer']['transaction_threshold']
144
144
  assert_equal 4.4, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
145
145
  end
146
-
146
+
147
147
  def test_transaction_threshold__default
148
-
148
+
149
149
  forced_start :transaction_tracer => { :transaction_threshold => nil}
150
150
  assert_nil c['transaction_tracer']['transaction_threshold']
151
151
  assert_equal 2.0, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
152
152
  end
153
-
153
+
154
154
  def test_transaction_threshold__override
155
155
  forced_start :transaction_tracer => { :transaction_threshold => 1}
156
156
  assert_equal 1, c['transaction_tracer']['transaction_threshold']
@@ -166,8 +166,8 @@ class NewRelic::ControlTest < Test::Unit::TestCase
166
166
  private
167
167
  def forced_start overrides = {}
168
168
  NewRelic::Agent.manual_start overrides
169
- # This is to force the agent to start again.
169
+ # This is to force the agent to start again.
170
170
  NewRelic::Agent.instance.stubs(:started?).returns(nil)
171
- NewRelic::Agent.instance.start
171
+ NewRelic::Agent.instance.start
172
172
  end
173
173
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
2
2
  class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
3
-
3
+
4
4
  def teardown
5
5
  # To remove mock server instances from ObjectSpace
6
6
  ObjectSpace.garbage_collect
@@ -12,16 +12,16 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
12
12
  end
13
13
  end
14
14
  MOCK_OPTIONS = MockOptions.new
15
-
15
+
16
16
  def test_environment
17
17
  e = NewRelic::LocalEnvironment.new
18
- assert_equal nil, e.environment
18
+ assert(nil == e.environment) # working around a bug in 1.9.1
19
19
  assert_match /test/i, e.dispatcher_instance_id
20
20
  end
21
21
  def test_no_webrick
22
22
  Object.const_set :OPTIONS, 'foo'
23
23
  e = NewRelic::LocalEnvironment.new
24
- assert_equal nil, e.environment
24
+ assert(nil == e.environment) # working around a bug in 1.9.1
25
25
  assert_match /test/i, e.dispatcher_instance_id
26
26
  Object.class_eval { remove_const :OPTIONS }
27
27
  end
@@ -35,15 +35,15 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
35
35
  e = NewRelic::LocalEnvironment.new
36
36
  assert_equal :passenger, e.environment
37
37
  assert_nil e.dispatcher_instance_id, "dispatcher instance id should be nil: #{e.dispatcher_instance_id}"
38
-
38
+
39
39
  NewRelic::Control.instance.instance_eval do
40
40
  @settings['app_name'] = 'myapp'
41
41
  end
42
-
43
- e = NewRelic::LocalEnvironment.new
42
+
43
+ e = NewRelic::LocalEnvironment.new
44
44
  assert_equal :passenger, e.environment
45
45
  assert_nil e.dispatcher_instance_id
46
-
46
+
47
47
  ::Passenger.class_eval { remove_const :AbstractServer }
48
48
  end
49
49
  def test_snapshot
@@ -59,8 +59,8 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
59
59
  assert s.assoc('Processors').last.to_i > 0
60
60
  end
61
61
  end
62
-
63
-
62
+
63
+
64
64
  def test_default_port
65
65
  e = NewRelic::LocalEnvironment.new
66
66
  assert_equal 3000, e.send(:default_port)
@@ -68,5 +68,5 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
68
68
  assert_equal '3121', e.send(:default_port)
69
69
  ARGV.pop
70
70
  end
71
-
71
+
72
72
  end
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
2
- class NewRelic::MetricSpecTest < Test::Unit::TestCase
3
-
2
+ class NewRelic::MetricSpecTest < Test::Unit::TestCase
3
+
4
4
  def test_equal
5
5
  spec1 = NewRelic::MetricSpec.new('Controller')
6
6
  spec2 = NewRelic::MetricSpec.new('Controller', nil)
7
-
7
+
8
8
  assert spec1.eql?(NewRelic::MetricSpec.new('Controller'))
9
9
  assert spec2.eql?(NewRelic::MetricSpec.new('Controller', nil))
10
10
  assert spec1.eql?(spec2)
@@ -21,53 +21,53 @@ class NewRelic::MetricSpecTest < Test::Unit::TestCase
21
21
  s2 = NewRelic::MetricSpec.new('Controller', 'hap')
22
22
  assert_equal [s2, s1].sort, [s1, s2]
23
23
  assert_equal [s1, s2].sort, [s1, s2]
24
-
24
+
25
25
  s1 = NewRelic::MetricSpec.new('Controller', 'hap')
26
26
  s2 = NewRelic::MetricSpec.new('Controller', nil)
27
27
  assert_equal [s2, s1].sort, [s2, s1]
28
28
  assert_equal [s1, s2].sort, [s2, s1]
29
-
29
+
30
30
  s1 = NewRelic::MetricSpec.new('Controller')
31
31
  s2 = NewRelic::MetricSpec.new('Controller')
32
32
  assert_equal [s2, s1].sort, [s2, s1] # unchanged due to no sort criteria
33
33
  assert_equal [s1, s2].sort, [s1, s2] # unchanged due to no sort criteria
34
-
34
+
35
35
  s1 = NewRelic::MetricSpec.new('Controller', nil)
36
36
  s2 = NewRelic::MetricSpec.new('Controller', nil)
37
37
  assert_equal [s2, s1].sort, [s2, s1] # unchanged due to no sort criteria
38
- assert_equal [s1, s2].sort, [s1, s2] # unchanged due to no sort criteria
38
+ assert_equal [s1, s2].sort, [s1, s2] # unchanged due to no sort criteria
39
39
  end
40
40
 
41
41
  # test to make sure the MetricSpec class can serialize to json
42
42
  def test_json
43
43
  spec = NewRelic::MetricSpec.new("controller", "metric#find")
44
-
44
+
45
45
  import = ::ActiveSupport::JSON.decode(spec.to_json)
46
-
46
+
47
47
  compare_spec(spec, import)
48
-
48
+
49
49
  stats = NewRelic::MethodTraceStats.new
50
-
50
+
51
51
  import = ::ActiveSupport::JSON.decode(stats.to_json)
52
-
52
+
53
53
  compare_stat(stats, import)
54
-
54
+
55
55
  metric_data = NewRelic::MetricData.new(spec, stats, 10)
56
-
56
+
57
57
  import = ::ActiveSupport::JSON.decode(metric_data.to_json)
58
-
58
+
59
59
  compare_metric_data(metric_data, import)
60
60
  end
61
-
62
-
63
- private
64
-
61
+
62
+
63
+ private
64
+
65
65
  def compare_spec(spec, import)
66
66
  assert_equal 2, import.length
67
67
  assert_equal spec.name, import['name']
68
68
  assert_equal spec.scope, import['scope']
69
69
  end
70
-
70
+
71
71
  def compare_stat(stats, import)
72
72
  assert_equal 6, import.length
73
73
  assert_equal stats.total_call_time, import['total_call_time']
@@ -77,7 +77,7 @@ class NewRelic::MetricSpecTest < Test::Unit::TestCase
77
77
  assert_equal stats.call_count, import['call_count']
78
78
  assert_equal stats.total_exclusive_time, import['total_exclusive_time']
79
79
  end
80
-
80
+
81
81
  def compare_metric_data(metric_data, import)
82
82
  assert_equal 3, import.length
83
83
  assert_equal metric_data.metric_id, import['metric_id']