newrelic_rpm 3.16.2.321 → 3.16.3.323
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -14
- data/CHANGELOG +21 -1
- data/lib/new_relic/agent.rb +25 -10
- data/lib/new_relic/agent/agent.rb +3 -1
- data/lib/new_relic/agent/audit_logger.rb +1 -0
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -0
- data/lib/new_relic/agent/configuration/default_source.rb +8 -0
- data/lib/new_relic/agent/configuration/manager.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +5 -1
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +59 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +3 -1
- data/lib/new_relic/agent/instrumentation/http.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -0
- data/lib/new_relic/agent/sampler.rb +7 -7
- data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -0
- data/lib/new_relic/agent/supported_versions.rb +8 -1
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -0
- data/lib/new_relic/agent/transaction.rb +7 -4
- data/lib/new_relic/agent/transaction/attributes.rb +1 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +5 -10
- data/lib/new_relic/agent/transaction_state.rb +1 -0
- data/lib/new_relic/agent/worker_loop.rb +3 -2
- data/lib/new_relic/cli/commands/deployments.rb +3 -0
- data/lib/new_relic/cli/commands/install.rb +2 -1
- data/lib/new_relic/control/frameworks/rails.rb +4 -4
- data/lib/new_relic/helper.rb +0 -4
- data/lib/new_relic/metric_data.rb +1 -0
- data/lib/new_relic/noticed_error.rb +2 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/config.rake +1 -1
- data/lib/tasks/tests.rake +1 -1
- data/lib/tasks/versions.rake +2 -2
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +5 -10
- data/test/fixtures/cross_agent_tests/docker_container_id/README.md +2 -2
- data/test/fixtures/cross_agent_tests/labels.json +71 -9
- data/test/fixtures/cross_agent_tests/rules.json +1 -1
- data/test/fixtures/cross_agent_tests/synthetics/README.md +2 -2
- data/test/fixtures/cross_agent_tests/synthetics/synthetics.json +5 -5
- data/test/multiverse/lib/multiverse/runner.rb +1 -1
- data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +11 -0
- data/test/multiverse/suites/httprb/Envfile +19 -0
- data/test/multiverse/suites/httprb/config/newrelic.yml +18 -0
- data/test/multiverse/suites/httprb/httprb_test.rb +78 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +19 -0
- data/test/new_relic/agent/agent_logger_test.rb +0 -14
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +1 -0
- data/test/new_relic/agent/configuration/manager_test.rb +3 -2
- data/test/new_relic/agent/error_collector_test.rb +27 -2
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +2 -3
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -0
- data/test/new_relic/agent/method_tracer_test.rb +1 -0
- data/test/new_relic/agent/sampler_test.rb +2 -2
- data/test/new_relic/agent/synthetics_event_aggregator_test.rb +1 -0
- data/test/new_relic/agent/threading/backtrace_service_test.rb +8 -0
- data/test/new_relic/agent/transaction/trace_node_test.rb +4 -4
- data/test/new_relic/agent_test.rb +31 -0
- data/test/new_relic/cli/commands/deployments_test.rb +11 -6
- data/test/new_relic/control/class_methods_test.rb +5 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +2 -2
- data/test/performance/lib/performance/platform.rb +1 -0
- data/test/performance/suites/active_record_subscriber.rb +100 -0
- data/ui/helpers/developer_mode_helper.rb +2 -1
- data/ui/helpers/google_pie_chart.rb +1 -0
- data/ui/views/newrelic/explain_sql.rhtml +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +1 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +1 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +1 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +1 -1
- metadata +8 -3
@@ -87,7 +87,7 @@ module Multiverse
|
|
87
87
|
"api" => ["grape"],
|
88
88
|
"background" => ["delayed_job", "rake", "resque", "sidekiq"],
|
89
89
|
"database" => ["datamapper", "mongo", "redis", "sequel"],
|
90
|
-
"httpclients" => ["curb", "excon", "httpclient", "typhoeus", "net_http"],
|
90
|
+
"httpclients" => ["curb", "excon", "httpclient", "typhoeus", "net_http", "httprb"],
|
91
91
|
"rails" => ["active_record", "rails"],
|
92
92
|
"serialization" => ["json", "marshalling", "yajl"],
|
93
93
|
"sinatra" => ["sinatra", "padrino"],
|
@@ -10,6 +10,11 @@ class StartUpTest < Minitest::Test
|
|
10
10
|
JRUBY_9000_NOISE = [
|
11
11
|
/uri\:classloader\:\/jruby\/kernel\/kernel\.rb\:\d*\: warning: unsupported exec option: close_others/, # https://github.com/jruby/jruby/issues/1913
|
12
12
|
/.*\/lib\/ruby\/stdlib\/jar_dependencies.rb:\d*: warning: shadowing outer local variable - (group_id|artifact_id)/, #https://github.com/mkristian/jar-dependencies/commit/65c71261b1522f7b10fcb95de42ea4799de3a83a
|
13
|
+
/.*warning\: too many arguments for format string/ # Fixed in 9.1.3.0, see https://github.com/jruby/jruby/issues/3934
|
14
|
+
]
|
15
|
+
BUNDLER_NOISE = [
|
16
|
+
%r{.*gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:468: warning: method redefined; discarding old find_spec_for_exe},
|
17
|
+
%r{.*lib/ruby/site_ruby/2.3.0/rubygems.rb:261: warning: previous definition of find_spec_for_exe was here}
|
13
18
|
]
|
14
19
|
|
15
20
|
include MultiverseHelpers
|
@@ -73,6 +78,7 @@ class StartUpTest < Minitest::Test
|
|
73
78
|
expected_noise = [GIT_NOISE]
|
74
79
|
|
75
80
|
expected_noise << JRUBY_9000_NOISE if jruby_9000
|
81
|
+
expected_noise << BUNDLER_NOISE if bundler_rubygem_conflicts?
|
76
82
|
|
77
83
|
expected_noise.flatten.each {|noise| output.gsub!(noise, "")}
|
78
84
|
output.strip!
|
@@ -93,4 +99,9 @@ class StartUpTest < Minitest::Test
|
|
93
99
|
def jruby_9000
|
94
100
|
defined?(JRUBY_VERSION) && NewRelic::VersionNumber.new(JRUBY_VERSION) >= "9.0.0"
|
95
101
|
end
|
102
|
+
|
103
|
+
def bundler_rubygem_conflicts?
|
104
|
+
NewRelic::VersionNumber.new(Gem::VERSION) == "2.6.6" and
|
105
|
+
NewRelic::VersionNumber.new(Bundler::VERSION) == "1.12.5"
|
106
|
+
end
|
96
107
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
suite_condition("http.rb is only supported for versions >= 2.0.0") do
|
2
|
+
RUBY_VERSION >= '2.0.0'
|
3
|
+
end
|
4
|
+
|
5
|
+
httprb_versions = %w(2.0.3
|
6
|
+
2.0.2
|
7
|
+
2.0.1
|
8
|
+
2.0.0
|
9
|
+
1.0.4
|
10
|
+
0.9.9
|
11
|
+
0.8.14
|
12
|
+
0.7.4)
|
13
|
+
|
14
|
+
httprb_versions.each do |httprb_version|
|
15
|
+
gemfile <<-RB
|
16
|
+
gem 'http', '~> #{httprb_version}'
|
17
|
+
gem 'rack'
|
18
|
+
RB
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
development:
|
3
|
+
error_collector:
|
4
|
+
enabled: true
|
5
|
+
apdex_t: 0.5
|
6
|
+
ssl: false
|
7
|
+
monitor_mode: true
|
8
|
+
license_key: bootstrap_newrelic_admin_license_key_000
|
9
|
+
developer_mode: false
|
10
|
+
app_name: test
|
11
|
+
host: 127.0.0.1
|
12
|
+
api_host: 127.0.0.1
|
13
|
+
transaction_tracer:
|
14
|
+
record_sql: obfuscated
|
15
|
+
enabled: true
|
16
|
+
stack_trace_threshold: 0.5
|
17
|
+
transaction_threshold: 1.0
|
18
|
+
capture_params: false
|
@@ -0,0 +1,78 @@
|
|
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 "http"
|
6
|
+
require "newrelic_rpm"
|
7
|
+
require "http_client_test_cases"
|
8
|
+
|
9
|
+
class HTTPTest < Minitest::Test
|
10
|
+
include HttpClientTestCases
|
11
|
+
|
12
|
+
def client_name
|
13
|
+
"http.rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_unsupported_1x?
|
17
|
+
defined?(::HTTP::VERSION) && HTTP::VERSION < '1.0.0'
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_response(url=nil, headers=nil)
|
21
|
+
HTTP.get(url || default_url, :headers => headers)
|
22
|
+
end
|
23
|
+
|
24
|
+
def head_response
|
25
|
+
HTTP.head(default_url)
|
26
|
+
end
|
27
|
+
|
28
|
+
def post_response
|
29
|
+
HTTP.post(default_url, :body => "")
|
30
|
+
end
|
31
|
+
|
32
|
+
def put_response
|
33
|
+
HTTP.put(default_url, :body => "")
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_response
|
37
|
+
HTTP.delete(default_url, :body => "")
|
38
|
+
end
|
39
|
+
|
40
|
+
def body(res)
|
41
|
+
res.body.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def request_instance
|
45
|
+
options = {
|
46
|
+
verb: :get,
|
47
|
+
uri: 'http://newrelic.com'
|
48
|
+
}
|
49
|
+
|
50
|
+
httprb_req =
|
51
|
+
if is_unsupported_1x?
|
52
|
+
HTTP::Request.new(*options.values)
|
53
|
+
else
|
54
|
+
HTTP::Request.new(options)
|
55
|
+
end
|
56
|
+
|
57
|
+
::NewRelic::Agent::HTTPClients::HTTPRequest.new(httprb_req)
|
58
|
+
end
|
59
|
+
|
60
|
+
def response_instance(headers = {})
|
61
|
+
options = {
|
62
|
+
status: 200,
|
63
|
+
version: '1.1',
|
64
|
+
headers: headers,
|
65
|
+
body: ''
|
66
|
+
}
|
67
|
+
|
68
|
+
httprb_resp =
|
69
|
+
if is_unsupported_1x?
|
70
|
+
HTTP::Response.new(*options.values)
|
71
|
+
else
|
72
|
+
HTTP::Response.new(options)
|
73
|
+
end
|
74
|
+
|
75
|
+
::NewRelic::Agent::HTTPClients::HTTPResponse.new(httprb_resp)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -70,6 +70,11 @@ class ErrorController < ApplicationController
|
|
70
70
|
raise 'bad things'
|
71
71
|
end
|
72
72
|
|
73
|
+
def noticed_error_with_trace_only
|
74
|
+
NewRelic::Agent.notice_error("Raise the gates!", :trace_only => true)
|
75
|
+
render :text => 'Runner 5'
|
76
|
+
end
|
77
|
+
|
73
78
|
if Rails::VERSION::MAJOR == 2
|
74
79
|
filter_parameter_logging(:secret)
|
75
80
|
end
|
@@ -285,6 +290,20 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
|
|
285
290
|
end
|
286
291
|
end
|
287
292
|
|
293
|
+
def test_should_not_increment_metrics_on_trace_only_errors
|
294
|
+
get '/error/noticed_error_with_trace_only'
|
295
|
+
|
296
|
+
assert_equal(1, errors.size,
|
297
|
+
'Error with :trace_only should have been recorded')
|
298
|
+
|
299
|
+
assert_metrics_not_recorded([
|
300
|
+
'Errors/all',
|
301
|
+
'Errors/Controller/error/noticed_error_with_trace_only'
|
302
|
+
])
|
303
|
+
|
304
|
+
assert_metrics_recorded("Apdex" => { :apdex_s => 1 })
|
305
|
+
end
|
306
|
+
|
288
307
|
protected
|
289
308
|
|
290
309
|
def errors
|
@@ -6,20 +6,6 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
|
|
6
6
|
require 'new_relic/agent/agent_logger'
|
7
7
|
require 'new_relic/agent/null_logger'
|
8
8
|
|
9
|
-
class ArrayLogDevice
|
10
|
-
def initialize( array=[] )
|
11
|
-
@array = array
|
12
|
-
end
|
13
|
-
attr_reader :array
|
14
|
-
|
15
|
-
def write( message )
|
16
|
-
@array << message
|
17
|
-
end
|
18
|
-
|
19
|
-
def close; end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
9
|
class AgentLoggerTest < Minitest::Test
|
24
10
|
|
25
11
|
LEVELS = [:fatal, :error, :warn, :info, :debug]
|
@@ -298,8 +298,9 @@ module NewRelic::Agent::Configuration
|
|
298
298
|
|
299
299
|
assert_warning if testcase["warning"]
|
300
300
|
assert_equal(testcase["expected"].sort_by { |h| h["label_type"] },
|
301
|
-
@manager.parse_labels_from_string.sort_by { |h| h["label_type"] }
|
302
|
-
|
301
|
+
@manager.parse_labels_from_string.sort_by { |h| h["label_type"] },
|
302
|
+
"failed on #{testcase["name"]}")
|
303
|
+
end unless RUBY_VERSION < '1.9'
|
303
304
|
end
|
304
305
|
|
305
306
|
def test_parse_labels_from_dictionary_with_hard_failure
|
@@ -129,7 +129,7 @@ class NewRelic::Agent::ErrorCollectorTest < Minitest::Test
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def
|
132
|
+
def test_increment_error_count_record_summary_and_web_txn_metric
|
133
133
|
in_web_transaction('Controller/class/method') do
|
134
134
|
@error_collector.increment_error_count!(NewRelic::Agent::TransactionState.tl_get, StandardError.new('Boo'))
|
135
135
|
end
|
@@ -139,7 +139,7 @@ class NewRelic::Agent::ErrorCollectorTest < Minitest::Test
|
|
139
139
|
'Errors/Controller/class/method'])
|
140
140
|
end
|
141
141
|
|
142
|
-
def
|
142
|
+
def test_increment_error_count_record_summary_and_other_txn_metric
|
143
143
|
in_background_transaction('OtherTransaction/AnotherFramework/Job/perform') do
|
144
144
|
@error_collector.increment_error_count!(NewRelic::Agent::TransactionState.tl_get, StandardError.new('Boo'))
|
145
145
|
end
|
@@ -383,6 +383,31 @@ class NewRelic::Agent::ErrorCollectorTest < Minitest::Test
|
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
|
+
def test_trace_only_does_not_increment_metrics
|
387
|
+
@error_collector.notice_error(StandardError.new, :trace_only => true)
|
388
|
+
traces = harvest_error_traces
|
389
|
+
events = harvest_error_events
|
390
|
+
|
391
|
+
assert_equal 1, traces.length
|
392
|
+
assert_equal 1, events.length
|
393
|
+
assert_metrics_not_recorded ['Errors/all']
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_trace_only_not_recorded_as_custom_attribute
|
397
|
+
@error_collector.notice_error(StandardError.new, :trace_only => true)
|
398
|
+
traces = harvest_error_traces
|
399
|
+
events = harvest_error_events
|
400
|
+
|
401
|
+
assert_equal 1, traces.length
|
402
|
+
assert_equal 1, events.length
|
403
|
+
|
404
|
+
event_attrs = events[0][1]
|
405
|
+
refute event_attrs.key?("trace_only"), "Unexpected attribute trace_only found in custom attributes"
|
406
|
+
|
407
|
+
trace_attrs = traces[0].attributes_from_notice_error
|
408
|
+
refute trace_attrs.key?(:trace_only), "Unexpected attribute trace_only found in custom attributes"
|
409
|
+
end
|
410
|
+
|
386
411
|
private
|
387
412
|
|
388
413
|
def expects_error_count_increase(increase)
|
@@ -208,7 +208,6 @@ class NewRelic::Agent::Instrumentation::MiddlewareProxyTest < Minitest::Test
|
|
208
208
|
def test_should_emit_events_once
|
209
209
|
app = Proc.new { |env| [200, {}, ["nothing"]]}
|
210
210
|
middleware = Proc.new { |env| app.call(env) }
|
211
|
-
wrapped_app = NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true)
|
212
211
|
wrapped_middleware = NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(middleware, true)
|
213
212
|
|
214
213
|
before_call_count = 0
|
@@ -217,7 +216,7 @@ class NewRelic::Agent::Instrumentation::MiddlewareProxyTest < Minitest::Test
|
|
217
216
|
NewRelic::Agent.instance.events.subscribe(:before_call) { before_call_count += 1 }
|
218
217
|
NewRelic::Agent.instance.events.subscribe(:after_call) { after_call_count += 1 }
|
219
218
|
|
220
|
-
|
219
|
+
wrapped_middleware.call({})
|
221
220
|
assert_equal 1, before_call_count
|
222
221
|
assert_equal 1, after_call_count
|
223
222
|
end
|
@@ -235,7 +234,7 @@ class NewRelic::Agent::Instrumentation::MiddlewareProxyTest < Minitest::Test
|
|
235
234
|
assert_same original_env, env_from_before_call
|
236
235
|
end
|
237
236
|
|
238
|
-
def
|
237
|
+
def test_after_call_should_receive_rack_env_hash
|
239
238
|
app = Proc.new { |env| [200, {}, ["nothing"]] }
|
240
239
|
wrapped_app = NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true)
|
241
240
|
|
@@ -79,6 +79,7 @@ class NewRelic::Agent::MethodTracerTest < Minitest::Test
|
|
79
79
|
@scope_listener = NewRelic::Agent::MockScopeListener.new
|
80
80
|
@old_sampler = NewRelic::Agent.instance.transaction_sampler
|
81
81
|
NewRelic::Agent.instance.stubs(:transaction_sampler).returns(@scope_listener)
|
82
|
+
@metric_name ||= nil
|
82
83
|
|
83
84
|
freeze_time
|
84
85
|
|
@@ -18,8 +18,8 @@ class NewRelic::Agent::SamplerTest < Minitest::Test
|
|
18
18
|
|
19
19
|
def test_inherited_should_append_subclasses_to_sampler_classes
|
20
20
|
test_class = Class.new(NewRelic::Agent::Sampler)
|
21
|
-
sampler_classes = NewRelic::Agent::Sampler.
|
22
|
-
assert(sampler_classes.include?(test_class), "Sampler classes (#{
|
21
|
+
sampler_classes = NewRelic::Agent::Sampler.instance_variable_get :@sampler_classes
|
22
|
+
assert(sampler_classes.include?(test_class), "Sampler classes (#{sampler_classes.inspect}) does not include #{test_class.inspect}")
|
23
23
|
# cleanup the sampler created above
|
24
24
|
NewRelic::Agent::Sampler.instance_eval { @sampler_classes.delete(test_class) }
|
25
25
|
end
|
@@ -487,6 +487,14 @@ if NewRelic::Agent::Threading::BacktraceService.is_supported?
|
|
487
487
|
end
|
488
488
|
|
489
489
|
def fake_last_poll_took(last_poll_length)
|
490
|
+
# avoid method redefinition warnings
|
491
|
+
class << @service
|
492
|
+
begin
|
493
|
+
remove_method :adjust_polling_time
|
494
|
+
rescue NameError
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
490
498
|
# We need to adjust Time.now during the midst of poll
|
491
499
|
# Slip in before the adjust_polling_time call to advance the clock
|
492
500
|
@service.define_singleton_method(:adjust_polling_time) do |end_time, *args|
|
@@ -232,7 +232,7 @@ class NewRelic::Agent::Transaction::TraceNodeTest < Minitest::Test
|
|
232
232
|
s = NewRelic::Agent::Transaction::TraceNode.new(Time.now, 'Custom/test/metric')
|
233
233
|
|
234
234
|
# should have a default value
|
235
|
-
assert_equal(
|
235
|
+
assert_equal({}, s.instance_variable_get(:@params))
|
236
236
|
assert_equal({}, s.params)
|
237
237
|
|
238
238
|
# should otherwise take the value from the @params var
|
@@ -329,12 +329,12 @@ class NewRelic::Agent::Transaction::TraceNodeTest < Minitest::Test
|
|
329
329
|
|
330
330
|
def test_params_equal
|
331
331
|
s = NewRelic::Agent::Transaction::TraceNode.new(Time.now, 'Custom/test/metric')
|
332
|
-
assert_equal(
|
332
|
+
assert_equal({}, s.instance_variable_get(:@params))
|
333
333
|
|
334
334
|
params = {:foo => 'correct'}
|
335
335
|
|
336
336
|
s.params = params
|
337
|
-
assert_equal(params, s.
|
337
|
+
assert_equal(params, s.instance_variable_get(:@params))
|
338
338
|
end
|
339
339
|
|
340
340
|
def test_obfuscated_sql
|
@@ -353,7 +353,7 @@ class NewRelic::Agent::Transaction::TraceNodeTest < Minitest::Test
|
|
353
353
|
|
354
354
|
def test_parent_node_equals
|
355
355
|
s = NewRelic::Agent::Transaction::TraceNode.new(Time.now, 'Custom/test/metric')
|
356
|
-
assert_equal(nil, s.
|
356
|
+
assert_equal(nil, s.parent_node)
|
357
357
|
fake_node = mock('node')
|
358
358
|
s.send(:parent_node=, fake_node)
|
359
359
|
assert_equal(fake_node, s.parent_node)
|
@@ -434,6 +434,37 @@ module NewRelic
|
|
434
434
|
NewRelic::Agent.set_user_attributes(:is => "bunk")
|
435
435
|
end
|
436
436
|
|
437
|
+
def test_modules_and_classes_return_name_properly
|
438
|
+
valid = [Module, Class]
|
439
|
+
stack = [NewRelic]
|
440
|
+
|
441
|
+
loop do
|
442
|
+
a = stack.pop
|
443
|
+
|
444
|
+
if a.respond_to? :name
|
445
|
+
b = if RUBY_VERSION < '2.0.0'
|
446
|
+
a.name.split('::').reduce(nil) { |c,n| (c || Kernel).const_get n }
|
447
|
+
else
|
448
|
+
Kernel.const_get a.name
|
449
|
+
end
|
450
|
+
assert_equal a, b
|
451
|
+
end
|
452
|
+
|
453
|
+
if a.respond_to? :constants
|
454
|
+
stack.concat a.constants.map { |c| a.const_get c }.select do |c|
|
455
|
+
if valid.include?(c.class) && !c.ancestors.include?(Minitest::Test)
|
456
|
+
assert_instance_of String, c.name
|
457
|
+
c.name.start_with?(a.name)
|
458
|
+
else
|
459
|
+
false
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
break if stack.empty?
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
437
468
|
private
|
438
469
|
|
439
470
|
def with_unstarted_agent
|