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
@@ -316,8 +316,9 @@ module NewRelic
|
|
316
316
|
engine = NewRelic::Agent.instance.stats_engine
|
317
317
|
engine.reset!
|
318
318
|
Transactor.new.txn do
|
319
|
-
NewRelic::Agent::Transaction.current.
|
320
|
-
|
319
|
+
NewRelic::Agent::Transaction.current.freeze_name_and_execute_if_not_ignored do
|
320
|
+
NewRelic::Agent.set_transaction_name('new_name')
|
321
|
+
end
|
321
322
|
end
|
322
323
|
assert_nil engine.lookup_stats('Controller/new_name')
|
323
324
|
end
|
@@ -10,6 +10,7 @@ class NewRelic::ControlTest < Minitest::Test
|
|
10
10
|
def setup
|
11
11
|
@control = NewRelic::Control.instance
|
12
12
|
raise 'oh geez, wrong class' unless NewRelic::Control.instance.is_a?(::NewRelic::Control::Frameworks::Test)
|
13
|
+
NewRelic::Agent.config.reset_to_defaults
|
13
14
|
end
|
14
15
|
|
15
16
|
def shutdown
|
@@ -135,8 +136,8 @@ class NewRelic::ControlTest < Minitest::Test
|
|
135
136
|
|
136
137
|
def test_sql_tracer_disabled_with_record_sql_false
|
137
138
|
with_config(:slow_sql => { :enabled => true, :record_sql => 'off' }) do
|
138
|
-
|
139
|
-
'sql tracer enabled when config calls for disabled'
|
139
|
+
refute NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
140
|
+
'sql tracer enabled when config calls for disabled'
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
@@ -144,19 +145,19 @@ class NewRelic::ControlTest < Minitest::Test
|
|
144
145
|
with_config(:'transaction_tracer.enabled' => false,
|
145
146
|
:'slow_sql.enabled' => true,
|
146
147
|
:developer_mode => false, :monitor_mode => true) do
|
147
|
-
|
148
|
-
'sql enabled when transaction tracer disabled'
|
148
|
+
refute NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
149
|
+
'sql enabled when transaction tracer disabled'
|
149
150
|
end
|
150
151
|
end
|
151
152
|
|
152
153
|
def test_sql_tracer_disabled_when_tt_disabled_by_server
|
153
|
-
with_config({:'slow_sql.enabled'
|
154
|
-
|
155
|
-
|
154
|
+
with_config({:'slow_sql.enabled' => true,
|
155
|
+
:'transaction_tracer.enabled' => true,
|
156
|
+
:monitor_mode => true}, :level => 2) do
|
156
157
|
NewRelic::Agent.instance.finish_setup('collect_traces' => false)
|
157
158
|
|
158
|
-
|
159
|
-
'sql enabled when tracing disabled by server'
|
159
|
+
refute NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
|
160
|
+
'sql enabled when tracing disabled by server'
|
160
161
|
end
|
161
162
|
end
|
162
163
|
|
@@ -185,6 +185,8 @@ module NewRelic
|
|
185
185
|
TransactionSampleDataPost.new(opts)
|
186
186
|
when 'analytic_event_data'
|
187
187
|
AnalyticEventDataPost.new(opts)
|
188
|
+
when 'error_data'
|
189
|
+
ErrorDataPost.new(opts)
|
188
190
|
else
|
189
191
|
new(opts)
|
190
192
|
end
|
@@ -241,6 +243,10 @@ module NewRelic
|
|
241
243
|
super
|
242
244
|
@body[0][0][9] = unblob(@body[0][0][9]) if @format == :json
|
243
245
|
end
|
246
|
+
|
247
|
+
def traces
|
248
|
+
@body[0]
|
249
|
+
end
|
244
250
|
end
|
245
251
|
|
246
252
|
class TransactionSampleDataPost < AgentPost
|
@@ -305,14 +311,40 @@ module NewRelic
|
|
305
311
|
samples.first.metric_name
|
306
312
|
end
|
307
313
|
end
|
314
|
+
|
308
315
|
class AnalyticEventDataPost < AgentPost
|
309
316
|
|
317
|
+
attr_reader :events
|
318
|
+
|
310
319
|
def initialize(opts={})
|
311
|
-
|
312
|
-
|
320
|
+
super
|
321
|
+
|
322
|
+
@events = @body[1]
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
class ErrorDataPost < AgentPost
|
313
327
|
|
328
|
+
attr_reader :errors
|
329
|
+
|
330
|
+
def initialize(opts={})
|
314
331
|
super
|
332
|
+
@errors = @body[1].map { |e| SubmittedError.new(e) }
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
class SubmittedError
|
337
|
+
|
338
|
+
attr_reader :timestamp, :path, :message, :exception_class_name, :params
|
339
|
+
|
340
|
+
def initialize(error_info)
|
341
|
+
@timestamp = error_info[0]
|
342
|
+
@path = error_info[1]
|
343
|
+
@message = error_info[2]
|
344
|
+
@exception_class_name = error_info[3]
|
345
|
+
@params = error_info[4]
|
315
346
|
end
|
347
|
+
|
316
348
|
end
|
317
349
|
end
|
318
350
|
|
@@ -381,8 +381,6 @@ module HttpClientTestCases
|
|
381
381
|
end
|
382
382
|
|
383
383
|
def test_doesnt_misbehave_when_transaction_tracing_is_disabled
|
384
|
-
@engine.transaction_sampler = nil
|
385
|
-
|
386
384
|
# The error should have any other consequence other than logging the error, so
|
387
385
|
# this will capture logs
|
388
386
|
logger = NewRelic::Agent::MemoryLogger.new
|
@@ -394,9 +392,6 @@ module HttpClientTestCases
|
|
394
392
|
|
395
393
|
refute_match( /undefined method `rename_scope_segment" for nil:NilClass/i,
|
396
394
|
logger.messages.flatten.map {|log| log.to_s }.join(" ") )
|
397
|
-
|
398
|
-
ensure
|
399
|
-
@engine.transaction_sampler = NewRelic::Agent.agent.transaction_sampler
|
400
395
|
end
|
401
396
|
|
402
397
|
def test_includes_full_url_in_transaction_trace
|
@@ -63,7 +63,7 @@ class LicenseTest < Minitest::Test
|
|
63
63
|
# skip directories
|
64
64
|
!File.file?(path) ||
|
65
65
|
# skip binary files
|
66
|
-
%w| .sqlite3 .log .png .ico .gif .gem |.include?(File.extname(path)) ||
|
66
|
+
%w| .sqlite3 .log .png .ico .gif .pdf .gem |.include?(File.extname(path)) ||
|
67
67
|
# skip this file
|
68
68
|
File.expand_path(__FILE__) == path ||
|
69
69
|
# skip rpm_test_app and other stuff that ends up in tmp
|
@@ -71,7 +71,9 @@ class LicenseTest < Minitest::Test
|
|
71
71
|
# skip the auto-generated build.rb file
|
72
72
|
path =~ %r{lib/new_relic/build\.rb} ||
|
73
73
|
# skip tags file
|
74
|
-
path =~ %r{/tags$}i
|
74
|
+
path =~ %r{/tags$}i ||
|
75
|
+
# skip multiverse auto-generated gemfiles
|
76
|
+
path =~ %r{/test/multiverse/suites/.*/Gemfile\.\d+(\.lock)?$}
|
75
77
|
)
|
76
78
|
end
|
77
79
|
|
@@ -10,22 +10,17 @@ class NewRelic::LocalEnvironmentTest < Minitest::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_passenger
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
NewRelic::Agent.reset_config
|
18
|
-
e = NewRelic::LocalEnvironment.new
|
19
|
-
assert_equal :passenger, e.discovered_dispatcher
|
20
|
-
assert_equal :passenger, NewRelic::Agent.config[:dispatcher]
|
21
|
-
|
22
|
-
with_config(:app_name => 'myapp') do
|
13
|
+
with_constant_defined(:PhusionPassenger, Module.new) do
|
14
|
+
NewRelic::Agent.reset_config
|
23
15
|
e = NewRelic::LocalEnvironment.new
|
24
16
|
assert_equal :passenger, e.discovered_dispatcher
|
25
|
-
|
17
|
+
assert_equal :passenger, NewRelic::Agent.config[:dispatcher]
|
26
18
|
|
27
|
-
|
28
|
-
|
19
|
+
with_config(:app_name => 'myapp') do
|
20
|
+
e = NewRelic::LocalEnvironment.new
|
21
|
+
assert_equal :passenger, e.discovered_dispatcher
|
22
|
+
end
|
23
|
+
end
|
29
24
|
end
|
30
25
|
|
31
26
|
# LocalEnvironment won't talk to ObjectSpace on JRuby, and these tests are
|
@@ -34,22 +29,13 @@ class NewRelic::LocalEnvironmentTest < Minitest::Test
|
|
34
29
|
def test_mongrel_only_checks_once
|
35
30
|
return unless NewRelic::LanguageSupport.object_space_usable?
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
e = NewRelic::LocalEnvironment.new
|
42
|
-
5.times { e.mongrel }
|
43
|
-
assert_nil e.mongrel
|
44
|
-
ensure
|
45
|
-
Object.send(:remove_const, :Mongrel) if defined?(Mongrel)
|
46
|
-
end
|
47
|
-
end
|
32
|
+
with_constant_defined(:'Mongrel', Module.new) do
|
33
|
+
with_constant_defined(:'Mongrel::HttpServer', Class.new) do
|
34
|
+
ObjectSpace.expects(:each_object).with(::Mongrel::HttpServer).once
|
48
35
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
class HttpServer
|
36
|
+
e = NewRelic::LocalEnvironment.new
|
37
|
+
5.times { e.mongrel }
|
38
|
+
assert_nil e.mongrel
|
53
39
|
end
|
54
40
|
end
|
55
41
|
end
|
@@ -50,8 +50,8 @@ module MultiverseHelpers
|
|
50
50
|
NewRelic::Agent.config.reset_to_defaults
|
51
51
|
|
52
52
|
# Renaming rules don't get cleared on connect--only appended to
|
53
|
-
NewRelic::Agent.instance.transaction_rules.
|
54
|
-
NewRelic::Agent.instance.stats_engine.metric_rules.
|
53
|
+
NewRelic::Agent.instance.transaction_rules.clear
|
54
|
+
NewRelic::Agent.instance.stats_engine.metric_rules.clear
|
55
55
|
|
56
56
|
# Clear out lingering stats we didn't transmit
|
57
57
|
NewRelic::Agent.drop_buffered_data
|
@@ -23,11 +23,10 @@ class DeveloperModeTest < Minitest::Test
|
|
23
23
|
def setup
|
24
24
|
@test_config = { :developer_mode => true }
|
25
25
|
NewRelic::Agent.config.apply_config(@test_config)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
NewRelic::Agent.instance.stubs(:transaction_sampler).returns(@sampler)
|
26
|
+
run_sample_trace('/here')
|
27
|
+
run_sample_trace('/there')
|
28
|
+
run_sample_trace('/somewhere')
|
29
|
+
@sampler = NewRelic::Agent.instance.transaction_sampler
|
31
30
|
end
|
32
31
|
|
33
32
|
def teardown
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'multiverse_helpers'
|
6
|
+
|
7
|
+
module TransactionIgnoringTestCases
|
8
|
+
|
9
|
+
include MultiverseHelpers
|
10
|
+
|
11
|
+
TXN_PREFIX = 'Controller/'
|
12
|
+
|
13
|
+
setup_and_teardown_agent do |collector|
|
14
|
+
collector.stub('connect', {
|
15
|
+
'transaction_name_rules' => [{"match_expression" => "ignored_transaction",
|
16
|
+
"ignore" => true}],
|
17
|
+
'agent_run_id' => 1,
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
# Test classes that include this module are expected to define:
|
22
|
+
# trigger_transaction(txn_name)
|
23
|
+
# trigger_transaction_with_error(txn_name, error_msg)
|
24
|
+
# trigger_transaction_with_slow_sql(txn_name)
|
25
|
+
|
26
|
+
|
27
|
+
def test_does_not_record_metrics_for_ignored_transaction
|
28
|
+
trigger_transaction('accepted_transaction')
|
29
|
+
trigger_transaction('ignored_transaction')
|
30
|
+
|
31
|
+
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
32
|
+
|
33
|
+
stats = $collector.reported_stats_for_metric(TXN_PREFIX+'accepted_transaction')
|
34
|
+
assert_equal(1, stats.size)
|
35
|
+
|
36
|
+
stats = $collector.reported_stats_for_metric(TXN_PREFIX+'ignored_transaction')
|
37
|
+
assert_equal(0, stats.size)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_does_not_record_traced_errors_for_ignored_transactions
|
41
|
+
trigger_transaction_with_error('ignored_transaction', 'Buffy dies :(')
|
42
|
+
trigger_transaction_with_error('accepted_transaction', 'Buffy lives :)')
|
43
|
+
|
44
|
+
NewRelic::Agent.instance.send(:harvest_and_send_errors)
|
45
|
+
|
46
|
+
posts = $collector.calls_for('error_data')
|
47
|
+
assert_equal(1, posts.size)
|
48
|
+
|
49
|
+
errors = posts.first.errors
|
50
|
+
|
51
|
+
assert_equal(1, errors.size)
|
52
|
+
assert_equal('Buffy lives :)', errors.first.message)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_does_not_record_transaction_trace_for_ignored_transactions
|
56
|
+
with_config(:'transaction_tracer.transaction_threshold' => 0) do
|
57
|
+
trigger_transaction('accepted_transaction')
|
58
|
+
NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)
|
59
|
+
assert_equal(1, $collector.calls_for('transaction_sample_data').size)
|
60
|
+
|
61
|
+
trigger_transaction('ignored_transaction')
|
62
|
+
NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)
|
63
|
+
assert_equal(1, $collector.calls_for('transaction_sample_data').size)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_does_not_record_analytics_for_ignored_transactions
|
68
|
+
trigger_transaction('ignored_transaction')
|
69
|
+
trigger_transaction('accepted_transaction')
|
70
|
+
|
71
|
+
NewRelic::Agent.instance.send(:harvest_and_send_analytic_event_data)
|
72
|
+
|
73
|
+
posts = $collector.calls_for('analytic_event_data')
|
74
|
+
assert_equal(1, posts.size)
|
75
|
+
|
76
|
+
events = posts.first.events
|
77
|
+
|
78
|
+
assert_equal(1, events.size)
|
79
|
+
assert_equal(TXN_PREFIX+'accepted_transaction', events.first[0]['name'])
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_does_not_record_sql_traces_for_ignored_transactions
|
83
|
+
trigger_transaction_with_slow_sql('ignored_transaction')
|
84
|
+
trigger_transaction_with_slow_sql('accepted_transaction')
|
85
|
+
|
86
|
+
NewRelic::Agent.instance.send(:harvest_and_send_slowest_sql)
|
87
|
+
|
88
|
+
posts = $collector.calls_for('sql_trace_data')
|
89
|
+
assert_equal(1, posts.size)
|
90
|
+
|
91
|
+
traces = posts.first.traces
|
92
|
+
|
93
|
+
assert_equal(1, traces.size)
|
94
|
+
|
95
|
+
trace = traces.first
|
96
|
+
|
97
|
+
# From SqlTrace#to_collector_array
|
98
|
+
# 0 -> path
|
99
|
+
# 5 -> call_count
|
100
|
+
assert_equal(TXN_PREFIX+'accepted_transaction', trace[0])
|
101
|
+
assert_equal(1, trace[5])
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -12,6 +12,9 @@ class NewRelic::TransactionSampleTest < Minitest::Test
|
|
12
12
|
def setup
|
13
13
|
@test_config = { :developer_mode => true }
|
14
14
|
NewRelic::Agent.config.apply_config(@test_config)
|
15
|
+
|
16
|
+
NewRelic::Agent.agent.transaction_sampler.reset!
|
17
|
+
|
15
18
|
@connection_stub = Mocha::Mockery.instance.named_mock('connection')
|
16
19
|
@connection_stub.stubs(:execute).returns(dummy_mysql_explain_result({'foo' => 'bar'}))
|
17
20
|
|
@@ -23,6 +26,7 @@ class NewRelic::TransactionSampleTest < Minitest::Test
|
|
23
26
|
else
|
24
27
|
@marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
|
25
28
|
end
|
29
|
+
|
26
30
|
end
|
27
31
|
|
28
32
|
def teardown
|
@@ -130,6 +134,8 @@ class NewRelic::TransactionSampleTest < Minitest::Test
|
|
130
134
|
end
|
131
135
|
|
132
136
|
def test_not_record_transactions
|
137
|
+
NewRelic::Agent.instance.transaction_sampler.reset!
|
138
|
+
|
133
139
|
NewRelic::Agent.disable_transaction_tracing do
|
134
140
|
t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
|
135
141
|
assert t.nil?
|
@@ -214,15 +220,16 @@ class NewRelic::TransactionSampleTest < Minitest::Test
|
|
214
220
|
end
|
215
221
|
|
216
222
|
def test_count_segments
|
217
|
-
transaction =
|
218
|
-
sampler.
|
219
|
-
sampler.
|
220
|
-
sampler.
|
223
|
+
transaction = run_sample_trace do |sampler|
|
224
|
+
sampler.notice_push_frame "level0"
|
225
|
+
sampler.notice_push_frame "level-1"
|
226
|
+
sampler.notice_push_frame "level-2"
|
221
227
|
sampler.notice_sql(::SQL_STATEMENT, {}, 0)
|
222
|
-
sampler.
|
223
|
-
sampler.
|
224
|
-
sampler.
|
228
|
+
sampler.notice_pop_frame "level-2"
|
229
|
+
sampler.notice_pop_frame "level-1"
|
230
|
+
sampler.notice_pop_frame "level0"
|
225
231
|
end
|
232
|
+
|
226
233
|
assert_equal 6, transaction.count_segments
|
227
234
|
end
|
228
235
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
module Performance
|
6
6
|
module Instrumentation
|
7
7
|
class MRIGCStats < Instrumentor
|
8
|
-
platforms :mri_193, :mri_20
|
8
|
+
platforms :mri_193, :mri_20, :mri_21
|
9
9
|
on_by_default
|
10
10
|
|
11
11
|
def before(*)
|
@@ -17,9 +17,12 @@ module Performance
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def results
|
20
|
+
heap_live_before = @stats_before[:heap_live_num] || @stats_before[:heap_live_slot]
|
21
|
+
heap_live_after = @stats_after[:heap_live_num] || @stats_after[:heap_live_slot]
|
22
|
+
|
20
23
|
res = {
|
21
|
-
:gc_runs
|
22
|
-
:live_objects =>
|
24
|
+
:gc_runs => @stats_after[:count] - @stats_before[:count],
|
25
|
+
:live_objects => heap_live_after - heap_live_before
|
23
26
|
}
|
24
27
|
if RUBY_VERSION >= "2.0.0"
|
25
28
|
res[:allocations] = @stats_after[:total_allocated_object] - @stats_before[:total_allocated_object]
|
@@ -49,7 +49,10 @@ class TransactionTracingPerfTests < Performance::TestCase
|
|
49
49
|
|
50
50
|
def setup
|
51
51
|
@dummy = klass(true).new
|
52
|
-
NewRelic::Agent.manual_start(
|
52
|
+
NewRelic::Agent.manual_start(
|
53
|
+
:developer_mode => false,
|
54
|
+
:monitor_mode => false
|
55
|
+
)
|
53
56
|
end
|
54
57
|
|
55
58
|
def teardown
|
data/test/test_helper.rb
CHANGED
@@ -171,39 +171,6 @@ def load_cross_agent_test(name)
|
|
171
171
|
NewRelic::JSONWrapper.load(data)
|
172
172
|
end
|
173
173
|
|
174
|
-
class ArrayLogDevice
|
175
|
-
def initialize( array=[] )
|
176
|
-
@array = array
|
177
|
-
end
|
178
|
-
attr_reader :array
|
179
|
-
|
180
|
-
def write( message )
|
181
|
-
@array << message
|
182
|
-
end
|
183
|
-
|
184
|
-
def close; end
|
185
|
-
end
|
186
|
-
|
187
|
-
def with_array_logger( level=:info )
|
188
|
-
orig_logger = NewRelic::Agent.logger
|
189
|
-
config = {
|
190
|
-
:log_file_path => nil,
|
191
|
-
:log_file_name => nil,
|
192
|
-
:log_level => level,
|
193
|
-
}
|
194
|
-
logdev = ArrayLogDevice.new
|
195
|
-
override_logger = Logger.new( logdev )
|
196
|
-
NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new("", override_logger)
|
197
|
-
|
198
|
-
with_config(config) do
|
199
|
-
yield
|
200
|
-
end
|
201
|
-
|
202
|
-
return logdev
|
203
|
-
ensure
|
204
|
-
NewRelic::Agent.logger = orig_logger
|
205
|
-
end
|
206
|
-
|
207
174
|
def dummy_mysql_explain_result(hash=nil)
|
208
175
|
hash ||= {
|
209
176
|
'Id' => '1',
|
@@ -225,34 +192,38 @@ end
|
|
225
192
|
module TransactionSampleTestHelper
|
226
193
|
module_function
|
227
194
|
def make_sql_transaction(*sql)
|
228
|
-
sampler =
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
195
|
+
sampler = nil
|
196
|
+
|
197
|
+
in_transaction('/path') do
|
198
|
+
sampler = NewRelic::Agent.instance.transaction_sampler
|
199
|
+
sampler.notice_push_frame "a"
|
200
|
+
explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
|
201
|
+
sql.each {|sql_statement| sampler.notice_sql(sql_statement, {:adapter => "mysql"}, 0, &explainer) }
|
202
|
+
sleep 0.02
|
203
|
+
yield if block_given?
|
204
|
+
sampler.notice_pop_frame "a"
|
205
|
+
end
|
206
|
+
|
207
|
+
return sampler.last_sample
|
240
208
|
end
|
241
209
|
|
242
|
-
def
|
243
|
-
sampler
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
210
|
+
def run_sample_trace(path='/path')
|
211
|
+
sampler = nil
|
212
|
+
|
213
|
+
request = stub(:uri => path)
|
214
|
+
|
215
|
+
in_transaction("Controller/sandwiches/index", :request => request) do
|
216
|
+
sampler = NewRelic::Agent.instance.transaction_sampler
|
217
|
+
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0)
|
218
|
+
sampler.notice_push_frame "ab"
|
219
|
+
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0)
|
220
|
+
yield sampler if block_given?
|
221
|
+
sampler.notice_pop_frame "ab"
|
222
|
+
sampler.notice_push_frame "lew"
|
223
|
+
sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0)
|
224
|
+
sampler.notice_pop_frame "lew"
|
225
|
+
end
|
226
|
+
|
227
|
+
return sampler.last_sample
|
257
228
|
end
|
258
229
|
end
|