newrelic_rpm 3.17.2.327 → 3.18.0.329
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +32 -10
- data/CHANGELOG.md +43 -3
- data/Rakefile +0 -21
- data/lib/new_relic/agent/cross_app_tracing.rb +34 -269
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +10 -2
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +18 -9
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +12 -6
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +13 -6
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +13 -6
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +14 -3
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +10 -15
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +4 -7
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -19
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +0 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +9 -7
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +15 -5
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +17 -12
- data/lib/new_relic/agent/instrumentation/http.rb +12 -5
- data/lib/new_relic/agent/instrumentation/httpclient.rb +13 -4
- data/lib/new_relic/agent/instrumentation/net.rb +13 -2
- data/lib/new_relic/agent/instrumentation/rails5/action_controller.rb +2 -10
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +8 -3
- data/lib/new_relic/agent/method_tracer_helpers.rb +3 -1
- data/lib/new_relic/agent/parameter_filtering.rb +1 -1
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -18
- data/lib/new_relic/agent/supported_versions.rb +1 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +7 -9
- data/lib/new_relic/agent/transaction/external_request_segment.rb +139 -0
- data/lib/new_relic/agent/transaction/segment.rb +1 -1
- data/lib/new_relic/agent/transaction/tracing.rb +10 -1
- data/lib/new_relic/recipes/capistrano3.rb +3 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/multiverse.rb +27 -7
- data/test/environments/rails42/Gemfile +1 -0
- data/test/multiverse/lib/multiverse.rb +32 -0
- data/test/multiverse/lib/multiverse/runner.rb +2 -2
- data/test/multiverse/lib/multiverse/suite.rb +43 -22
- data/test/multiverse/suites/active_record/Envfile +3 -1
- data/test/multiverse/suites/activemerchant/Envfile +5 -1
- data/test/multiverse/suites/agent_only/Envfile +1 -0
- data/test/multiverse/suites/capistrano/deployment_test.rb +6 -9
- data/test/multiverse/suites/capistrano2/deployment_test.rb +6 -6
- data/test/multiverse/suites/curb/curb_test.rb +2 -3
- data/test/multiverse/suites/datamapper/Envfile +4 -0
- data/test/multiverse/suites/datamapper/datamapper_test.rb +106 -36
- data/test/multiverse/suites/delayed_job/Envfile +3 -3
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/grape/grape_test.rb +1 -1
- data/test/multiverse/suites/grape/grape_test_api.rb +1 -1
- data/test/multiverse/suites/grape/grape_versioning_test.rb +1 -1
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +1 -1
- data/test/multiverse/suites/grape/unsupported_version_test.rb +1 -1
- data/test/multiverse/suites/httpclient/Envfile +2 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +1 -1
- data/test/multiverse/suites/httprb/Envfile +2 -0
- data/test/multiverse/suites/httprb/httprb_test.rb +1 -1
- data/test/multiverse/suites/json/Envfile +7 -2
- data/test/multiverse/suites/memcached/Envfile +2 -0
- data/test/multiverse/suites/mongo/Envfile +2 -0
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +95 -33
- data/test/multiverse/suites/mongo/mongo2_instrumentation_test.rb +62 -23
- data/test/multiverse/suites/net_http/Envfile +2 -0
- data/test/multiverse/suites/net_http/net_http_test.rb +7 -3
- data/test/multiverse/suites/padrino/Envfile +2 -0
- data/test/multiverse/suites/rack/Envfile +2 -0
- data/test/multiverse/suites/rack/url_map_test.rb +4 -0
- data/test/multiverse/suites/rails/Envfile +34 -29
- data/test/multiverse/suites/rake/Envfile +11 -6
- data/test/multiverse/suites/redis/Envfile +2 -0
- data/test/multiverse/suites/redis/redis_instrumentation_test.rb +31 -12
- data/test/multiverse/suites/sidekiq/Envfile +6 -2
- data/test/multiverse/suites/sinatra/Envfile +2 -0
- data/test/multiverse/suites/typhoeus/Envfile +31 -27
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +4 -3
- data/test/multiverse/suites/yajl/Envfile +4 -2
- data/test/new_relic/agent/datastores_test.rb +0 -10
- data/test/new_relic/agent/instrumentation/action_cable_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +64 -65
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +11 -9
- data/test/new_relic/agent/instrumentation/instance_identification_test.rb +9 -8
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +7 -11
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +0 -9
- data/test/new_relic/agent/method_tracer_test.rb +24 -8
- data/test/new_relic/agent/parameter_filtering_test.rb +2 -2
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +1 -0
- data/test/new_relic/agent/transaction/abstract_segment_test.rb +25 -16
- data/test/new_relic/agent/transaction/datastore_segment_test.rb +55 -38
- data/test/new_relic/agent/transaction/external_request_segment_test.rb +330 -0
- data/test/new_relic/agent/transaction/segment_test.rb +28 -4
- data/test/new_relic/agent/transaction/tracing_test.rb +60 -22
- data/test/new_relic/agent_test.rb +2 -1
- data/test/new_relic/collection_helper_test.rb +1 -0
- data/test/new_relic/dispatcher_test.rb +1 -0
- data/test/new_relic/fake_external_server.rb +1 -1
- data/test/new_relic/filtering_test_app.rb +1 -1
- data/test/new_relic/http_client_test_cases.rb +38 -20
- data/test/new_relic/rack/error_collector_test.rb +1 -0
- data/test/performance/suites/external_segment.rb +82 -0
- data/test/script/before_install/update_bundler.sh +12 -0
- data/test/script/external_server.rb +31 -0
- metadata +8 -5
- data/test/multiverse/lib/multiverse/environment.rb +0 -19
- data/test/new_relic/agent/cross_app_tracing_test.rb +0 -71
- data/test/script/before_install/jruby_bundler.sh +0 -22
@@ -3,7 +3,7 @@ suite_condition("SideKiq requires MRI 1.9.3 or JRuby 1.6 in 1.9 mode") do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
# Sidekiq 3.x does not support MRI 1.9.x
|
6
|
-
if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
|
6
|
+
if (RUBY_VERSION >= '2.0.0' && RUBY_VERSION < '2.4.0') || (RUBY_PLATFORM == 'java')
|
7
7
|
gemfile <<-RB
|
8
8
|
gem 'json'
|
9
9
|
gem 'sidekiq', '~> 3.4.2'
|
@@ -11,7 +11,9 @@ if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
|
|
11
11
|
|
12
12
|
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
13
13
|
RB
|
14
|
+
end
|
14
15
|
|
16
|
+
if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
|
15
17
|
gemfile <<-RB
|
16
18
|
gem 'json'
|
17
19
|
gem 'sidekiq', '~> 4.0.0'
|
@@ -20,7 +22,7 @@ if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
|
|
20
22
|
RB
|
21
23
|
end
|
22
24
|
|
23
|
-
if RUBY_VERSION >= '2.0.0' && RUBY_PLATFORM != 'java'
|
25
|
+
if RUBY_VERSION >= '2.0.0' && RUBY_VERSION < '2.4.0' && RUBY_PLATFORM != 'java'
|
24
26
|
# We skip testing Sidekiq 3.5.3 on JRuby due to an error in Sidekiq's shutdown:
|
25
27
|
# https://github.com/mperham/sidekiq/issues/2703
|
26
28
|
gemfile <<-RB
|
@@ -47,3 +49,5 @@ gemfile <<-RB
|
|
47
49
|
gem 'rack'
|
48
50
|
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
49
51
|
RB
|
52
|
+
|
53
|
+
# vim: ft=ruby
|
@@ -32,38 +32,40 @@ gemfile <<-RB
|
|
32
32
|
gem 'json', :platforms => [:rbx, :mri_18]
|
33
33
|
RB
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if RUBY_VERSION < '2.4.0'
|
36
|
+
gemfile <<-RB
|
37
|
+
# Compatibility issues with ethon 0.5.12 https://github.com/typhoeus/ethon/issues/51
|
38
|
+
gem 'ethon', '0.5.11'
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
# ethon 0.5.11 requires mime-types ~> 1.18
|
41
|
+
# normally, this wouldn't be a problem, but
|
42
|
+
# we have other checks to work around other
|
43
|
+
# mime-type dependency issues, so we need
|
44
|
+
# to specify it here.
|
45
|
+
gem 'mime-types', '~> 1.18'
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
RB
|
47
|
+
gem 'typhoeus', '~> 0.5.4'
|
48
|
+
gem 'rack'
|
49
|
+
gem 'json', :platforms => [:rbx, :mri_18]
|
50
|
+
RB
|
50
51
|
|
51
|
-
# Earliest supported version
|
52
|
-
gemfile <<-RB
|
53
|
-
|
54
|
-
|
52
|
+
# Earliest supported version
|
53
|
+
gemfile <<-RB
|
54
|
+
# Compatibility issues with ethon 0.5.12 https://github.com/typhoeus/ethon/issues/51
|
55
|
+
gem 'ethon', '0.5.11'
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
# ethon 0.5.11 requires mime-types ~> 1.18
|
58
|
+
# normally, this wouldn't be a problem, but
|
59
|
+
# we have other checks to work around other
|
60
|
+
# mime-type dependency issues, so we need
|
61
|
+
# to specify it here.
|
62
|
+
gem 'mime-types', '~> 1.18'
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
RB
|
64
|
+
gem 'typhoeus', '0.5.3'
|
65
|
+
gem 'rack'
|
66
|
+
gem 'json', :platforms => [:rbx, :mri_18]
|
67
|
+
RB
|
68
|
+
end
|
67
69
|
|
68
70
|
# Prior to supported versions
|
69
71
|
gemfile <<-RB
|
@@ -81,3 +83,5 @@ gemfile <<-RB
|
|
81
83
|
gem 'rack'
|
82
84
|
gem 'json', :platforms => [:rbx, :mri_18]
|
83
85
|
RB
|
86
|
+
|
87
|
+
# vim: ft=ruby
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require "typhoeus"
|
@@ -103,7 +103,7 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
103
103
|
|
104
104
|
def test_request_succeeds_even_if_tracing_doesnt
|
105
105
|
in_transaction("test") do
|
106
|
-
::NewRelic::Agent::CrossAppTracing.stubs(:
|
106
|
+
::NewRelic::Agent::CrossAppTracing.stubs(:cross_app_enabled?).raises("Booom")
|
107
107
|
res = get_response
|
108
108
|
|
109
109
|
assert_match %r/<head>/i, body(res)
|
@@ -124,7 +124,8 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
124
124
|
|
125
125
|
if CURRENT_TYPHOEUS_VERSION >= SUPPORTS_URI_OBJECT_VERSION
|
126
126
|
def test_get_with_uri
|
127
|
-
res =
|
127
|
+
res = nil
|
128
|
+
in_transaction { res = get_response(default_uri) }
|
128
129
|
assert_match %r/<head>/i, body(res)
|
129
130
|
assert_externals_recorded_for("localhost", "GET")
|
130
131
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
suite_condition("Yajl not supported for JRuby") do
|
2
|
-
RUBY_PLATFORM != 'java'
|
1
|
+
suite_condition("Yajl not supported for JRuby or 2.4") do
|
2
|
+
RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.4.0'
|
3
3
|
end
|
4
4
|
|
5
5
|
gemfile <<-RB
|
@@ -11,3 +11,5 @@ gemfile <<-RB
|
|
11
11
|
gem 'rack'
|
12
12
|
gem 'yajl-ruby', '~> 1.1.0'
|
13
13
|
RB
|
14
|
+
|
15
|
+
# vim: ft=ruby
|
@@ -56,16 +56,6 @@ class NewRelic::Agent::DatastoresTest < Minitest::Test
|
|
56
56
|
assert_metrics("find", "Other")
|
57
57
|
end
|
58
58
|
|
59
|
-
def test_outside_transaction
|
60
|
-
MyFirstDatabase.new.find
|
61
|
-
assert_metrics_recorded([
|
62
|
-
"Datastore/operation/MyFirstDatabase/find",
|
63
|
-
"Datastore/MyFirstDatabase/allOther",
|
64
|
-
"Datastore/MyFirstDatabase/all",
|
65
|
-
"Datastore/allOther",
|
66
|
-
"Datastore/all"])
|
67
|
-
end
|
68
|
-
|
69
59
|
def test_separate_operation_name
|
70
60
|
in_background_transaction("txn") do
|
71
61
|
MyFirstDatabase.new.save
|
@@ -98,7 +98,7 @@ module NewRelic
|
|
98
98
|
refute_nil(find_node_with_name(sample, metric_name), "Expected trace to have node with name: #{metric_name}")
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
101
|
+
def test_does_not_record_unscoped_metrics_nor_create_trace_for_transmit_outside_of_active_txn
|
102
102
|
@subscriber.start('transmit.action_cable', :id, payload_for_transmit)
|
103
103
|
advance_time(1.0)
|
104
104
|
@subscriber.finish('transmit.action_cable', :id, payload_for_transmit)
|
@@ -106,7 +106,7 @@ module NewRelic
|
|
106
106
|
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
107
107
|
|
108
108
|
assert_nil sample, "Did not expect a transaction to be created for transmit"
|
109
|
-
|
109
|
+
refute_metrics_recorded ['Ruby/ActionCable/TestChannel/transmit']
|
110
110
|
end
|
111
111
|
|
112
112
|
def payload_for_perform_action action = 'test_action'
|
@@ -19,106 +19,105 @@ class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < Minitest::Tes
|
|
19
19
|
|
20
20
|
def test_records_metrics_for_simple_template
|
21
21
|
params = { :identifier => '/root/app/views/model/index.html.erb' }
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
freeze_time
|
23
|
+
in_transaction do
|
24
|
+
@subscriber.start('render_template.action_view', :id, params)
|
25
|
+
@subscriber.start('!render_template.action_view', :id,
|
26
|
+
:virtual_path => 'model/index')
|
27
|
+
advance_time 2.0
|
28
|
+
@subscriber.finish('!render_template.action_view', :id,
|
29
|
+
:virtual_path => 'model/index')
|
30
|
+
@subscriber.finish('render_template.action_view', :id, params)
|
31
|
+
end
|
33
32
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
34
33
|
assert_metrics_recorded('View/model/index.html.erb/Rendering' => expected)
|
35
34
|
end
|
36
35
|
|
37
36
|
def test_records_metrics_for_simple_file
|
38
37
|
params = { :identifier => '/root/something.txt' }
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
freeze_time
|
39
|
+
in_transaction do
|
40
|
+
@subscriber.start('render_template.action_view', :id, params)
|
41
|
+
@subscriber.start('!render_template.action_view', :id,
|
42
|
+
:virtual_path => nil)
|
43
|
+
advance_time 2.0
|
44
|
+
@subscriber.finish('!render_template.action_view', :id,
|
45
|
+
:virtual_path => nil)
|
46
|
+
@subscriber.finish('render_template.action_view', :id, params)
|
47
|
+
end
|
49
48
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
50
49
|
assert_metrics_recorded('View/file/Rendering' => expected)
|
51
50
|
end
|
52
51
|
|
53
52
|
def test_records_metrics_for_simple_inline
|
54
53
|
params = { :identifier => 'inline template' }
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
freeze_time
|
55
|
+
in_transaction do
|
56
|
+
@subscriber.start('render_template.action_view', :id, params)
|
57
|
+
@subscriber.start('!render_template.action_view', :id,
|
58
|
+
:virtual_path => nil)
|
59
|
+
advance_time 2.0
|
60
|
+
@subscriber.finish('!render_template.action_view', :id,
|
61
|
+
:virtual_path => nil)
|
62
|
+
@subscriber.finish('render_template.action_view', :id, params)
|
63
|
+
end
|
65
64
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
66
65
|
assert_metrics_recorded('View/inline template/Rendering' => expected)
|
67
66
|
end
|
68
67
|
|
69
68
|
def test_records_metrics_for_simple_text
|
70
69
|
params = { :identifier => 'text template' }
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
freeze_time
|
71
|
+
in_transaction do
|
72
|
+
@subscriber.start('render_template.action_view', :id, params)
|
73
|
+
advance_time 2.0
|
74
|
+
@subscriber.finish('render_template.action_view', :id, params)
|
75
|
+
end
|
77
76
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
78
77
|
assert_metrics_recorded('View/text template/Rendering' => expected)
|
79
78
|
end
|
80
79
|
|
81
80
|
def test_records_metrics_for_simple_partial
|
82
81
|
params = { :identifier => '/root/app/views/model/_form.html.erb' }
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
82
|
+
freeze_time
|
83
|
+
in_transaction do
|
84
|
+
@subscriber.start('render_partial.action_view', :id, params)
|
85
|
+
@subscriber.start('!render_template.action_view', :id,
|
86
|
+
:virtual_path => 'model/_form')
|
87
|
+
advance_time 2.0
|
88
|
+
@subscriber.finish('!render_template.action_view', :id,
|
89
|
+
:virtual_path => 'model/_form')
|
90
|
+
@subscriber.finish('render_partial.action_view', :id, params)
|
91
|
+
end
|
93
92
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
94
93
|
assert_metrics_recorded('View/model/_form.html.erb/Partial' => expected)
|
95
94
|
end
|
96
95
|
|
97
96
|
def test_records_metrics_for_simple_collection
|
98
97
|
params = { :identifier => '/root/app/views/model/_user.html.erb' }
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
98
|
+
freeze_time
|
99
|
+
in_transaction do
|
100
|
+
@subscriber.start('render_collection.action_view', :id, params)
|
101
|
+
@subscriber.start('!render_template.action_view', :id,
|
102
|
+
:virtual_path => 'model/_user')
|
103
|
+
advance_time 2.0
|
104
|
+
@subscriber.finish('!render_template.action_view', :id,
|
105
|
+
:virtual_path => 'model/_user')
|
106
|
+
@subscriber.finish('render_collection.action_view', :id, params)
|
107
|
+
end
|
109
108
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
110
109
|
assert_metrics_recorded('View/model/_user.html.erb/Partial' => expected)
|
111
110
|
end
|
112
111
|
|
113
112
|
def test_records_metrics_for_layout
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
113
|
+
freeze_time
|
114
|
+
in_transaction do
|
115
|
+
@subscriber.start('!render_template.action_view', :id,
|
116
|
+
:virtual_path => 'layouts/application')
|
117
|
+
advance_time 2.0
|
118
|
+
@subscriber.finish('!render_template.action_view', :id,
|
119
|
+
:virtual_path => 'layouts/application')
|
120
|
+
end
|
122
121
|
expected = { :call_count => 1, :total_call_time => 2.0 }
|
123
122
|
assert_metrics_recorded('View/layouts/application/Rendering' => expected)
|
124
123
|
end
|
@@ -33,7 +33,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
33
33
|
def test_records_metrics_for_simple_find
|
34
34
|
freeze_time
|
35
35
|
|
36
|
-
simulate_query(2)
|
36
|
+
in_transaction('test_txn') { simulate_query(2) }
|
37
37
|
|
38
38
|
metric_name = 'Datastore/statement/ActiveRecord/NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest::Order/find'
|
39
39
|
assert_metrics_recorded(
|
@@ -56,7 +56,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
56
56
|
config = { :adapter => "mysql", :host => "jonan.gummy_planet", :port => 3306 }
|
57
57
|
@subscriber.stubs(:active_record_config).returns(config)
|
58
58
|
|
59
|
-
simulate_query(2)
|
59
|
+
in_transaction('test_txn') { simulate_query(2) }
|
60
60
|
|
61
61
|
assert_metrics_recorded('Datastore/instance/MySQL/jonan.gummy_planet/3306')
|
62
62
|
end
|
@@ -65,14 +65,14 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
65
65
|
config = { :adapter => "mysql", :host => "jonan.gummy_planet", :port => "" }
|
66
66
|
@subscriber.stubs(:active_record_config).returns(config)
|
67
67
|
|
68
|
-
simulate_query(2)
|
68
|
+
in_transaction('test_txn') { simulate_query(2) }
|
69
69
|
|
70
70
|
assert_metrics_recorded('Datastore/instance/MySQL/jonan.gummy_planet/unknown')
|
71
71
|
|
72
72
|
config = { :adapter => "mysql", :host => "", :port => 3306 }
|
73
73
|
@subscriber.stubs(:active_record_config).returns(config)
|
74
74
|
|
75
|
-
simulate_query(2)
|
75
|
+
in_transaction('test_txn') { simulate_query(2) }
|
76
76
|
|
77
77
|
assert_metrics_recorded('Datastore/instance/MySQL/unknown/3306')
|
78
78
|
end
|
@@ -81,7 +81,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
81
81
|
config = { :adapter => "JonanDB", :host => "jonan.gummy_planet" }
|
82
82
|
@subscriber.stubs(:active_record_config).returns(config)
|
83
83
|
|
84
|
-
simulate_query(2)
|
84
|
+
in_transaction('test_txn') { simulate_query(2) }
|
85
85
|
|
86
86
|
assert_metrics_not_recorded('Datastore/instance/JonanDB/jonan.gummy_planet/default')
|
87
87
|
end
|
@@ -91,7 +91,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
91
91
|
config = { :host => "jonan.gummy_planet" }
|
92
92
|
@subscriber.stubs(:active_record_config).returns(config)
|
93
93
|
|
94
|
-
simulate_query(2)
|
94
|
+
in_transaction('test_txn') { simulate_query(2) }
|
95
95
|
|
96
96
|
assert_metrics_not_recorded('Datastore/instance/ActiveRecord/jonan.gummy_planet/default')
|
97
97
|
end
|
@@ -101,7 +101,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
101
101
|
config = { :adapter => "", :host => "" }
|
102
102
|
@subscriber.stubs(:active_record_config).returns(config)
|
103
103
|
|
104
|
-
simulate_query(2)
|
104
|
+
in_transaction('test_txn') { simulate_query(2) }
|
105
105
|
|
106
106
|
assert_metrics_not_recorded('Datastore/instance/unknown/unknown')
|
107
107
|
end
|
@@ -124,7 +124,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
124
124
|
config = {:adapter => 'mysql', :host => "127.0.0.1"}
|
125
125
|
@subscriber.stubs(:active_record_config).returns(config)
|
126
126
|
|
127
|
-
simulate_query
|
127
|
+
in_transaction('test_txn') { simulate_query(2) }
|
128
128
|
|
129
129
|
assert_metrics_recorded("Datastore/instance/MySQL/unknown/unknown")
|
130
130
|
end
|
@@ -132,7 +132,9 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
|
|
132
132
|
def test_records_nothing_if_tracing_disabled
|
133
133
|
freeze_time
|
134
134
|
|
135
|
-
|
135
|
+
in_transaction('test_txn') do
|
136
|
+
NewRelic::Agent.disable_all_tracing { simulate_query(2) }
|
137
|
+
end
|
136
138
|
|
137
139
|
metric_name = 'Datastore/statement/ActiveRecord/NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest::Order/find'
|
138
140
|
assert_metrics_not_recorded([metric_name])
|
@@ -121,14 +121,15 @@ module NewRelic
|
|
121
121
|
NewRelic::Agent.drop_buffered_data
|
122
122
|
NewRelic::Agent::Hostname.stubs(:get).returns(test['system_hostname'])
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
124
|
+
in_transaction do
|
125
|
+
config = convert_test_case_to_config test
|
126
|
+
product, operation, collection = ActiveRecordHelper.product_operation_collection_for "Blog Find", nil , config[:adapter]
|
127
|
+
host = ActiveRecordHelper::InstanceIdentification.host(config)
|
128
|
+
port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(config)
|
129
|
+
|
130
|
+
segment = NewRelic::Agent::Transaction.start_datastore_segment product, operation, collection, host, port_path_or_id
|
131
|
+
segment.finish
|
132
|
+
end
|
132
133
|
|
133
134
|
assert_metrics_recorded test['expected_instance_metric']
|
134
135
|
end
|