instana 1.192.1 → 1.193.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +200 -133
- data/.gitignore +3 -0
- data/.rubocop.yml +10 -1145
- data/.rubocop_todo.yml +1140 -0
- data/Appraisals +103 -0
- data/Gemfile +14 -32
- data/LICENSE +2 -1
- data/Rakefile +19 -39
- data/benchmarks/10k-rack-traces.rb +3 -0
- data/benchmarks/Gemfile +4 -0
- data/benchmarks/id_generation.rb +4 -0
- data/benchmarks/opentracing.rb +4 -0
- data/benchmarks/rack_vanilla_vs_traced.rb +3 -0
- data/benchmarks/stackprof_rack_tracing.rb +3 -0
- data/benchmarks/time_processing.rb +4 -0
- data/bin/console +8 -4
- data/examples/opentracing.rb +4 -0
- data/examples/tracing.rb +4 -0
- data/extras/license_header.rb +44 -0
- data/gemfiles/.bundle/config +1 -2
- data/gemfiles/cuba_30.gemfile +18 -0
- data/gemfiles/dalli_20.gemfile +18 -0
- data/gemfiles/excon_02.gemfile +18 -0
- data/gemfiles/graphql_10.gemfile +18 -0
- data/gemfiles/grpc_10.gemfile +18 -0
- data/gemfiles/net_http_01.gemfile +17 -0
- data/gemfiles/rack_16.gemfile +18 -0
- data/gemfiles/rack_20.gemfile +18 -0
- data/gemfiles/rails_42.gemfile +21 -0
- data/gemfiles/rails_50.gemfile +21 -0
- data/gemfiles/rails_52.gemfile +21 -0
- data/gemfiles/rails_60.gemfile +21 -0
- data/gemfiles/redis_40.gemfile +18 -0
- data/gemfiles/resque_122.gemfile +19 -0
- data/gemfiles/resque_20.gemfile +18 -0
- data/gemfiles/rest_client_16.gemfile +18 -0
- data/gemfiles/rest_client_20.gemfile +18 -0
- data/gemfiles/roda_20.gemfile +18 -0
- data/gemfiles/roda_30.gemfile +18 -0
- data/gemfiles/sidekiq_42.gemfile +18 -0
- data/gemfiles/sidekiq_50.gemfile +18 -0
- data/gemfiles/sinatra_14.gemfile +18 -0
- data/instana.gemspec +5 -7
- data/lib/instana.rb +3 -0
- data/lib/instana/activator.rb +44 -0
- data/lib/instana/activators/action_cable.rb +24 -0
- data/lib/instana/activators/action_controller_api.rb +21 -0
- data/lib/instana/activators/action_controller_base.rb +21 -0
- data/lib/instana/activators/action_view.rb +21 -0
- data/lib/instana/activators/active_record.rb +21 -0
- data/lib/instana/activators/cuba.rb +21 -0
- data/lib/instana/activators/dalli.rb +23 -0
- data/lib/instana/activators/excon.rb +20 -0
- data/lib/instana/activators/graphql.rb +22 -0
- data/lib/instana/activators/grpc_client.rb +20 -0
- data/lib/instana/activators/grpc_server.rb +20 -0
- data/lib/instana/activators/net_http.rb +20 -0
- data/lib/instana/activators/rack.rb +16 -0
- data/lib/instana/activators/rails.rb +18 -0
- data/lib/instana/activators/redis.rb +20 -0
- data/lib/instana/activators/resque_client.rb +21 -0
- data/lib/instana/activators/resque_worker.rb +33 -0
- data/lib/instana/activators/rest_client.rb +20 -0
- data/lib/instana/activators/roda.rb +21 -0
- data/lib/instana/activators/sidekiq_client.rb +24 -0
- data/lib/instana/activators/sidekiq_worker.rb +24 -0
- data/lib/instana/activators/sinatra.rb +21 -0
- data/lib/instana/agent.rb +3 -0
- data/lib/instana/agent/helpers.rb +3 -0
- data/lib/instana/agent/hooks.rb +3 -0
- data/lib/instana/agent/tasks.rb +3 -0
- data/lib/instana/base.rb +3 -0
- data/lib/instana/collector.rb +3 -0
- data/lib/instana/collectors/gc.rb +3 -0
- data/lib/instana/collectors/memory.rb +3 -0
- data/lib/instana/collectors/thread.rb +3 -0
- data/lib/instana/config.rb +3 -0
- data/lib/instana/frameworks/cuba.rb +9 -13
- data/lib/instana/frameworks/rails.rb +22 -32
- data/lib/instana/frameworks/roda.rb +10 -13
- data/lib/instana/frameworks/sinatra.rb +4 -8
- data/lib/instana/helpers.rb +3 -0
- data/lib/instana/instrumentation/action_cable.rb +53 -0
- data/lib/instana/instrumentation/action_controller.rb +84 -0
- data/lib/instana/instrumentation/action_view.rb +30 -0
- data/lib/instana/instrumentation/active_record.rb +50 -0
- data/lib/instana/instrumentation/dalli.rb +10 -18
- data/lib/instana/instrumentation/excon.rb +54 -57
- data/lib/instana/instrumentation/graphql.rb +19 -18
- data/lib/instana/instrumentation/grpc.rb +73 -66
- data/lib/instana/instrumentation/instrumented_request.rb +6 -1
- data/lib/instana/instrumentation/net-http.rb +46 -47
- data/lib/instana/instrumentation/rack.rb +4 -0
- data/lib/instana/instrumentation/redis.rb +13 -18
- data/lib/instana/instrumentation/resque.rb +17 -50
- data/lib/instana/instrumentation/rest-client.rb +5 -17
- data/lib/instana/instrumentation/sidekiq-client.rb +3 -9
- data/lib/instana/instrumentation/sidekiq-worker.rb +3 -9
- data/lib/instana/opentracing/carrier.rb +3 -0
- data/lib/instana/opentracing/tracer.rb +3 -0
- data/lib/instana/rack.rb +4 -0
- data/lib/instana/secrets.rb +10 -7
- data/lib/instana/setup.rb +6 -1
- data/lib/instana/thread_local.rb +3 -0
- data/lib/instana/tracer.rb +3 -0
- data/lib/instana/tracing/processor.rb +3 -0
- data/lib/instana/tracing/span.rb +3 -0
- data/lib/instana/tracing/span_context.rb +3 -0
- data/lib/instana/util.rb +4 -41
- data/lib/instana/version.rb +4 -1
- data/lib/oj_check.rb +3 -0
- data/lib/opentracing.rb +3 -0
- data/test/activator_test.rb +30 -0
- data/test/agent/agent_test.rb +3 -0
- data/test/benchmarks/bench_id_generation.rb +3 -0
- data/test/benchmarks/bench_opentracing.rb +3 -0
- data/test/config_test.rb +3 -0
- data/test/frameworks/cuba_test.rb +41 -40
- data/test/frameworks/roda_test.rb +43 -41
- data/test/frameworks/sinatra_test.rb +64 -64
- data/test/instana_test.rb +3 -0
- data/test/instrumentation/dalli_test.rb +3 -0
- data/test/instrumentation/excon_test.rb +4 -0
- data/test/instrumentation/graphql_test.rb +3 -0
- data/test/instrumentation/grpc_test.rb +5 -1
- data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +4 -0
- data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb} +4 -1
- data/test/{frameworks → instrumentation}/rack_test.rb +3 -1
- data/test/instrumentation/rails_action_cable_test.rb +131 -0
- data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +40 -21
- data/test/instrumentation/rails_action_view_test.rb +151 -0
- data/test/instrumentation/rails_active_record_test.rb +122 -0
- data/test/instrumentation/redis_test.rb +3 -0
- data/test/instrumentation/resque_test.rb +6 -11
- data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +9 -0
- data/test/instrumentation/sidekiq-client_test.rb +4 -0
- data/test/instrumentation/sidekiq-worker_test.rb +4 -0
- data/test/secrets_test.rb +3 -0
- data/test/support/apps/active_record/active_record.rb +24 -0
- data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +4 -1
- data/test/{apps → support/apps/grpc}/grpc_server.rb +3 -0
- data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +3 -0
- data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +10 -13
- data/test/{models → support/apps/rails/models}/block.rb +4 -1
- data/test/{models → support/apps/rails/models}/block6.rb +3 -0
- data/test/support/apps/resque/boot.rb +5 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +3 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +3 -0
- data/test/support/apps/sidekiq/boot.rb +25 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +3 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +3 -0
- data/test/{servers → support/apps}/sidekiq/worker.rb +5 -2
- data/test/support/helpers.rb +97 -0
- data/test/test_helper.rb +27 -144
- data/test/tracing/custom_test.rb +3 -0
- data/test/tracing/id_management_test.rb +4 -0
- data/test/tracing/opentracing_test.rb +3 -0
- data/test/tracing/tracer_async_test.rb +3 -0
- data/test/tracing/tracer_test.rb +3 -0
- metadata +105 -96
- data/gemfiles/libraries.gemfile +0 -73
- data/gemfiles/rails32.gemfile +0 -51
- data/gemfiles/rails42.gemfile +0 -50
- data/gemfiles/rails50.gemfile +0 -52
- data/gemfiles/rails52.gemfile +0 -52
- data/gemfiles/rails60.gemfile +0 -72
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
- data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
- data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
- data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -87
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -62
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -103
- data/lib/instana/instrumentation.rb +0 -25
- data/lib/instana/test.rb +0 -43
- data/test/apps/cuba.rb +0 -19
- data/test/apps/roda.rb +0 -13
- data/test/apps/sinatra.rb +0 -9
- data/test/frameworks/rails/actionview3_test.rb +0 -210
- data/test/frameworks/rails/actionview4_test.rb +0 -208
- data/test/frameworks/rails/actionview5_test.rb +0 -221
- data/test/frameworks/rails/activerecord_test.rb +0 -279
- data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
data/test/instana_test.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2017
|
3
|
+
|
1
4
|
require 'test_helper'
|
5
|
+
require 'support/apps/grpc/boot'
|
2
6
|
|
3
7
|
class GrpcTest < Minitest::Test
|
4
8
|
def client_stub
|
@@ -225,7 +229,7 @@ class GrpcTest < Minitest::Test
|
|
225
229
|
server_span = find_spans_by_name(spans, :'rpc-server').first
|
226
230
|
|
227
231
|
validate_sdk_span(sdk_span)
|
228
|
-
|
232
|
+
|
229
233
|
assert_client_span(
|
230
234
|
client_span,
|
231
235
|
call: '/PingPongService/FailToPing',
|
data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb}
RENAMED
@@ -1,6 +1,9 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
1
4
|
require 'test_helper'
|
2
5
|
|
3
|
-
class
|
6
|
+
class RackInstrumentedRequestTest < Minitest::Test
|
4
7
|
def test_skip_trace_with_header
|
5
8
|
req = Instana::InstrumentedRequest.new(
|
6
9
|
'HTTP_X_INSTANA_L' => '0;sample-data'
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
require 'rails'
|
7
|
+
require 'action_cable'
|
8
|
+
|
9
|
+
require 'ostruct'
|
10
|
+
require 'logger'
|
11
|
+
|
12
|
+
class RailsActionCableTest < Minitest::Test
|
13
|
+
def setup
|
14
|
+
skip unless defined?(::ActionCable::Connection::Base)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_transmit_no_parent
|
18
|
+
clear_all!
|
19
|
+
|
20
|
+
connection = mock_connection
|
21
|
+
channel_klass = Class.new(ActionCable::Channel::Base)
|
22
|
+
|
23
|
+
channel_klass
|
24
|
+
.new(connection, :test)
|
25
|
+
.send(:transmit, 'action' => 'sample')
|
26
|
+
|
27
|
+
span, rest = Instana.processor.queued_spans
|
28
|
+
data = span[:data]
|
29
|
+
|
30
|
+
assert_nil rest
|
31
|
+
assert :"rpc-server", span[:n]
|
32
|
+
assert :actioncable, data[:rpc][:flavor]
|
33
|
+
assert channel_klass.to_s, data[:rpc][:call]
|
34
|
+
assert :transmit, data[:rpc][:call_type]
|
35
|
+
assert Socket.gethostname, data[:rpc][:host]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_transmit_parent
|
39
|
+
clear_all!
|
40
|
+
|
41
|
+
connection = mock_connection
|
42
|
+
connection.instance_variable_set(
|
43
|
+
:@instana_trace_context,
|
44
|
+
Instana::SpanContext.new('ABC', 'ABC')
|
45
|
+
)
|
46
|
+
channel_klass = Class.new(ActionCable::Channel::Base)
|
47
|
+
|
48
|
+
channel_klass
|
49
|
+
.new(connection, :test)
|
50
|
+
.send(:transmit, 'action' => 'sample')
|
51
|
+
|
52
|
+
span, rest = Instana.processor.queued_spans
|
53
|
+
data = span[:data]
|
54
|
+
|
55
|
+
assert_nil rest
|
56
|
+
assert 'ABC', span[:t]
|
57
|
+
assert :"rpc-server", span[:n]
|
58
|
+
assert :actioncable, data[:rpc][:flavor]
|
59
|
+
assert channel_klass.to_s, data[:rpc][:call]
|
60
|
+
assert :transmit, data[:rpc][:call_type]
|
61
|
+
assert Socket.gethostname, data[:rpc][:host]
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_action_no_parent
|
65
|
+
clear_all!
|
66
|
+
|
67
|
+
connection = mock_connection
|
68
|
+
channel_klass = Class.new(ActionCable::Channel::Base) do
|
69
|
+
def sample
|
70
|
+
raise unless Instana.tracer.tracing?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
channel_klass
|
75
|
+
.new(connection, :test)
|
76
|
+
.perform_action('action' => 'sample')
|
77
|
+
|
78
|
+
span, rest = Instana.processor.queued_spans
|
79
|
+
data = span[:data]
|
80
|
+
|
81
|
+
assert_nil rest
|
82
|
+
assert :"rpc-server", span[:n]
|
83
|
+
assert :actioncable, data[:rpc][:flavor]
|
84
|
+
assert "#{channel_klass}#sample", data[:rpc][:call]
|
85
|
+
assert :action, data[:rpc][:call_type]
|
86
|
+
assert Socket.gethostname, data[:rpc][:host]
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_action_parent
|
90
|
+
clear_all!
|
91
|
+
|
92
|
+
connection = mock_connection
|
93
|
+
connection.instance_variable_set(
|
94
|
+
:@instana_trace_context,
|
95
|
+
Instana::SpanContext.new('ABC', 'ABC')
|
96
|
+
)
|
97
|
+
channel_klass = Class.new(ActionCable::Channel::Base) do
|
98
|
+
def sample
|
99
|
+
raise unless Instana.tracer.tracing?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
channel_klass
|
104
|
+
.new(connection, :test)
|
105
|
+
.perform_action('action' => 'sample')
|
106
|
+
|
107
|
+
span, rest = Instana.processor.queued_spans
|
108
|
+
data = span[:data]
|
109
|
+
|
110
|
+
assert_nil rest
|
111
|
+
assert 'ABC', span[:t]
|
112
|
+
assert :"rpc-server", span[:n]
|
113
|
+
assert :actioncable, data[:rpc][:flavor]
|
114
|
+
assert "#{channel_klass}#sample", data[:rpc][:call]
|
115
|
+
assert :action, data[:rpc][:call_type]
|
116
|
+
assert Socket.gethostname, data[:rpc][:host]
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def mock_connection
|
122
|
+
server = OpenStruct.new(
|
123
|
+
logger: Logger.new('/dev/null'),
|
124
|
+
worker_pool: nil,
|
125
|
+
config: OpenStruct.new(log_tags: [])
|
126
|
+
)
|
127
|
+
connection = ActionCable::Connection::Base.new(server, {})
|
128
|
+
connection.define_singleton_method(:transmit) { |*_args| true }
|
129
|
+
connection
|
130
|
+
end
|
131
|
+
end
|
@@ -1,6 +1,16 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2017
|
3
|
+
|
1
4
|
require 'test_helper'
|
2
5
|
|
3
|
-
class
|
6
|
+
class RailsActionControllerTest < Minitest::Test
|
7
|
+
include Rack::Test::Methods
|
8
|
+
APP = Rack::Builder.parse_file('test/support/apps/action_controller/config.ru').first
|
9
|
+
|
10
|
+
def app
|
11
|
+
APP
|
12
|
+
end
|
13
|
+
|
4
14
|
def test_config_defaults
|
5
15
|
assert ::Instana.config[:action_controller].is_a?(Hash)
|
6
16
|
assert ::Instana.config[:action_controller].key?(:enabled)
|
@@ -10,33 +20,35 @@ class ActionControllerTest < Minitest::Test
|
|
10
20
|
def test_controller_reporting
|
11
21
|
clear_all!
|
12
22
|
|
13
|
-
|
23
|
+
get '/base/world'
|
24
|
+
assert last_response.ok?
|
14
25
|
|
15
26
|
spans = ::Instana.processor.queued_spans
|
16
27
|
assert_equal 3, spans.length
|
17
28
|
|
18
29
|
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
19
30
|
|
20
|
-
assert_equal "
|
31
|
+
assert_equal "TestBaseController", ac_span[:data][:actioncontroller][:controller]
|
21
32
|
assert_equal "world", ac_span[:data][:actioncontroller][:action]
|
22
33
|
end
|
23
34
|
|
24
35
|
def test_controller_error
|
25
36
|
clear_all!
|
26
37
|
|
27
|
-
|
38
|
+
get '/base/error'
|
39
|
+
refute last_response.ok?
|
28
40
|
|
29
41
|
spans = ::Instana.processor.queued_spans
|
30
42
|
assert_equal 2, spans.length
|
31
43
|
|
32
44
|
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
33
45
|
|
34
|
-
assert_equal "
|
46
|
+
assert_equal "TestBaseController", ac_span[:data][:actioncontroller][:controller]
|
35
47
|
assert_equal "error", ac_span[:data][:actioncontroller][:action]
|
36
48
|
assert ac_span.key?(:error)
|
37
49
|
assert ac_span.key?(:stack)
|
38
50
|
assert_equal "Warning: This is a simulated Error", ac_span[:data][:log][:message]
|
39
|
-
assert_equal "
|
51
|
+
assert_equal "StandardError", ac_span[:data][:log][:parameters]
|
40
52
|
end
|
41
53
|
|
42
54
|
def test_api_controller_reporting
|
@@ -45,7 +57,8 @@ class ActionControllerTest < Minitest::Test
|
|
45
57
|
|
46
58
|
clear_all!
|
47
59
|
|
48
|
-
|
60
|
+
get '/api/world'
|
61
|
+
assert last_response.ok?
|
49
62
|
|
50
63
|
spans = ::Instana.processor.queued_spans
|
51
64
|
assert_equal 3, spans.length
|
@@ -53,7 +66,7 @@ class ActionControllerTest < Minitest::Test
|
|
53
66
|
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
54
67
|
|
55
68
|
assert_equal :actioncontroller, ac_span[:n]
|
56
|
-
assert_equal "
|
69
|
+
assert_equal "TestApiController", ac_span[:data][:actioncontroller][:controller]
|
57
70
|
assert_equal "world", ac_span[:data][:actioncontroller][:action]
|
58
71
|
end
|
59
72
|
|
@@ -63,28 +76,30 @@ class ActionControllerTest < Minitest::Test
|
|
63
76
|
|
64
77
|
clear_all!
|
65
78
|
|
66
|
-
|
79
|
+
get '/api/error'
|
80
|
+
refute last_response.ok?
|
67
81
|
|
68
82
|
spans = ::Instana.processor.queued_spans
|
69
83
|
assert_equal 2, spans.length
|
70
84
|
|
71
85
|
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
72
86
|
|
73
|
-
assert_equal "
|
87
|
+
assert_equal "TestApiController", ac_span[:data][:actioncontroller][:controller]
|
74
88
|
assert_equal "error", ac_span[:data][:actioncontroller][:action]
|
75
89
|
assert ac_span.key?(:error)
|
76
90
|
assert ac_span.key?(:stack)
|
77
91
|
assert_equal "Warning: This is a simulated Socket API Error", ac_span[:data][:log][:message]
|
78
|
-
assert_equal "
|
92
|
+
assert_equal "StandardError", ac_span[:data][:log][:parameters]
|
79
93
|
end
|
80
94
|
|
81
|
-
def
|
95
|
+
def test_api_controller_not_found
|
82
96
|
# Run only when ActionController::API is used/defined
|
83
97
|
skip unless defined?(::ActionController::API)
|
84
98
|
|
85
99
|
clear_all!
|
86
100
|
|
87
|
-
|
101
|
+
get '/api/thispathdoesnotexist'
|
102
|
+
refute last_response.ok?
|
88
103
|
|
89
104
|
spans = ::Instana.processor.queued_spans
|
90
105
|
assert_equal 1, spans.length
|
@@ -103,7 +118,8 @@ class ActionControllerTest < Minitest::Test
|
|
103
118
|
|
104
119
|
clear_all!
|
105
120
|
|
106
|
-
|
121
|
+
get '/api/raise_route_error'
|
122
|
+
refute last_response.ok?
|
107
123
|
|
108
124
|
spans = ::Instana.processor.queued_spans
|
109
125
|
assert_equal 2, spans.length
|
@@ -121,10 +137,11 @@ class ActionControllerTest < Minitest::Test
|
|
121
137
|
assert 1, ac_span[:ec]
|
122
138
|
end
|
123
139
|
|
124
|
-
def
|
140
|
+
def test_not_found
|
125
141
|
clear_all!
|
126
142
|
|
127
|
-
|
143
|
+
get '/base/404'
|
144
|
+
refute last_response.ok?
|
128
145
|
|
129
146
|
spans = ::Instana.processor.queued_spans
|
130
147
|
assert_equal 1, spans.length
|
@@ -138,7 +155,8 @@ class ActionControllerTest < Minitest::Test
|
|
138
155
|
def test_raise_routing_error
|
139
156
|
clear_all!
|
140
157
|
|
141
|
-
|
158
|
+
get '/base/raise_route_error'
|
159
|
+
refute last_response.ok?
|
142
160
|
|
143
161
|
spans = ::Instana.processor.queued_spans
|
144
162
|
assert_equal 2, spans.length
|
@@ -153,16 +171,17 @@ class ActionControllerTest < Minitest::Test
|
|
153
171
|
assert ac_span.key?(:stack)
|
154
172
|
assert 1, ac_span[:ec]
|
155
173
|
end
|
156
|
-
|
174
|
+
|
157
175
|
def test_path_template
|
158
176
|
clear_all!
|
159
177
|
|
160
|
-
|
161
|
-
|
178
|
+
get '/base/world'
|
179
|
+
assert last_response.ok?
|
180
|
+
|
162
181
|
spans = ::Instana.processor.queued_spans
|
163
182
|
rack_span = find_first_span_by_name(spans, :rack)
|
164
183
|
|
165
184
|
assert_equal false, rack_span.key?(:error)
|
166
|
-
assert_equal '/
|
185
|
+
assert_equal '/base/world(.:format)', rack_span[:data][:http][:path_tpl]
|
167
186
|
end
|
168
187
|
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class RailsActionViewTest < Minitest::Test
|
7
|
+
include Rack::Test::Methods
|
8
|
+
APP = Rack::Builder.parse_file('test/support/apps/action_view/config.ru').first
|
9
|
+
|
10
|
+
def app
|
11
|
+
APP
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
clear_all!
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_config_defaults
|
19
|
+
assert ::Instana.config[:action_view].is_a?(Hash)
|
20
|
+
assert ::Instana.config[:action_view].key?(:enabled)
|
21
|
+
assert_equal true, ::Instana.config[:action_view][:enabled]
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_render_view
|
25
|
+
get '/render_view'
|
26
|
+
assert last_response.ok?
|
27
|
+
|
28
|
+
spans = ::Instana.processor.queued_spans
|
29
|
+
span = find_first_span_by_name(spans, :actionview)
|
30
|
+
|
31
|
+
assert_equal 'Default', span[:data][:actionview][:name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_render_view_direct
|
35
|
+
get '/render_view_direct'
|
36
|
+
assert last_response.ok?
|
37
|
+
|
38
|
+
spans = ::Instana.processor.queued_spans
|
39
|
+
span = find_first_span_by_name(spans, :actionview)
|
40
|
+
|
41
|
+
assert_equal 'Default', span[:data][:actionview][:name]
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_render_nothing
|
45
|
+
# `render nothing: true` was removed in 5.1
|
46
|
+
skip unless Rails::VERSION::MAJOR <= 5 && Rails::VERSION::MINOR <= 1
|
47
|
+
get '/render_nothing'
|
48
|
+
assert last_response.ok?
|
49
|
+
|
50
|
+
spans = ::Instana.processor.queued_spans
|
51
|
+
span = find_first_span_by_name(spans, :actionview)
|
52
|
+
|
53
|
+
assert_equal 'Nothing', span[:data][:actionview][:name]
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_render_file
|
57
|
+
get '/render_file'
|
58
|
+
assert last_response.ok?
|
59
|
+
|
60
|
+
spans = ::Instana.processor.queued_spans
|
61
|
+
span = find_first_span_by_name(spans, :actionview)
|
62
|
+
|
63
|
+
assert_equal 'test/support/apps/action_view/config.ru', span[:data][:actionview][:name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_render_json
|
67
|
+
get '/render_json'
|
68
|
+
assert last_response.ok?
|
69
|
+
|
70
|
+
spans = ::Instana.processor.queued_spans
|
71
|
+
span = find_first_span_by_name(spans, :actionview)
|
72
|
+
|
73
|
+
assert_equal 'JSON', span[:data][:actionview][:name]
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_render_xml
|
77
|
+
get '/render_xml'
|
78
|
+
assert last_response.ok?
|
79
|
+
|
80
|
+
spans = ::Instana.processor.queued_spans
|
81
|
+
span = find_first_span_by_name(spans, :actionview)
|
82
|
+
|
83
|
+
assert_equal 'XML', span[:data][:actionview][:name]
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_render_body
|
87
|
+
get '/render_rawbody'
|
88
|
+
assert last_response.ok?
|
89
|
+
|
90
|
+
spans = ::Instana.processor.queued_spans
|
91
|
+
span = find_first_span_by_name(spans, :actionview)
|
92
|
+
|
93
|
+
assert_equal 'Raw', span[:data][:actionview][:name]
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_render_js
|
97
|
+
get '/render_js'
|
98
|
+
assert last_response.ok?
|
99
|
+
|
100
|
+
spans = ::Instana.processor.queued_spans
|
101
|
+
span = find_first_span_by_name(spans, :actionview)
|
102
|
+
|
103
|
+
assert_equal 'Javascript', span[:data][:actionview][:name]
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_render_alternate_layout
|
107
|
+
get '/render_alternate_layout'
|
108
|
+
assert last_response.ok?
|
109
|
+
|
110
|
+
spans = ::Instana.processor.queued_spans
|
111
|
+
span = find_first_span_by_name(spans, :actionview)
|
112
|
+
|
113
|
+
assert_equal 'layouts/mobile', span[:data][:actionview][:name]
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_render_partial
|
117
|
+
get '/render_partial'
|
118
|
+
assert last_response.ok?
|
119
|
+
|
120
|
+
spans = ::Instana.processor.queued_spans
|
121
|
+
span = find_first_span_by_name(spans, :render)
|
122
|
+
|
123
|
+
assert_equal 'message', span[:data][:render][:name]
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_render_partial_that_errors
|
127
|
+
get '/render_partial_that_errors'
|
128
|
+
refute last_response.ok?
|
129
|
+
|
130
|
+
spans = ::Instana.processor.queued_spans
|
131
|
+
span = find_first_span_by_name(spans, :render)
|
132
|
+
|
133
|
+
assert_equal :partial, span[:data][:render][:type]
|
134
|
+
assert_equal 'syntax_error', span[:data][:render][:name]
|
135
|
+
assert span[:data][:log].key?(:message)
|
136
|
+
assert span[:data][:log][:parameters].include?('SyntaxError')
|
137
|
+
assert span[:error]
|
138
|
+
assert span[:stack]
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_render_collection
|
142
|
+
get '/render_collection'
|
143
|
+
assert last_response.ok?
|
144
|
+
|
145
|
+
spans = ::Instana.processor.queued_spans
|
146
|
+
span = find_first_span_by_name(spans, :render)
|
147
|
+
|
148
|
+
assert_equal :collection, span[:data][:render][:type]
|
149
|
+
assert_equal 'blocks/block', span[:data][:render][:name]
|
150
|
+
end
|
151
|
+
end
|