newrelic_rpm 3.7.0.174.beta → 3.7.0.177
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -4
- data/bin/nrdebug +10 -4
- data/lib/new_relic/agent.rb +33 -11
- data/lib/new_relic/agent/agent.rb +83 -120
- data/lib/new_relic/agent/agent_logger.rb +28 -16
- data/lib/new_relic/agent/audit_logger.rb +3 -4
- data/lib/new_relic/agent/autostart.rb +20 -8
- data/lib/new_relic/agent/commands/agent_command_router.rb +26 -17
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -2
- data/lib/new_relic/agent/configuration/default_source.rb +146 -59
- data/lib/new_relic/agent/configuration/manager.rb +3 -3
- data/lib/new_relic/agent/cross_app_monitor.rb +15 -40
- data/lib/new_relic/agent/cross_app_tracing.rb +20 -12
- data/lib/new_relic/agent/database.rb +24 -0
- data/lib/new_relic/agent/error_collector.rb +6 -2
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +187 -0
- data/lib/new_relic/agent/new_relic_service.rb +30 -22
- data/lib/new_relic/agent/obfuscator.rb +48 -0
- data/lib/new_relic/agent/request_sampler.rb +5 -13
- data/lib/new_relic/agent/shim_agent.rb +1 -0
- data/lib/new_relic/agent/sql_sampler.rb +15 -5
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +9 -4
- data/lib/new_relic/agent/transaction.rb +0 -1
- data/lib/new_relic/agent/transaction_sampler.rb +28 -16
- data/lib/new_relic/agent/transaction_state.rb +9 -0
- data/lib/new_relic/agent/transaction_timings.rb +5 -1
- data/lib/new_relic/agent/worker_loop.rb +0 -10
- data/lib/new_relic/cli/deployments.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/lib/new_relic/helper.rb +3 -1
- data/lib/new_relic/rack/browser_monitoring.rb +1 -2
- data/lib/new_relic/transaction_sample.rb +11 -13
- data/lib/newrelic_rpm.rb +1 -0
- data/test/agent_helper.rb +20 -5
- data/test/environments/lib/environments/runner.rb +1 -0
- data/test/helpers/file_searching.rb +28 -0
- data/test/multiverse/lib/multiverse/suite.rb +36 -19
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +49 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +2 -2
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +4 -2
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +7 -4
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +2 -1
- data/test/multiverse/suites/rails/error_tracing_test.rb +34 -4
- data/test/multiverse/suites/rails/ignore_test.rb +1 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +1 -3
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sinatra/ignoring_test.rb +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
- data/test/new_relic/agent/agent_logger_test.rb +108 -114
- data/test/new_relic/agent/agent_test.rb +139 -21
- data/test/new_relic/agent/audit_logger_test.rb +22 -20
- data/test/new_relic/agent/autostart_test.rb +3 -2
- data/test/new_relic/agent/commands/agent_command_router_test.rb +51 -32
- data/test/new_relic/agent/configuration/default_source_test.rb +8 -2
- data/test/new_relic/agent/configuration/manager_test.rb +5 -1
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +57 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +10 -26
- data/test/new_relic/agent/database_test.rb +32 -0
- data/test/new_relic/agent/error_collector_test.rb +33 -16
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +88 -71
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/javascript_instrumentor_test.rb +341 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +91 -89
- data/test/new_relic/agent/method_tracer_test.rb +1 -1
- data/test/new_relic/agent/obfuscator_test.rb +77 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +5 -5
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +21 -11
- data/test/new_relic/agent/sql_sampler_test.rb +52 -8
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +6 -6
- data/test/new_relic/agent/stats_engine_test.rb +18 -2
- data/test/new_relic/agent/transaction_sampler_test.rb +98 -53
- data/test/new_relic/agent/transaction_state_test.rb +44 -0
- data/test/new_relic/agent/transaction_test.rb +1 -1
- data/test/new_relic/agent/transaction_timings_test.rb +15 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -9
- data/test/new_relic/agent_test.rb +9 -21
- data/test/new_relic/data_container_tests.rb +72 -0
- data/test/new_relic/fake_collector.rb +69 -20
- data/test/new_relic/http_client_test_cases.rb +17 -2
- data/test/new_relic/license_test.rb +6 -15
- data/test/new_relic/multiverse_helpers.rb +2 -3
- data/test/new_relic/rack/browser_monitoring_test.rb +15 -37
- data/test/new_relic/transaction_sample_test.rb +92 -62
- data/test/performance/suites/rum_autoinsertion.rb +0 -3
- data/test/rum/x_ua_meta_tag_spaces_around_equals.result.html +10 -0
- data/test/rum/x_ua_meta_tag_spaces_around_equals.source.html +10 -0
- data/test/test_helper.rb +9 -5
- metadata +29 -11
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/beacon_configuration.rb +0 -37
- data/lib/new_relic/agent/browser_monitoring.rb +0 -257
- data/test/new_relic/agent/beacon_configuration_test.rb +0 -44
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -474
@@ -14,7 +14,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def teardown
|
17
|
-
@engine.
|
17
|
+
@engine.reset!
|
18
18
|
super
|
19
19
|
end
|
20
20
|
|
@@ -46,7 +46,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
46
46
|
assert_equal 2, @engine.get_stats("c").call_count
|
47
47
|
assert_equal 4, @engine.get_stats("c").total_call_time
|
48
48
|
|
49
|
-
harvested = @engine.harvest
|
49
|
+
harvested = @engine.harvest!
|
50
50
|
|
51
51
|
# after harvest, all the metrics should be reset
|
52
52
|
assert_equal 0, @engine.get_stats("a").call_count
|
@@ -73,7 +73,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
73
73
|
@engine.get_stats_no_scope('Custom/foo/3/bar/44').record_data_point(1)
|
74
74
|
@engine.get_stats_no_scope('Custom/foo/5/bar/66').record_data_point(1)
|
75
75
|
|
76
|
-
harvested = @engine.harvest
|
76
|
+
harvested = @engine.harvest!
|
77
77
|
|
78
78
|
assert !harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/1/bar/22'))
|
79
79
|
assert !harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/3/bar/44'))
|
@@ -87,7 +87,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
87
87
|
s.trace_call 1
|
88
88
|
assert_equal 1, @engine.get_stats("a").call_count
|
89
89
|
|
90
|
-
harvest = @engine.harvest
|
90
|
+
harvest = @engine.harvest!
|
91
91
|
|
92
92
|
s = @engine.get_stats "a"
|
93
93
|
assert_equal 0, s.call_count
|
@@ -97,7 +97,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
97
97
|
# this should merge the contents of the previous harvest,
|
98
98
|
# so the stats for metric "a" should have 2 data points
|
99
99
|
@engine.merge!(harvest)
|
100
|
-
harvest = @engine.harvest
|
100
|
+
harvest = @engine.harvest!
|
101
101
|
stats = harvest.fetch(NewRelic::MetricSpec.new("a"))
|
102
102
|
assert_equal 2, stats.call_count
|
103
103
|
assert_equal 3, stats.total_call_time
|
@@ -120,7 +120,7 @@ class NewRelic::Agent::MetricStatsTest < Test::Unit::TestCase
|
|
120
120
|
|
121
121
|
def test_harvest_adds_harvested_at_time
|
122
122
|
t0 = freeze_time
|
123
|
-
result = @engine.harvest
|
123
|
+
result = @engine.harvest!
|
124
124
|
assert_equal(t0, result.harvested_at)
|
125
125
|
end
|
126
126
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..', 'test_helper'))
|
6
|
-
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','data_container_tests'))
|
7
7
|
|
8
8
|
class NewRelic::Agent::StatsEngineTest < Test::Unit::TestCase
|
9
9
|
def setup
|
@@ -15,11 +15,27 @@ class NewRelic::Agent::StatsEngineTest < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def teardown
|
18
|
-
@engine.
|
18
|
+
@engine.reset!
|
19
19
|
mocha_teardown
|
20
20
|
super
|
21
21
|
end
|
22
22
|
|
23
|
+
# Helpers for DataContainerTests
|
24
|
+
|
25
|
+
def create_container
|
26
|
+
NewRelic::Agent::StatsEngine.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def populate_container(engine, n)
|
30
|
+
n.times do |i|
|
31
|
+
engine.record_metrics("metric#{i}", i)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
include NewRelic::DataContainerTests
|
36
|
+
|
37
|
+
# Tests
|
38
|
+
|
23
39
|
def test_scope
|
24
40
|
@engine.push_scope(:scope1)
|
25
41
|
assert_equal 1, @engine.scope_stack.size
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','data_container_tests'))
|
6
7
|
|
7
8
|
class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
8
9
|
|
@@ -45,6 +46,23 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
45
46
|
NewRelic::Agent.instance.instance_variable_set(:@transaction_sampler, @old_sampler)
|
46
47
|
end
|
47
48
|
|
49
|
+
# Helpers for DataContainerTests
|
50
|
+
|
51
|
+
def create_container
|
52
|
+
@sampler
|
53
|
+
end
|
54
|
+
|
55
|
+
def populate_container(sampler, n)
|
56
|
+
n.times do |i|
|
57
|
+
sample = sample_with(:duration => 1, :transaction_name => "t#{i}", :force_persist => true)
|
58
|
+
@sampler.store_sample(sample)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
include NewRelic::DataContainerTests
|
63
|
+
|
64
|
+
# Tests
|
65
|
+
|
48
66
|
def test_notice_first_scope_push_default
|
49
67
|
@sampler.expects(:start_builder).with(100.0)
|
50
68
|
@sampler.notice_first_scope_push(Time.at(100))
|
@@ -200,8 +218,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
200
218
|
segment = mock('segment')
|
201
219
|
@sampler.expects(:builder).returns(builder).twice
|
202
220
|
builder.expects(:current_segment).returns(segment)
|
203
|
-
segment.expects(:[]).with(key).returns(nil)
|
204
|
-
@sampler.expects(:append_new_message).with(nil, 'a message').returns('a message')
|
205
221
|
NewRelic::Agent::TransactionSampler.expects(:truncate_message) \
|
206
222
|
.with('a message').returns('truncated_message')
|
207
223
|
segment.expects(:[]=).with(key, 'truncated_message')
|
@@ -209,30 +225,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
209
225
|
@sampler.send(:notice_extra_data, 'a message', 1.0, key)
|
210
226
|
end
|
211
227
|
|
212
|
-
def test_truncate_message_short_message
|
213
|
-
message = 'a message'
|
214
|
-
assert_equal(message, NewRelic::Agent::TransactionSampler.truncate_message(message))
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_truncate_message_long_message
|
218
|
-
message = 'a' * 16384
|
219
|
-
truncated_message = NewRelic::Agent::TransactionSampler.truncate_message(message)
|
220
|
-
assert_equal(16384, truncated_message.length)
|
221
|
-
assert_equal('a' * 16381 + '...', truncated_message)
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_append_new_message_no_old_message
|
225
|
-
old_message = nil
|
226
|
-
new_message = 'a message'
|
227
|
-
assert_equal(new_message, @sampler.append_new_message(old_message, new_message))
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_append_new_message_with_old_message
|
231
|
-
old_message = 'old message'
|
232
|
-
new_message = ' a message'
|
233
|
-
assert_equal("old message;\n a message", @sampler.append_new_message(old_message, new_message))
|
234
|
-
end
|
235
|
-
|
236
228
|
def test_append_backtrace_under_duration
|
237
229
|
with_config(:'transaction_tracer.stack_trace_threshold' => 2.0) do
|
238
230
|
segment = mock('segment')
|
@@ -271,7 +263,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
271
263
|
def test_harvest_when_disabled
|
272
264
|
with_config(:'transaction_tracer.enabled' => false,
|
273
265
|
:developer_mode => false) do
|
274
|
-
assert_equal([], @sampler.harvest)
|
266
|
+
assert_equal([], @sampler.harvest!)
|
275
267
|
end
|
276
268
|
end
|
277
269
|
|
@@ -281,26 +273,26 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
281
273
|
@last_sample = 'a sample'
|
282
274
|
end
|
283
275
|
|
284
|
-
assert_equal([], @sampler.harvest)
|
276
|
+
assert_equal([], @sampler.harvest!)
|
285
277
|
|
286
278
|
# make sure the samples have been cleared
|
287
279
|
assert_equal(nil, @sampler.instance_variable_get('@last_sample'))
|
288
280
|
end
|
289
281
|
|
290
282
|
def test_harvest_no_data
|
291
|
-
assert_equal([], @sampler.harvest)
|
283
|
+
assert_equal([], @sampler.harvest!)
|
292
284
|
end
|
293
285
|
|
294
286
|
def test_add_samples_holds_onto_previous_result
|
295
287
|
sample = sample_with(:duration => 1)
|
296
288
|
@sampler.merge!([sample])
|
297
|
-
assert_equal([sample], @sampler.harvest)
|
289
|
+
assert_equal([sample], @sampler.harvest!)
|
298
290
|
end
|
299
291
|
|
300
292
|
def test_merge_avoids_dups
|
301
293
|
sample = sample_with(:duration => 1)
|
302
294
|
@sampler.merge!([sample, sample])
|
303
|
-
assert_equal([sample], @sampler.harvest)
|
295
|
+
assert_equal([sample], @sampler.harvest!)
|
304
296
|
end
|
305
297
|
|
306
298
|
def test_harvest_avoids_dups_from_harvested_samples
|
@@ -308,20 +300,20 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
308
300
|
@sampler.store_sample(sample)
|
309
301
|
@sampler.store_sample(sample)
|
310
302
|
|
311
|
-
assert_equal([sample], @sampler.harvest)
|
303
|
+
assert_equal([sample], @sampler.harvest!)
|
312
304
|
end
|
313
305
|
|
314
306
|
def test_merge_avoids_dups_from_forced
|
315
307
|
sample = sample_with(:duration => 1, :force_persist => true)
|
316
308
|
@sampler.merge!([sample, sample])
|
317
|
-
assert_equal([sample], @sampler.harvest)
|
309
|
+
assert_equal([sample], @sampler.harvest!)
|
318
310
|
end
|
319
311
|
|
320
312
|
def test_harvest_adding_slowest
|
321
313
|
sample = sample_with(:duration => 2.5, :force_persist => false)
|
322
314
|
@sampler.store_sample(sample)
|
323
315
|
|
324
|
-
assert_equal([sample], @sampler.harvest)
|
316
|
+
assert_equal([sample], @sampler.harvest!)
|
325
317
|
end
|
326
318
|
|
327
319
|
def test_harvest_new_slower_sample_replaces_older
|
@@ -331,7 +323,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
331
323
|
@sampler.store_sample(slower_sample)
|
332
324
|
@sampler.merge!([faster_sample])
|
333
325
|
|
334
|
-
assert_equal([slower_sample], @sampler.harvest)
|
326
|
+
assert_equal([slower_sample], @sampler.harvest!)
|
335
327
|
end
|
336
328
|
|
337
329
|
def test_harvest_keep_older_slower_sample
|
@@ -341,7 +333,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
341
333
|
@sampler.store_sample(faster_sample)
|
342
334
|
@sampler.merge!([slower_sample])
|
343
335
|
|
344
|
-
assert_equal([slower_sample], @sampler.harvest)
|
336
|
+
assert_equal([slower_sample], @sampler.harvest!)
|
345
337
|
end
|
346
338
|
|
347
339
|
def test_harvest_keep_force_persist_in_previous_results
|
@@ -349,7 +341,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
349
341
|
forced_sample = sample_with(:duration => 1, :force_persist => true)
|
350
342
|
|
351
343
|
@sampler.merge!([unforced_sample, forced_sample])
|
352
|
-
result = @sampler.harvest
|
344
|
+
result = @sampler.harvest!
|
353
345
|
|
354
346
|
assert_includes(result, unforced_sample)
|
355
347
|
assert_includes(result, forced_sample)
|
@@ -362,7 +354,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
362
354
|
unforced_sample = sample_with(:duration => 10, :force_persist => false)
|
363
355
|
@sampler.store_sample(unforced_sample)
|
364
356
|
|
365
|
-
result = @sampler.harvest
|
357
|
+
result = @sampler.harvest!
|
366
358
|
|
367
359
|
assert_includes(result, unforced_sample)
|
368
360
|
assert_includes(result, forced_sample)
|
@@ -375,7 +367,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
375
367
|
old_forced = sample_with(:duration => 1, :force_persist => true)
|
376
368
|
|
377
369
|
@sampler.merge!([old_forced])
|
378
|
-
result = @sampler.harvest
|
370
|
+
result = @sampler.harvest!
|
379
371
|
|
380
372
|
assert_includes(result, new_forced)
|
381
373
|
assert_includes(result, old_forced)
|
@@ -398,7 +390,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
398
390
|
result = nil
|
399
391
|
with_active_xray_session("Active/xray") do
|
400
392
|
@sampler.merge!(previous)
|
401
|
-
result = @sampler.harvest
|
393
|
+
result = @sampler.harvest!
|
402
394
|
end
|
403
395
|
|
404
396
|
expected = [slowest]
|
@@ -424,7 +416,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
424
416
|
end
|
425
417
|
end
|
426
418
|
|
427
|
-
result = @sampler.harvest
|
419
|
+
result = @sampler.harvest!
|
428
420
|
|
429
421
|
expected = [slowest]
|
430
422
|
expected = expected.concat(forced_samples.last(FORCE_PERSIST_MAX))
|
@@ -449,7 +441,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
449
441
|
@sampler.store_sample(sample)
|
450
442
|
end
|
451
443
|
|
452
|
-
result = @sampler.harvest
|
444
|
+
result = @sampler.harvest!
|
453
445
|
assert_equal NewRelic::Agent::Transaction::TransactionSampleBuffer::SINGLE_BUFFER_MAX, result.length
|
454
446
|
end
|
455
447
|
|
@@ -513,7 +505,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
513
505
|
|
514
506
|
@sampler.notice_pop_scope "a"
|
515
507
|
@sampler.notice_scope_empty(@txn)
|
516
|
-
sample = @sampler.harvest
|
508
|
+
sample = @sampler.harvest!.first
|
517
509
|
assert_equal "ROOT{a{b,c{d}}}", sample.to_s_compact
|
518
510
|
end
|
519
511
|
end
|
@@ -540,7 +532,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
540
532
|
@sampler.notice_pop_scope "a"
|
541
533
|
@sampler.notice_scope_empty(@txn)
|
542
534
|
|
543
|
-
sample = @sampler.harvest
|
535
|
+
sample = @sampler.harvest!.first
|
544
536
|
assert_equal "ROOT{a{b,c{d}}}", sample.to_s_compact
|
545
537
|
end
|
546
538
|
ensure
|
@@ -559,7 +551,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
559
551
|
run_sample_trace(0,0.1)
|
560
552
|
run_sample_trace(0,0.1)
|
561
553
|
|
562
|
-
slowest = @sampler.harvest[0]
|
554
|
+
slowest = @sampler.harvest![0]
|
563
555
|
first_duration = slowest.duration
|
564
556
|
assert((first_duration.round >= 2),
|
565
557
|
"expected sample duration = 2, but was: #{slowest.duration.inspect}")
|
@@ -567,13 +559,13 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
567
559
|
# 1 second duration
|
568
560
|
run_sample_trace(0,1)
|
569
561
|
@sampler.merge!([slowest])
|
570
|
-
not_as_slow = @sampler.harvest[0]
|
562
|
+
not_as_slow = @sampler.harvest![0]
|
571
563
|
assert((not_as_slow == slowest), "Should re-harvest the same transaction since it should be slower than the new transaction - expected #{slowest.inspect} but got #{not_as_slow.inspect}")
|
572
564
|
|
573
565
|
run_sample_trace(0,10)
|
574
566
|
|
575
567
|
@sampler.merge!([slowest])
|
576
|
-
new_slowest = @sampler.harvest[0]
|
568
|
+
new_slowest = @sampler.harvest![0]
|
577
569
|
assert((new_slowest != slowest), "Should not harvest the same trace since the new one should be slower")
|
578
570
|
assert_equal(new_slowest.duration.round, 10, "Slowest duration must be = 10, but was: #{new_slowest.duration.inspect}")
|
579
571
|
end
|
@@ -582,7 +574,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
582
574
|
def test_prepare_to_send
|
583
575
|
sample = with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
584
576
|
run_sample_trace { sleep 0.002 }
|
585
|
-
@sampler.harvest[0]
|
577
|
+
@sampler.harvest![0]
|
586
578
|
end
|
587
579
|
|
588
580
|
ready_to_send = sample.prepare_to_send!
|
@@ -643,7 +635,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
643
635
|
@sampler.notice_scope_empty(@txn)
|
644
636
|
@sampler.notice_scope_empty(@txn)
|
645
637
|
|
646
|
-
assert_not_nil @sampler.harvest[0]
|
638
|
+
assert_not_nil @sampler.harvest![0]
|
647
639
|
end
|
648
640
|
end
|
649
641
|
|
@@ -733,7 +725,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
733
725
|
@sampler.notice_first_scope_push Time.now.to_f
|
734
726
|
@sampler.notice_transaction(nil, :param => 'hi')
|
735
727
|
@sampler.notice_scope_empty(@txn)
|
736
|
-
@sampler.harvest[0]
|
728
|
+
@sampler.harvest![0]
|
737
729
|
end
|
738
730
|
|
739
731
|
assert_equal (capture ? 1 : 0), tt.params[:request_params].length
|
@@ -745,13 +737,18 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
745
737
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
746
738
|
run_sample_trace do
|
747
739
|
@sampler.notice_push_scope
|
748
|
-
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = '
|
740
|
+
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'challah'", {}, 0)
|
749
741
|
@sampler.notice_push_scope
|
750
742
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'semolina'", {}, 0)
|
751
743
|
@sampler.notice_pop_scope "a11"
|
752
744
|
@sampler.notice_pop_scope "a1"
|
753
745
|
end
|
754
746
|
assert_equal 3, @sampler.last_sample.count_segments
|
747
|
+
|
748
|
+
expected_sql = "SELECT * FROM sandwiches WHERE bread = 'challah'"
|
749
|
+
deepest_segment = find_last_transaction_segment(@sampler.last_sample)
|
750
|
+
assert_equal([], deepest_segment.called_segments)
|
751
|
+
assert_equal(expected_sql, deepest_segment[:sql])
|
755
752
|
end
|
756
753
|
end
|
757
754
|
|
@@ -782,7 +779,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
782
779
|
|
783
780
|
samples = nil
|
784
781
|
assert_nothing_raised do
|
785
|
-
samples = @sampler.harvest
|
782
|
+
samples = @sampler.harvest!
|
786
783
|
end
|
787
784
|
assert_equal(1, samples.size)
|
788
785
|
|
@@ -809,6 +806,54 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
809
806
|
end
|
810
807
|
end
|
811
808
|
|
809
|
+
def test_harvest_prepare_samples
|
810
|
+
samples = [mock('TT0'), mock('TT1')]
|
811
|
+
samples[0].expects(:prepare_to_send!)
|
812
|
+
samples[1].expects(:prepare_to_send!)
|
813
|
+
@sampler.stubs(:harvest_from_sample_buffers).returns(samples)
|
814
|
+
prepared = @sampler.harvest!
|
815
|
+
assert_equal(samples, prepared)
|
816
|
+
end
|
817
|
+
|
818
|
+
def test_harvest_prepare_samples_with_error
|
819
|
+
samples = [mock('TT0'), mock('TT1')]
|
820
|
+
samples[0].expects(:prepare_to_send!).raises('an error')
|
821
|
+
samples[1].expects(:prepare_to_send!)
|
822
|
+
@sampler.stubs(:harvest_from_sample_buffers).returns(samples)
|
823
|
+
prepared = @sampler.harvest!
|
824
|
+
assert_equal([samples[1]], prepared)
|
825
|
+
end
|
826
|
+
|
827
|
+
def test_custom_params_omitted_if_config_says_so
|
828
|
+
config = {
|
829
|
+
:'transaction_tracer.transaction_threshold' => 0.0,
|
830
|
+
:'capture_attributes.traces' => false
|
831
|
+
}
|
832
|
+
with_config(config) do
|
833
|
+
in_transaction do
|
834
|
+
NewRelic::Agent.add_custom_parameters(:foo => 'bar')
|
835
|
+
end
|
836
|
+
end
|
837
|
+
sample = NewRelic::Agent.agent.transaction_sampler.harvest![0]
|
838
|
+
custom_params = sample.params[:custom_params]
|
839
|
+
assert_false(custom_params.keys.include?(:foo))
|
840
|
+
end
|
841
|
+
|
842
|
+
def test_custom_params_included_if_config_says_so
|
843
|
+
config = {
|
844
|
+
:'transaction_tracer.transaction_threshold' => 0.0,
|
845
|
+
:'capture_attributes.traces' => true
|
846
|
+
}
|
847
|
+
with_config(config) do
|
848
|
+
in_transaction do
|
849
|
+
NewRelic::Agent.add_custom_parameters(:foo => 'bar')
|
850
|
+
end
|
851
|
+
end
|
852
|
+
sample = NewRelic::Agent.agent.transaction_sampler.harvest![0]
|
853
|
+
custom_params = sample.params[:custom_params]
|
854
|
+
assert(custom_params.keys.include?(:foo), "Expected custom param on TT because capture_attributes.traces is true")
|
855
|
+
end
|
856
|
+
|
812
857
|
class Dummy
|
813
858
|
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
814
859
|
def run(n)
|
@@ -823,7 +868,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
823
868
|
def sadly_do_not_test_harvest_during_transaction_safety
|
824
869
|
n = 3000
|
825
870
|
harvester = Thread.new do
|
826
|
-
n.times { @sampler.harvest }
|
871
|
+
n.times { @sampler.harvest! }
|
827
872
|
end
|
828
873
|
|
829
874
|
assert_nothing_raised { Dummy.new.run(n) }
|
@@ -71,5 +71,49 @@ module NewRelic::Agent
|
|
71
71
|
assert_equal 5.0, timings.app_time_in_seconds
|
72
72
|
assert_equal transaction.name, timings.transaction_name
|
73
73
|
end
|
74
|
+
|
75
|
+
GUID = "goo-id"
|
76
|
+
|
77
|
+
def test_request_guid_to_include
|
78
|
+
with_config(:apdex_t => 2.0) do
|
79
|
+
freeze_time
|
80
|
+
|
81
|
+
state.request_token = "token"
|
82
|
+
state.request_guid = GUID
|
83
|
+
state.transaction = NewRelic::Agent::Transaction.new
|
84
|
+
|
85
|
+
advance_time(4.0)
|
86
|
+
|
87
|
+
assert_equal GUID, state.request_guid_to_include
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_requst_guid_excluded_if_request_fast_enough
|
92
|
+
with_config(:apdex_t => 2.0) do
|
93
|
+
freeze_time
|
94
|
+
|
95
|
+
state.request_token = "token"
|
96
|
+
state.request_guid = GUID
|
97
|
+
state.transaction = NewRelic::Agent::Transaction.new
|
98
|
+
|
99
|
+
advance_time(1.0)
|
100
|
+
|
101
|
+
assert_equal "", state.request_guid_to_include
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_request_guid_excluded_if_no_token
|
106
|
+
with_config(:apdex_t => 2.0) do
|
107
|
+
freeze_time
|
108
|
+
|
109
|
+
state.request_token = nil
|
110
|
+
state.request_guid = GUID
|
111
|
+
state.transaction = NewRelic::Agent::Transaction.new
|
112
|
+
|
113
|
+
advance_time(4.0)
|
114
|
+
|
115
|
+
assert_equal "", state.request_guid_to_include
|
116
|
+
end
|
117
|
+
end
|
74
118
|
end
|
75
119
|
end
|