newrelic_rpm 3.7.0.174.beta → 3.7.0.177
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -4
- data/bin/nrdebug +10 -4
- data/lib/new_relic/agent.rb +33 -11
- data/lib/new_relic/agent/agent.rb +83 -120
- data/lib/new_relic/agent/agent_logger.rb +28 -16
- data/lib/new_relic/agent/audit_logger.rb +3 -4
- data/lib/new_relic/agent/autostart.rb +20 -8
- data/lib/new_relic/agent/commands/agent_command_router.rb +26 -17
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -2
- data/lib/new_relic/agent/configuration/default_source.rb +146 -59
- data/lib/new_relic/agent/configuration/manager.rb +3 -3
- data/lib/new_relic/agent/cross_app_monitor.rb +15 -40
- data/lib/new_relic/agent/cross_app_tracing.rb +20 -12
- data/lib/new_relic/agent/database.rb +24 -0
- data/lib/new_relic/agent/error_collector.rb +6 -2
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +187 -0
- data/lib/new_relic/agent/new_relic_service.rb +30 -22
- data/lib/new_relic/agent/obfuscator.rb +48 -0
- data/lib/new_relic/agent/request_sampler.rb +5 -13
- data/lib/new_relic/agent/shim_agent.rb +1 -0
- data/lib/new_relic/agent/sql_sampler.rb +15 -5
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +9 -4
- data/lib/new_relic/agent/transaction.rb +0 -1
- data/lib/new_relic/agent/transaction_sampler.rb +28 -16
- data/lib/new_relic/agent/transaction_state.rb +9 -0
- data/lib/new_relic/agent/transaction_timings.rb +5 -1
- data/lib/new_relic/agent/worker_loop.rb +0 -10
- data/lib/new_relic/cli/deployments.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/lib/new_relic/helper.rb +3 -1
- data/lib/new_relic/rack/browser_monitoring.rb +1 -2
- data/lib/new_relic/transaction_sample.rb +11 -13
- data/lib/newrelic_rpm.rb +1 -0
- data/test/agent_helper.rb +20 -5
- data/test/environments/lib/environments/runner.rb +1 -0
- data/test/helpers/file_searching.rb +28 -0
- data/test/multiverse/lib/multiverse/suite.rb +36 -19
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +49 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +2 -2
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +4 -2
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +7 -4
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +2 -1
- data/test/multiverse/suites/rails/error_tracing_test.rb +34 -4
- data/test/multiverse/suites/rails/ignore_test.rb +1 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +1 -3
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sinatra/ignoring_test.rb +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
- data/test/new_relic/agent/agent_logger_test.rb +108 -114
- data/test/new_relic/agent/agent_test.rb +139 -21
- data/test/new_relic/agent/audit_logger_test.rb +22 -20
- data/test/new_relic/agent/autostart_test.rb +3 -2
- data/test/new_relic/agent/commands/agent_command_router_test.rb +51 -32
- data/test/new_relic/agent/configuration/default_source_test.rb +8 -2
- data/test/new_relic/agent/configuration/manager_test.rb +5 -1
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +57 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +10 -26
- data/test/new_relic/agent/database_test.rb +32 -0
- data/test/new_relic/agent/error_collector_test.rb +33 -16
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +88 -71
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/javascript_instrumentor_test.rb +341 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +91 -89
- data/test/new_relic/agent/method_tracer_test.rb +1 -1
- data/test/new_relic/agent/obfuscator_test.rb +77 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +5 -5
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +21 -11
- data/test/new_relic/agent/sql_sampler_test.rb +52 -8
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +6 -6
- data/test/new_relic/agent/stats_engine_test.rb +18 -2
- data/test/new_relic/agent/transaction_sampler_test.rb +98 -53
- data/test/new_relic/agent/transaction_state_test.rb +44 -0
- data/test/new_relic/agent/transaction_test.rb +1 -1
- data/test/new_relic/agent/transaction_timings_test.rb +15 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -9
- data/test/new_relic/agent_test.rb +9 -21
- data/test/new_relic/data_container_tests.rb +72 -0
- data/test/new_relic/fake_collector.rb +69 -20
- data/test/new_relic/http_client_test_cases.rb +17 -2
- data/test/new_relic/license_test.rb +6 -15
- data/test/new_relic/multiverse_helpers.rb +2 -3
- data/test/new_relic/rack/browser_monitoring_test.rb +15 -37
- data/test/new_relic/transaction_sample_test.rb +92 -62
- data/test/performance/suites/rum_autoinsertion.rb +0 -3
- data/test/rum/x_ua_meta_tag_spaces_around_equals.result.html +10 -0
- data/test/rum/x_ua_meta_tag_spaces_around_equals.source.html +10 -0
- data/test/test_helper.rb +9 -5
- metadata +29 -11
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/beacon_configuration.rb +0 -37
- data/lib/new_relic/agent/browser_monitoring.rb +0 -257
- data/test/new_relic/agent/beacon_configuration_test.rb +0 -44
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -474
@@ -47,7 +47,7 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def setup_logging(env)
|
50
|
-
NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new
|
50
|
+
NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new
|
51
51
|
NewRelic::Agent.logger.info("Running Capistrano from '#{env}' environment for application '#{@appname}'")
|
52
52
|
end
|
53
53
|
|
@@ -59,7 +59,7 @@ module NewRelic
|
|
59
59
|
|
60
60
|
# Be sure to only create once! RUBY-1020
|
61
61
|
if ::NewRelic::Agent.logger.is_startup_logger?
|
62
|
-
::NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new(
|
62
|
+
::NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new(root, options.delete(:log))
|
63
63
|
end
|
64
64
|
|
65
65
|
# Merge the stringified options into the config as overrides:
|
data/lib/new_relic/helper.rb
CHANGED
@@ -13,7 +13,9 @@ module NewRelic
|
|
13
13
|
if RUBY_VERSION >= '1.9'
|
14
14
|
def correctly_encoded(string)
|
15
15
|
return string unless string.is_a? String
|
16
|
-
|
16
|
+
# The .dup here is intentional, since force_encoding mutates the target,
|
17
|
+
# and we don't know who is going to use this string downstream of us.
|
18
|
+
string.valid_encoding? ? string : string.dup.force_encoding("ASCII-8BIT")
|
17
19
|
end
|
18
20
|
else
|
19
21
|
#noop
|
@@ -46,7 +46,7 @@ module NewRelic::Rack
|
|
46
46
|
!headers['Content-Disposition'].to_s.include?('attachment')
|
47
47
|
end
|
48
48
|
|
49
|
-
X_UA_COMPATIBLE_RE = /<\s*meta[^>]+http-equiv
|
49
|
+
X_UA_COMPATIBLE_RE = /<\s*meta[^>]+http-equiv\s*=\s*['"]x-ua-compatible['"][^>]*>/im.freeze
|
50
50
|
|
51
51
|
def autoinstrument_source(response, headers)
|
52
52
|
source = gather_source(response)
|
@@ -63,7 +63,6 @@ module NewRelic::Rack
|
|
63
63
|
|
64
64
|
if insertion_index
|
65
65
|
source = source[0...insertion_index] <<
|
66
|
-
NewRelic::Agent.browser_timing_footer << # sic, footer is now considered "config". Rename soon?
|
67
66
|
NewRelic::Agent.browser_timing_header <<
|
68
67
|
source[insertion_index..-1]
|
69
68
|
else
|
@@ -183,18 +183,13 @@ module NewRelic
|
|
183
183
|
end
|
184
184
|
|
185
185
|
# Return a new transaction sample that can be sent to the New
|
186
|
-
# Relic service.
|
187
|
-
|
188
|
-
#
|
189
|
-
# :explain_sql : run EXPLAIN on all queries whose response times equal the value for this key
|
190
|
-
# (for example :explain_sql => 2.0 would explain everything over 2 seconds. 0.0 would explain everything.)
|
191
|
-
# :record_sql => [ :raw | :obfuscated] : copy over the sql, obfuscating if necessary
|
192
|
-
def prepare_to_send!(options={})
|
186
|
+
# Relic service.
|
187
|
+
def prepare_to_send!
|
193
188
|
return self if @prepared
|
194
189
|
|
195
|
-
if
|
196
|
-
collect_explain_plans!
|
197
|
-
prepare_sql_for_transmission!
|
190
|
+
if Agent::Database.should_record_sql?
|
191
|
+
collect_explain_plans!
|
192
|
+
prepare_sql_for_transmission!
|
198
193
|
else
|
199
194
|
strip_sql!
|
200
195
|
end
|
@@ -260,7 +255,9 @@ module NewRelic
|
|
260
255
|
end
|
261
256
|
end
|
262
257
|
|
263
|
-
def collect_explain_plans!
|
258
|
+
def collect_explain_plans!
|
259
|
+
return unless Agent::Database.should_collect_explain_plans?
|
260
|
+
threshold = Agent.config[:'transaction_tracer.explain_threshold']
|
264
261
|
each_segment do |segment|
|
265
262
|
if segment[:sql] && segment.duration > threshold
|
266
263
|
segment[:explain_plan] = segment.explain_sql
|
@@ -268,14 +265,15 @@ module NewRelic
|
|
268
265
|
end
|
269
266
|
end
|
270
267
|
|
271
|
-
def prepare_sql_for_transmission!
|
268
|
+
def prepare_sql_for_transmission!
|
269
|
+
strategy = Agent::Database.record_sql_method
|
272
270
|
each_segment do |segment|
|
273
271
|
if segment[:sql]
|
274
272
|
segment[:sql] = case strategy
|
275
273
|
when :raw
|
276
274
|
segment[:sql].to_s
|
277
275
|
when :obfuscated
|
278
|
-
|
276
|
+
Agent::Database.obfuscate_sql(segment[:sql]).to_s
|
279
277
|
end
|
280
278
|
end
|
281
279
|
end
|
data/lib/newrelic_rpm.rb
CHANGED
data/test/agent_helper.rb
CHANGED
@@ -97,6 +97,12 @@ unless defined?( assert_not_includes )
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
unless defined?( assert_empty )
|
101
|
+
def assert_empty(collection, msg=nil)
|
102
|
+
assert collection.empty?, msg
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
100
106
|
def assert_equal_unordered(left, right)
|
101
107
|
assert_equal(left.length, right.length, "Lengths don't match. #{left.length} != #{right.length}")
|
102
108
|
left.each { |element| assert_includes(right, element) }
|
@@ -241,10 +247,16 @@ def in_web_transaction(name='dummy')
|
|
241
247
|
end
|
242
248
|
end
|
243
249
|
|
244
|
-
def find_last_transaction_segment
|
245
|
-
|
250
|
+
def find_last_transaction_segment(transaction_sample=nil)
|
251
|
+
if transaction_sample
|
252
|
+
root_segment = transaction_sample.root_segment
|
253
|
+
else
|
254
|
+
builder = NewRelic::Agent.agent.transaction_sampler.builder
|
255
|
+
root_segment = builder.current_segment
|
256
|
+
end
|
257
|
+
|
246
258
|
last_segment = nil
|
247
|
-
|
259
|
+
root_segment.each_segment {|s| last_segment = s }
|
248
260
|
|
249
261
|
return last_segment
|
250
262
|
end
|
@@ -314,8 +326,11 @@ def with_debug_logging
|
|
314
326
|
orig_logger = NewRelic::Agent.logger
|
315
327
|
$stderr.puts '', '---', ''
|
316
328
|
NewRelic::Agent.logger =
|
317
|
-
NewRelic::Agent::AgentLogger.new(
|
318
|
-
|
329
|
+
NewRelic::Agent::AgentLogger.new('', Logger.new($stderr) )
|
330
|
+
|
331
|
+
with_config(:log_level => 'debug') do
|
332
|
+
yield
|
333
|
+
end
|
319
334
|
ensure
|
320
335
|
NewRelic::Agent.logger = orig_logger
|
321
336
|
end
|
@@ -18,6 +18,7 @@ module Environments
|
|
18
18
|
"1.9.2" => ["rails21", "rails22", "rails40"],
|
19
19
|
"1.9.3" => ["rails21", "rails22"],
|
20
20
|
"2.0.0" => ["rails21", "rails22", "rails23"],
|
21
|
+
"2.1.0" => ["rails21", "rails22", "rails23"],
|
21
22
|
"jruby-1.6" => ["rails40"],
|
22
23
|
"jruby-1.7" => ["rails21", "rails22", "rails23"],
|
23
24
|
"rbx-2.0" => ["rails21", "rails22", "rails23", "rails30", "rails31", "rails32"],
|
@@ -0,0 +1,28 @@
|
|
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
|
+
module NewRelic
|
6
|
+
module TestHelpers
|
7
|
+
module FileSearching
|
8
|
+
def all_rb_files
|
9
|
+
pattern = File.expand_path(gem_root + "/**/*.rb")
|
10
|
+
Dir[pattern]
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_rb_and_js_files
|
14
|
+
pattern = File.expand_path(gem_root + "/**/*.{rb,js}")
|
15
|
+
Dir[pattern]
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_files
|
19
|
+
pattern = File.expand_path(gem_root + "/**/*")
|
20
|
+
Dir[pattern]
|
21
|
+
end
|
22
|
+
|
23
|
+
def gem_root
|
24
|
+
File.expand_path(File.dirname(__FILE__) + "/../../")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -143,6 +143,10 @@ module Multiverse
|
|
143
143
|
trigger_test_run
|
144
144
|
end
|
145
145
|
|
146
|
+
def should_serialize?
|
147
|
+
ENV['SERIALIZE']
|
148
|
+
end
|
149
|
+
|
146
150
|
# Load the test suite's environment and execute it.
|
147
151
|
#
|
148
152
|
# Normally we fork to do this, and wait for the child to exit, to avoid
|
@@ -154,16 +158,31 @@ module Multiverse
|
|
154
158
|
puts yellow("SKIPPED #{directory.inspect}: #{environments.skip_message}")
|
155
159
|
return
|
156
160
|
end
|
157
|
-
|
161
|
+
|
162
|
+
label = should_serialize? ? 'serial' : 'parallel'
|
163
|
+
puts yellow("\nRunning #{directory.inspect} in #{environments.size} environments in #{label}")
|
164
|
+
|
158
165
|
environments.before.call if environments.before
|
166
|
+
if should_serialize?
|
167
|
+
execute_serial
|
168
|
+
else
|
169
|
+
execute_parallel
|
170
|
+
end
|
171
|
+
environments.after.call if environments.after
|
172
|
+
end
|
159
173
|
|
174
|
+
def execute_serial
|
175
|
+
environments.each_with_index do |gemfile_text, i|
|
176
|
+
execute_with_pipe(i)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def execute_parallel
|
160
181
|
threads = []
|
161
182
|
environments.each_with_index do |gemfile_text, i|
|
162
|
-
threads << execute_with_pipe(i)
|
183
|
+
threads << Thread.new { execute_with_pipe(i) }
|
163
184
|
end
|
164
185
|
threads.each {|t| t.join}
|
165
|
-
|
166
|
-
environments.after.call if environments.after
|
167
186
|
end
|
168
187
|
|
169
188
|
def with_clean_env
|
@@ -177,24 +196,22 @@ module Multiverse
|
|
177
196
|
end
|
178
197
|
|
179
198
|
def execute_with_pipe(env)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
OutputCollector.write(suite, env, chars)
|
189
|
-
end
|
190
|
-
OutputCollector.suite_report(suite, env)
|
199
|
+
with_clean_env do
|
200
|
+
suite = File.basename(directory)
|
201
|
+
IO.popen("#{__FILE__} #{directory} #{env} '#{seed}' '#{names.join(",")}'") do |io|
|
202
|
+
OutputCollector.write(suite, env, yellow("Running #{suite.inspect} for Envfile entry #{env}\n"))
|
203
|
+
OutputCollector.write(suite, env, yellow("Starting tests in child PID #{io.pid}\n"))
|
204
|
+
until io.eof do
|
205
|
+
chars = io.read
|
206
|
+
OutputCollector.write(suite, env, chars)
|
191
207
|
end
|
208
|
+
OutputCollector.suite_report(suite, env)
|
209
|
+
end
|
192
210
|
|
193
|
-
|
194
|
-
|
195
|
-
end
|
196
|
-
Multiverse::Runner.notice_exit_status $?
|
211
|
+
if $? != 0
|
212
|
+
OutputCollector.failed(suite, env)
|
197
213
|
end
|
214
|
+
Multiverse::Runner.notice_exit_status $?
|
198
215
|
end
|
199
216
|
end
|
200
217
|
|
@@ -0,0 +1,49 @@
|
|
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
|
+
# RUBY-839 make sure there is no STDOUT chatter
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
class CollectorExceptionHandlingTest < MiniTest::Unit::TestCase
|
9
|
+
include MultiverseHelpers
|
10
|
+
|
11
|
+
setup_and_teardown_agent
|
12
|
+
|
13
|
+
def test_should_reconnect_on_force_restart_exception
|
14
|
+
$collector.reset
|
15
|
+
|
16
|
+
payload = { 'error_type' => 'NewRelic::Agent::ForceRestartException' }
|
17
|
+
$collector.stub_exception('metric_data', payload).once
|
18
|
+
|
19
|
+
with_config(:data_report_period => 0) do
|
20
|
+
worker_loop = NewRelic::Agent::WorkerLoop.new(:limit => 1)
|
21
|
+
NewRelic::Agent.agent.stubs(:create_worker_loop).returns(worker_loop)
|
22
|
+
# there's a call to sleep in handle_force_restart that we want to skip
|
23
|
+
NewRelic::Agent.agent.stubs(:sleep)
|
24
|
+
NewRelic::Agent.agent.deferred_work!({})
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_equal(2, $collector.calls_for('connect').size)
|
28
|
+
|
29
|
+
# We expect one metric_data post that the collector responds to with the
|
30
|
+
# ForceRestartException, and then another that gets through successfully.
|
31
|
+
metric_data_calls = $collector.calls_for('metric_data')
|
32
|
+
assert_equal(2, metric_data_calls.size)
|
33
|
+
refute_equal(metric_data_calls[0].run_id, metric_data_calls[1].run_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_stop_reporting_after_force_disconnect
|
37
|
+
$collector.reset
|
38
|
+
|
39
|
+
payload = { 'error_type' => 'NewRelic::Agent::ForceDisconnectException' }
|
40
|
+
$collector.stub_exception('metric_data', payload).once
|
41
|
+
|
42
|
+
with_config(:data_report_period => 0) do
|
43
|
+
NewRelic::Agent.agent.deferred_work!({})
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_equal(1, $collector.calls_for('connect').size)
|
47
|
+
assert_equal(1, $collector.calls_for('metric_data').size)
|
48
|
+
end
|
49
|
+
end
|
@@ -12,7 +12,7 @@ class HttpResponseCodeTest < MiniTest::Unit::TestCase
|
|
12
12
|
setup_and_teardown_agent
|
13
13
|
|
14
14
|
def test_request_entity_too_large
|
15
|
-
$collector.
|
15
|
+
$collector.stub_exception('metric_data', {'error_type' => 'RuntimeError', 'message' => 'too much'}, 413)
|
16
16
|
|
17
17
|
NewRelic::Agent.increment_metric('Custom/too_big')
|
18
18
|
assert_metrics_recorded(['Custom/too_big'])
|
@@ -25,7 +25,7 @@ class HttpResponseCodeTest < MiniTest::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_unsupported_media_type
|
28
|
-
$collector.
|
28
|
+
$collector.stub_exception('metric_data', {'error_type' => 'RuntimeError', 'message' => 'looks bad'}, 415)
|
29
29
|
|
30
30
|
NewRelic::Agent.increment_metric('Custom/too_big')
|
31
31
|
assert_metrics_recorded(['Custom/too_big'])
|
@@ -19,8 +19,10 @@ class RumAutoTest < MiniTest::Unit::TestCase
|
|
19
19
|
LOADER_REGEX = "\n<script.*>JS_AGENT_LOADER</script>"
|
20
20
|
CONFIG_REGEX = "\n<script.*>.*NREUM.info=.*</script>"
|
21
21
|
|
22
|
-
setup_and_teardown_agent(:
|
23
|
-
|
22
|
+
setup_and_teardown_agent(:application_id => 'appId',
|
23
|
+
:beacon => 'beacon',
|
24
|
+
:browser_key => 'browserKey',
|
25
|
+
:js_agent_loader => JS_AGENT_LOADER)
|
24
26
|
|
25
27
|
def after_setup
|
26
28
|
@inner_app = TestingApp.new
|
@@ -25,7 +25,7 @@ class ServiceTimeoutTest < MiniTest::Unit::TestCase
|
|
25
25
|
|
26
26
|
service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
|
27
27
|
|
28
|
-
assert_raises
|
28
|
+
assert_raises NewRelic::Agent::ServerConnectionException do
|
29
29
|
service.send('send_request',
|
30
30
|
:uri => '/agent_listener/8/bd0e1d52adade840f7ca727d29a86249e89a6f1c/get_redirect_host',
|
31
31
|
:encoding => 'UTF-8', :collector => server, :data => 'blah')
|
@@ -9,8 +9,10 @@ class SetTransactionNameTest < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
include MultiverseHelpers
|
11
11
|
|
12
|
-
setup_and_teardown_agent(:
|
13
|
-
:beacon => 'beacon',
|
12
|
+
setup_and_teardown_agent(:application_id => 'appId',
|
13
|
+
:beacon => 'beacon',
|
14
|
+
:browser_key => 'browserKey',
|
15
|
+
:js_agent_loader => 'loader')
|
14
16
|
|
15
17
|
class TestTransactor
|
16
18
|
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
@@ -75,8 +77,9 @@ class SetTransactionNameTest < MiniTest::Unit::TestCase
|
|
75
77
|
|
76
78
|
def test_does_not_overwrite_name_when_set_by_RUM
|
77
79
|
TestTransactor.new.parent_txn do
|
78
|
-
|
79
|
-
NewRelic::Agent.
|
80
|
+
# Transaction name is only frozen if RUM is actually injected
|
81
|
+
refute_empty NewRelic::Agent.browser_timing_header
|
82
|
+
|
80
83
|
NewRelic::Agent.set_transaction_name('this/should/not/work')
|
81
84
|
end
|
82
85
|
assert_metrics_not_recorded(['Controller/this/should/not/work'])
|
@@ -113,6 +113,7 @@ class ThreadProfilingTest < MiniTest::Unit::TestCase
|
|
113
113
|
def issue_command(cmd)
|
114
114
|
$collector.stub('get_agent_commands', cmd)
|
115
115
|
agent.send(:check_for_and_handle_agent_commands)
|
116
|
+
$collector.stub('get_agent_commands', [])
|
116
117
|
end
|
117
118
|
|
118
119
|
# Runs a thread we expect to span entire test and be killed at the end
|
@@ -129,7 +130,7 @@ class ThreadProfilingTest < MiniTest::Unit::TestCase
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def harvest
|
132
|
-
agent.
|
133
|
+
agent.shutdown
|
133
134
|
end
|
134
135
|
|
135
136
|
def assert_saw_traces(profile_data, type)
|
@@ -58,6 +58,11 @@ class ErrorController < ApplicationController
|
|
58
58
|
def middleware_error
|
59
59
|
render :text => 'everything went great'
|
60
60
|
end
|
61
|
+
|
62
|
+
def error_with_custom_params
|
63
|
+
NewRelic::Agent.add_custom_parameters(:texture => 'chunky')
|
64
|
+
raise 'bad things'
|
65
|
+
end
|
61
66
|
end
|
62
67
|
|
63
68
|
class IgnoredError < StandardError; end
|
@@ -75,7 +80,7 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
75
80
|
|
76
81
|
# Let base class override this without moving where we start the agent
|
77
82
|
def setup_collector_mocks
|
78
|
-
$collector.
|
83
|
+
$collector.stub('connect', {"agent_run_id" => 666 }, 200)
|
79
84
|
end
|
80
85
|
|
81
86
|
def last_error
|
@@ -202,8 +207,33 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
202
207
|
assert_error_reported_once('middleware error', nil, nil)
|
203
208
|
end
|
204
209
|
|
210
|
+
# These really shouldn't be skipped for Rails 4, see RUBY-1242
|
211
|
+
if ::Rails::VERSION::MAJOR.to_i < 4
|
212
|
+
def test_captured_errors_should_include_custom_params
|
213
|
+
get '/error/error_with_custom_params'
|
214
|
+
assert_error_reported_once('bad things')
|
215
|
+
error = errors_with_message('bad things').first
|
216
|
+
custom_params = error.params[:custom_params]
|
217
|
+
assert_equal({:texture => 'chunky'}, custom_params)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_captured_errors_should_not_include_custom_params_if_config_says_no
|
221
|
+
with_config(:'capture_attributes.traces' => false) do
|
222
|
+
get '/error/error_with_custom_params'
|
223
|
+
end
|
224
|
+
assert_error_reported_once('bad things')
|
225
|
+
error = errors_with_message('bad things').first
|
226
|
+
custom_params = error.params[:custom_params]
|
227
|
+
assert_equal({}, custom_params)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
205
231
|
protected
|
206
232
|
|
233
|
+
def errors_with_message(message)
|
234
|
+
@error_collector.errors.select{|error| error.message == message}
|
235
|
+
end
|
236
|
+
|
207
237
|
def assert_errors_reported(message, queued_count, total_count=queued_count, txn_name=nil, apdex_f=1)
|
208
238
|
expected = { :call_count => total_count }
|
209
239
|
assert_metrics_recorded("Errors/all" => expected)
|
@@ -214,7 +244,7 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
214
244
|
end
|
215
245
|
|
216
246
|
assert_equal(queued_count,
|
217
|
-
|
247
|
+
errors_with_message(message).size,
|
218
248
|
"Wrong number of errors with message #{message.inspect} found")
|
219
249
|
end
|
220
250
|
|
@@ -225,14 +255,14 @@ end
|
|
225
255
|
|
226
256
|
class ErrorsWithSSCTest < ErrorsWithoutSSCTest
|
227
257
|
def setup_collector_mocks
|
228
|
-
$collector.
|
258
|
+
$collector.stub('connect', {
|
229
259
|
"listen_to_server_config" => true,
|
230
260
|
"agent_run_id" => 1,
|
231
261
|
"error_collector.ignore_errors" => 'IgnoredError,ServerIgnoredError',
|
232
262
|
"error_collector.enabled" => true,
|
233
263
|
"error_collector.capture_source" => true,
|
234
264
|
"collect_errors" => true
|
235
|
-
}
|
265
|
+
}, 200)
|
236
266
|
end
|
237
267
|
|
238
268
|
def test_should_notice_server_ignored_error_if_no_server_side_config
|