instana 1.4.11 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/gemfiles/libraries.gemfile +5 -2
- data/lib/instana/config.rb +1 -0
- data/lib/instana/instrumentation/grpc.rb +84 -0
- data/lib/instana/tracing/span.rb +6 -4
- data/lib/instana/version.rb +1 -1
- data/test/apps/grpc_server.rb +81 -0
- data/test/instrumentation/grpc_test.rb +317 -0
- data/test/servers/grpc_50051.rb +20 -0
- data/test/test_helper.rb +2 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bead9a4a515329922c151505eae7f209c49be9d2
|
4
|
+
data.tar.gz: bb7eb569bb0127e6d245858f3bbe595b1c8a62d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbe325aa85a8bca25ae4aaa0cd4317d2476d9b475d1fbd497722ccd3ea54472482f42f78cc1d7d035c4305344fd3fbc9e8531feb1dd4dcd5208aab20c14f5ae6
|
7
|
+
data.tar.gz: 4cfd9167eec7ad906cea0259c238ed47efa07748a6ba8aaa8de243b4a957632576b8ffebc98ae308d729226c714d1a06bd7ac6c43676e17b1aefb017a575dc9d
|
data/.gitignore
CHANGED
data/gemfiles/libraries.gemfile
CHANGED
@@ -13,10 +13,10 @@ end
|
|
13
13
|
group :development do
|
14
14
|
gem 'ruby-debug', :platforms => [:mri_18, :jruby]
|
15
15
|
gem 'debugger', :platform => :mri_19
|
16
|
-
gem 'byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23]
|
16
|
+
gem 'byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24]
|
17
17
|
if RUBY_VERSION > '1.8.7'
|
18
18
|
gem 'pry'
|
19
|
-
gem 'pry-byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23]
|
19
|
+
gem 'pry-byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24]
|
20
20
|
else
|
21
21
|
gem 'pry', '0.9.12.4'
|
22
22
|
end
|
@@ -27,6 +27,9 @@ gem "sinatra", '1.4.7'
|
|
27
27
|
gem "cuba"
|
28
28
|
gem "roda"
|
29
29
|
|
30
|
+
# gRPC
|
31
|
+
gem 'grpc'
|
32
|
+
|
30
33
|
# HTTP Clients
|
31
34
|
gem 'rest-client'
|
32
35
|
|
data/lib/instana/config.rb
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
call_types = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
2
|
+
|
3
|
+
if defined?(GRPC::ActiveCall) && ::Instana.config[:grpc][:enabled]
|
4
|
+
call_types.each do |call_type|
|
5
|
+
GRPC::ClientStub.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
6
|
+
def #{call_type}_with_instana(method, *others, **options)
|
7
|
+
kvs = { rpc: {} }
|
8
|
+
|
9
|
+
unless ::Instana.tracer.tracing?
|
10
|
+
return #{call_type}_without_instana(method, *others, **options)
|
11
|
+
end
|
12
|
+
|
13
|
+
kvs[:rpc][:flavor] = :grpc
|
14
|
+
kvs[:rpc][:host] = @host
|
15
|
+
kvs[:rpc][:call] = method
|
16
|
+
kvs[:rpc][:call_type] = :#{call_type}
|
17
|
+
|
18
|
+
::Instana.tracer.log_entry(:'rpc-client', kvs)
|
19
|
+
|
20
|
+
context = ::Instana.tracer.context
|
21
|
+
if context
|
22
|
+
options[:metadata] = (options[:metadata] || {}).merge(
|
23
|
+
'x-instana-t' => context.trace_id_header,
|
24
|
+
'x-instana-s' => context.span_id_header
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
#{call_type}_without_instana(method, *others, **options)
|
29
|
+
rescue => e
|
30
|
+
kvs[:rpc][:error] = true
|
31
|
+
::Instana.tracer.log_info(kvs)
|
32
|
+
::Instana.tracer.log_error(e)
|
33
|
+
raise
|
34
|
+
ensure
|
35
|
+
::Instana.tracer.log_exit(:'rpc-client', {})
|
36
|
+
end
|
37
|
+
|
38
|
+
alias #{call_type}_without_instana #{call_type}
|
39
|
+
alias #{call_type} #{call_type}_with_instana
|
40
|
+
RUBY
|
41
|
+
end
|
42
|
+
::Instana.logger.warn 'Instrumenting GRPC client'
|
43
|
+
end
|
44
|
+
|
45
|
+
if defined?(GRPC::RpcDesc) && ::Instana.config[:grpc][:enabled]
|
46
|
+
call_types.each do |call_type|
|
47
|
+
GRPC::RpcDesc.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
48
|
+
def handle_#{call_type}_with_instana(active_call, mth)
|
49
|
+
kvs = { rpc: {} }
|
50
|
+
metadata = active_call.metadata
|
51
|
+
|
52
|
+
incoming_context = {}
|
53
|
+
if metadata.key?('x-instana-t')
|
54
|
+
incoming_context[:trace_id] = ::Instana::Util.header_to_id(metadata['x-instana-t'])
|
55
|
+
incoming_context[:span_id] = ::Instana::Util.header_to_id(metadata['x-instana-s']) if metadata.key?('x-instana-s')
|
56
|
+
incoming_context[:level] = metadata['x-instana-l'] if metadata.key?('x-instana-l')
|
57
|
+
end
|
58
|
+
|
59
|
+
kvs[:rpc][:flavor] = :grpc
|
60
|
+
kvs[:rpc][:host] = Socket.gethostname
|
61
|
+
kvs[:rpc][:call] = "/\#{mth.owner.service_name}/\#{name}"
|
62
|
+
kvs[:rpc][:call_type] = :#{call_type}
|
63
|
+
kvs[:rpc][:peer] = { address: active_call.peer }
|
64
|
+
|
65
|
+
::Instana.tracer.log_start_or_continue(
|
66
|
+
:'rpc-server', kvs, incoming_context
|
67
|
+
)
|
68
|
+
|
69
|
+
handle_#{call_type}_without_instana(active_call, mth)
|
70
|
+
rescue => e
|
71
|
+
kvs[:rpc][:error] = true
|
72
|
+
::Instana.tracer.log_info(kvs)
|
73
|
+
::Instana.tracer.log_error(e)
|
74
|
+
raise
|
75
|
+
ensure
|
76
|
+
::Instana.tracer.log_end(:'rpc-server', {}) if ::Instana.tracer.tracing?
|
77
|
+
end
|
78
|
+
|
79
|
+
alias handle_#{call_type}_without_instana handle_#{call_type}
|
80
|
+
alias handle_#{call_type} handle_#{call_type}_with_instana
|
81
|
+
RUBY
|
82
|
+
end
|
83
|
+
::Instana.logger.warn 'Instrumenting GRPC server'
|
84
|
+
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Instana
|
2
2
|
class Span
|
3
|
-
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
4
|
+
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
5
|
+
:'rpc-server' ].freeze
|
6
|
+
ENTRY_SPANS = [ :rack, :'rpc-server' ].freeze
|
7
|
+
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'rpc-client' ].freeze
|
8
|
+
HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
|
7
9
|
|
8
10
|
attr_accessor :parent
|
9
11
|
attr_accessor :baggage
|
data/lib/instana/version.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'google/protobuf'
|
2
|
+
|
3
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
4
|
+
add_message "PingPongService.PingRequest" do
|
5
|
+
optional :message, :string, 1
|
6
|
+
end
|
7
|
+
add_message "PingPongService.PongReply" do
|
8
|
+
optional :message, :string, 1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module PingPongService
|
13
|
+
PingRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPongService.PingRequest").msgclass
|
14
|
+
PongReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPongService.PongReply").msgclass
|
15
|
+
end
|
16
|
+
require 'grpc'
|
17
|
+
|
18
|
+
module PingPongService
|
19
|
+
# The greeting service definition.
|
20
|
+
class Service
|
21
|
+
include GRPC::GenericService
|
22
|
+
|
23
|
+
self.marshal_class_method = :encode
|
24
|
+
self.unmarshal_class_method = :decode
|
25
|
+
self.service_name = 'PingPongService'
|
26
|
+
|
27
|
+
rpc :Ping, PingRequest, PongReply
|
28
|
+
rpc :PingWithClientStream, stream(PingRequest), PongReply
|
29
|
+
rpc :PingWithServerStream, PingRequest, stream(PongReply)
|
30
|
+
rpc :PingWithBidiStream, stream(PingRequest), stream(PongReply)
|
31
|
+
|
32
|
+
rpc :FailToPing, PingRequest, PongReply
|
33
|
+
rpc :FailToPingWithClientStream, stream(PingRequest), PongReply
|
34
|
+
rpc :FailToPingWithServerStream, PingRequest, stream(PongReply)
|
35
|
+
rpc :FailToPingWithBidiStream, stream(PingRequest), stream(PongReply)
|
36
|
+
end
|
37
|
+
|
38
|
+
Stub = Service.rpc_stub_class
|
39
|
+
end
|
40
|
+
|
41
|
+
class PingPongServer < PingPongService::Service
|
42
|
+
def ping(ping_request, active_call)
|
43
|
+
PingPongService::PongReply.new(message: "Hello #{ping_request.message}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def ping_with_client_stream(active_call)
|
47
|
+
message = ''
|
48
|
+
active_call.each_remote_read do |req|
|
49
|
+
message += req.message
|
50
|
+
end
|
51
|
+
PingPongService::PongReply.new(message: message)
|
52
|
+
end
|
53
|
+
|
54
|
+
def ping_with_server_stream(ping_request, active_call)
|
55
|
+
(0..5).map do |index|
|
56
|
+
PingPongService::PongReply.new(message: index.to_s)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def ping_with_bidi_stream(ping_requests)
|
61
|
+
ping_requests.map do |ping_request|
|
62
|
+
PingPongService::PongReply.new(message: ping_request.message)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def fail_to_ping(ping_request, active_call)
|
67
|
+
raise 'Unexpected failed'
|
68
|
+
end
|
69
|
+
|
70
|
+
def fail_to_ping_with_client_stream(active_call)
|
71
|
+
raise 'Unexpected failed'
|
72
|
+
end
|
73
|
+
|
74
|
+
def fail_to_ping_with_server_stream(ping_request, active_call)
|
75
|
+
raise 'Unexpected failed'
|
76
|
+
end
|
77
|
+
|
78
|
+
def fail_to_ping_with_bidi_stream(ping_requests)
|
79
|
+
raise 'Unexpected failed'
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GrpcTest < Minitest::Test
|
4
|
+
def client_stub
|
5
|
+
PingPongService::Stub.new('127.0.0.1:50051', :this_channel_is_insecure)
|
6
|
+
end
|
7
|
+
|
8
|
+
# The order of traces are non-deterministic, could not predict
|
9
|
+
# which trace is server or client. This method is to choose the
|
10
|
+
# right trace based on span's name
|
11
|
+
def differentiate_trace(traces)
|
12
|
+
trying_client = traces[0]
|
13
|
+
trying_server = traces[1]
|
14
|
+
|
15
|
+
try_successfully = trying_client.spans.any? do |span|
|
16
|
+
span.name == :'rpc-client'
|
17
|
+
end
|
18
|
+
|
19
|
+
if try_successfully
|
20
|
+
[trying_client, trying_server]
|
21
|
+
else
|
22
|
+
[trying_server, trying_client]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_client_trace(client_trace, call: '', call_type: '', error: nil)
|
27
|
+
assert_equal 2, client_trace.spans.count
|
28
|
+
spans = client_trace.spans.to_a
|
29
|
+
first_span = spans[0]
|
30
|
+
second_span = spans[1]
|
31
|
+
|
32
|
+
# Span name validation
|
33
|
+
assert_equal :sdk, first_span[:n]
|
34
|
+
assert_equal :rpctests, first_span[:data][:sdk][:name]
|
35
|
+
assert_equal :'rpc-client', second_span[:n]
|
36
|
+
|
37
|
+
# first_span is the parent of second_span
|
38
|
+
assert_equal first_span.id, second_span[:p]
|
39
|
+
|
40
|
+
data = second_span[:data]
|
41
|
+
assert_equal '127.0.0.1:50051', data[:rpc][:host]
|
42
|
+
assert_equal :grpc, data[:rpc][:flavor]
|
43
|
+
assert_equal call, data[:rpc][:call]
|
44
|
+
assert_equal call_type, data[:rpc][:call_type]
|
45
|
+
|
46
|
+
if error
|
47
|
+
assert_equal true, data[:rpc][:error]
|
48
|
+
assert_equal "2:RuntimeError: #{error}", data[:log][:message]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def assert_server_trace(server_trace, call: '', call_type: '', error: nil)
|
53
|
+
assert_equal 1, server_trace.spans.count
|
54
|
+
span = server_trace.spans.to_a.first
|
55
|
+
|
56
|
+
# Span name validation
|
57
|
+
assert_equal :'rpc-server', span[:n]
|
58
|
+
|
59
|
+
data = span[:data]
|
60
|
+
assert_equal :grpc, data[:rpc][:flavor]
|
61
|
+
assert_equal call, data[:rpc][:call]
|
62
|
+
assert_equal call_type, data[:rpc][:call_type]
|
63
|
+
|
64
|
+
if error
|
65
|
+
assert_equal true, data[:rpc][:error]
|
66
|
+
assert_equal error, data[:log][:message]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_request_response
|
71
|
+
clear_all!
|
72
|
+
response = nil
|
73
|
+
|
74
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
75
|
+
response = client_stub.ping(
|
76
|
+
PingPongService::PingRequest.new(message: 'Hello World')
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
assert 'Hello World', response.message
|
81
|
+
|
82
|
+
assert_equal 2, ::Instana.processor.queue_count
|
83
|
+
client_trace, server_trace = differentiate_trace(
|
84
|
+
Instana.processor.queued_traces
|
85
|
+
)
|
86
|
+
|
87
|
+
assert_client_trace(
|
88
|
+
client_trace,
|
89
|
+
call: '/PingPongService/Ping',
|
90
|
+
call_type: :request_response
|
91
|
+
)
|
92
|
+
|
93
|
+
assert_server_trace(
|
94
|
+
server_trace,
|
95
|
+
call: '/PingPongService/Ping',
|
96
|
+
call_type: :request_response
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_client_streamer
|
101
|
+
clear_all!
|
102
|
+
response = nil
|
103
|
+
|
104
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
105
|
+
response = client_stub.ping_with_client_stream(
|
106
|
+
(0..5).map do |index|
|
107
|
+
PingPongService::PingRequest.new(message: index.to_s)
|
108
|
+
end
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
assert '01234', response.message
|
113
|
+
|
114
|
+
assert_equal 2, ::Instana.processor.queue_count
|
115
|
+
client_trace, server_trace = differentiate_trace(
|
116
|
+
Instana.processor.queued_traces
|
117
|
+
)
|
118
|
+
|
119
|
+
assert_client_trace(
|
120
|
+
client_trace,
|
121
|
+
call: '/PingPongService/PingWithClientStream',
|
122
|
+
call_type: :client_streamer
|
123
|
+
)
|
124
|
+
|
125
|
+
assert_server_trace(
|
126
|
+
server_trace,
|
127
|
+
call: '/PingPongService/PingWithClientStream',
|
128
|
+
call_type: :client_streamer
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_server_streamer
|
133
|
+
clear_all!
|
134
|
+
responses = []
|
135
|
+
|
136
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
137
|
+
responses = client_stub.ping_with_server_stream(
|
138
|
+
PingPongService::PingRequest.new(message: 'Hello World')
|
139
|
+
)
|
140
|
+
end
|
141
|
+
sleep 1
|
142
|
+
|
143
|
+
assert %w(0 1 2 3 4), responses.map(&:message)
|
144
|
+
|
145
|
+
assert_equal 2, ::Instana.processor.queue_count
|
146
|
+
client_trace, server_trace = differentiate_trace(
|
147
|
+
Instana.processor.queued_traces
|
148
|
+
)
|
149
|
+
|
150
|
+
assert_client_trace(
|
151
|
+
client_trace,
|
152
|
+
call: '/PingPongService/PingWithServerStream',
|
153
|
+
call_type: :server_streamer
|
154
|
+
)
|
155
|
+
|
156
|
+
assert_server_trace(
|
157
|
+
server_trace,
|
158
|
+
call: '/PingPongService/PingWithServerStream',
|
159
|
+
call_type: :server_streamer
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_bidi_streamer
|
164
|
+
clear_all!
|
165
|
+
responses = []
|
166
|
+
|
167
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
168
|
+
responses = client_stub.ping_with_bidi_stream(
|
169
|
+
(0..5).map do |index|
|
170
|
+
PingPongService::PingRequest.new(message: (index * 2).to_s)
|
171
|
+
end
|
172
|
+
)
|
173
|
+
end
|
174
|
+
sleep 1
|
175
|
+
|
176
|
+
assert %w(0 2 4 6 8), responses.to_a.map(&:message)
|
177
|
+
|
178
|
+
assert_equal 2, ::Instana.processor.queue_count
|
179
|
+
client_trace, server_trace = differentiate_trace(
|
180
|
+
Instana.processor.queued_traces
|
181
|
+
)
|
182
|
+
|
183
|
+
assert_client_trace(
|
184
|
+
client_trace,
|
185
|
+
call: '/PingPongService/PingWithBidiStream',
|
186
|
+
call_type: :bidi_streamer
|
187
|
+
)
|
188
|
+
|
189
|
+
assert_server_trace(
|
190
|
+
server_trace,
|
191
|
+
call: '/PingPongService/PingWithBidiStream',
|
192
|
+
call_type: :bidi_streamer
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_request_response_failure
|
197
|
+
clear_all!
|
198
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
199
|
+
begin
|
200
|
+
client_stub.fail_to_ping( PingPongService::PingRequest.new(message: 'Hello World'))
|
201
|
+
rescue
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
assert_equal 2, ::Instana.processor.queue_count
|
206
|
+
client_trace, server_trace = differentiate_trace(
|
207
|
+
Instana.processor.queued_traces
|
208
|
+
)
|
209
|
+
|
210
|
+
assert_client_trace(
|
211
|
+
client_trace,
|
212
|
+
call: '/PingPongService/FailToPing',
|
213
|
+
call_type: :request_response,
|
214
|
+
error: 'Unexpected failed'
|
215
|
+
)
|
216
|
+
assert_server_trace(
|
217
|
+
server_trace,
|
218
|
+
call: '/PingPongService/FailToPing',
|
219
|
+
call_type: :request_response,
|
220
|
+
error: 'Unexpected failed'
|
221
|
+
)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_client_streamer_failure
|
225
|
+
clear_all!
|
226
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
227
|
+
begin
|
228
|
+
client_stub.fail_to_ping_with_client_stream(
|
229
|
+
(0..5).map do |index|
|
230
|
+
PingPongService::PingRequest.new(message: index.to_s)
|
231
|
+
end
|
232
|
+
)
|
233
|
+
rescue
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
assert_equal 2, ::Instana.processor.queue_count
|
238
|
+
client_trace, server_trace = differentiate_trace(
|
239
|
+
Instana.processor.queued_traces
|
240
|
+
)
|
241
|
+
|
242
|
+
assert_client_trace(
|
243
|
+
client_trace,
|
244
|
+
call: '/PingPongService/FailToPingWithClientStream',
|
245
|
+
call_type: :client_streamer,
|
246
|
+
error: 'Unexpected failed'
|
247
|
+
)
|
248
|
+
|
249
|
+
assert_server_trace(
|
250
|
+
server_trace,
|
251
|
+
call: '/PingPongService/FailToPingWithClientStream',
|
252
|
+
call_type: :client_streamer,
|
253
|
+
error: 'Unexpected failed'
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_server_streamer_failure
|
258
|
+
clear_all!
|
259
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
260
|
+
begin
|
261
|
+
client_stub.fail_to_ping_with_server_stream(
|
262
|
+
PingPongService::PingRequest.new(message: 'Hello World')
|
263
|
+
)
|
264
|
+
rescue
|
265
|
+
end
|
266
|
+
end
|
267
|
+
sleep 1
|
268
|
+
|
269
|
+
assert_equal 2, ::Instana.processor.queue_count
|
270
|
+
client_trace, server_trace = differentiate_trace(
|
271
|
+
Instana.processor.queued_traces
|
272
|
+
)
|
273
|
+
|
274
|
+
assert_client_trace(
|
275
|
+
client_trace,
|
276
|
+
call: '/PingPongService/FailToPingWithServerStream',
|
277
|
+
call_type: :server_streamer
|
278
|
+
)
|
279
|
+
|
280
|
+
assert_server_trace(
|
281
|
+
server_trace,
|
282
|
+
call: '/PingPongService/FailToPingWithServerStream',
|
283
|
+
call_type: :server_streamer,
|
284
|
+
error: 'Unexpected failed'
|
285
|
+
)
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_bidi_streamer_failure
|
289
|
+
clear_all!
|
290
|
+
Instana.tracer.start_or_continue_trace(:rpctests) do
|
291
|
+
client_stub.fail_to_ping_with_bidi_stream(
|
292
|
+
(0..5).map do |index|
|
293
|
+
PingPongService::PingRequest.new(message: (index * 2).to_s)
|
294
|
+
end
|
295
|
+
)
|
296
|
+
end
|
297
|
+
sleep 1
|
298
|
+
|
299
|
+
assert_equal 2, ::Instana.processor.queue_count
|
300
|
+
client_trace, server_trace = differentiate_trace(
|
301
|
+
Instana.processor.queued_traces
|
302
|
+
)
|
303
|
+
|
304
|
+
assert_client_trace(
|
305
|
+
client_trace,
|
306
|
+
call: '/PingPongService/FailToPingWithBidiStream',
|
307
|
+
call_type: :bidi_streamer
|
308
|
+
)
|
309
|
+
|
310
|
+
assert_server_trace(
|
311
|
+
server_trace,
|
312
|
+
call: '/PingPongService/FailToPingWithBidiStream',
|
313
|
+
call_type: :bidi_streamer,
|
314
|
+
error: 'Unexpected failed'
|
315
|
+
)
|
316
|
+
end
|
317
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../apps/grpc_server.rb')
|
2
|
+
|
3
|
+
::Instana.logger.info "Booting instrumented gRPC server on port 50051 for tests."
|
4
|
+
|
5
|
+
grpc_thread = Thread.new do
|
6
|
+
s = GRPC::RpcServer.new
|
7
|
+
Thread.current[:server] = s
|
8
|
+
|
9
|
+
s.add_http2_port('127.0.0.1:50051', :this_port_is_insecure)
|
10
|
+
s.handle(PingPongServer)
|
11
|
+
s.run_till_terminated
|
12
|
+
end
|
13
|
+
|
14
|
+
Minitest.after_run do
|
15
|
+
::Instana.logger.info "Killing gRPC server"
|
16
|
+
grpc_thread[:server].stop
|
17
|
+
sleep 2
|
18
|
+
end
|
19
|
+
|
20
|
+
sleep 2
|
data/test/test_helper.rb
CHANGED
@@ -21,6 +21,8 @@ when /rails50|rails42|rails32/
|
|
21
21
|
# Allow localhost calls to the internal rails servers
|
22
22
|
::WebMock.disable_net_connect!(allow_localhost: true)
|
23
23
|
require './test/servers/rails_3205'
|
24
|
+
when /libraries/
|
25
|
+
require './test/servers/grpc_50051.rb'
|
24
26
|
end
|
25
27
|
|
26
28
|
Minitest::Reporters.use! MiniTest::Reporters::SpecReporter.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/instana/instrumentation.rb
|
202
202
|
- lib/instana/instrumentation/dalli.rb
|
203
203
|
- lib/instana/instrumentation/excon.rb
|
204
|
+
- lib/instana/instrumentation/grpc.rb
|
204
205
|
- lib/instana/instrumentation/net-http.rb
|
205
206
|
- lib/instana/instrumentation/rack.rb
|
206
207
|
- lib/instana/instrumentation/rest-client.rb
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- log/.keep
|
223
224
|
- test/agent/agent_test.rb
|
224
225
|
- test/apps/cuba.rb
|
226
|
+
- test/apps/grpc_server.rb
|
225
227
|
- test/apps/roda.rb
|
226
228
|
- test/apps/sinatra.rb
|
227
229
|
- test/config_test.rb
|
@@ -239,9 +241,11 @@ files:
|
|
239
241
|
- test/instana_test.rb
|
240
242
|
- test/instrumentation/dalli_test.rb
|
241
243
|
- test/instrumentation/excon_test.rb
|
244
|
+
- test/instrumentation/grpc_test.rb
|
242
245
|
- test/instrumentation/net-http_test.rb
|
243
246
|
- test/instrumentation/rest-client_test.rb
|
244
247
|
- test/models/block.rb
|
248
|
+
- test/servers/grpc_50051.rb
|
245
249
|
- test/servers/rackapp_6511.rb
|
246
250
|
- test/servers/rails_3205.rb
|
247
251
|
- test/test_helper.rb
|
@@ -277,6 +281,7 @@ summary: Ruby sensor for Instana
|
|
277
281
|
test_files:
|
278
282
|
- test/agent/agent_test.rb
|
279
283
|
- test/apps/cuba.rb
|
284
|
+
- test/apps/grpc_server.rb
|
280
285
|
- test/apps/roda.rb
|
281
286
|
- test/apps/sinatra.rb
|
282
287
|
- test/config_test.rb
|
@@ -294,9 +299,11 @@ test_files:
|
|
294
299
|
- test/instana_test.rb
|
295
300
|
- test/instrumentation/dalli_test.rb
|
296
301
|
- test/instrumentation/excon_test.rb
|
302
|
+
- test/instrumentation/grpc_test.rb
|
297
303
|
- test/instrumentation/net-http_test.rb
|
298
304
|
- test/instrumentation/rest-client_test.rb
|
299
305
|
- test/models/block.rb
|
306
|
+
- test/servers/grpc_50051.rb
|
300
307
|
- test/servers/rackapp_6511.rb
|
301
308
|
- test/servers/rails_3205.rb
|
302
309
|
- test/test_helper.rb
|