newrelic_rpm 3.8.0.218 → 3.8.1.221
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 +32 -0
- data/README.md +4 -7
- data/Rakefile +3 -0
- data/lib/new_relic/agent.rb +3 -7
- data/lib/new_relic/agent/agent.rb +4 -14
- data/lib/new_relic/agent/agent_logger.rb +19 -11
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +25 -12
- data/lib/new_relic/agent/configuration/manager.rb +14 -7
- data/lib/new_relic/agent/configuration/yaml_source.rb +39 -8
- data/lib/new_relic/agent/cross_app_monitor.rb +9 -7
- data/lib/new_relic/agent/cross_app_tracing.rb +6 -6
- data/lib/new_relic/agent/datastores/mongo.rb +6 -7
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +32 -13
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +4 -3
- data/lib/new_relic/agent/error_collector.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -69
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +77 -93
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/mongo.rb +26 -42
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +15 -6
- data/lib/new_relic/agent/method_tracer.rb +41 -92
- data/lib/new_relic/agent/request_sampler.rb +0 -1
- data/lib/new_relic/agent/rules_engine.rb +36 -12
- data/lib/new_relic/agent/shim_agent.rb +0 -1
- data/lib/new_relic/agent/sql_sampler.rb +8 -15
- data/lib/new_relic/agent/stats_engine.rb +2 -6
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +8 -2
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/supported_versions.rb +1 -1
- data/lib/new_relic/agent/traced_method_stack.rb +87 -0
- data/lib/new_relic/agent/transaction.rb +277 -107
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -2
- data/lib/new_relic/agent/transaction_sampler.rb +18 -27
- data/lib/new_relic/agent/transaction_state.rb +15 -40
- data/lib/new_relic/control/instance_methods.rb +8 -4
- data/lib/new_relic/recipes.rb +3 -3
- data/lib/new_relic/transaction_sample.rb +3 -7
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +3 -3
- data/newrelic_rpm.gemspec +15 -9
- data/test/agent_helper.rb +71 -36
- data/test/environments/norails/Gemfile +2 -0
- data/test/environments/rails21/Gemfile +2 -0
- data/test/environments/rails22/Gemfile +2 -0
- data/test/environments/rails23/Gemfile +2 -0
- data/test/environments/rails30/Gemfile +2 -0
- data/test/environments/rails31/Gemfile +2 -0
- data/test/environments/rails32/Gemfile +2 -0
- data/test/environments/rails40/Gemfile +2 -0
- data/test/environments/rails41/Gemfile +1 -0
- data/test/helpers/mongo_metric_builder.rb +1 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +2 -2
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +9 -1
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/logging_test.rb +2 -2
- data/test/multiverse/suites/agent_only/marshaling_test.rb +8 -9
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +14 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +30 -13
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +9 -8
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +43 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +77 -5
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/mongo/Envfile +4 -7
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +55 -16
- data/test/multiverse/suites/mongo/helpers/mongo_server.rb +6 -4
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +3 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +14 -14
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +45 -0
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/agent/connect_test.rb +4 -4
- data/test/new_relic/agent/agent_logger_test.rb +32 -0
- data/test/new_relic/agent/configuration/manager_test.rb +12 -4
- data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
- data/test/new_relic/agent/cross_app_monitor_test.rb +6 -2
- data/test/new_relic/agent/cross_app_tracing_test.rb +5 -5
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +7 -6
- data/test/new_relic/agent/error_collector_test.rb +1 -2
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +24 -11
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +12 -17
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +43 -32
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +3 -4
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +36 -20
- data/test/new_relic/agent/javascript_instrumentor_test.rb +1 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +15 -26
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +66 -103
- data/test/new_relic/agent/method_tracer_test.rb +2 -2
- data/test/new_relic/agent/mock_scope_listener.rb +3 -6
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -4
- data/test/new_relic/agent/rules_engine_test.rb +13 -0
- data/test/new_relic/agent/sql_sampler_test.rb +8 -10
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +18 -0
- data/test/new_relic/agent/stats_engine_test.rb +0 -173
- data/test/new_relic/agent/threading/agent_thread_test.rb +27 -26
- data/test/new_relic/agent/traced_method_stack_test.rb +139 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +2 -12
- data/test/new_relic/agent/transaction_sampler_test.rb +98 -107
- data/test/new_relic/agent/transaction_state_test.rb +52 -61
- data/test/new_relic/agent/transaction_test.rb +209 -140
- data/test/new_relic/agent_test.rb +3 -2
- data/test/new_relic/control_test.rb +10 -9
- data/test/new_relic/fake_collector.rb +34 -2
- data/test/new_relic/http_client_test_cases.rb +0 -5
- data/test/new_relic/license_test.rb +4 -2
- data/test/new_relic/local_environment_test.rb +14 -28
- data/test/new_relic/multiverse_helpers.rb +2 -2
- data/test/new_relic/rack/developer_mode_test.rb +4 -5
- data/test/new_relic/transaction_ignoring_test_cases.rb +104 -0
- data/test/new_relic/transaction_sample_test.rb +14 -7
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +6 -3
- data/test/performance/suites/transaction_tracing.rb +4 -1
- data/test/test_helper.rb +31 -60
- data/ui/views/newrelic/show_sample.rhtml +1 -1
- metadata +46 -101
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +0 -114
- data/lib/new_relic/agent/transaction/pop.rb +0 -52
- data/test/new_relic/agent/transaction/pop_test.rb +0 -79
@@ -31,12 +31,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
31
31
|
stats_engine = NewRelic::Agent::StatsEngine.new
|
32
32
|
agent.stubs(:stats_engine).returns(stats_engine)
|
33
33
|
@sampler = NewRelic::Agent::TransactionSampler.new
|
34
|
-
stats_engine.transaction_sampler = @sampler
|
35
34
|
@old_sampler = NewRelic::Agent.instance.transaction_sampler
|
36
35
|
NewRelic::Agent.instance.instance_variable_set(:@transaction_sampler, @sampler)
|
37
36
|
@test_config = { :'transaction_tracer.enabled' => true }
|
38
37
|
NewRelic::Agent.config.apply_config(@test_config)
|
39
|
-
@txn = stub('txn', :
|
38
|
+
@txn = stub('txn', :best_name => '/path', :custom_parameters => {}, :guid => 'a guid')
|
40
39
|
end
|
41
40
|
|
42
41
|
def teardown
|
@@ -63,39 +62,39 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
63
62
|
|
64
63
|
# Tests
|
65
64
|
|
66
|
-
def
|
65
|
+
def test_on_start_transaction_default
|
67
66
|
@sampler.expects(:start_builder).with(100.0)
|
68
|
-
@sampler.
|
67
|
+
@sampler.on_start_transaction(Time.at(100))
|
69
68
|
end
|
70
69
|
|
71
|
-
def
|
70
|
+
def test_on_start_transaction_disabled
|
72
71
|
with_config(:'transaction_tracer.enabled' => false,
|
73
72
|
:developer_mode => false) do
|
74
73
|
@sampler.expects(:start_builder).never
|
75
|
-
@sampler.
|
74
|
+
@sampler.on_start_transaction(Time.at(100))
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
79
|
-
def
|
78
|
+
def test_notice_push_frame_no_builder
|
80
79
|
@sampler.expects(:builder)
|
81
|
-
assert_equal(nil, @sampler.
|
80
|
+
assert_equal(nil, @sampler.notice_push_frame())
|
82
81
|
end
|
83
82
|
|
84
|
-
def
|
83
|
+
def test_notice_push_frame_with_builder
|
85
84
|
with_config(:developer_mode => false) do
|
86
85
|
builder = mock('builder')
|
87
86
|
builder.expects(:trace_entry).with(100.0)
|
88
87
|
@sampler.expects(:builder).returns(builder).twice
|
89
|
-
@sampler.
|
88
|
+
@sampler.notice_push_frame(Time.at(100))
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
def
|
92
|
+
def test_notice_pop_frame_no_builder
|
94
93
|
@sampler.expects(:builder).returns(nil)
|
95
|
-
assert_equal(nil, @sampler.
|
94
|
+
assert_equal(nil, @sampler.notice_pop_frame('a frame', Time.at(100)))
|
96
95
|
end
|
97
96
|
|
98
|
-
def
|
97
|
+
def test_notice_pop_frame_with_finished_sample
|
99
98
|
builder = mock('builder')
|
100
99
|
sample = mock('sample')
|
101
100
|
builder.expects(:sample).returns(sample)
|
@@ -103,27 +102,27 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
103
102
|
@sampler.expects(:builder).returns(builder).twice
|
104
103
|
|
105
104
|
assert_raises(RuntimeError) do
|
106
|
-
@sampler.
|
105
|
+
@sampler.notice_pop_frame('a frame', Time.at(100))
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
110
|
-
def
|
109
|
+
def test_notice_pop_frame_builder_delegation
|
111
110
|
builder = mock('builder')
|
112
|
-
builder.expects(:trace_exit).with('a
|
111
|
+
builder.expects(:trace_exit).with('a frame', 100.0)
|
113
112
|
sample = mock('sample')
|
114
113
|
builder.expects(:sample).returns(sample)
|
115
114
|
sample.expects(:finished).returns(false)
|
116
115
|
@sampler.expects(:builder).returns(builder).times(3)
|
117
116
|
|
118
|
-
@sampler.
|
117
|
+
@sampler.notice_pop_frame('a frame', Time.at(100))
|
119
118
|
end
|
120
119
|
|
121
|
-
def
|
120
|
+
def test_on_finishing_transaction_no_builder
|
122
121
|
@sampler.expects(:builder).returns(nil)
|
123
|
-
assert_equal(nil, @sampler.
|
122
|
+
assert_equal(nil, @sampler.on_finishing_transaction(@txn))
|
124
123
|
end
|
125
124
|
|
126
|
-
def
|
125
|
+
def test_on_finishing_transaction_ignored_transaction
|
127
126
|
builder = mock('builder')
|
128
127
|
# the builder should be cached, so only called once
|
129
128
|
@sampler.expects(:builder).returns(builder).once
|
@@ -135,10 +134,10 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
135
134
|
builder.expects(:ignored?).returns(true)
|
136
135
|
builder.expects(:set_transaction_name).returns(true)
|
137
136
|
|
138
|
-
assert_equal(nil, @sampler.
|
137
|
+
assert_equal(nil, @sampler.on_finishing_transaction(@txn, Time.at(100)))
|
139
138
|
end
|
140
139
|
|
141
|
-
def
|
140
|
+
def test_on_finishing_transaction_with_builder
|
142
141
|
builder = mock('builder')
|
143
142
|
@sampler.stubs(:builder).returns(builder)
|
144
143
|
|
@@ -154,13 +153,13 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
154
153
|
builder.expects(:sample).returns(sample)
|
155
154
|
@sampler.expects(:store_sample).with(sample)
|
156
155
|
|
157
|
-
@sampler.
|
158
|
-
@sampler.
|
156
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
157
|
+
@sampler.on_finishing_transaction(@txn, Time.at(100))
|
159
158
|
|
160
159
|
assert_equal(sample, @sampler.instance_variable_get('@last_sample'))
|
161
160
|
end
|
162
161
|
|
163
|
-
def
|
162
|
+
def test_on_finishing_transaction_passes_guid_along
|
164
163
|
builder = stub_everything('builder')
|
165
164
|
@sampler.stubs(:builder).returns(builder)
|
166
165
|
|
@@ -170,8 +169,8 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
170
169
|
sample.expects(:guid=).with(@txn.guid)
|
171
170
|
builder.stubs(:sample).returns(sample)
|
172
171
|
|
173
|
-
@sampler.
|
174
|
-
@sampler.
|
172
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
173
|
+
@sampler.on_finishing_transaction(@txn, Time.at(100))
|
175
174
|
end
|
176
175
|
|
177
176
|
def test_ignore_transaction_no_builder
|
@@ -496,20 +495,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
496
495
|
|
497
496
|
def test_sample_tree
|
498
497
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
499
|
-
@sampler.
|
500
|
-
@sampler.
|
501
|
-
@sampler.notice_push_scope
|
498
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
499
|
+
@sampler.notice_push_frame
|
502
500
|
|
503
|
-
@sampler.
|
504
|
-
@sampler.
|
501
|
+
@sampler.notice_push_frame
|
502
|
+
@sampler.notice_pop_frame "b"
|
505
503
|
|
506
|
-
@sampler.
|
507
|
-
@sampler.
|
508
|
-
@sampler.
|
509
|
-
@sampler.
|
504
|
+
@sampler.notice_push_frame
|
505
|
+
@sampler.notice_push_frame
|
506
|
+
@sampler.notice_pop_frame "d"
|
507
|
+
@sampler.notice_pop_frame "c"
|
510
508
|
|
511
|
-
@sampler.
|
512
|
-
@sampler.
|
509
|
+
@sampler.notice_pop_frame "a"
|
510
|
+
@sampler.on_finishing_transaction(@txn)
|
513
511
|
sample = @sampler.harvest!.first
|
514
512
|
assert_equal "ROOT{a{b,c{d}}}", sample.to_s_compact
|
515
513
|
end
|
@@ -522,20 +520,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
522
520
|
MockGCStats.mock_values = [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0]
|
523
521
|
|
524
522
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
525
|
-
@sampler.
|
526
|
-
@sampler.
|
527
|
-
@sampler.notice_push_scope
|
523
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
524
|
+
@sampler.notice_push_frame
|
528
525
|
|
529
|
-
@sampler.
|
530
|
-
@sampler.
|
526
|
+
@sampler.notice_push_frame
|
527
|
+
@sampler.notice_pop_frame "b"
|
531
528
|
|
532
|
-
@sampler.
|
533
|
-
@sampler.
|
534
|
-
@sampler.
|
535
|
-
@sampler.
|
529
|
+
@sampler.notice_push_frame
|
530
|
+
@sampler.notice_push_frame
|
531
|
+
@sampler.notice_pop_frame "d"
|
532
|
+
@sampler.notice_pop_frame "c"
|
536
533
|
|
537
|
-
@sampler.
|
538
|
-
@sampler.
|
534
|
+
@sampler.notice_pop_frame "a"
|
535
|
+
@sampler.on_finishing_transaction(@txn)
|
539
536
|
|
540
537
|
sample = @sampler.harvest!.first
|
541
538
|
assert_equal "ROOT{a{b,c{d}}}", sample.to_s_compact
|
@@ -577,15 +574,15 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
577
574
|
end
|
578
575
|
|
579
576
|
def test_prepare_to_send
|
577
|
+
t0 = freeze_time
|
580
578
|
sample = with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
581
|
-
run_sample_trace {
|
579
|
+
run_sample_trace { advance_time(2.0) }
|
582
580
|
@sampler.harvest![0]
|
583
581
|
end
|
584
582
|
|
585
583
|
ready_to_send = sample.prepare_to_send!
|
586
|
-
|
587
|
-
|
588
|
-
assert ready_to_send.start_time.is_a?(Time)
|
584
|
+
assert_equal 2.0, ready_to_send.duration
|
585
|
+
assert_equal t0.to_f, ready_to_send.start_time
|
589
586
|
end
|
590
587
|
|
591
588
|
def test_multithread
|
@@ -606,22 +603,20 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
606
603
|
|
607
604
|
def test_sample_with_parallel_paths
|
608
605
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
609
|
-
@sampler.
|
610
|
-
@sampler.
|
611
|
-
@sampler.notice_push_scope
|
606
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
607
|
+
@sampler.notice_push_frame
|
612
608
|
|
613
609
|
assert_equal 1, @sampler.builder.scope_depth
|
614
610
|
|
615
|
-
@sampler.
|
616
|
-
@sampler.
|
611
|
+
@sampler.notice_pop_frame "a"
|
612
|
+
@sampler.on_finishing_transaction(@txn)
|
617
613
|
|
618
614
|
assert_nil @sampler.builder
|
619
615
|
|
620
|
-
@sampler.
|
621
|
-
@sampler.
|
622
|
-
@sampler.
|
623
|
-
@sampler.
|
624
|
-
@sampler.notice_scope_empty(@txn)
|
616
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
617
|
+
@sampler.notice_push_frame
|
618
|
+
@sampler.notice_pop_frame "a"
|
619
|
+
@sampler.on_finishing_transaction(@txn)
|
625
620
|
|
626
621
|
assert_nil @sampler.builder
|
627
622
|
|
@@ -629,16 +624,15 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
629
624
|
end
|
630
625
|
end
|
631
626
|
|
632
|
-
def
|
627
|
+
def test_double_traced_method_stack_empty
|
633
628
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
634
|
-
@sampler.
|
635
|
-
@sampler.
|
636
|
-
@sampler.
|
637
|
-
@sampler.
|
638
|
-
@sampler.
|
639
|
-
@sampler.
|
640
|
-
@sampler.
|
641
|
-
@sampler.notice_scope_empty(@txn)
|
629
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
630
|
+
@sampler.notice_push_frame
|
631
|
+
@sampler.notice_pop_frame "a"
|
632
|
+
@sampler.on_finishing_transaction(@txn)
|
633
|
+
@sampler.on_finishing_transaction(@txn)
|
634
|
+
@sampler.on_finishing_transaction(@txn)
|
635
|
+
@sampler.on_finishing_transaction(@txn)
|
642
636
|
|
643
637
|
refute_nil @sampler.harvest![0]
|
644
638
|
end
|
@@ -646,7 +640,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
646
640
|
|
647
641
|
|
648
642
|
def test_record_sql_off
|
649
|
-
@sampler.
|
643
|
+
@sampler.on_start_transaction Time.now.to_f
|
650
644
|
|
651
645
|
NewRelic::Agent::TransactionState.get.record_sql = false
|
652
646
|
|
@@ -657,9 +651,9 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
657
651
|
assert_nil segment[:sql]
|
658
652
|
end
|
659
653
|
|
660
|
-
def
|
654
|
+
def test_stack_trace_sql
|
661
655
|
with_config(:'transaction_tracer.stack_trace_threshold' => 0) do
|
662
|
-
@sampler.
|
656
|
+
@sampler.on_start_transaction Time.now.to_f
|
663
657
|
@sampler.notice_sql("test", {}, 1)
|
664
658
|
segment = @sampler.send(:builder).current_segment
|
665
659
|
|
@@ -668,11 +662,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
668
662
|
end
|
669
663
|
end
|
670
664
|
|
671
|
-
def
|
665
|
+
def test_stack_trace_scope
|
672
666
|
with_config(:'transaction_tracer.stack_trace_threshold' => 0) do
|
673
667
|
t = Time.now
|
674
|
-
@sampler.
|
675
|
-
@sampler.
|
668
|
+
@sampler.on_start_transaction t.to_f
|
669
|
+
@sampler.notice_push_frame((t+1).to_f)
|
676
670
|
|
677
671
|
segment = @sampler.send(:builder).current_segment
|
678
672
|
assert segment[:backtrace]
|
@@ -681,7 +675,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
681
675
|
|
682
676
|
def test_nil_stacktrace
|
683
677
|
with_config(:'transaction_tracer.stack_trace_threshold' => 2) do
|
684
|
-
@sampler.
|
678
|
+
@sampler.on_start_transaction Time.now.to_f
|
685
679
|
@sampler.notice_sql("test", {}, 1)
|
686
680
|
segment = @sampler.send(:builder).current_segment
|
687
681
|
|
@@ -691,7 +685,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
691
685
|
end
|
692
686
|
|
693
687
|
def test_big_sql
|
694
|
-
@sampler.
|
688
|
+
@sampler.on_start_transaction Time.now.to_f
|
695
689
|
|
696
690
|
sql = "SADJKHASDHASD KAJSDH ASKDH ASKDHASDK JASHD KASJDH ASKDJHSAKDJHAS DKJHSADKJSAH DKJASHD SAKJDH SAKDJHS"
|
697
691
|
|
@@ -709,8 +703,8 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
709
703
|
end
|
710
704
|
|
711
705
|
def test_segment_obfuscated
|
712
|
-
@sampler.
|
713
|
-
@sampler.
|
706
|
+
@sampler.on_start_transaction Time.now.to_f
|
707
|
+
@sampler.notice_push_frame
|
714
708
|
|
715
709
|
orig_sql = "SELECT * from Jim where id=66"
|
716
710
|
|
@@ -720,16 +714,15 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
720
714
|
|
721
715
|
assert_equal orig_sql, segment[:sql]
|
722
716
|
assert_equal "SELECT * from Jim where id=?", segment.obfuscated_sql
|
723
|
-
@sampler.
|
717
|
+
@sampler.notice_pop_frame "foo"
|
724
718
|
end
|
725
719
|
|
726
720
|
def test_param_capture
|
727
721
|
[true, false].each do |capture|
|
728
722
|
with_config(:capture_params => capture) do
|
729
723
|
tt = with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
730
|
-
@sampler.
|
731
|
-
@sampler.
|
732
|
-
@sampler.notice_scope_empty(@txn)
|
724
|
+
@sampler.on_start_transaction(Time.now, nil, :param => 'hi')
|
725
|
+
@sampler.on_finishing_transaction(@txn)
|
733
726
|
@sampler.harvest![0]
|
734
727
|
end
|
735
728
|
|
@@ -741,12 +734,12 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
741
734
|
def test_should_not_collect_segments_beyond_limit
|
742
735
|
with_config(:'transaction_tracer.limit_segments' => 3) do
|
743
736
|
run_sample_trace do
|
744
|
-
@sampler.
|
737
|
+
@sampler.notice_push_frame
|
745
738
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'challah'", {}, 0)
|
746
|
-
@sampler.
|
739
|
+
@sampler.notice_push_frame
|
747
740
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'semolina'", {}, 0)
|
748
|
-
@sampler.
|
749
|
-
@sampler.
|
741
|
+
@sampler.notice_pop_frame "a11"
|
742
|
+
@sampler.notice_pop_frame "a1"
|
750
743
|
end
|
751
744
|
assert_equal 3, @sampler.last_sample.count_segments
|
752
745
|
|
@@ -759,14 +752,14 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
759
752
|
|
760
753
|
def test_renaming_current_segment_midflight
|
761
754
|
@sampler.start_builder
|
762
|
-
segment = @sampler.
|
755
|
+
segment = @sampler.notice_push_frame
|
763
756
|
segment.metric_name = 'External/www.google.com/Net::HTTP/GET'
|
764
|
-
@sampler.
|
757
|
+
@sampler.notice_pop_frame( 'External/www.google.com/Net::HTTP/GET' )
|
765
758
|
end
|
766
759
|
|
767
760
|
def test_adding_segment_parameters
|
768
761
|
@sampler.start_builder
|
769
|
-
@sampler.
|
762
|
+
@sampler.notice_push_frame
|
770
763
|
@sampler.add_segment_parameters( :transaction_guid => '97612F92E6194080' )
|
771
764
|
assert_equal '97612F92E6194080', @sampler.builder.current_segment[:transaction_guid]
|
772
765
|
end
|
@@ -909,29 +902,27 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
|
|
909
902
|
end
|
910
903
|
|
911
904
|
def run_long_sample_trace(n)
|
912
|
-
@sampler.
|
913
|
-
@sampler.notice_first_scope_push(Time.now.to_f)
|
905
|
+
@sampler.on_start_transaction(Time.now, nil, {})
|
914
906
|
n.times do |i|
|
915
|
-
@sampler.
|
907
|
+
@sampler.notice_push_frame
|
916
908
|
yield if block_given?
|
917
|
-
@sampler.
|
909
|
+
@sampler.notice_pop_frame "node#{i}"
|
918
910
|
end
|
919
|
-
@sampler.
|
911
|
+
@sampler.on_finishing_transaction(@txn, Time.now.to_f)
|
920
912
|
end
|
921
913
|
|
922
914
|
def run_sample_trace(start = Time.now.to_f, stop = nil)
|
923
|
-
@sampler.
|
924
|
-
@sampler.
|
925
|
-
@sampler.notice_push_scope
|
915
|
+
@sampler.on_start_transaction(start, nil, {})
|
916
|
+
@sampler.notice_push_frame
|
926
917
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0)
|
927
|
-
@sampler.
|
918
|
+
@sampler.notice_push_frame
|
928
919
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0)
|
929
920
|
yield if block_given?
|
930
|
-
@sampler.
|
931
|
-
@sampler.
|
921
|
+
@sampler.notice_pop_frame "ab"
|
922
|
+
@sampler.notice_push_frame
|
932
923
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0)
|
933
|
-
@sampler.
|
934
|
-
@sampler.
|
935
|
-
@sampler.
|
924
|
+
@sampler.notice_pop_frame "ac"
|
925
|
+
@sampler.notice_pop_frame "a"
|
926
|
+
@sampler.on_finishing_transaction(@txn, (stop || Time.now.to_f))
|
936
927
|
end
|
937
928
|
end
|
@@ -11,38 +11,32 @@ module NewRelic::Agent
|
|
11
11
|
attr_reader :state
|
12
12
|
|
13
13
|
def setup
|
14
|
-
|
14
|
+
TransactionState.clear
|
15
|
+
@state = TransactionState.get
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
TransactionState.clear
|
15
20
|
end
|
16
21
|
|
17
22
|
def test_without_transaction_stack_on_thread
|
18
|
-
state.current_transaction_stack = nil
|
19
23
|
assert_equal false, state.in_background_transaction?
|
20
24
|
assert_equal false, state.in_request_transaction?
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_in_background_transaction
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
in_transaction(:type => :task) do |txn|
|
29
|
+
txn.request = nil # this makes it a "background transaction"
|
30
|
+
assert state.in_background_transaction?
|
31
|
+
end
|
27
32
|
end
|
28
33
|
|
29
34
|
def test_in_request_tranasction
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
state.current_transaction_stack = [transaction]
|
34
|
-
|
35
|
-
assert state.in_request_transaction?
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_in_request_transaction_checks_last
|
39
|
-
earlier_transaction = NewRelic::Agent::Transaction.new
|
40
|
-
transaction = NewRelic::Agent::Transaction.new
|
41
|
-
transaction.request = stub()
|
35
|
+
in_transaction do |txn|
|
36
|
+
txn.request = stub()
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
assert state.in_request_transaction?
|
38
|
+
assert state.in_request_transaction?
|
39
|
+
end
|
46
40
|
end
|
47
41
|
|
48
42
|
def test_timings_without_transaction
|
@@ -58,24 +52,24 @@ module NewRelic::Agent
|
|
58
52
|
|
59
53
|
def test_timings_with_transaction
|
60
54
|
earliest_time = freeze_time
|
61
|
-
transaction = NewRelic::Agent::Transaction.new
|
62
|
-
transaction.apdex_start = earliest_time
|
63
|
-
transaction.start_time = earliest_time + 5
|
64
|
-
transaction.name = "Transaction/name"
|
65
|
-
state.transaction = transaction
|
66
55
|
|
67
|
-
|
68
|
-
|
56
|
+
in_transaction("Transaction/name") do |txn|
|
57
|
+
txn.apdex_start = earliest_time
|
58
|
+
txn.start_time = earliest_time + 5
|
69
59
|
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
advance_time(10.0)
|
61
|
+
timings = state.timings
|
62
|
+
|
63
|
+
assert_equal 5.0, timings.queue_time_in_seconds
|
64
|
+
assert_equal 5.0, timings.app_time_in_seconds
|
65
|
+
assert_equal txn.best_name, timings.transaction_name
|
66
|
+
end
|
73
67
|
end
|
74
68
|
|
75
69
|
def test_guid_from_transaction
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
in_transaction do |txn|
|
71
|
+
assert_equal state.request_guid, txn.guid
|
72
|
+
end
|
79
73
|
end
|
80
74
|
|
81
75
|
GUID = "goo-id"
|
@@ -85,11 +79,11 @@ module NewRelic::Agent
|
|
85
79
|
freeze_time
|
86
80
|
|
87
81
|
state.request_token = "token"
|
88
|
-
state.transaction = NewRelic::Agent::Transaction.new
|
89
82
|
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
in_transaction do |txn|
|
84
|
+
advance_time(4.0)
|
85
|
+
assert_equal state.current_transaction.guid, state.request_guid_to_include
|
86
|
+
end
|
93
87
|
end
|
94
88
|
end
|
95
89
|
|
@@ -98,11 +92,10 @@ module NewRelic::Agent
|
|
98
92
|
freeze_time
|
99
93
|
|
100
94
|
state.request_token = "token"
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
assert_equal "", state.request_guid_to_include
|
95
|
+
in_transaction do |txn|
|
96
|
+
advance_time(1.0)
|
97
|
+
assert_equal "", state.request_guid_to_include
|
98
|
+
end
|
106
99
|
end
|
107
100
|
end
|
108
101
|
|
@@ -111,11 +104,10 @@ module NewRelic::Agent
|
|
111
104
|
freeze_time
|
112
105
|
|
113
106
|
state.request_token = nil
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
assert_equal "", state.request_guid_to_include
|
107
|
+
in_transaction do |txn|
|
108
|
+
advance_time(4.0)
|
109
|
+
assert_equal "", state.request_guid_to_include
|
110
|
+
end
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
@@ -123,38 +115,37 @@ module NewRelic::Agent
|
|
123
115
|
state.request_token = nil
|
124
116
|
state.is_cross_app_caller = false
|
125
117
|
state.referring_transaction_info = nil
|
126
|
-
|
127
|
-
|
128
|
-
|
118
|
+
in_transaction do
|
119
|
+
assert_nil state.request_guid_for_event
|
120
|
+
end
|
129
121
|
end
|
130
122
|
|
131
123
|
def test_request_guid_for_event
|
132
124
|
state.request_token = nil
|
133
125
|
state.is_cross_app_caller = true
|
134
126
|
state.referring_transaction_info = nil
|
135
|
-
|
136
|
-
|
137
|
-
|
127
|
+
in_transaction do
|
128
|
+
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
129
|
+
end
|
138
130
|
end
|
139
131
|
|
140
132
|
def test_request_guid_for_event_if_referring_transaction
|
141
133
|
state.request_token = nil
|
142
134
|
state.is_cross_app_caller = false
|
143
135
|
state.referring_transaction_info = ["another"]
|
144
|
-
|
145
|
-
|
146
|
-
|
136
|
+
in_transaction do
|
137
|
+
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
138
|
+
end
|
147
139
|
end
|
148
140
|
|
149
141
|
def test_request_guid_for_event_if_there_for_rum
|
150
142
|
with_config(:apdex_t => 2.0) do
|
151
143
|
state.request_token = "token"
|
152
144
|
state.is_cross_app_caller = false
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
assert_equal state.transaction.guid, state.request_guid_for_event
|
145
|
+
in_transaction do
|
146
|
+
advance_time(10.0)
|
147
|
+
assert_equal state.current_transaction.guid, state.request_guid_for_event
|
148
|
+
end
|
158
149
|
end
|
159
150
|
end
|
160
151
|
|