instana 1.192.0 → 1.193.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +200 -133
  3. data/.editorconfig +10 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop.yml +5 -1147
  6. data/.rubocop_todo.yml +1140 -0
  7. data/Appraisals +100 -0
  8. data/Gemfile +11 -32
  9. data/Rakefile +16 -39
  10. data/bin/console +5 -4
  11. data/gemfiles/.bundle/config +1 -2
  12. data/gemfiles/cuba_30.gemfile +15 -0
  13. data/gemfiles/dalli_20.gemfile +15 -0
  14. data/gemfiles/excon_02.gemfile +15 -0
  15. data/gemfiles/graphql_10.gemfile +15 -0
  16. data/gemfiles/grpc_10.gemfile +15 -0
  17. data/gemfiles/net_http_01.gemfile +14 -0
  18. data/gemfiles/rack_16.gemfile +15 -0
  19. data/gemfiles/rack_20.gemfile +15 -0
  20. data/gemfiles/rails_42.gemfile +18 -0
  21. data/gemfiles/rails_50.gemfile +18 -0
  22. data/gemfiles/rails_52.gemfile +18 -0
  23. data/gemfiles/rails_60.gemfile +18 -0
  24. data/gemfiles/redis_40.gemfile +15 -0
  25. data/gemfiles/resque_122.gemfile +16 -0
  26. data/gemfiles/resque_20.gemfile +15 -0
  27. data/gemfiles/rest_client_16.gemfile +15 -0
  28. data/gemfiles/rest_client_20.gemfile +15 -0
  29. data/gemfiles/roda_20.gemfile +15 -0
  30. data/gemfiles/roda_30.gemfile +15 -0
  31. data/gemfiles/sidekiq_42.gemfile +15 -0
  32. data/gemfiles/sidekiq_50.gemfile +15 -0
  33. data/gemfiles/sinatra_14.gemfile +15 -0
  34. data/instana.gemspec +1 -7
  35. data/lib/instana/activator.rb +41 -0
  36. data/lib/instana/activators/action_controller_api.rb +18 -0
  37. data/lib/instana/activators/action_controller_base.rb +18 -0
  38. data/lib/instana/activators/action_view.rb +18 -0
  39. data/lib/instana/activators/active_record.rb +18 -0
  40. data/lib/instana/activators/cuba.rb +18 -0
  41. data/lib/instana/activators/dalli.rb +20 -0
  42. data/lib/instana/activators/excon.rb +17 -0
  43. data/lib/instana/activators/graphql.rb +19 -0
  44. data/lib/instana/activators/grpc_client.rb +17 -0
  45. data/lib/instana/activators/grpc_server.rb +17 -0
  46. data/lib/instana/activators/net_http.rb +17 -0
  47. data/lib/instana/activators/rack.rb +13 -0
  48. data/lib/instana/activators/rails.rb +15 -0
  49. data/lib/instana/activators/redis.rb +17 -0
  50. data/lib/instana/activators/resque_client.rb +18 -0
  51. data/lib/instana/activators/resque_worker.rb +30 -0
  52. data/lib/instana/activators/rest_client.rb +17 -0
  53. data/lib/instana/activators/roda.rb +18 -0
  54. data/lib/instana/activators/sidekiq_client.rb +21 -0
  55. data/lib/instana/activators/sidekiq_worker.rb +21 -0
  56. data/lib/instana/activators/sinatra.rb +18 -0
  57. data/lib/instana/frameworks/cuba.rb +6 -13
  58. data/lib/instana/frameworks/rails.rb +20 -33
  59. data/lib/instana/frameworks/roda.rb +7 -13
  60. data/lib/instana/frameworks/sinatra.rb +1 -8
  61. data/lib/instana/instrumentation/action_controller.rb +81 -0
  62. data/lib/instana/instrumentation/action_view.rb +27 -0
  63. data/lib/instana/instrumentation/active_record.rb +47 -0
  64. data/lib/instana/instrumentation/dalli.rb +7 -18
  65. data/lib/instana/instrumentation/excon.rb +51 -57
  66. data/lib/instana/instrumentation/graphql.rb +16 -18
  67. data/lib/instana/instrumentation/grpc.rb +70 -66
  68. data/lib/instana/instrumentation/instrumented_request.rb +69 -0
  69. data/lib/instana/instrumentation/net-http.rb +43 -47
  70. data/lib/instana/instrumentation/rack.rb +14 -53
  71. data/lib/instana/instrumentation/redis.rb +10 -18
  72. data/lib/instana/instrumentation/resque.rb +14 -50
  73. data/lib/instana/instrumentation/rest-client.rb +2 -17
  74. data/lib/instana/instrumentation/sidekiq-client.rb +0 -9
  75. data/lib/instana/instrumentation/sidekiq-worker.rb +0 -9
  76. data/lib/instana/secrets.rb +7 -7
  77. data/lib/instana/setup.rb +3 -1
  78. data/lib/instana/tracer.rb +6 -0
  79. data/lib/instana/util.rb +15 -69
  80. data/lib/instana/version.rb +1 -1
  81. data/test/activator_test.rb +27 -0
  82. data/test/frameworks/cuba_test.rb +38 -40
  83. data/test/frameworks/roda_test.rb +39 -41
  84. data/test/frameworks/sinatra_test.rb +61 -64
  85. data/test/instrumentation/excon_test.rb +1 -0
  86. data/test/instrumentation/grpc_test.rb +2 -1
  87. data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +1 -0
  88. data/test/instrumentation/rack_instrumented_request_test.rb +84 -0
  89. data/test/{frameworks → instrumentation}/rack_test.rb +30 -10
  90. data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +37 -21
  91. data/test/instrumentation/rails_action_view_test.rb +148 -0
  92. data/test/instrumentation/rails_active_record_test.rb +121 -0
  93. data/test/instrumentation/resque_test.rb +3 -11
  94. data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +6 -0
  95. data/test/instrumentation/sidekiq-client_test.rb +1 -0
  96. data/test/instrumentation/sidekiq-worker_test.rb +1 -0
  97. data/test/support/apps/active_record/active_record.rb +21 -0
  98. data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +1 -1
  99. data/test/{apps → support/apps/grpc}/grpc_server.rb +0 -0
  100. data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +0 -0
  101. data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +8 -14
  102. data/test/{models → support/apps/rails/models}/block.rb +1 -1
  103. data/test/{models → support/apps/rails/models}/block6.rb +0 -0
  104. data/test/support/apps/resque/boot.rb +2 -0
  105. data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +0 -0
  106. data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +0 -0
  107. data/test/support/apps/sidekiq/boot.rb +21 -0
  108. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +0 -0
  109. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +0 -0
  110. data/test/{servers → support/apps}/sidekiq/worker.rb +2 -2
  111. data/test/support/helpers.rb +94 -0
  112. data/test/test_helper.rb +24 -144
  113. data/test/tracing/id_management_test.rb +4 -66
  114. metadata +103 -95
  115. data/gemfiles/libraries.gemfile +0 -73
  116. data/gemfiles/rails32.gemfile +0 -51
  117. data/gemfiles/rails42.gemfile +0 -50
  118. data/gemfiles/rails50.gemfile +0 -52
  119. data/gemfiles/rails52.gemfile +0 -52
  120. data/gemfiles/rails60.gemfile +0 -72
  121. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
  122. data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
  123. data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
  124. data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
  125. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -87
  126. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -62
  127. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -103
  128. data/lib/instana/instrumentation.rb +0 -25
  129. data/lib/instana/test.rb +0 -43
  130. data/test/apps/cuba.rb +0 -19
  131. data/test/apps/roda.rb +0 -13
  132. data/test/apps/sinatra.rb +0 -9
  133. data/test/frameworks/rails/actionview3_test.rb +0 -210
  134. data/test/frameworks/rails/actionview4_test.rb +0 -208
  135. data/test/frameworks/rails/actionview5_test.rb +0 -221
  136. data/test/frameworks/rails/activerecord_test.rb +0 -279
  137. data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'support/apps/http_endpoint/boot'
2
3
 
3
4
  class ExconTest < Minitest::Test
4
5
  def test_config_defaults
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'support/apps/grpc/boot'
2
3
 
3
4
  class GrpcTest < Minitest::Test
4
5
  def client_stub
@@ -225,7 +226,7 @@ class GrpcTest < Minitest::Test
225
226
  server_span = find_spans_by_name(spans, :'rpc-server').first
226
227
 
227
228
  validate_sdk_span(sdk_span)
228
-
229
+
229
230
  assert_client_span(
230
231
  client_span,
231
232
  call: '/PingPongService/FailToPing',
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'support/apps/http_endpoint/boot'
2
3
 
3
4
  class NetHTTPTest < Minitest::Test
4
5
  def test_config_defaults
@@ -0,0 +1,84 @@
1
+ require 'test_helper'
2
+
3
+ class RackInstrumentedRequestTest < Minitest::Test
4
+ def test_skip_trace_with_header
5
+ req = Instana::InstrumentedRequest.new(
6
+ 'HTTP_X_INSTANA_L' => '0;sample-data'
7
+ )
8
+
9
+ assert req.skip_trace?
10
+ end
11
+
12
+ def test_skip_trace_without_header
13
+ req = Instana::InstrumentedRequest.new({})
14
+
15
+ refute req.skip_trace?
16
+ end
17
+
18
+ def test_incomming_context
19
+ id = Instana::Util.generate_id
20
+ req = Instana::InstrumentedRequest.new(
21
+ 'HTTP_X_INSTANA_L' => '1',
22
+ 'HTTP_X_INSTANA_T' => id,
23
+ 'HTTP_X_INSTANA_S' => id
24
+ )
25
+
26
+ expected = {
27
+ trace_id: id,
28
+ span_id: id,
29
+ level: '1'
30
+ }
31
+
32
+ assert_equal expected, req.incoming_context
33
+ end
34
+
35
+ def test_request_tags
36
+ ::Instana.agent.extra_headers = %w[X-Capture-This]
37
+ req = Instana::InstrumentedRequest.new(
38
+ 'HTTP_HOST' => 'example.com',
39
+ 'REQUEST_METHOD' => 'GET',
40
+ 'HTTP_X_CAPTURE_THIS' => 'that',
41
+ 'PATH_INFO' => '/'
42
+ )
43
+
44
+ expected = {
45
+ method: 'GET',
46
+ url: '/',
47
+ host: 'example.com',
48
+ header: {
49
+ "X-Capture-This": 'that'
50
+ }
51
+ }
52
+
53
+ assert_equal expected, req.request_tags
54
+ ::Instana.agent.extra_headers = nil
55
+ end
56
+
57
+ def test_correlation_data_valid
58
+ req = Instana::InstrumentedRequest.new(
59
+ 'HTTP_X_INSTANA_L' => '1,correlationType=web ;correlationId=1234567890abcdef'
60
+ )
61
+ expected = {
62
+ type: 'web',
63
+ id: '1234567890abcdef'
64
+ }
65
+
66
+ assert_equal expected, req.correlation_data
67
+ end
68
+
69
+ def test_correlation_data_invalid
70
+ req = Instana::InstrumentedRequest.new(
71
+ 'HTTP_X_INSTANA_L' => '0;sample-data'
72
+ )
73
+
74
+ assert_equal({}, req.correlation_data)
75
+ end
76
+
77
+ def test_correlation_data_legacy
78
+ req = Instana::InstrumentedRequest.new(
79
+ 'HTTP_X_INSTANA_L' => '1'
80
+ )
81
+
82
+ assert_equal({}, req.correlation_data)
83
+ end
84
+ end
@@ -1,11 +1,10 @@
1
1
  require 'test_helper'
2
2
  require 'rack/test'
3
3
  require 'rack/lobster'
4
- require "instana/rack"
5
4
 
6
5
  class RackTest < Minitest::Test
7
6
  include Rack::Test::Methods
8
-
7
+
9
8
  class PathTemplateApp
10
9
  def call(env)
11
10
  env['INSTANA_HTTP_PATH_TEMPLATE'] = 'sample_template'
@@ -147,8 +146,9 @@ class RackTest < Minitest::Test
147
146
 
148
147
  def test_context_continuation
149
148
  clear_all!
150
- header 'X-INSTANA-T', Instana::Util.id_to_header(1234)
151
- header 'X-INSTANA-S', Instana::Util.id_to_header(4321)
149
+ continuation_id = Instana::Util.generate_id
150
+ header 'X-INSTANA-T', continuation_id
151
+ header 'X-INSTANA-S', continuation_id
152
152
 
153
153
  get '/mrlobster'
154
154
  assert last_response.ok?
@@ -182,10 +182,30 @@ class RackTest < Minitest::Test
182
182
  # Context validation
183
183
  # The first span should have the passed in trace ID
184
184
  # and specify the passed in span ID as it's parent.
185
- assert_equal 1234, rack_span[:t]
186
- assert_equal 4321, rack_span[:p]
185
+ assert_equal continuation_id, rack_span[:t]
186
+ assert_equal continuation_id, rack_span[:p]
187
187
  end
188
188
 
189
+ def test_correlation_information
190
+ clear_all!
191
+
192
+ header 'X-INSTANA-L', '1,correlationType=test;correlationId=abcdefh123'
193
+
194
+ get '/mrlobster'
195
+ assert last_response.ok?
196
+
197
+ spans = ::Instana.processor.queued_spans
198
+
199
+ # Span validation
200
+ assert_equal 1, spans.count
201
+ rack_span = spans.first
202
+ assert_equal :rack, rack_span[:n]
203
+
204
+ assert_equal 'abcdefh123', rack_span[:crid]
205
+ assert_equal 'test', rack_span[:crtp]
206
+ end
207
+
208
+
189
209
  def test_instana_response_headers
190
210
  clear_all!
191
211
  get '/mrlobster'
@@ -235,16 +255,16 @@ class RackTest < Minitest::Test
235
255
  ::Instana.config[:collect_backtraces] = false
236
256
  ::Instana.agent.extra_headers = nil
237
257
  end
238
-
258
+
239
259
  def test_capture_http_path_template
240
260
  clear_all!
241
-
261
+
242
262
  get '/path_tpl'
243
263
  assert last_response.ok?
244
-
264
+
245
265
  spans = ::Instana.processor.queued_spans
246
266
  assert_equal 1, spans.length
247
-
267
+
248
268
  rack_span = spans.first
249
269
  assert_equal :rack, rack_span[:n]
250
270
  assert_equal 'sample_template', rack_span[:data][:http][:path_tpl]
@@ -1,6 +1,13 @@
1
1
  require 'test_helper'
2
2
 
3
- class ActionControllerTest < Minitest::Test
3
+ class RailsActionControllerTest < Minitest::Test
4
+ include Rack::Test::Methods
5
+ APP = Rack::Builder.parse_file('test/support/apps/action_controller/config.ru').first
6
+
7
+ def app
8
+ APP
9
+ end
10
+
4
11
  def test_config_defaults
5
12
  assert ::Instana.config[:action_controller].is_a?(Hash)
6
13
  assert ::Instana.config[:action_controller].key?(:enabled)
@@ -10,33 +17,35 @@ class ActionControllerTest < Minitest::Test
10
17
  def test_controller_reporting
11
18
  clear_all!
12
19
 
13
- Net::HTTP.get(URI.parse('http://localhost:3205/test/world'))
20
+ get '/base/world'
21
+ assert last_response.ok?
14
22
 
15
23
  spans = ::Instana.processor.queued_spans
16
24
  assert_equal 3, spans.length
17
25
 
18
26
  ac_span = find_first_span_by_name(spans, :actioncontroller)
19
27
 
20
- assert_equal "TestController", ac_span[:data][:actioncontroller][:controller]
28
+ assert_equal "TestBaseController", ac_span[:data][:actioncontroller][:controller]
21
29
  assert_equal "world", ac_span[:data][:actioncontroller][:action]
22
30
  end
23
31
 
24
32
  def test_controller_error
25
33
  clear_all!
26
34
 
27
- Net::HTTP.get(URI.parse('http://localhost:3205/test/error'))
35
+ get '/base/error'
36
+ refute last_response.ok?
28
37
 
29
38
  spans = ::Instana.processor.queued_spans
30
39
  assert_equal 2, spans.length
31
40
 
32
41
  ac_span = find_first_span_by_name(spans, :actioncontroller)
33
42
 
34
- assert_equal "TestController", ac_span[:data][:actioncontroller][:controller]
43
+ assert_equal "TestBaseController", ac_span[:data][:actioncontroller][:controller]
35
44
  assert_equal "error", ac_span[:data][:actioncontroller][:action]
36
45
  assert ac_span.key?(:error)
37
46
  assert ac_span.key?(:stack)
38
47
  assert_equal "Warning: This is a simulated Error", ac_span[:data][:log][:message]
39
- assert_equal "Exception", ac_span[:data][:log][:parameters]
48
+ assert_equal "StandardError", ac_span[:data][:log][:parameters]
40
49
  end
41
50
 
42
51
  def test_api_controller_reporting
@@ -45,7 +54,8 @@ class ActionControllerTest < Minitest::Test
45
54
 
46
55
  clear_all!
47
56
 
48
- Net::HTTP.get(URI.parse('http://localhost:3205/api/world'))
57
+ get '/api/world'
58
+ assert last_response.ok?
49
59
 
50
60
  spans = ::Instana.processor.queued_spans
51
61
  assert_equal 3, spans.length
@@ -53,7 +63,7 @@ class ActionControllerTest < Minitest::Test
53
63
  ac_span = find_first_span_by_name(spans, :actioncontroller)
54
64
 
55
65
  assert_equal :actioncontroller, ac_span[:n]
56
- assert_equal "SocketController", ac_span[:data][:actioncontroller][:controller]
66
+ assert_equal "TestApiController", ac_span[:data][:actioncontroller][:controller]
57
67
  assert_equal "world", ac_span[:data][:actioncontroller][:action]
58
68
  end
59
69
 
@@ -63,28 +73,30 @@ class ActionControllerTest < Minitest::Test
63
73
 
64
74
  clear_all!
65
75
 
66
- Net::HTTP.get(URI.parse('http://localhost:3205/api/error'))
76
+ get '/api/error'
77
+ refute last_response.ok?
67
78
 
68
79
  spans = ::Instana.processor.queued_spans
69
80
  assert_equal 2, spans.length
70
81
 
71
82
  ac_span = find_first_span_by_name(spans, :actioncontroller)
72
83
 
73
- assert_equal "SocketController", ac_span[:data][:actioncontroller][:controller]
84
+ assert_equal "TestApiController", ac_span[:data][:actioncontroller][:controller]
74
85
  assert_equal "error", ac_span[:data][:actioncontroller][:action]
75
86
  assert ac_span.key?(:error)
76
87
  assert ac_span.key?(:stack)
77
88
  assert_equal "Warning: This is a simulated Socket API Error", ac_span[:data][:log][:message]
78
- assert_equal "Exception", ac_span[:data][:log][:parameters]
89
+ assert_equal "StandardError", ac_span[:data][:log][:parameters]
79
90
  end
80
91
 
81
- def test_api_controller_404
92
+ def test_api_controller_not_found
82
93
  # Run only when ActionController::API is used/defined
83
94
  skip unless defined?(::ActionController::API)
84
95
 
85
96
  clear_all!
86
97
 
87
- Net::HTTP.get(URI.parse('http://localhost:3205/api/thispathdoesnotexist'))
98
+ get '/api/thispathdoesnotexist'
99
+ refute last_response.ok?
88
100
 
89
101
  spans = ::Instana.processor.queued_spans
90
102
  assert_equal 1, spans.length
@@ -103,7 +115,8 @@ class ActionControllerTest < Minitest::Test
103
115
 
104
116
  clear_all!
105
117
 
106
- Net::HTTP.get(URI.parse('http://localhost:3205/api/raise_route_error'))
118
+ get '/api/raise_route_error'
119
+ refute last_response.ok?
107
120
 
108
121
  spans = ::Instana.processor.queued_spans
109
122
  assert_equal 2, spans.length
@@ -121,10 +134,11 @@ class ActionControllerTest < Minitest::Test
121
134
  assert 1, ac_span[:ec]
122
135
  end
123
136
 
124
- def test_404
137
+ def test_not_found
125
138
  clear_all!
126
139
 
127
- Net::HTTP.get(URI.parse('http://localhost:3205/test/404'))
140
+ get '/base/404'
141
+ refute last_response.ok?
128
142
 
129
143
  spans = ::Instana.processor.queued_spans
130
144
  assert_equal 1, spans.length
@@ -138,7 +152,8 @@ class ActionControllerTest < Minitest::Test
138
152
  def test_raise_routing_error
139
153
  clear_all!
140
154
 
141
- Net::HTTP.get(URI.parse('http://localhost:3205/test/raise_route_error'))
155
+ get '/base/raise_route_error'
156
+ refute last_response.ok?
142
157
 
143
158
  spans = ::Instana.processor.queued_spans
144
159
  assert_equal 2, spans.length
@@ -153,16 +168,17 @@ class ActionControllerTest < Minitest::Test
153
168
  assert ac_span.key?(:stack)
154
169
  assert 1, ac_span[:ec]
155
170
  end
156
-
171
+
157
172
  def test_path_template
158
173
  clear_all!
159
174
 
160
- Net::HTTP.get(URI.parse('http://localhost:3205/test/world'))
161
-
175
+ get '/base/world'
176
+ assert last_response.ok?
177
+
162
178
  spans = ::Instana.processor.queued_spans
163
179
  rack_span = find_first_span_by_name(spans, :rack)
164
180
 
165
181
  assert_equal false, rack_span.key?(:error)
166
- assert_equal '/test/world(.:format)', rack_span[:data][:http][:path_tpl]
182
+ assert_equal '/base/world(.:format)', rack_span[:data][:http][:path_tpl]
167
183
  end
168
184
  end
@@ -0,0 +1,148 @@
1
+ require 'test_helper'
2
+
3
+ class RailsActionViewTest < Minitest::Test
4
+ include Rack::Test::Methods
5
+ APP = Rack::Builder.parse_file('test/support/apps/action_view/config.ru').first
6
+
7
+ def app
8
+ APP
9
+ end
10
+
11
+ def setup
12
+ clear_all!
13
+ end
14
+
15
+ def test_config_defaults
16
+ assert ::Instana.config[:action_view].is_a?(Hash)
17
+ assert ::Instana.config[:action_view].key?(:enabled)
18
+ assert_equal true, ::Instana.config[:action_view][:enabled]
19
+ end
20
+
21
+ def test_render_view
22
+ get '/render_view'
23
+ assert last_response.ok?
24
+
25
+ spans = ::Instana.processor.queued_spans
26
+ span = find_first_span_by_name(spans, :actionview)
27
+
28
+ assert_equal 'Default', span[:data][:actionview][:name]
29
+ end
30
+
31
+ def test_render_view_direct
32
+ get '/render_view_direct'
33
+ assert last_response.ok?
34
+
35
+ spans = ::Instana.processor.queued_spans
36
+ span = find_first_span_by_name(spans, :actionview)
37
+
38
+ assert_equal 'Default', span[:data][:actionview][:name]
39
+ end
40
+
41
+ def test_render_nothing
42
+ # `render nothing: true` was removed in 5.1
43
+ skip unless Rails::VERSION::MAJOR <= 5 && Rails::VERSION::MINOR <= 1
44
+ get '/render_nothing'
45
+ assert last_response.ok?
46
+
47
+ spans = ::Instana.processor.queued_spans
48
+ span = find_first_span_by_name(spans, :actionview)
49
+
50
+ assert_equal 'Nothing', span[:data][:actionview][:name]
51
+ end
52
+
53
+ def test_render_file
54
+ get '/render_file'
55
+ assert last_response.ok?
56
+
57
+ spans = ::Instana.processor.queued_spans
58
+ span = find_first_span_by_name(spans, :actionview)
59
+
60
+ assert_equal 'test/support/apps/action_view/config.ru', span[:data][:actionview][:name]
61
+ end
62
+
63
+ def test_render_json
64
+ get '/render_json'
65
+ assert last_response.ok?
66
+
67
+ spans = ::Instana.processor.queued_spans
68
+ span = find_first_span_by_name(spans, :actionview)
69
+
70
+ assert_equal 'JSON', span[:data][:actionview][:name]
71
+ end
72
+
73
+ def test_render_xml
74
+ get '/render_xml'
75
+ assert last_response.ok?
76
+
77
+ spans = ::Instana.processor.queued_spans
78
+ span = find_first_span_by_name(spans, :actionview)
79
+
80
+ assert_equal 'XML', span[:data][:actionview][:name]
81
+ end
82
+
83
+ def test_render_body
84
+ get '/render_rawbody'
85
+ assert last_response.ok?
86
+
87
+ spans = ::Instana.processor.queued_spans
88
+ span = find_first_span_by_name(spans, :actionview)
89
+
90
+ assert_equal 'Raw', span[:data][:actionview][:name]
91
+ end
92
+
93
+ def test_render_js
94
+ get '/render_js'
95
+ assert last_response.ok?
96
+
97
+ spans = ::Instana.processor.queued_spans
98
+ span = find_first_span_by_name(spans, :actionview)
99
+
100
+ assert_equal 'Javascript', span[:data][:actionview][:name]
101
+ end
102
+
103
+ def test_render_alternate_layout
104
+ get '/render_alternate_layout'
105
+ assert last_response.ok?
106
+
107
+ spans = ::Instana.processor.queued_spans
108
+ span = find_first_span_by_name(spans, :actionview)
109
+
110
+ assert_equal 'layouts/mobile', span[:data][:actionview][:name]
111
+ end
112
+
113
+ def test_render_partial
114
+ get '/render_partial'
115
+ assert last_response.ok?
116
+
117
+ spans = ::Instana.processor.queued_spans
118
+ span = find_first_span_by_name(spans, :render)
119
+
120
+ assert_equal 'message', span[:data][:render][:name]
121
+ end
122
+
123
+ def test_render_partial_that_errors
124
+ get '/render_partial_that_errors'
125
+ refute last_response.ok?
126
+
127
+ spans = ::Instana.processor.queued_spans
128
+ span = find_first_span_by_name(spans, :render)
129
+
130
+ assert_equal :partial, span[:data][:render][:type]
131
+ assert_equal 'syntax_error', span[:data][:render][:name]
132
+ assert span[:data][:log].key?(:message)
133
+ assert span[:data][:log][:parameters].include?('SyntaxError')
134
+ assert span[:error]
135
+ assert span[:stack]
136
+ end
137
+
138
+ def test_render_collection
139
+ get '/render_collection'
140
+ assert last_response.ok?
141
+
142
+ spans = ::Instana.processor.queued_spans
143
+ span = find_first_span_by_name(spans, :render)
144
+
145
+ assert_equal :collection, span[:data][:render][:type]
146
+ assert_equal 'blocks/block', span[:data][:render][:name]
147
+ end
148
+ end