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
@@ -62,7 +62,7 @@ class ExconTest < Minitest::Test
|
|
62
62
|
end
|
63
63
|
|
64
64
|
tt = NewRelic::Agent.agent.transaction_sampler.last_sample
|
65
|
-
segment = tt.root_segment.called_segments.first
|
65
|
+
segment = tt.root_segment.called_segments.first.called_segments.first
|
66
66
|
assert_equal("External/localhost/Excon/GET", segment.metric_name)
|
67
67
|
assert_equal(target_url, segment.params[:uri])
|
68
68
|
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
gem 'bson_ext', :platforms => :ruby
|
6
|
-
RB
|
7
|
-
end
|
1
|
+
gemfile <<-RB
|
2
|
+
gem 'mongo', '1.10.0'
|
3
|
+
gem 'bson_ext', :platforms => :ruby
|
4
|
+
RB
|
8
5
|
|
9
6
|
gemfile <<-RB
|
10
7
|
gem 'mongo', '1.9.2'
|
@@ -134,10 +134,31 @@ module MongoOperationTests
|
|
134
134
|
def test_records_metrics_for_create_index
|
135
135
|
@collection.create_index([[unique_field_name, Mongo::ASCENDING]])
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
# The createIndexes command was added to the mongo server in version 2.6.
|
138
|
+
# As of version 1.10.0 of the Ruby driver, the driver will attempt to
|
139
|
+
# service a create_index call by first issuing a createIndexes command to
|
140
|
+
# the server. If the server replies that it doesn't know this command, the
|
141
|
+
# driver will re-issue an equivalent createIndex command.
|
142
|
+
#
|
143
|
+
# So, if we're running with version 1.10.0 or later of the driver, we expect
|
144
|
+
# some additional metrics to be recorded.
|
145
|
+
client_is_1_10_or_later = NewRelic::Agent::Datastores::Mongo.is_version_1_10_or_later?
|
146
|
+
|
147
|
+
create_index_metrics = metrics_with_attributes(build_test_metrics(:createIndex))
|
148
|
+
create_indexes_metrics = metrics_with_attributes(build_test_metrics(:createIndexes))
|
149
|
+
|
150
|
+
if !client_is_1_10_or_later
|
151
|
+
metrics = create_index_metrics
|
152
|
+
elsif client_is_1_10_or_later && !server_is_2_6_or_later?
|
153
|
+
metrics = create_index_metrics.merge(create_indexes_metrics)
|
154
|
+
metrics['ActiveRecord/all'][:call_count] += 1
|
155
|
+
metrics['Datastore/allWeb'][:call_count] += 1
|
156
|
+
metrics['Datastore/all'][:call_count] += 1
|
157
|
+
elsif client_is_1_10_or_later && server_is_2_6_or_later?
|
158
|
+
metrics = create_indexes_metrics
|
159
|
+
end
|
139
160
|
|
140
|
-
assert_metrics_recorded(
|
161
|
+
assert_metrics_recorded(metrics)
|
141
162
|
end
|
142
163
|
|
143
164
|
def test_records_metrics_for_ensure_index
|
@@ -269,16 +290,18 @@ module MongoOperationTests
|
|
269
290
|
|
270
291
|
in_transaction do
|
271
292
|
@collection.insert(@tribble)
|
293
|
+
|
272
294
|
segment = find_last_transaction_segment
|
273
295
|
end
|
274
296
|
|
275
|
-
expected = {
|
276
|
-
|
277
|
-
|
297
|
+
expected = {
|
298
|
+
:database => @database_name,
|
299
|
+
:collection => @collection_name,
|
300
|
+
:operation => :insert
|
301
|
+
}
|
278
302
|
|
279
303
|
result = segment.params[:statement]
|
280
|
-
|
281
|
-
assert_equal expected, result, "Expected result (#{result}) to be #{expected}"
|
304
|
+
assert_equal expected, result
|
282
305
|
end
|
283
306
|
|
284
307
|
def test_noticed_nosql_includes_operation
|
@@ -289,12 +312,25 @@ module MongoOperationTests
|
|
289
312
|
segment = find_last_transaction_segment
|
290
313
|
end
|
291
314
|
|
292
|
-
|
315
|
+
query = segment.params[:statement]
|
316
|
+
|
317
|
+
assert_equal :insert, query[:operation]
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_noticed_nosql_includes_update_operation
|
321
|
+
segment = nil
|
322
|
+
|
323
|
+
in_transaction do
|
324
|
+
updated = @tribble.dup
|
325
|
+
updated['name'] = 't-rex'
|
326
|
+
@collection.update(@tribble, updated)
|
327
|
+
|
328
|
+
segment = find_last_transaction_segment
|
329
|
+
end
|
293
330
|
|
294
331
|
query = segment.params[:statement]
|
295
|
-
result = query[:operation]
|
296
332
|
|
297
|
-
assert_equal
|
333
|
+
assert_equal :update, query[:operation]
|
298
334
|
end
|
299
335
|
|
300
336
|
def test_noticed_nosql_includes_save_operation
|
@@ -305,12 +341,8 @@ module MongoOperationTests
|
|
305
341
|
segment = find_last_transaction_segment
|
306
342
|
end
|
307
343
|
|
308
|
-
expected = :save
|
309
|
-
|
310
344
|
query = segment.params[:statement]
|
311
|
-
|
312
|
-
|
313
|
-
assert_equal expected, result
|
345
|
+
assert_equal :save, query[:operation]
|
314
346
|
end
|
315
347
|
|
316
348
|
def test_noticed_nosql_includes_ensure_index_operation
|
@@ -377,6 +409,8 @@ module MongoOperationTests
|
|
377
409
|
|
378
410
|
statement = segment.params[:statement]
|
379
411
|
|
412
|
+
refute statement.inspect.include?('$secret')
|
413
|
+
|
380
414
|
assert_equal '?', statement[:selector]['password']
|
381
415
|
end
|
382
416
|
|
@@ -438,4 +472,9 @@ module MongoOperationTests
|
|
438
472
|
NewRelic::Agent.drop_buffered_data
|
439
473
|
end
|
440
474
|
|
475
|
+
def server_is_2_6_or_later?
|
476
|
+
client = @collection.db.respond_to?(:client) && @collection.db.client
|
477
|
+
return false unless client
|
478
|
+
client.respond_to?(:max_wire_version) && client.max_wire_version >= 2
|
479
|
+
end
|
441
480
|
end
|
@@ -115,18 +115,20 @@ class MongoServer
|
|
115
115
|
def startup_command
|
116
116
|
pid_file = "--pidfilepath #{pid_path}"
|
117
117
|
log_file = "--logpath #{log_path} "
|
118
|
+
fork = "--fork"
|
118
119
|
|
119
120
|
dbpath = "--dbpath #{db_path}"
|
120
121
|
port_flag = "--port #{self.port}"
|
121
122
|
small_mongo = "--oplogSize 128 --smallfiles"
|
122
|
-
repl_set = "--
|
123
|
+
repl_set = "--replSet multiverse"
|
123
124
|
|
124
|
-
base = "#{port_flag} #{pid_file} #{log_file} #{small_mongo} #{dbpath}"
|
125
|
+
base = "#{port_flag} #{fork} #{pid_file} #{log_file} #{small_mongo} #{dbpath}"
|
125
126
|
|
127
|
+
mongod_path = ENV['MONGOD_PATH'] || 'mongod'
|
126
128
|
if self.type == :single
|
127
|
-
"
|
129
|
+
"#{mongod_path} #{base}"
|
128
130
|
elsif self.type == :replica
|
129
|
-
"
|
131
|
+
"#{mongod_path} #{repl_set} #{base}"
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
@@ -8,12 +8,12 @@ class BadInstrumentationController < ApplicationController
|
|
8
8
|
include Rails.application.routes.url_helpers
|
9
9
|
|
10
10
|
# This action is intended to simulate a chunk of instrumentation that pushes
|
11
|
-
# a
|
11
|
+
# a traced method frame, but then never pops it. Such a situation will break
|
12
12
|
# instrumentation of that request, but should not actually cause the request
|
13
13
|
# to fail.
|
14
14
|
# https://newrelic.atlassian.net/browse/RUBY-1158
|
15
15
|
def failwhale
|
16
|
-
NewRelic::Agent.
|
16
|
+
NewRelic::Agent::TracedMethodStack.push_frame('failwhale', Time.now)
|
17
17
|
render :text => 'everything went great'
|
18
18
|
end
|
19
19
|
end
|
@@ -136,7 +136,9 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
136
136
|
get '/error/controller_error'
|
137
137
|
end
|
138
138
|
|
139
|
-
assert_errors_reported('this is an uncaught controller error',
|
139
|
+
assert_errors_reported('this is an uncaught controller error',
|
140
|
+
NewRelic::Agent::ErrorCollector::MAX_ERROR_QUEUE_LENGTH,
|
141
|
+
40, nil, 40)
|
140
142
|
end
|
141
143
|
|
142
144
|
def test_should_capture_manually_noticed_error
|
@@ -54,10 +54,10 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
54
54
|
post = $collector.calls_for('analytic_event_data').first
|
55
55
|
|
56
56
|
refute_nil( post )
|
57
|
-
assert_kind_of Array, post.
|
58
|
-
assert_kind_of Array, post.
|
57
|
+
assert_kind_of Array, post.events
|
58
|
+
assert_kind_of Array, post.events.first
|
59
59
|
|
60
|
-
sample = post.
|
60
|
+
sample = post.events.first.first
|
61
61
|
assert_kind_of Hash, sample
|
62
62
|
|
63
63
|
assert_equal 'Controller/request_stats/stats_action', sample['name']
|
@@ -80,10 +80,10 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
80
80
|
post = $collector.calls_for('analytic_event_data').first
|
81
81
|
|
82
82
|
refute_nil( post )
|
83
|
-
assert_kind_of Array, post.
|
84
|
-
assert_kind_of Array, post.
|
83
|
+
assert_kind_of Array, post.events
|
84
|
+
assert_kind_of Array, post.events.first
|
85
85
|
|
86
|
-
sample = post.
|
86
|
+
sample = post.events.first.first
|
87
87
|
assert_kind_of Hash, sample
|
88
88
|
|
89
89
|
assert_kind_of String, sample['nr.guid']
|
@@ -106,10 +106,10 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
106
106
|
post = $collector.calls_for('analytic_event_data').first
|
107
107
|
|
108
108
|
refute_nil( post )
|
109
|
-
assert_kind_of Array, post.
|
110
|
-
assert_kind_of Array, post.
|
109
|
+
assert_kind_of Array, post.events
|
110
|
+
assert_kind_of Array, post.events.first
|
111
111
|
|
112
|
-
sample = post.
|
112
|
+
sample = post.events.first.first
|
113
113
|
|
114
114
|
assert_kind_of Hash, sample
|
115
115
|
assert_kind_of String, sample['nr.guid']
|
@@ -126,10 +126,10 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
126
126
|
post = $collector.calls_for('analytic_event_data').first
|
127
127
|
|
128
128
|
refute_nil( post )
|
129
|
-
assert_kind_of Array, post.
|
130
|
-
assert_kind_of Array, post.
|
129
|
+
assert_kind_of Array, post.events
|
130
|
+
assert_kind_of Array, post.events.first
|
131
131
|
|
132
|
-
sample = post.
|
132
|
+
sample = post.events.first[0]
|
133
133
|
assert_kind_of Hash, sample
|
134
134
|
|
135
135
|
assert_equal 'Controller/request_stats/stats_action_with_custom_params', sample['name']
|
@@ -139,7 +139,7 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
139
139
|
assert_not_includes(sample, key)
|
140
140
|
end
|
141
141
|
|
142
|
-
custom_params = post.
|
142
|
+
custom_params = post.events.first[1]
|
143
143
|
assert_equal 'blue', custom_params['color']
|
144
144
|
assert_equal 'bar', custom_params['1']
|
145
145
|
assert_false custom_params.has_key?('bad')
|
@@ -160,7 +160,7 @@ class RequestStatsTest < ActionDispatch::IntegrationTest
|
|
160
160
|
|
161
161
|
post = $collector.calls_for('analytic_event_data').last
|
162
162
|
|
163
|
-
samples = post.
|
163
|
+
samples = post.events
|
164
164
|
assert_equal(5, samples.size)
|
165
165
|
samples.each do |sample|
|
166
166
|
# undo the extra layer of wrapping that the collector wants
|
@@ -0,0 +1,45 @@
|
|
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 'rails/test_help'
|
6
|
+
require './app'
|
7
|
+
require 'multiverse_helpers'
|
8
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
9
|
+
require 'transaction_ignoring_test_cases'
|
10
|
+
|
11
|
+
class TransactionIgnorerController < ApplicationController
|
12
|
+
include Rails.application.routes.url_helpers
|
13
|
+
|
14
|
+
def run_transaction
|
15
|
+
NewRelic::Agent.set_transaction_name(params[:txn_name])
|
16
|
+
NewRelic::Agent.notice_error(params[:error_msg]) if params[:error_msg]
|
17
|
+
NewRelic::Agent.instance.sql_sampler.notice_sql("select * from test",
|
18
|
+
"Database/test/select",
|
19
|
+
nil, 1.5) if params[:slow_sql]
|
20
|
+
render :text => 'some stuff'
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class TransactionIgnoringTest < ActionDispatch::IntegrationTest
|
27
|
+
|
28
|
+
include MultiverseHelpers
|
29
|
+
include TransactionIgnoringTestCases
|
30
|
+
|
31
|
+
def trigger_transaction(txn_name)
|
32
|
+
get '/transaction_ignorer/run_transaction', :txn_name => txn_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def trigger_transaction_with_error(txn_name, error_msg)
|
36
|
+
get '/transaction_ignorer/run_transaction', :txn_name => txn_name,
|
37
|
+
:error_msg => error_msg
|
38
|
+
end
|
39
|
+
|
40
|
+
def trigger_transaction_with_slow_sql(txn_name)
|
41
|
+
get '/transaction_ignorer/run_transaction', :txn_name => txn_name,
|
42
|
+
:slow_sql => 'true'
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -252,7 +252,7 @@ class NewRelic::Agent::Instrumentation::SequelInstrumentationTest < Minitest::Te
|
|
252
252
|
# This is particular to sqlite plans currently. To abstract it up, we'd need to
|
253
253
|
# be able to specify a flavor (e.g., :sqlite, :postgres, :mysql, etc.)
|
254
254
|
def assert_segment_has_explain_plan( segment, msg=nil )
|
255
|
-
msg =
|
255
|
+
msg = "Expected #{segment.inspect} to have an explain plan"
|
256
256
|
assert_block( msg ) { segment.params[:explain_plan].join =~ SQLITE_EXPLAIN_PLAN_COLUMNS_RE }
|
257
257
|
end
|
258
258
|
|
@@ -214,9 +214,9 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
|
|
214
214
|
|
215
215
|
rules = NewRelic::Agent.instance.transaction_rules
|
216
216
|
assert_equal 2, rules.size
|
217
|
-
assert(rules.find{|r| r.match_expression == /88/ && r.replacement == '**' },
|
217
|
+
assert(rules.find{|r| r.match_expression == /88/i && r.replacement == '**' },
|
218
218
|
"rule not found among #{rules}")
|
219
|
-
assert(rules.find{|r| r.match_expression == /xx/ && r.replacement == 'XX' },
|
219
|
+
assert(rules.find{|r| r.match_expression == /xx/i && r.replacement == 'XX' },
|
220
220
|
"rule not found among #{rules}")
|
221
221
|
ensure
|
222
222
|
NewRelic::Agent.instance.instance_variable_set(:@transaction_rules,
|
@@ -236,9 +236,9 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
|
|
236
236
|
|
237
237
|
rules = @stats_engine.metric_rules
|
238
238
|
assert_equal 2, rules.size
|
239
|
-
assert(rules.find{|r| r.match_expression == /77/ && r.replacement == '&&' },
|
239
|
+
assert(rules.find{|r| r.match_expression == /77/i && r.replacement == '&&' },
|
240
240
|
"rule not found among #{rules}")
|
241
|
-
assert(rules.find{|r| r.match_expression == /yy/ && r.replacement == 'YY' },
|
241
|
+
assert(rules.find{|r| r.match_expression == /yy/i && r.replacement == 'YY' },
|
242
242
|
"rule not found among #{rules}")
|
243
243
|
ensure
|
244
244
|
NewRelic::Agent.instance.instance_variable_set(:@metric_rules,
|
@@ -287,6 +287,38 @@ class AgentLoggerTest < Minitest::Test
|
|
287
287
|
assert_logged(host_regex, host_regex, host_regex)
|
288
288
|
end
|
289
289
|
|
290
|
+
def test_should_not_evaluate_blocks_unless_log_level_is_high_enough
|
291
|
+
with_config(:log_level => 'warn') do
|
292
|
+
logger = create_basic_logger
|
293
|
+
|
294
|
+
block_was_evalutated = false
|
295
|
+
logger.info do
|
296
|
+
block_was_evalutated = true
|
297
|
+
end
|
298
|
+
|
299
|
+
refute block_was_evalutated
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_should_allow_blocks_that_return_a_single_string
|
304
|
+
logger = create_basic_logger
|
305
|
+
logger.warn { "Surely you jest!" }
|
306
|
+
|
307
|
+
assert_logged(/WARN : Surely you jest!/)
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_should_allow_blocks_that_return_an_array
|
311
|
+
logger = create_basic_logger
|
312
|
+
logger.warn do
|
313
|
+
["You must be joking!", "You can't be serious!"]
|
314
|
+
end
|
315
|
+
|
316
|
+
assert_logged(
|
317
|
+
/WARN : You must be joking!/,
|
318
|
+
/WARN : You can't be serious!/
|
319
|
+
)
|
320
|
+
end
|
321
|
+
|
290
322
|
#
|
291
323
|
# Helpers
|
292
324
|
#
|
@@ -245,16 +245,24 @@ module NewRelic::Agent::Configuration
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_should_log_when_applying
|
248
|
-
|
249
|
-
|
248
|
+
log = with_array_logger(:debug) do
|
249
|
+
@manager.apply_config(:test => "asdf")
|
250
|
+
end
|
251
|
+
|
252
|
+
log_lines = log.array
|
253
|
+
assert_match(/DEBUG.*asdf/, log_lines[0])
|
250
254
|
end
|
251
255
|
|
252
256
|
def test_should_log_when_removing
|
253
257
|
config = { :test => "asdf" }
|
254
258
|
@manager.apply_config(config)
|
255
259
|
|
256
|
-
|
257
|
-
|
260
|
+
log = with_array_logger(:debug) do
|
261
|
+
@manager.remove_config(config)
|
262
|
+
end
|
263
|
+
|
264
|
+
log_lines = log.array
|
265
|
+
refute_match(/DEBUG.*asdf/, log_lines[0])
|
258
266
|
end
|
259
267
|
|
260
268
|
def test_config_stack_index_for
|
@@ -58,7 +58,7 @@ module NewRelic::Agent::Configuration
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_should_log_if_no_file_is_found
|
61
|
-
expects_logging(:
|
61
|
+
expects_logging(:warn, any_parameters)
|
62
62
|
source = YamlSource.new('no_such_file.yml', 'test')
|
63
63
|
end
|
64
64
|
|
@@ -69,7 +69,7 @@ module NewRelic::Agent::Configuration
|
|
69
69
|
|
70
70
|
def test_should_not_fail_to_log_missing_file_during_startup
|
71
71
|
without_logger do
|
72
|
-
::NewRelic::Agent::StartupLogger.any_instance.expects(:
|
72
|
+
::NewRelic::Agent::StartupLogger.any_instance.expects(:warn)
|
73
73
|
source = YamlSource.new('no_such_file.yml', 'test')
|
74
74
|
end
|
75
75
|
end
|
@@ -175,13 +175,17 @@ module NewRelic::Agent
|
|
175
175
|
|
176
176
|
when_request_runs(for_id(''))
|
177
177
|
|
178
|
-
assert_metrics_recorded_exclusive([])
|
178
|
+
assert_metrics_recorded_exclusive(['transaction'])
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_setting_response_headers_freezes_transaction_name
|
182
|
+
request = for_id(REQUEST_CROSS_APP_ID)
|
183
|
+
event_listener = NewRelic::Agent.instance.events
|
184
|
+
event_listener.notify(:before_call, request)
|
185
|
+
|
182
186
|
in_transaction do
|
183
187
|
assert !NewRelic::Agent::Transaction.current.name_frozen?
|
184
|
-
|
188
|
+
event_listener.notify(:after_call, request, [200, @response, ''])
|
185
189
|
assert NewRelic::Agent::Transaction.current.name_frozen?
|
186
190
|
end
|
187
191
|
end
|