newrelic_rpm 3.16.0.318 → 3.16.1.320
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -4
- data/CHANGELOG +41 -2
- data/lib/new_relic/agent/database.rb +15 -4
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +2 -1
- data/lib/new_relic/agent/datastores.rb +13 -13
- data/lib/new_relic/agent/datastores/metric_helper.rb +33 -2
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -9
- data/lib/new_relic/agent/error_collector.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -19
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +2 -6
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +49 -40
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +29 -23
- data/lib/new_relic/agent/instrumentation/grape.rb +20 -11
- data/lib/new_relic/agent/instrumentation/memcache.rb +8 -10
- data/lib/new_relic/agent/instrumentation/mongo.rb +25 -16
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +14 -19
- data/lib/new_relic/agent/method_tracer_helpers.rb +4 -8
- data/lib/new_relic/agent/sql_sampler.rb +14 -1
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +18 -0
- data/lib/new_relic/agent/supported_versions.rb +2 -3
- data/lib/new_relic/agent/traced_method_stack.rb +7 -1
- data/lib/new_relic/agent/transaction.rb +6 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +73 -0
- data/lib/new_relic/agent/transaction/datastore_segment.rb +49 -0
- data/lib/new_relic/agent/transaction/segment.rb +30 -0
- data/lib/new_relic/agent/transaction/tracing.rb +53 -0
- data/lib/new_relic/agent/transaction_sampler.rb +8 -1
- data/lib/new_relic/noticed_error.rb +3 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +22 -15
- data/lib/sequel/plugins/newrelic_instrumentation.rb +4 -3
- data/newrelic_rpm.gemspec +1 -9
- data/test/environments/lib/environments/runner.rb +6 -4
- data/test/environments/norails/Gemfile +9 -3
- data/test/environments/rails21/Gemfile +6 -3
- data/test/environments/rails22/Gemfile +5 -2
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +2 -2
- data/test/environments/rails41/Gemfile +2 -2
- data/test/environments/rails42/Gemfile +2 -2
- data/test/environments/rails50/Gemfile +2 -2
- data/test/helpers/mongo_metric_builder.rb +3 -4
- data/test/multiverse/lib/multiverse/shell_utils.rb +27 -0
- data/test/multiverse/lib/multiverse/suite.rb +47 -2
- data/test/multiverse/suites/active_record/Envfile +1 -1
- data/test/multiverse/suites/delayed_job/Envfile +2 -0
- data/test/multiverse/suites/grape/grape_versioning_test.rb +55 -1
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +61 -3
- data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +18 -0
- data/test/multiverse/suites/rails/Envfile +3 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +2 -2
- data/test/multiverse/suites/sequel/Envfile +7 -0
- data/test/multiverse/suites/sequel/sequel_extension_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +9 -0
- data/test/new_relic/agent/datastores/metric_helper_test.rb +76 -43
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +67 -117
- data/test/new_relic/agent/datastores_test.rb +17 -0
- data/test/new_relic/agent/error_collector_test.rb +21 -5
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +40 -45
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -3
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +2 -0
- data/test/new_relic/agent/method_tracer_test.rb +54 -52
- data/test/new_relic/agent/mock_scope_listener.rb +4 -1
- data/test/new_relic/agent/sql_sampler_test.rb +15 -0
- data/test/new_relic/agent/transaction/abstract_segment_test.rb +94 -0
- data/test/new_relic/agent/transaction/datastore_segment_test.rb +99 -0
- data/test/new_relic/agent/transaction/segment_test.rb +53 -0
- data/test/new_relic/agent/transaction/tracing_test.rb +121 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +13 -0
- data/test/new_relic/noticed_error_test.rb +7 -0
- data/test/performance/suites/datastores.rb +59 -0
- data/test/performance/suites/trace_execution_scoped.rb +8 -9
- metadata +13 -46
@@ -24,6 +24,12 @@ class NewRelic::Agent::DatastoresTest < Minitest::Test
|
|
24
24
|
NewRelic::Agent::Datastores.trace self, :find, "MyFirstDatabase"
|
25
25
|
NewRelic::Agent::Datastores.trace self, :save, "MyFirstDatabase", "create"
|
26
26
|
NewRelic::Agent::Datastores.trace self, :internal, "MyFirstDatabase"
|
27
|
+
|
28
|
+
def boom
|
29
|
+
raise "haha"
|
30
|
+
end
|
31
|
+
|
32
|
+
NewRelic::Agent::Datastores.trace self, :boom, "MyFirstDatabase", "boom"
|
27
33
|
end
|
28
34
|
|
29
35
|
def setup
|
@@ -172,6 +178,17 @@ class NewRelic::Agent::DatastoresTest < Minitest::Test
|
|
172
178
|
end
|
173
179
|
end
|
174
180
|
|
181
|
+
def test_node_created_when_exception_occurs
|
182
|
+
db = MyFirstDatabase.new
|
183
|
+
in_transaction do
|
184
|
+
db.find
|
185
|
+
db.boom
|
186
|
+
end
|
187
|
+
rescue
|
188
|
+
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
189
|
+
refute_nil find_node_with_name(sample, "Datastore/operation/MyFirstDatabase/boom")
|
190
|
+
end
|
191
|
+
|
175
192
|
def assert_statement_metrics(operation, collection, type)
|
176
193
|
assert_metrics_recorded([
|
177
194
|
"Datastore/statement/MyFirstDatabase/#{collection}/#{operation}",
|
@@ -250,17 +250,33 @@ class NewRelic::Agent::ErrorCollectorTest < Minitest::Test
|
|
250
250
|
end
|
251
251
|
|
252
252
|
def test_extract_stack_trace
|
253
|
-
exception = mock('exception', :
|
253
|
+
exception = mock('exception', :cause => nil,
|
254
|
+
:original_exception => nil,
|
254
255
|
:backtrace => nil)
|
255
256
|
|
256
257
|
assert_equal('<no stack trace>', @error_collector.extract_stack_trace(exception))
|
257
258
|
end
|
258
259
|
|
259
|
-
def
|
260
|
-
|
261
|
-
exception = mock('exception', :
|
260
|
+
def test_extract_stack_trace_uses_cause_first
|
261
|
+
nested_exception = mock('exception', :backtrace => "Foo STACK")
|
262
|
+
exception = mock('exception', :cause => nested_exception)
|
262
263
|
|
263
|
-
assert_equal('
|
264
|
+
assert_equal('Foo STACK', @error_collector.extract_stack_trace(exception))
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_extract_stack_trace_uses_original_exception_second
|
268
|
+
nested_exception = mock('exception', :backtrace => "Bar STACK")
|
269
|
+
exception = mock('exception', :cause => nil, :original_exception => nested_exception)
|
270
|
+
|
271
|
+
assert_equal('Bar STACK', @error_collector.extract_stack_trace(exception))
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_extract_stack_trace_uses_backtrace_last
|
275
|
+
exception = mock('exception', :cause => nil,
|
276
|
+
:original_exception => nil,
|
277
|
+
:backtrace => "Baz STACK")
|
278
|
+
|
279
|
+
assert_equal('Baz STACK', @error_collector.extract_stack_trace(exception))
|
264
280
|
end
|
265
281
|
|
266
282
|
def test_skip_notice_error_is_true_if_the_error_collector_is_disabled
|
@@ -7,52 +7,60 @@ require 'new_relic/agent/instrumentation/active_record_helper'
|
|
7
7
|
module NewRelic::Agent::Instrumentation
|
8
8
|
class ActiveRecordHelperTest < Minitest::Test
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
assert_equal
|
10
|
+
def test_product_operation_collection_for_find
|
11
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Namespace::Model Load', nil, nil)
|
12
|
+
assert_equal "ActiveRecord", product
|
13
|
+
assert_equal "find", operation
|
14
|
+
assert_equal "Namespace::Model", collection
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
assert_equal
|
17
|
+
def test_product_operation_collection_for_destroy
|
18
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Model Destroy', nil, nil)
|
19
|
+
assert_equal "ActiveRecord", product
|
20
|
+
assert_equal "destroy", operation
|
21
|
+
assert_equal "Model", collection
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
assert_equal
|
24
|
+
def test_product_operation_collection_for_create
|
25
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Model Create', nil, nil)
|
26
|
+
assert_equal "ActiveRecord", product
|
27
|
+
assert_equal "create", operation
|
28
|
+
assert_equal "Model", collection
|
26
29
|
end
|
27
30
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
assert_equal
|
31
|
+
def test_product_operation_collection_for_update
|
32
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Model Update', nil, nil)
|
33
|
+
assert_equal "ActiveRecord", product
|
34
|
+
assert_equal "update", operation
|
35
|
+
assert_equal "Model", collection
|
32
36
|
end
|
33
37
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal
|
38
|
+
def test_product_operation_collection_for_name_columns
|
39
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Model Columns', nil, nil)
|
40
|
+
assert_equal "ActiveRecord", product
|
41
|
+
assert_equal "columns", operation
|
42
|
+
assert_equal "Model", collection
|
38
43
|
end
|
39
44
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
assert_equal
|
45
|
+
def test_product_operation_collection_for_with_product_name_from_adapter
|
46
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('Model Load', nil, "mysql")
|
47
|
+
assert_equal "MySQL", product
|
48
|
+
assert_equal "find", operation
|
49
|
+
assert_equal "Model", collection
|
44
50
|
end
|
45
51
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
assert_equal
|
52
|
+
def test_product_operation_collection_for_from_sql
|
53
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('invalid', "SELECT * FROM boo", nil)
|
54
|
+
assert_equal "ActiveRecord", product
|
55
|
+
assert_equal "select", operation
|
56
|
+
assert_nil collection
|
50
57
|
end
|
51
58
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
assert_equal
|
59
|
+
def test_product_operation_collection_for_name_with_integer_returns_nil
|
60
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for(1, '', nil)
|
61
|
+
assert_equal "ActiveRecord", product
|
62
|
+
assert_equal "other", operation
|
63
|
+
assert_nil collection
|
56
64
|
end
|
57
65
|
|
58
66
|
def test_rollup_metrics_for_is_deprecated
|
@@ -60,18 +68,5 @@ module NewRelic::Agent::Instrumentation
|
|
60
68
|
result = ActiveRecordHelper.rollup_metrics_for("boo")
|
61
69
|
assert_equal ["Datastore/allOther", "Datastore/all"], result
|
62
70
|
end
|
63
|
-
|
64
|
-
def expected_statement_metrics(operation, statement, product = "ActiveRecord")
|
65
|
-
["Datastore/statement/#{product}/#{statement}"] +
|
66
|
-
expected_operation_metrics(operation, product)
|
67
|
-
end
|
68
|
-
|
69
|
-
def expected_operation_metrics(operation, product = "ActiveRecord")
|
70
|
-
["Datastore/operation/#{product}/#{operation}",
|
71
|
-
"Datastore/#{product}/allOther",
|
72
|
-
"Datastore/#{product}/all",
|
73
|
-
"Datastore/allOther",
|
74
|
-
"Datastore/all"]
|
75
|
-
end
|
76
71
|
end
|
77
72
|
end
|
@@ -119,10 +119,9 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
119
119
|
target_connection = ActiveRecord::Base.connection_handler.connection_pool_list.first.connections.first
|
120
120
|
expected_config = target_connection.instance_variable_get(:@config)
|
121
121
|
|
122
|
-
|
123
|
-
event.stubs(:payload).returns({ :connection_id => target_connection.object_id })
|
122
|
+
payload = { :connection_id => target_connection.object_id }
|
124
123
|
|
125
|
-
result = @subscriber.
|
124
|
+
result = @subscriber.active_record_config(payload)
|
126
125
|
assert_equal expected_config, result
|
127
126
|
end
|
128
127
|
end
|
@@ -9,6 +9,7 @@ class NewRelic::Agent::Instrumentation::MongodbCommandSubscriberTest < Minitest:
|
|
9
9
|
|
10
10
|
if RUBY_VERSION > "1.9.3"
|
11
11
|
def setup
|
12
|
+
freeze_time
|
12
13
|
@started_event = mock('started event')
|
13
14
|
@started_event.stubs(:operation_id).returns(1)
|
14
15
|
@started_event.stubs(:command_name).returns('find')
|
@@ -66,6 +67,7 @@ class NewRelic::Agent::Instrumentation::MongodbCommandSubscriberTest < Minitest:
|
|
66
67
|
|
67
68
|
def simulate_query
|
68
69
|
@subscriber.started(@started_event)
|
70
|
+
advance_time @succeeded_event.duration
|
69
71
|
@subscriber.succeeded(@succeeded_event)
|
70
72
|
end
|
71
73
|
end
|
@@ -128,46 +128,38 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
128
128
|
assert_metrics_recorded_exclusive([])
|
129
129
|
end
|
130
130
|
|
131
|
-
def test_trace_execution_scoped_records_metric_data_from_callback
|
132
|
-
metric = "hello"
|
133
|
-
callback_metric = "goodbye"
|
134
|
-
callback = Proc.new { callback_metric }
|
135
|
-
options = { :additional_metrics_callback => callback }
|
136
|
-
|
137
|
-
self.class.trace_execution_scoped(metric, options) do
|
138
|
-
advance_time 0.05
|
139
|
-
end
|
140
|
-
|
141
|
-
stats = @stats_engine.get_stats(callback_metric)
|
142
|
-
check_time 0.05, stats.total_call_time
|
143
|
-
assert_equal 1, stats.call_count
|
144
|
-
end
|
145
|
-
|
146
131
|
def test_trace_execution_scoped_pushes_transaction_scope
|
147
|
-
|
148
|
-
'
|
132
|
+
in_transaction do
|
133
|
+
self.class.trace_execution_scoped('yeap') do
|
134
|
+
'ptoo'
|
135
|
+
end
|
136
|
+
assert_equal 'yeap', @scope_listener.scopes.last
|
149
137
|
end
|
150
|
-
assert_equal 'yeap', @scope_listener.scopes.last
|
151
138
|
end
|
152
139
|
|
153
140
|
def test_basic__original_api
|
154
141
|
metric = "hello"
|
155
|
-
|
156
|
-
|
142
|
+
in_transaction do |txn|
|
143
|
+
self.class.trace_method_execution(metric, true, true, true) do
|
144
|
+
advance_time(0.05)
|
145
|
+
end
|
146
|
+
assert_equal metric, @scope_listener.scopes.last
|
157
147
|
end
|
158
148
|
|
159
149
|
stats = @stats_engine.get_stats(metric)
|
160
150
|
check_time 0.05, stats.total_call_time
|
161
151
|
assert_equal 1, stats.call_count
|
162
|
-
assert_equal metric, @scope_listener.scopes.last
|
163
152
|
end
|
164
153
|
|
165
154
|
METRIC = "metric"
|
166
155
|
def test_add_method_tracer
|
167
156
|
@metric_name = METRIC
|
168
157
|
self.class.add_method_tracer :method_to_be_traced, METRIC
|
158
|
+
in_transaction do
|
159
|
+
method_to_be_traced 1,2,3,true,METRIC
|
169
160
|
|
170
|
-
|
161
|
+
assert_equal METRIC, @scope_listener.scopes.last
|
162
|
+
end
|
171
163
|
|
172
164
|
begin
|
173
165
|
self.class.remove_method_tracer :method_to_be_traced, METRIC
|
@@ -179,7 +171,6 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
179
171
|
stats = @stats_engine.get_stats(METRIC)
|
180
172
|
check_time 0.05, stats.total_call_time
|
181
173
|
assert_equal 1, stats.call_count
|
182
|
-
assert_equal METRIC, @scope_listener.scopes.last
|
183
174
|
end
|
184
175
|
|
185
176
|
def test_add_method_tracer__default
|
@@ -238,12 +229,13 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
238
229
|
self.class.add_method_tracer :method_c2, "c2", :metric => false
|
239
230
|
self.class.add_method_tracer :method_c3, "c3", :push_scope => false
|
240
231
|
|
241
|
-
|
232
|
+
in_transaction do
|
233
|
+
method_c1
|
234
|
+
assert_equal ['c2', 'c1'], @scope_listener.scopes
|
235
|
+
end
|
242
236
|
|
243
237
|
assert_metrics_recorded(['c1', 'c3'])
|
244
238
|
assert_metrics_not_recorded('c2')
|
245
|
-
|
246
|
-
assert_equal ['c2', 'c1'], @scope_listener.scopes
|
247
239
|
end
|
248
240
|
|
249
241
|
def test_nested_scope_tracer
|
@@ -270,7 +262,12 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
270
262
|
self.class.add_method_tracer :method_to_be_traced, METRIC
|
271
263
|
self.class.add_method_tracer :method_to_be_traced, METRIC
|
272
264
|
|
273
|
-
|
265
|
+
in_transaction do
|
266
|
+
method_to_be_traced 1,2,3,true,METRIC
|
267
|
+
assert_equal METRIC, @scope_listener.scopes.last
|
268
|
+
assert(METRIC != @scope_listener.scopes[-2],
|
269
|
+
'duplicate scope detected when redundant tracer is present')
|
270
|
+
end
|
274
271
|
|
275
272
|
begin
|
276
273
|
self.class.remove_method_tracer :method_to_be_traced, METRIC
|
@@ -281,9 +278,6 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
281
278
|
stats = @stats_engine.get_stats(METRIC)
|
282
279
|
check_time 0.05, stats.total_call_time
|
283
280
|
assert_equal 1, stats.call_count
|
284
|
-
assert_equal METRIC, @scope_listener.scopes.last
|
285
|
-
assert(METRIC != @scope_listener.scopes[-2],
|
286
|
-
'duplicate scope detected when redundant tracer is present')
|
287
281
|
end
|
288
282
|
|
289
283
|
def test_add_tracer_with_dynamic_metric
|
@@ -292,7 +286,10 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
292
286
|
expected_metric = "1.2"
|
293
287
|
self.class.add_method_tracer :method_to_be_traced, metric_code
|
294
288
|
|
295
|
-
|
289
|
+
in_transaction do
|
290
|
+
method_to_be_traced 1,2,3,true,expected_metric
|
291
|
+
assert_equal expected_metric, @scope_listener.scopes.last
|
292
|
+
end
|
296
293
|
|
297
294
|
begin
|
298
295
|
self.class.remove_method_tracer :method_to_be_traced, metric_code
|
@@ -303,20 +300,21 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
303
300
|
stats = @stats_engine.get_stats(expected_metric)
|
304
301
|
check_time 0.05, stats.total_call_time
|
305
302
|
assert_equal 1, stats.call_count
|
306
|
-
assert_equal expected_metric, @scope_listener.scopes.last
|
307
303
|
end
|
308
304
|
|
309
305
|
def test_trace_method_with_block
|
310
306
|
self.class.add_method_tracer :method_with_block, METRIC
|
307
|
+
in_transaction do
|
308
|
+
method_with_block(1,2,3,true,METRIC) do
|
309
|
+
advance_time 0.1
|
310
|
+
end
|
311
311
|
|
312
|
-
|
313
|
-
advance_time 0.1
|
312
|
+
assert_equal METRIC, @scope_listener.scopes.last
|
314
313
|
end
|
315
314
|
|
316
315
|
stats = @stats_engine.get_stats(METRIC)
|
317
316
|
check_time 0.15, stats.total_call_time
|
318
317
|
assert_equal 1, stats.call_count
|
319
|
-
assert_equal METRIC, @scope_listener.scopes.last
|
320
318
|
end
|
321
319
|
|
322
320
|
def test_trace_module_method
|
@@ -351,15 +349,16 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
351
349
|
|
352
350
|
def test_multiple_metrics__scoped
|
353
351
|
metrics = %w[first second third]
|
354
|
-
|
355
|
-
|
352
|
+
in_transaction do
|
353
|
+
self.class.trace_execution_scoped metrics do
|
354
|
+
advance_time 0.05
|
355
|
+
end
|
356
356
|
end
|
357
357
|
elapsed = @stats_engine.get_stats('first').total_call_time
|
358
358
|
metrics.map{|name| @stats_engine.get_stats name}.each do | m |
|
359
359
|
assert_equal 1, m.call_count
|
360
360
|
assert_equal elapsed, m.total_call_time
|
361
361
|
end
|
362
|
-
assert_equal 'first', @scope_listener.scopes.last
|
363
362
|
end
|
364
363
|
|
365
364
|
def test_multiple_metrics__unscoped
|
@@ -378,14 +377,16 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
378
377
|
def test_exception
|
379
378
|
begin
|
380
379
|
metric = "hey"
|
381
|
-
|
382
|
-
|
380
|
+
in_transaction do
|
381
|
+
self.class.trace_execution_scoped(metric) do
|
382
|
+
raise StandardError.new
|
383
|
+
end
|
384
|
+
# make sure the scope gets popped
|
385
|
+
assert_equal metric, @scope_listener.scopes.last
|
383
386
|
end
|
384
387
|
|
385
388
|
assert false # should never get here
|
386
389
|
rescue StandardError
|
387
|
-
# make sure the scope gets popped
|
388
|
-
assert_equal metric, @scope_listener.scopes.last
|
389
390
|
end
|
390
391
|
|
391
392
|
stats = @stats_engine.get_stats metric
|
@@ -393,16 +394,17 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
393
394
|
end
|
394
395
|
|
395
396
|
def test_add_multiple_tracers
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
397
|
+
in_transaction do
|
398
|
+
self.class.add_method_tracer :method_to_be_traced, 'XX', :push_scope => false
|
399
|
+
method_to_be_traced 1,2,3,true,nil
|
400
|
+
self.class.add_method_tracer :method_to_be_traced, 'YY'
|
401
|
+
method_to_be_traced 1,2,3,true,'YY'
|
402
|
+
self.class.remove_method_tracer :method_to_be_traced, 'YY'
|
403
|
+
method_to_be_traced 1,2,3,true,nil
|
404
|
+
self.class.remove_method_tracer :method_to_be_traced, 'XX'
|
405
|
+
method_to_be_traced 1,2,3,false,'XX'
|
406
|
+
assert_equal ['YY'], @scope_listener.scopes
|
407
|
+
end
|
406
408
|
end
|
407
409
|
|
408
410
|
def test_add_method_tracer_module_double_inclusion
|
@@ -64,6 +64,21 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
|
|
64
64
|
assert_equal 2, @sampler.tl_transaction_data.sql_data.size
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_notice_sql_statement
|
68
|
+
@sampler.on_start_transaction(@state, nil)
|
69
|
+
|
70
|
+
sql = "select * from test"
|
71
|
+
metric_name = "Database/test/select"
|
72
|
+
statement = NewRelic::Agent::Database::Statement.new sql, {:adapter => :mysql}
|
73
|
+
|
74
|
+
@sampler.notice_sql_statement(statement, metric_name, 1.5)
|
75
|
+
|
76
|
+
slow_sql = @sampler.tl_transaction_data.sql_data[0]
|
77
|
+
|
78
|
+
assert_equal statement, slow_sql.statement
|
79
|
+
assert_equal metric_name, slow_sql.metric_name
|
80
|
+
end
|
81
|
+
|
67
82
|
def test_notice_sql_truncates_query
|
68
83
|
@sampler.on_start_transaction(@state, nil)
|
69
84
|
message = 'a' * 17_000
|