newrelic_rpm 3.9.9.275 → 3.10.0.279
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 +51 -0
- data/config.dot +0 -3
- data/lib/new_relic/agent.rb +7 -5
- data/lib/new_relic/agent/agent.rb +4 -4
- data/lib/new_relic/agent/instrumentation/active_job.rb +5 -8
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -34
- data/lib/new_relic/agent/instrumentation/grape.rb +60 -23
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +10 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +33 -21
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -3
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +0 -9
- data/lib/new_relic/agent/instrumentation/sinatra.rb +9 -12
- data/lib/new_relic/agent/javascript_instrumentor.rb +1 -0
- data/lib/new_relic/agent/new_relic_service.rb +9 -6
- data/lib/new_relic/agent/parameter_filtering.rb +37 -0
- data/lib/new_relic/agent/supported_versions.rb +7 -0
- data/lib/new_relic/agent/traced_method_stack.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +182 -186
- data/lib/new_relic/agent/vm/rubinius_vm.rb +93 -3
- data/lib/new_relic/control/frameworks/rails.rb +1 -0
- data/lib/new_relic/rack/agent_hooks.rb +15 -23
- data/lib/new_relic/version.rb +2 -2
- data/newrelic_rpm.gemspec +12 -5
- data/test/agent_helper.rb +26 -14
- data/test/multiverse/lib/multiverse/suite.rb +1 -5
- data/test/multiverse/suites/activemerchant/Envfile +4 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +2 -12
- data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +4 -0
- data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -8
- data/test/multiverse/suites/agent_only/testing_app.rb +1 -7
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +11 -11
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +4 -0
- data/test/multiverse/suites/grape/Envfile +1 -3
- data/test/multiverse/suites/grape/grape_test.rb +87 -6
- data/test/multiverse/suites/grape/grape_test_api.rb +5 -0
- data/test/multiverse/suites/grape/grape_versioning_test.rb +67 -0
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +72 -0
- data/test/multiverse/suites/rack/example_app.rb +31 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +11 -10
- data/test/multiverse/suites/rack/rack_cascade_test.rb +46 -0
- data/test/multiverse/suites/rack/rack_parameter_filtering_test.rb +40 -0
- data/test/multiverse/suites/rails/Envfile +8 -0
- data/test/multiverse/suites/rails/activejob_test.rb +16 -0
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +4 -2
- data/test/multiverse/suites/rails/parameter_capture_test.rb +49 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +12 -1
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +4 -0
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +4 -0
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +11 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +0 -58
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +49 -0
- data/test/new_relic/agent/instrumentation/middleware_tracing_test.rb +26 -14
- data/test/new_relic/agent/parameter_filtering_test.rb +39 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
- data/test/new_relic/agent/transaction_test.rb +106 -2
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +38 -37
- data/test/new_relic/agent_test.rb +8 -3
- data/test/new_relic/filtering_test_app.rb +18 -0
- data/test/new_relic/latest_changes_test.rb +1 -1
- data/test/new_relic/rack/browser_monitoring_test.rb +4 -4
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +6 -4
- data/test/performance/lib/performance/platform.rb +1 -0
- data/test/performance/suites/thread_profiling.rb +12 -0
- metadata +38 -15
- metadata.gz.sig +2 -1
@@ -9,10 +9,6 @@ class TestingApp
|
|
9
9
|
attr_accessor :response, :headers
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
reset_headers
|
13
|
-
end
|
14
|
-
|
15
|
-
def reset_headers
|
16
12
|
@headers = {'Content-Type' => 'text/html'}
|
17
13
|
end
|
18
14
|
|
@@ -23,7 +19,7 @@ class TestingApp
|
|
23
19
|
opts = {}
|
24
20
|
if params['transaction_category']
|
25
21
|
opts[:category] = params['transaction_category']
|
26
|
-
NewRelic::Agent::
|
22
|
+
NewRelic::Agent::TransactionState.tl_get.current_transaction.stubs(:similar_category?).returns true
|
27
23
|
end
|
28
24
|
NewRelic::Agent.set_transaction_name(params['transaction_name'], opts)
|
29
25
|
end
|
@@ -34,6 +30,4 @@ class TestingApp
|
|
34
30
|
sleep(params['sleep'].to_f) if params['sleep']
|
35
31
|
[200, headers, [response]]
|
36
32
|
end
|
37
|
-
|
38
|
-
include NewRelic::Agent::Instrumentation::Rack
|
39
33
|
end
|
@@ -28,11 +28,11 @@ class XraySessionsTest < Minitest::Test
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def app
|
31
|
-
|
31
|
+
Rack::Builder.app { run TestingApp.new }
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_tags_transaction_traces_with_xray_id
|
35
|
-
session = build_xray_session('key_transaction_name' => 'Controller/
|
35
|
+
session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
|
36
36
|
with_xray_sessions(session) do
|
37
37
|
5.times { get '/?transaction_name=A' }
|
38
38
|
trigger_harvest
|
@@ -43,12 +43,12 @@ class XraySessionsTest < Minitest::Test
|
|
43
43
|
|
44
44
|
traces = posts.first.samples
|
45
45
|
assert_equal(5, traces.size)
|
46
|
-
assert traces.all? { |t| t.metric_name == 'Controller/
|
46
|
+
assert traces.all? { |t| t.metric_name == 'Controller/Rack/A' }
|
47
47
|
assert traces.all? { |t| t.xray_id == session['x_ray_id'] }
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_does_not_collect_traces_for_non_xrayed_transactions
|
51
|
-
session = build_xray_session('key_transaction_name' => 'Controller/
|
51
|
+
session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
|
52
52
|
with_xray_sessions(session) do
|
53
53
|
get '/?transaction_name=OtherThing'
|
54
54
|
get '/?transaction_name=A'
|
@@ -63,8 +63,8 @@ class XraySessionsTest < Minitest::Test
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_gathers_transaction_traces_from_multiple_concurrent_xray_sessions
|
66
|
-
sessionA = build_xray_session('x_ray_id' => 12, 'key_transaction_name' => 'Controller/
|
67
|
-
sessionB = build_xray_session('x_ray_id' => 13, 'key_transaction_name' => 'Controller/
|
66
|
+
sessionA = build_xray_session('x_ray_id' => 12, 'key_transaction_name' => 'Controller/Rack/A')
|
67
|
+
sessionB = build_xray_session('x_ray_id' => 13, 'key_transaction_name' => 'Controller/Rack/B')
|
68
68
|
|
69
69
|
with_xray_sessions(sessionA, sessionB) do
|
70
70
|
2.times do
|
@@ -80,14 +80,14 @@ class XraySessionsTest < Minitest::Test
|
|
80
80
|
traces = posts.first.samples
|
81
81
|
assert_equal(4, traces.size)
|
82
82
|
|
83
|
-
tracesA = traces.select { |t| t.metric_name == 'Controller/
|
84
|
-
tracesB = traces.select { |t| t.metric_name == 'Controller/
|
83
|
+
tracesA = traces.select { |t| t.metric_name == 'Controller/Rack/A' }
|
84
|
+
tracesB = traces.select { |t| t.metric_name == 'Controller/Rack/B' }
|
85
85
|
assert_equal(2, tracesA.size, "Expected 2 traces for transaction A")
|
86
86
|
assert_equal(2, tracesB.size, "Expected 2 traces for transaction B")
|
87
87
|
end
|
88
88
|
|
89
89
|
def test_gathers_thread_profiles
|
90
|
-
session = build_xray_session('key_transaction_name' => 'Controller/
|
90
|
+
session = build_xray_session('key_transaction_name' => 'Controller/Rack/A')
|
91
91
|
with_xray_sessions(session) do
|
92
92
|
wait_for_backtrace_service_poll
|
93
93
|
get '/?transaction_name=A&sleep=1'
|
@@ -115,7 +115,7 @@ class XraySessionsTest < Minitest::Test
|
|
115
115
|
defaults = {
|
116
116
|
"x_ray_id" => next_xray_session_id,
|
117
117
|
"xray_session_name" => "Test XRay Session",
|
118
|
-
"key_transaction_name" => "Controller/
|
118
|
+
"key_transaction_name" => "Controller/Rack/Transaction",
|
119
119
|
"requested_trace_count" => 10,
|
120
120
|
"duration" => 100,
|
121
121
|
"sample_period" => 0.1,
|
@@ -137,7 +137,7 @@ class XraySessionsTest < Minitest::Test
|
|
137
137
|
def with_xray_sessions(*xray_metadatas)
|
138
138
|
xray_session_ids = xray_metadatas.map { |m| m['x_ray_id'] }
|
139
139
|
activate_cmd = build_active_xrays_command(xray_session_ids)
|
140
|
-
|
140
|
+
|
141
141
|
$collector.stub('get_xray_metadata', xray_metadatas)
|
142
142
|
issue_command(activate_cmd)
|
143
143
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
suite_condition("Grape is only supported for versions >= 1.9.3") do
|
2
|
-
|
3
|
-
# When set, should require 1.9.3 or greater
|
4
|
-
false
|
2
|
+
RUBY_VERSION >= '1.9.3'
|
5
3
|
end
|
6
4
|
|
7
5
|
versions = %w(0.9.0 0.8.0 0.7.0 0.6.1 0.5.0 0.4.1 0.3.2 0.2.6 0.2.0 0.1.5)
|
@@ -29,32 +29,113 @@ class GrapeTest < Minitest::Test
|
|
29
29
|
assert_raises(GrapeTestApiError) do
|
30
30
|
get '/self_destruct'
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
expected_txn_name = 'Controller/Grape/GrapeTestApi/self_destruct (GET)'
|
34
|
+
assert_grape_metrics(expected_txn_name)
|
35
|
+
assert_metrics_recorded(["Errors/#{expected_txn_name}"])
|
33
36
|
end
|
34
37
|
|
35
38
|
def test_getting_a_list_of_grape_apes
|
36
39
|
get '/grape_ape'
|
37
|
-
|
40
|
+
assert_grape_metrics('Controller/Grape/GrapeTestApi/grape_ape (GET)')
|
38
41
|
end
|
39
42
|
|
40
43
|
def test_showing_a_grape_ape
|
41
44
|
get '/grape_ape/1'
|
42
|
-
|
45
|
+
assert_grape_metrics('Controller/Grape/GrapeTestApi/grape_ape/:id (GET)')
|
43
46
|
end
|
44
47
|
|
45
48
|
def test_creating_a_grape_ape
|
46
49
|
post '/grape_ape', {}
|
47
|
-
|
50
|
+
assert_grape_metrics('Controller/Grape/GrapeTestApi/grape_ape (POST)')
|
48
51
|
end
|
49
52
|
|
50
53
|
def test_updating_a_grape_ape
|
51
54
|
put '/grape_ape/1', {}
|
52
|
-
|
55
|
+
assert_grape_metrics('Controller/Grape/GrapeTestApi/grape_ape/:id (PUT)')
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_deleting_a_grape_ape
|
56
59
|
delete '/grape_ape/1'
|
57
|
-
|
60
|
+
assert_grape_metrics('Controller/Grape/GrapeTestApi/grape_ape/:id (DELETE)')
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_transaction_renaming
|
64
|
+
get '/grape_ape/renamed'
|
65
|
+
# The second segment here is 'Rack' because of an idiosyncrasy of
|
66
|
+
# the set_transaction_name API: when you call set_transaction_name and
|
67
|
+
# don't provide an explicit category, you lock in the category prefix
|
68
|
+
# that was in use at the time you made the call.
|
69
|
+
#
|
70
|
+
# We may change this behavior in the future, once we have a better
|
71
|
+
# internal representation of the name and category of a transaction as
|
72
|
+
# truly separate entities.
|
73
|
+
#
|
74
|
+
assert_grape_metrics('Controller/Rack/RenamedTxn')
|
75
|
+
#assert_metrics_recorded(['Controller/Rack/RenamedTxn'])
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_params_are_not_captured_with_capture_params_disabled
|
79
|
+
with_config(:capture_params => false) do
|
80
|
+
get '/grape_ape/10'
|
81
|
+
assert_equal({}, last_transaction_trace_request_params)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_route_params_are_captured
|
86
|
+
with_config(:capture_params => true) do
|
87
|
+
get '/grape_ape/10'
|
88
|
+
assert_equal({"id" => "10"}, last_transaction_trace_request_params)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_query_params_are_captured
|
93
|
+
with_config(:capture_params => true) do
|
94
|
+
get '/grape_ape?q=1234&foo=bar'
|
95
|
+
assert_equal({'q' => '1234', 'foo' => 'bar'}, last_transaction_trace_request_params)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_post_body_params_are_captured
|
100
|
+
with_config(:capture_params => true) do
|
101
|
+
post '/grape_ape', {'q' => '1234', 'foo' => 'bar'}.to_json, "CONTENT_TYPE" => "application/json"
|
102
|
+
assert_equal({'q' => '1234', 'foo' => 'bar'}, last_transaction_trace_request_params)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_post_body_with_nested_params_are_captured
|
107
|
+
with_config(:capture_params => true) do
|
108
|
+
params = {"ape" => {"first_name" => "koko", "last_name" => "gorilla"}}
|
109
|
+
post '/grape_ape', params.to_json, "CONTENT_TYPE" => "application/json"
|
110
|
+
assert_equal(params, last_transaction_trace_request_params)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_file_upload_params_are_filtered
|
115
|
+
with_config(:capture_params => true) do
|
116
|
+
params = {
|
117
|
+
:title => "blah",
|
118
|
+
:file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
|
119
|
+
}
|
120
|
+
post '/grape_ape', params
|
121
|
+
assert_equal({"title" => "blah", "file" => "[FILE]"}, last_transaction_trace_request_params)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_404_with_params_does_not_capture_them
|
126
|
+
with_config(:capture_params => true) do
|
127
|
+
post '/grape_catfish', {"foo" => "bar"}
|
128
|
+
assert_equal({}, last_transaction_trace_request_params)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_grape_metrics(expected_txn_name)
|
133
|
+
expected_segment_name = 'Middleware/Grape/GrapeTestApi/call'
|
134
|
+
assert_metrics_recorded([
|
135
|
+
expected_segment_name,
|
136
|
+
[expected_segment_name, expected_txn_name],
|
137
|
+
expected_txn_name
|
138
|
+
])
|
58
139
|
end
|
59
140
|
end
|
60
141
|
end
|
@@ -0,0 +1,67 @@
|
|
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
|
+
unless ::Grape::VERSION == '0.1.5'
|
6
|
+
require 'multiverse_helpers'
|
7
|
+
require './grape_versioning_test_api'
|
8
|
+
|
9
|
+
require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
|
10
|
+
|
11
|
+
class GrapeVersioningTest < Minitest::Test
|
12
|
+
include Rack::Test::Methods
|
13
|
+
include MultiverseHelpers
|
14
|
+
|
15
|
+
setup_and_teardown_agent
|
16
|
+
|
17
|
+
def app
|
18
|
+
clazz = @app_class
|
19
|
+
Rack::Builder.app { run clazz.new }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_version_from_path_is_recorded_in_transaction_name
|
23
|
+
@app_class = GrapeVersioning::ApiV1
|
24
|
+
get '/v1/fish'
|
25
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV1-v1/fish (GET)')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_version_is_stripped_when_requesting_root_route
|
29
|
+
@app_class = GrapeVersioning::ApiV1
|
30
|
+
get '/v1'
|
31
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV1-v1/ (GET)')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_version_is_stripped_when_requesting_root_route_with_trailing_slash
|
35
|
+
@app_class = GrapeVersioning::ApiV1
|
36
|
+
get '/v1/'
|
37
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV1-v1/ (GET)')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_version_from_param_version_is_recorded_in_transaction_name
|
41
|
+
@app_class = GrapeVersioning::ApiV2
|
42
|
+
get '/fish?apiver=v2'
|
43
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV2-v2/fish (GET)')
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_version_from_header_is_recorded_in_transaction_name
|
47
|
+
@app_class = GrapeVersioning::ApiV3
|
48
|
+
get '/fish', {}, 'HTTP_ACCEPT' => 'application/vnd.newrelic-v3+json'
|
49
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV3-v3/fish (GET)')
|
50
|
+
end
|
51
|
+
|
52
|
+
#version from http accept header is not supported in older versions of grape
|
53
|
+
if NewRelic::VersionNumber.new(Grape::VERSION) >= NewRelic::VersionNumber.new('4.0.0')
|
54
|
+
def test_version_from_accept_version_header_is_recorded_in_transaction_name
|
55
|
+
@app_class = GrapeVersioning::ApiV4
|
56
|
+
get '/fish', {}, 'HTTP_ACCEPT_VERSION' => 'v4'
|
57
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::ApiV4-v4/fish (GET)')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_app_not_using_versioning_does_not_record_version_in_transaction_name
|
62
|
+
@app_class = GrapeVersioning::Unversioned
|
63
|
+
get '/fish'
|
64
|
+
assert_metrics_recorded('Controller/Grape/GrapeVersioning::Unversioned/fish (GET)')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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
|
+
unless ::Grape::VERSION == '0.1.5'
|
6
|
+
module GrapeVersioning
|
7
|
+
class ApiV1 < Grape::API
|
8
|
+
version 'v1'
|
9
|
+
|
10
|
+
format :json
|
11
|
+
|
12
|
+
get do
|
13
|
+
"root"
|
14
|
+
end
|
15
|
+
|
16
|
+
resource :fish do
|
17
|
+
get do
|
18
|
+
"api v1"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class ApiV2 < Grape::API
|
24
|
+
version 'v2', :using => :param
|
25
|
+
|
26
|
+
format :json
|
27
|
+
|
28
|
+
resource :fish do
|
29
|
+
get do
|
30
|
+
"api v2"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class ApiV3 < Grape::API
|
36
|
+
version 'v3', :using => :header, :vendor => "newrelic"
|
37
|
+
|
38
|
+
format :json
|
39
|
+
|
40
|
+
resource :fish do
|
41
|
+
get do
|
42
|
+
"api v3"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class ApiV4 < Grape::API
|
48
|
+
#version from http accept header is not supported in older versions of grape
|
49
|
+
if NewRelic::VersionNumber.new(Grape::VERSION) >= NewRelic::VersionNumber.new('4.0.0')
|
50
|
+
version 'v4', :using => :accept_version_header
|
51
|
+
end
|
52
|
+
|
53
|
+
format :json
|
54
|
+
|
55
|
+
resource :fish do
|
56
|
+
get do
|
57
|
+
"api v4"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Unversioned < Grape::API
|
63
|
+
format :json
|
64
|
+
|
65
|
+
resource :fish do
|
66
|
+
get do
|
67
|
+
"api v5"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -4,8 +4,38 @@
|
|
4
4
|
|
5
5
|
class ExampleApp
|
6
6
|
def call(env)
|
7
|
-
|
7
|
+
req = Rack::Request.new(env)
|
8
|
+
body = req.params['body'] || 'A barebones rack app.'
|
9
|
+
|
10
|
+
status = '404' unless req.path == '/'
|
11
|
+
[status || '200', {'Content-Type' => 'text/html', 'ExampleApp' => '0'}, [body]]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class FirstCascadeExampleApp
|
16
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
req = Rack::Request.new(env)
|
20
|
+
body = req.params['body'] || 'A barebones rack cascade app.'
|
21
|
+
|
22
|
+
status = '404' unless req.path == '/'
|
23
|
+
[status || '200', {'Content-Type' => 'text/html', 'FirstCascadeExampleApp' => '0'}, [body]]
|
24
|
+
end
|
25
|
+
add_transaction_tracer :call
|
26
|
+
end
|
27
|
+
|
28
|
+
class SecondCascadeExampleApp
|
29
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
30
|
+
|
31
|
+
def call(env)
|
32
|
+
req = Rack::Request.new(env)
|
33
|
+
body = req.params['body'] || 'A barebones rack cascade app.'
|
34
|
+
|
35
|
+
status = '404' unless req.path == '/'
|
36
|
+
[status || '200', {'Content-Type' => 'text/html', 'SecondCascadeExampleApp' => '0'}, [body]]
|
8
37
|
end
|
38
|
+
add_transaction_tracer :call
|
9
39
|
end
|
10
40
|
|
11
41
|
class MiddlewareOne
|
@@ -101,13 +101,14 @@ class RackAutoInstrumentationTest < Minitest::Test
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_middlewares_record_queue_time
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
freeze_time do |t0|
|
105
|
+
advance_time(5.0)
|
106
|
+
get '/', {}, { 'HTTP_X_REQUEST_START' => "t=#{t0.to_f}" }
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
assert_metrics_recorded(
|
109
|
+
'WebFrontend/QueueTime' => { :total_call_time => 5.0 }
|
110
|
+
)
|
111
|
+
end
|
111
112
|
end
|
112
113
|
|
113
114
|
def test_middleware_that_returns_early_records_middleware_rollup_metric
|
@@ -126,10 +127,10 @@ class RackAutoInstrumentationTest < Minitest::Test
|
|
126
127
|
end
|
127
128
|
|
128
129
|
def test_middleware_that_returns_early_middleware_all_has_correct_call_times
|
129
|
-
freeze_time
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
freeze_time do
|
131
|
+
get '/?return-early=true'
|
132
|
+
assert_metrics_recorded('Middleware/all' => { :total_exclusive_time => 3.0, :call_count => 2 })
|
133
|
+
end
|
133
134
|
end
|
134
135
|
|
135
136
|
def test_middleware_created_with_args_works
|