newrelic_rpm 3.0.1 → 3.1.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.
- data/CHANGELOG +2 -3
- data/README.rdoc +3 -3
- data/lib/new_relic/agent.rb +19 -7
- data/lib/new_relic/agent/agent.rb +83 -19
- data/lib/new_relic/agent/beacon_configuration.rb +8 -12
- data/lib/new_relic/agent/browser_monitoring.rb +8 -8
- data/lib/new_relic/agent/error_collector.rb +13 -13
- data/lib/new_relic/agent/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +10 -2
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +41 -35
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +92 -0
- data/lib/new_relic/agent/method_tracer.rb +0 -2
- data/lib/new_relic/agent/shim_agent.rb +2 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +89 -60
- data/lib/new_relic/agent/stats_engine/transactions.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/collection_helper.rb +0 -2
- data/lib/new_relic/control/class_methods.rb +25 -12
- data/lib/new_relic/control/logging_methods.rb +30 -17
- data/lib/new_relic/data_serialization.rb +81 -0
- data/lib/new_relic/local_environment.rb +1 -1
- data/lib/new_relic/metric_data.rb +9 -5
- data/lib/new_relic/metric_spec.rb +7 -1
- data/lib/new_relic/rack/browser_monitoring.rb +1 -7
- data/lib/new_relic/stats.rb +4 -0
- data/lib/new_relic/transaction_analysis.rb +45 -88
- data/lib/new_relic/transaction_analysis/segment_summary.rb +47 -0
- data/lib/new_relic/transaction_sample.rb +15 -332
- data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
- data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
- data/lib/new_relic/transaction_sample/segment.rb +250 -0
- data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
- data/lib/new_relic/version.rb +3 -3
- data/newrelic.yml +3 -3
- data/newrelic_rpm.gemspec +27 -4
- data/test/active_record_fixtures.rb +31 -13
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -3
- data/test/new_relic/agent/agent_test.rb +73 -28
- data/test/new_relic/agent/agent_test_controller_test.rb +11 -10
- data/test/new_relic/agent/beacon_configuration_test.rb +37 -20
- data/test/new_relic/agent/browser_monitoring_test.rb +17 -28
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -7
- data/test/new_relic/agent/error_collector_test.rb +6 -7
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +12 -5
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +195 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +60 -58
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +14 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -1
- data/test/new_relic/agent/method_tracer_test.rb +8 -8
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +20 -0
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +1 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +4 -3
- data/test/new_relic/agent/{stats_engine/stats_engine_test.rb → stats_engine_test.rb} +8 -8
- data/test/new_relic/agent/transaction_sampler_test.rb +1 -1
- data/test/new_relic/agent/worker_loop_test.rb +2 -2
- data/test/new_relic/control/class_methods_test.rb +62 -0
- data/test/new_relic/control/logging_methods_test.rb +157 -0
- data/test/new_relic/control_test.rb +10 -10
- data/test/new_relic/data_serialization_test.rb +50 -0
- data/test/new_relic/local_environment_test.rb +13 -13
- data/test/new_relic/metric_data_test.rb +125 -0
- data/test/new_relic/metric_spec_test.rb +8 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +77 -0
- data/test/new_relic/transaction_analysis_test.rb +121 -0
- data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
- data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
- data/test/new_relic/transaction_sample/segment_test.rb +454 -0
- data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
- data/test/new_relic/transaction_sample_test.rb +51 -0
- data/test/test_helper.rb +4 -14
- metadata +32 -7
@@ -139,20 +139,22 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def test_add_to_error_queue_positive
|
142
|
-
|
142
|
+
noticed_error = mock('noticed_error')
|
143
|
+
noticed_error.expects(:message).returns('a message')
|
143
144
|
@lock = Mutex.new
|
144
145
|
@errors = []
|
145
|
-
self.expects(:over_queue_limit?).with(
|
146
|
-
add_to_error_queue(
|
147
|
-
assert_equal([
|
146
|
+
self.expects(:over_queue_limit?).with('a message').returns(false)
|
147
|
+
add_to_error_queue(noticed_error)
|
148
|
+
assert_equal([noticed_error], @errors)
|
148
149
|
end
|
149
150
|
|
150
151
|
def test_add_to_error_queue_negative
|
151
|
-
|
152
|
+
noticed_error = mock('noticed_error')
|
153
|
+
noticed_error.expects(:message).returns('a message')
|
152
154
|
@lock = Mutex.new
|
153
155
|
@errors = []
|
154
|
-
self.expects(:over_queue_limit?).with(
|
155
|
-
add_to_error_queue(
|
156
|
+
self.expects(:over_queue_limit?).with('a message').returns(true)
|
157
|
+
add_to_error_queue(noticed_error)
|
156
158
|
assert_equal([], @errors)
|
157
159
|
end
|
158
160
|
|
@@ -72,22 +72,21 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
72
72
|
|
73
73
|
@error_collector.notice_error(Exception.new("message"), :metric => 'second', :request_params => {:x => 'y'})
|
74
74
|
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
75
|
-
@error_collector.notice_error(Exception.new("message"), :metric => '
|
75
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
76
76
|
|
77
77
|
errors = @error_collector.harvest_errors(errors)
|
78
78
|
|
79
|
-
assert_equal
|
79
|
+
assert_equal 4, errors.length
|
80
80
|
assert_equal 'first', errors.first.path
|
81
|
+
assert_equal 'last', errors.last.path
|
81
82
|
|
82
|
-
|
83
|
-
@error_collector.notice_error(Exception.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
83
|
+
@error_collector.notice_error(Exception.new("message"), :metric => 'first', :request_params => {:x => 'y'})
|
84
84
|
@error_collector.notice_error(Exception.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
85
85
|
|
86
86
|
errors = @error_collector.harvest_errors(nil)
|
87
|
-
assert_equal
|
88
|
-
assert_equal '
|
87
|
+
assert_equal 2, errors.length
|
88
|
+
assert_equal 'first', errors.first.path
|
89
89
|
assert_equal 'last', errors.last.path
|
90
|
-
|
91
90
|
end
|
92
91
|
|
93
92
|
def test_queue_overflow
|
@@ -2,20 +2,24 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_h
|
|
2
2
|
class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::Unit::TestCase
|
3
3
|
require 'active_record_fixtures'
|
4
4
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
5
|
+
|
6
|
+
@@setup = false
|
5
7
|
def setup
|
6
8
|
super
|
7
|
-
|
9
|
+
unless @@setup
|
10
|
+
NewRelic::Agent.manual_start
|
11
|
+
@setup = true
|
12
|
+
end
|
8
13
|
ActiveRecordFixtures.setup
|
9
14
|
NewRelic::Agent.instance.transaction_sampler.reset!
|
10
15
|
NewRelic::Agent.instance.stats_engine.clear_stats
|
11
|
-
rescue
|
16
|
+
rescue Exception => e
|
12
17
|
puts e
|
13
18
|
puts e.backtrace.join("\n")
|
14
19
|
end
|
15
20
|
|
16
21
|
def teardown
|
17
22
|
super
|
18
|
-
ActiveRecordFixtures.teardown
|
19
23
|
NewRelic::Agent.shutdown
|
20
24
|
end
|
21
25
|
|
@@ -373,6 +377,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
|
|
373
377
|
|
374
378
|
def test_transaction_mysql
|
375
379
|
return unless isMysql? && !defined?(JRuby)
|
380
|
+
ActiveRecordFixtures.setup
|
376
381
|
sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
377
382
|
perform_action_with_newrelic_trace :name => 'bogosity' do
|
378
383
|
ActiveRecordFixtures::Order.add_delay
|
@@ -386,9 +391,11 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
|
|
386
391
|
explanations = segment.params[:explanation]
|
387
392
|
assert_not_nil explanations, "No explains in segment: #{segment}"
|
388
393
|
assert_equal 1, explanations.size,"No explains in segment: #{segment}"
|
389
|
-
assert_equal 1, explanations.first.size
|
394
|
+
assert_equal 1, explanations.first.size, "should be one row of explanation"
|
390
395
|
|
391
|
-
|
396
|
+
row = explanations.first.first
|
397
|
+
assert_equal 10, row.size
|
398
|
+
assert_equal ['1', 'SIMPLE', ActiveRecordFixtures::Order.table_name], row[0..2]
|
392
399
|
|
393
400
|
s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
394
401
|
assert_equal 1, s.call_count
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'test_helper'))
|
2
|
+
require 'new_relic/agent/instrumentation/metric_frame/pop'
|
3
|
+
class NewRelic::Agent::Instrumentation::MetricFrame::PopTest < Test::Unit::TestCase
|
4
|
+
include NewRelic::Agent::Instrumentation::MetricFrame::Pop
|
5
|
+
|
6
|
+
attr_reader :agent
|
7
|
+
attr_reader :transaction_sampler
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@agent = mock('agent')
|
11
|
+
@transaction_sampler = mock('transaction sampler')
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Thread.current[:newrelic_start_time] = nil
|
16
|
+
Thread.current[:newrelic_metric_frame] = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_clear_thread_metric_frame
|
20
|
+
Thread.current[:newrelic_metric_frame] = 'whee'
|
21
|
+
clear_thread_metric_frame!
|
22
|
+
assert_equal nil, Thread.current[:newrelic_metric_frame], 'should nil out the thread var'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_set_last_start_time
|
26
|
+
start_time = Time.now
|
27
|
+
mock_frame = mock('frame')
|
28
|
+
mock_frame.expects(:respond_to?).with(:start).returns(true)
|
29
|
+
mock_frame.expects(:start).returns(start_time)
|
30
|
+
Thread.current[:newrelic_start_time] = nil
|
31
|
+
Thread.current[:newrelic_metric_frame] = mock_frame
|
32
|
+
|
33
|
+
set_last_start_time!
|
34
|
+
|
35
|
+
assert_equal(start_time, Thread.current[:newrelic_start_time], "should set the start time correctly: #{start_time.inspect} expected but was #{Thread.current[:newrelic_start_time].inspect}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_set_new_scope
|
39
|
+
fakeagent = mock('agent')
|
40
|
+
self.expects(:agent).returns(fakeagent)
|
41
|
+
fakeengine = mock('stats_engine')
|
42
|
+
fakeagent.expects(:stats_engine).returns(fakeengine)
|
43
|
+
fakeengine.expects(:scope_name=).with('A METRIC')
|
44
|
+
|
45
|
+
set_new_scope!('A METRIC')
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_log_underflow
|
49
|
+
NewRelic::Agent.logger.expects(:error).with(regexp_matches(/Underflow in metric frames: /))
|
50
|
+
log_underflow
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_process_histogram_for_transaction
|
54
|
+
fakehistogram = mock('histogram')
|
55
|
+
agent.expects(:histogram).returns(fakehistogram)
|
56
|
+
self.expects(:start).returns(2)
|
57
|
+
fakehistogram.expects(:process).with(1.0)
|
58
|
+
process_histogram_for_transaction(3)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_notice_scope_empty
|
62
|
+
transaction_sampler.expects(:notice_scope_empty)
|
63
|
+
notice_scope_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_record_transaction_cpu_positive
|
67
|
+
self.expects(:cpu_burn).once.returns(1.0)
|
68
|
+
transaction_sampler.expects(:notice_transaction_cpu_time).with(1.0)
|
69
|
+
record_transaction_cpu
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_record_transaction_cpu_negative
|
73
|
+
self.expects(:cpu_burn).once.returns(nil)
|
74
|
+
# should not be called for the nil case
|
75
|
+
transaction_sampler.expects(:notice_transaction_cpu_time).never
|
76
|
+
record_transaction_cpu
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_normal_cpu_burn_positive
|
80
|
+
@process_cpu_start = 3
|
81
|
+
self.expects(:process_cpu).returns(4)
|
82
|
+
assert_equal 1, normal_cpu_burn
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_normal_cpu_burn_negative
|
86
|
+
@process_cpu_start = nil
|
87
|
+
self.expects(:process_cpu).never
|
88
|
+
assert_equal nil, normal_cpu_burn
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_jruby_cpu_burn_positive
|
92
|
+
@jruby_cpu_start = 3
|
93
|
+
self.expects(:jruby_cpu_time).returns(4)
|
94
|
+
self.expects(:record_jruby_cpu_burn).with(1)
|
95
|
+
assert_equal 1, jruby_cpu_burn
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_jruby_cpu_burn_negative
|
99
|
+
@jruby_cpu_start = nil
|
100
|
+
self.expects(:jruby_cpu_time).never
|
101
|
+
self.expects(:record_jruby_cpu_burn).never
|
102
|
+
assert_equal nil, jruby_cpu_burn
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_record_jruby_cpu_burn
|
106
|
+
NewRelic::Agent.get_stats_no_scope(NewRelic::Metrics::USER_TIME).expects(:record_data_point).with(1.0)
|
107
|
+
record_jruby_cpu_burn(1.0)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_cpu_burn_normal
|
111
|
+
self.expects(:normal_cpu_burn).returns(1)
|
112
|
+
self.expects(:jruby_cpu_burn).never
|
113
|
+
assert_equal 1, cpu_burn
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_cpu_burn_jruby
|
117
|
+
self.expects(:normal_cpu_burn).returns(nil)
|
118
|
+
self.expects(:jruby_cpu_burn).returns(2)
|
119
|
+
assert_equal 2, cpu_burn
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_end_transaction
|
123
|
+
fake_stats_engine = mock('stats engine')
|
124
|
+
agent.expects(:stats_engine).returns(fake_stats_engine)
|
125
|
+
fake_stats_engine.expects(:end_transaction)
|
126
|
+
end_transaction!
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_notify_transaction_sampler_true
|
130
|
+
self.expects(:record_transaction_cpu)
|
131
|
+
self.expects(:process_histogram_for_transaction)
|
132
|
+
self.expects(:notice_scope_empty)
|
133
|
+
notify_transaction_sampler(true)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_notify_transaction_sampler_false
|
137
|
+
self.expects(:record_transaction_cpu)
|
138
|
+
self.expects(:process_histogram_for_transaction).never
|
139
|
+
self.expects(:notice_scope_empty)
|
140
|
+
notify_transaction_sampler(false)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_traced
|
144
|
+
NewRelic::Agent.expects(:is_execution_traced?)
|
145
|
+
traced?
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_handle_empty_path_stack_default
|
149
|
+
@path_stack = [] # it is empty
|
150
|
+
self.expects(:traced?).returns(true)
|
151
|
+
fakemetric = mock('metric')
|
152
|
+
fakemetric.expects(:is_web_transaction?).returns(true)
|
153
|
+
self.expects(:notify_transaction_sampler).with(true)
|
154
|
+
self.expects(:end_transaction!)
|
155
|
+
self.expects(:set_last_start_time!)
|
156
|
+
self.expects(:clear_thread_metric_frame!)
|
157
|
+
handle_empty_path_stack(fakemetric)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_handle_empty_path_stack_non_web
|
161
|
+
@path_stack = [] # it is empty
|
162
|
+
self.expects(:traced?).returns(true)
|
163
|
+
fakemetric = mock('metric')
|
164
|
+
fakemetric.expects(:is_web_transaction?).returns(false)
|
165
|
+
self.expects(:notify_transaction_sampler).with(false)
|
166
|
+
self.expects(:end_transaction!)
|
167
|
+
self.expects(:set_last_start_time!)
|
168
|
+
self.expects(:clear_thread_metric_frame!)
|
169
|
+
handle_empty_path_stack(fakemetric)
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_handle_empty_path_stack_error
|
173
|
+
@path_stack = ['not empty']
|
174
|
+
assert_raise(RuntimeError) do
|
175
|
+
handle_empty_path_stack(mock('metric'))
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_handle_empty_path_stack_untraced
|
180
|
+
@path_stack = [] # it is empty
|
181
|
+
self.expects(:traced?).returns(false)
|
182
|
+
fakemetric = mock('metric')
|
183
|
+
fakemetric.expects(:is_web_transaction?).never
|
184
|
+
self.expects(:end_transaction!)
|
185
|
+
self.expects(:set_last_start_time!)
|
186
|
+
self.expects(:clear_thread_metric_frame!)
|
187
|
+
handle_empty_path_stack(fakemetric)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_current_stack_metric
|
191
|
+
self.expects(:metric_name)
|
192
|
+
current_stack_metric
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
@@ -1,82 +1,84 @@
|
|
1
|
-
|
1
|
+
unless ENV['FAST_TESTS']
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
2
3
|
|
3
|
-
class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def metrics_without_gc
|
12
|
-
@engine.metrics - ['GC/cumulative']
|
13
|
-
end
|
4
|
+
class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::TestCase
|
5
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
6
|
+
def setup
|
7
|
+
NewRelic::Agent.manual_start
|
8
|
+
@engine = NewRelic::Agent.instance.stats_engine
|
9
|
+
@engine.clear_stats
|
10
|
+
end
|
14
11
|
|
15
|
-
|
12
|
+
def metrics_without_gc
|
13
|
+
@engine.metrics - ['GC/cumulative']
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
url = URI.parse('http://www.google.com/index.html')
|
19
|
-
res = Net::HTTP.start(url.host, url.port) {|http|
|
20
|
-
http.get('/index.html')
|
21
|
-
}
|
22
|
-
assert_match /<head>/, res.body
|
23
|
-
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort,
|
24
|
-
metrics_without_gc.sort
|
25
|
-
end
|
16
|
+
private :metrics_without_gc
|
26
17
|
|
27
|
-
|
28
|
-
perform_action_with_newrelic_trace("task", :category => :task) do
|
18
|
+
def test_get
|
29
19
|
url = URI.parse('http://www.google.com/index.html')
|
30
20
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
31
21
|
http.get('/index.html')
|
32
22
|
}
|
33
23
|
assert_match /<head>/, res.body
|
24
|
+
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort,
|
25
|
+
metrics_without_gc.sort
|
34
26
|
end
|
35
|
-
|
27
|
+
|
28
|
+
def test_background
|
29
|
+
perform_action_with_newrelic_trace("task", :category => :task) do
|
30
|
+
url = URI.parse('http://www.google.com/index.html')
|
31
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
32
|
+
http.get('/index.html')
|
33
|
+
}
|
34
|
+
assert_match /<head>/, res.body
|
35
|
+
end
|
36
|
+
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all
|
36
37
|
External/www.google.com/Net::HTTP/GET:OtherTransaction/Background/NewRelic::Agent::Instrumentation::NetInstrumentationTest/task].sort, metrics_without_gc.select{|m| m =~ /^External/}.sort
|
37
|
-
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
def test_transactional
|
41
|
+
perform_action_with_newrelic_trace("task") do
|
42
|
+
url = URI.parse('http://www.google.com/index.html')
|
43
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
44
|
+
http.get('/index.html')
|
45
|
+
}
|
46
|
+
assert_match /<head>/, res.body
|
47
|
+
end
|
48
|
+
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allWeb External/www.google.com/all
|
49
|
+
External/www.google.com/Net::HTTP/GET:Controller/NewRelic::Agent::Instrumentation::NetInstrumentationTest/task].sort, metrics_without_gc.select{|m| m =~ /^External/}.sort
|
50
|
+
end
|
51
|
+
def test_get__simple
|
52
|
+
Net::HTTP.get URI.parse('http://www.google.com/index.html')
|
53
|
+
assert_equal metrics_without_gc.sort,
|
54
|
+
%w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort
|
55
|
+
end
|
56
|
+
def test_ignore
|
57
|
+
NewRelic::Agent.disable_all_tracing do
|
58
|
+
url = URI.parse('http://www.google.com/index.html')
|
59
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
60
|
+
http.post('/index.html','data')
|
61
|
+
}
|
62
|
+
end
|
63
|
+
assert_equal 0, metrics_without_gc.size
|
64
|
+
end
|
65
|
+
def test_head
|
41
66
|
url = URI.parse('http://www.google.com/index.html')
|
42
67
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
43
|
-
http.
|
68
|
+
http.head('/index.html')
|
44
69
|
}
|
45
|
-
|
70
|
+
assert_equal %w[External/www.google.com/Net::HTTP/HEAD External/allOther External/www.google.com/all].sort,
|
71
|
+
metrics_without_gc.sort
|
46
72
|
end
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
def test_get__simple
|
51
|
-
Net::HTTP.get URI.parse('http://www.google.com/index.html')
|
52
|
-
assert_equal metrics_without_gc.sort,
|
53
|
-
%w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort
|
54
|
-
end
|
55
|
-
def test_ignore
|
56
|
-
NewRelic::Agent.disable_all_tracing do
|
73
|
+
|
74
|
+
def test_post
|
57
75
|
url = URI.parse('http://www.google.com/index.html')
|
58
76
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
59
77
|
http.post('/index.html','data')
|
60
78
|
}
|
79
|
+
assert_equal %w[External/www.google.com/Net::HTTP/POST External/allOther External/www.google.com/all].sort,
|
80
|
+
metrics_without_gc.sort
|
61
81
|
end
|
62
|
-
assert_equal 0, metrics_without_gc.size
|
63
|
-
end
|
64
|
-
def test_head
|
65
|
-
url = URI.parse('http://www.google.com/index.html')
|
66
|
-
res = Net::HTTP.start(url.host, url.port) {|http|
|
67
|
-
http.head('/index.html')
|
68
|
-
}
|
69
|
-
assert_equal %w[External/www.google.com/Net::HTTP/HEAD External/allOther External/www.google.com/all].sort,
|
70
|
-
metrics_without_gc.sort
|
71
|
-
end
|
72
82
|
|
73
|
-
def test_post
|
74
|
-
url = URI.parse('http://www.google.com/index.html')
|
75
|
-
res = Net::HTTP.start(url.host, url.port) {|http|
|
76
|
-
http.post('/index.html','data')
|
77
|
-
}
|
78
|
-
assert_equal %w[External/www.google.com/Net::HTTP/POST External/allOther External/www.google.com/all].sort,
|
79
|
-
metrics_without_gc.sort
|
80
83
|
end
|
81
|
-
|
82
84
|
end
|
@@ -25,6 +25,20 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
25
25
|
assert_equal(server_start, parse_frontend_headers({:env => 'hash'}), "should return the oldest start time")
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_parse_frontend_headers_should_return_earliest_start
|
29
|
+
middleware_start = Time.at(1002)
|
30
|
+
queue_start = Time.at(1000)
|
31
|
+
server_start = Time.at(1001)
|
32
|
+
Time.stubs(:now).returns(Time.at(1003)) # whee!
|
33
|
+
self.expects(:add_end_time_header).with(Time.at(1003), {:env => 'hash'})
|
34
|
+
# ordering is important here, unfortunately, the mocks don't
|
35
|
+
# support that kind of checking.
|
36
|
+
self.expects(:parse_middleware_time_from).with({:env => 'hash'}).returns(middleware_start)
|
37
|
+
self.expects(:parse_queue_time_from).with({:env => 'hash'}).returns(queue_start)
|
38
|
+
self.expects(:parse_server_time_from).with({:env => 'hash'}).returns(server_start)
|
39
|
+
assert_equal(queue_start, parse_frontend_headers({:env => 'hash'}), "should return the oldest start time")
|
40
|
+
end
|
41
|
+
|
28
42
|
def test_all_combined_frontend_headers
|
29
43
|
env = {}
|
30
44
|
env[MAIN_HEADER] = "t=#{convert_to_microseconds(Time.at(1000))}"
|