instana 1.9.7 → 1.10.0.slimfast
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/instana/agent.rb +19 -19
- data/lib/instana/agent/helpers.rb +2 -2
- data/lib/instana/agent/tasks.rb +2 -2
- data/lib/instana/collectors/gc.rb +1 -1
- data/lib/instana/collectors/memory.rb +1 -1
- data/lib/instana/collectors/thread.rb +1 -1
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +1 -1
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +1 -1
- data/lib/instana/helpers.rb +2 -2
- data/lib/instana/instrumentation.rb +1 -1
- data/lib/instana/instrumentation/excon.rb +8 -5
- data/lib/instana/instrumentation/rack.rb +2 -2
- data/lib/instana/instrumentation/resque.rb +3 -3
- data/lib/instana/tracer.rb +92 -117
- data/lib/instana/tracing/processor.rb +18 -133
- data/lib/instana/tracing/span.rb +40 -35
- data/lib/instana/tracing/span_context.rb +3 -1
- data/lib/instana/util.rb +5 -5
- data/lib/instana/version.rb +1 -1
- data/lib/opentracing.rb +1 -1
- data/test/frameworks/rack_test.rb +6 -11
- data/test/frameworks/rails/actioncontroller_test.rb +32 -62
- data/test/frameworks/rails/actionview5_test.rb +91 -132
- data/test/frameworks/rails/activerecord5_test.rb +14 -17
- data/test/instrumentation/dalli_test.rb +51 -72
- data/test/instrumentation/excon_test.rb +70 -94
- data/test/instrumentation/grpc_test.rb +164 -126
- data/test/instrumentation/net-http_test.rb +48 -57
- data/test/instrumentation/redis_test.rb +4 -6
- data/test/instrumentation/resque_test.rb +41 -41
- data/test/instrumentation/rest-client_test.rb +25 -31
- data/test/instrumentation/sidekiq-client_test.rb +12 -20
- data/test/instrumentation/sidekiq-worker_test.rb +48 -63
- data/test/jobs/resque_error_job.rb +7 -1
- data/test/jobs/resque_fast_job.rb +7 -1
- data/test/servers/sidekiq/worker.rb +1 -3
- data/test/test_helper.rb +58 -0
- data/test/tracing/custom_test.rb +11 -19
- data/test/tracing/opentracing_test.rb +48 -156
- data/test/tracing/trace_test.rb +67 -67
- data/test/tracing/tracer_async_test.rb +75 -175
- data/test/tracing/tracer_test.rb +75 -75
- metadata +4 -5
- data/lib/instana/tracing/trace.rb +0 -316
@@ -26,10 +26,10 @@ class ActiveRecordTest < Minitest::Test
|
|
26
26
|
third_span = spans[3]
|
27
27
|
fourth_span = spans[4]
|
28
28
|
|
29
|
-
assert_equal :rack, first_span
|
30
|
-
assert_equal :activerecord, second_span
|
31
|
-
assert_equal :activerecord, third_span
|
32
|
-
assert_equal :activerecord, fourth_span
|
29
|
+
assert_equal :rack, first_span[:n]
|
30
|
+
assert_equal :activerecord, second_span[:n]
|
31
|
+
assert_equal :activerecord, third_span[:n]
|
32
|
+
assert_equal :activerecord, fourth_span[:n]
|
33
33
|
|
34
34
|
assert_equal "INSERT INTO \"blocks\" (\"name\", \"color\", \"created_at\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\"", second_span[:data][:activerecord][:sql]
|
35
35
|
assert_equal "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = $? ORDER BY \"blocks\".\"id\" ASC LIMIT $?", third_span[:data][:activerecord][:sql]
|
@@ -55,21 +55,18 @@ class ActiveRecordTest < Minitest::Test
|
|
55
55
|
|
56
56
|
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
57
57
|
|
58
|
-
|
59
|
-
assert_equal
|
60
|
-
trace = traces.first
|
58
|
+
spans = ::Instana.processor.queued_spans
|
59
|
+
assert_equal 6, spans.length
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
third_span = spans[3]
|
67
|
-
fourth_span = spans[4]
|
61
|
+
first_span = spans[5]
|
62
|
+
second_span = spans[0]
|
63
|
+
third_span = spans[1]
|
64
|
+
fourth_span = spans[2]
|
68
65
|
|
69
|
-
assert_equal :rack, first_span
|
70
|
-
assert_equal :activerecord, second_span
|
71
|
-
assert_equal :activerecord, third_span
|
72
|
-
assert_equal :activerecord, fourth_span
|
66
|
+
assert_equal :rack, first_span[:n]
|
67
|
+
assert_equal :activerecord, second_span[:n]
|
68
|
+
assert_equal :activerecord, third_span[:n]
|
69
|
+
assert_equal :activerecord, fourth_span[:n]
|
73
70
|
|
74
71
|
assert_equal "INSERT INTO `blocks` (`name`, `color`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)", second_span[:data][:activerecord][:sql]
|
75
72
|
assert_equal "SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`name` = ? ORDER BY `blocks`.`id` ASC LIMIT ?", third_span[:data][:activerecord][:sql]
|
@@ -24,18 +24,15 @@ class DalliTest < Minitest::Test
|
|
24
24
|
|
25
25
|
assert_equal :boom, result
|
26
26
|
|
27
|
-
|
28
|
-
assert_equal
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal :dalli_test, first_span.name
|
38
|
-
assert_equal :memcache, second_span.name
|
27
|
+
spans = ::Instana.processor.queued_spans
|
28
|
+
assert_equal 2, spans.length
|
29
|
+
|
30
|
+
first_span = spans[1]
|
31
|
+
second_span = spans[0]
|
32
|
+
|
33
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
34
|
+
|
35
|
+
assert_equal :memcache, second_span[:n]
|
39
36
|
assert_equal false, second_span.key?(:error)
|
40
37
|
assert second_span[:p] == first_span[:s]
|
41
38
|
assert first_span[:t] == first_span[:s]
|
@@ -60,18 +57,15 @@ class DalliTest < Minitest::Test
|
|
60
57
|
|
61
58
|
assert result.is_a?(Integer)
|
62
59
|
|
63
|
-
|
64
|
-
assert_equal
|
65
|
-
trace = traces.first
|
60
|
+
spans = ::Instana.processor.queued_spans
|
61
|
+
assert_equal 2, spans.length
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
spans = trace.spans.to_a
|
70
|
-
first_span = spans[0]
|
71
|
-
second_span = spans[1]
|
63
|
+
first_span = spans[1]
|
64
|
+
second_span = spans[0]
|
72
65
|
|
73
|
-
|
74
|
-
|
66
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
67
|
+
|
68
|
+
assert_equal :memcache, second_span[:n]
|
75
69
|
assert_equal false, second_span.key?(:error)
|
76
70
|
assert second_span[:p] == first_span[:s]
|
77
71
|
assert first_span[:t] == first_span[:s]
|
@@ -97,18 +91,15 @@ class DalliTest < Minitest::Test
|
|
97
91
|
|
98
92
|
assert result.is_a?(Integer)
|
99
93
|
|
100
|
-
|
101
|
-
assert_equal
|
102
|
-
|
94
|
+
spans = ::Instana.processor.queued_spans
|
95
|
+
assert_equal 2, spans.length
|
96
|
+
|
97
|
+
first_span = spans[1]
|
98
|
+
second_span = spans[0]
|
103
99
|
|
104
|
-
|
105
|
-
assert_equal 2, trace.spans.length
|
106
|
-
spans = trace.spans.to_a
|
107
|
-
first_span = spans[0]
|
108
|
-
second_span = spans[1]
|
100
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
109
101
|
|
110
|
-
assert_equal :
|
111
|
-
assert_equal :memcache, second_span.name
|
102
|
+
assert_equal :memcache, second_span[:n]
|
112
103
|
assert_equal false, second_span.key?(:error)
|
113
104
|
assert second_span[:p] == first_span[:s]
|
114
105
|
assert first_span[:t] == first_span[:s]
|
@@ -134,18 +125,15 @@ class DalliTest < Minitest::Test
|
|
134
125
|
|
135
126
|
assert_equal true, result
|
136
127
|
|
137
|
-
|
138
|
-
assert_equal
|
139
|
-
trace = traces.first
|
128
|
+
spans = ::Instana.processor.queued_spans
|
129
|
+
assert_equal 2, spans.length
|
140
130
|
|
141
|
-
|
142
|
-
|
143
|
-
spans = trace.spans.to_a
|
144
|
-
first_span = spans[0]
|
145
|
-
second_span = spans[1]
|
131
|
+
first_span = spans[1]
|
132
|
+
second_span = spans[0]
|
146
133
|
|
147
|
-
|
148
|
-
|
134
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
135
|
+
|
136
|
+
assert_equal :memcache, second_span[:n]
|
149
137
|
assert_equal false, second_span.key?(:error)
|
150
138
|
assert second_span[:p] == first_span[:s]
|
151
139
|
assert first_span[:t] == first_span[:s]
|
@@ -171,18 +159,15 @@ class DalliTest < Minitest::Test
|
|
171
159
|
|
172
160
|
assert_equal 1, result
|
173
161
|
|
174
|
-
|
175
|
-
assert_equal
|
176
|
-
|
162
|
+
spans = ::Instana.processor.queued_spans
|
163
|
+
assert_equal 2, spans.length
|
164
|
+
|
165
|
+
first_span = spans[1]
|
166
|
+
second_span = spans[0]
|
177
167
|
|
178
|
-
|
179
|
-
assert_equal 2, trace.spans.length
|
180
|
-
spans = trace.spans.to_a
|
181
|
-
first_span = spans[0]
|
182
|
-
second_span = spans[1]
|
168
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
183
169
|
|
184
|
-
assert_equal :
|
185
|
-
assert_equal :memcache, second_span.name
|
170
|
+
assert_equal :memcache, second_span[:n]
|
186
171
|
assert_equal false, second_span.key?(:error)
|
187
172
|
assert second_span[:p] == first_span[:s]
|
188
173
|
assert first_span[:t] == first_span[:s]
|
@@ -208,18 +193,15 @@ class DalliTest < Minitest::Test
|
|
208
193
|
|
209
194
|
assert_equal 0, result
|
210
195
|
|
211
|
-
|
212
|
-
assert_equal
|
213
|
-
trace = traces.first
|
196
|
+
spans = ::Instana.processor.queued_spans
|
197
|
+
assert_equal 2, spans.length
|
214
198
|
|
215
|
-
|
216
|
-
|
217
|
-
spans = trace.spans.to_a
|
218
|
-
first_span = spans[0]
|
219
|
-
second_span = spans[1]
|
199
|
+
first_span = spans[1]
|
200
|
+
second_span = spans[0]
|
220
201
|
|
221
|
-
|
222
|
-
|
202
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
203
|
+
|
204
|
+
assert_equal :memcache, second_span[:n]
|
223
205
|
assert_equal false, second_span.key?(:error)
|
224
206
|
assert second_span[:p] == first_span[:s]
|
225
207
|
assert first_span[:t] == first_span[:s]
|
@@ -244,18 +226,15 @@ class DalliTest < Minitest::Test
|
|
244
226
|
@dc.get_multi(:one, :two, :three, :four)
|
245
227
|
end
|
246
228
|
|
247
|
-
|
248
|
-
assert_equal
|
249
|
-
|
229
|
+
spans = ::Instana.processor.queued_spans
|
230
|
+
assert_equal 2, spans.length
|
231
|
+
|
232
|
+
first_span = spans[1]
|
233
|
+
second_span = spans[0]
|
250
234
|
|
251
|
-
|
252
|
-
assert_equal 2, trace.spans.length
|
253
|
-
spans = trace.spans.to_a
|
254
|
-
first_span = spans[0]
|
255
|
-
second_span = spans[1]
|
235
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :intermediate})
|
256
236
|
|
257
|
-
assert_equal :
|
258
|
-
assert_equal :memcache, second_span.name
|
237
|
+
assert_equal :memcache, second_span[:n]
|
259
238
|
assert_equal false, second_span.key?(:error)
|
260
239
|
assert second_span[:p] == first_span[:s]
|
261
240
|
assert first_span[:t] == first_span[:s]
|
@@ -22,41 +22,29 @@ class ExconTest < Minitest::Test
|
|
22
22
|
connection.get(:path => '/?basic_get')
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
assert_equal
|
27
|
-
rs_trace = traces[0]
|
28
|
-
http_trace = traces[1]
|
25
|
+
spans = ::Instana.processor.queued_spans
|
26
|
+
assert_equal 3, spans.length
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
first_span = spans[0]
|
34
|
-
second_span = spans[1]
|
28
|
+
sdk_span = find_first_span_by_name(spans, :'excon-test')
|
29
|
+
excon_span = find_first_span_by_name(spans, :excon)
|
30
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
35
31
|
|
36
|
-
|
37
|
-
assert_equal :sdk, first_span[:n]
|
38
|
-
assert_equal :"excon-test", first_span[:data][:sdk][:name]
|
39
|
-
assert_equal :excon, second_span[:n]
|
40
|
-
|
41
|
-
# first_span is the parent of second_span
|
42
|
-
assert_equal first_span.id, second_span[:p]
|
32
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :intermediate})
|
43
33
|
|
44
34
|
# data keys/values
|
45
|
-
refute_nil
|
46
|
-
refute_nil
|
47
|
-
assert_equal "http://127.0.0.1:6511/",
|
48
|
-
assert_equal 200,
|
35
|
+
refute_nil excon_span.key?(:data)
|
36
|
+
refute_nil excon_span[:data].key?(:http)
|
37
|
+
assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
|
38
|
+
assert_equal 200, excon_span[:data][:http][:status]
|
49
39
|
|
50
40
|
# excon backtrace not included by default check
|
51
|
-
assert !
|
41
|
+
assert !excon_span.key?(:stack)
|
52
42
|
|
53
|
-
|
54
|
-
assert_equal
|
55
|
-
rs_span = rs_trace.spans.to_a[0]
|
43
|
+
assert_equal sdk_span[:t], excon_span[:t]
|
44
|
+
assert_equal rack_span[:t], excon_span[:t]
|
56
45
|
|
57
|
-
|
58
|
-
assert_equal
|
59
|
-
assert_equal rs_span[:p].to_i, second_span[:s]
|
46
|
+
assert_equal rack_span[:p], excon_span[:s]
|
47
|
+
assert_equal excon_span[:p], sdk_span[:s]
|
60
48
|
end
|
61
49
|
|
62
50
|
def test_basic_get_with_error
|
@@ -67,46 +55,37 @@ class ExconTest < Minitest::Test
|
|
67
55
|
Excon.defaults[:middlewares].delete ::WebMock::HttpLibAdapters::ExconAdapter
|
68
56
|
Excon.defaults[:middlewares].delete ::Excon::Middleware::Mock
|
69
57
|
|
70
|
-
url = "http://127.0.0.1:
|
58
|
+
url = "http://127.0.0.1:6511"
|
71
59
|
|
72
60
|
begin
|
73
61
|
connection = Excon.new(url)
|
74
62
|
Instana.tracer.start_or_continue_trace('excon-test') do
|
75
|
-
connection.get(:path => '
|
63
|
+
connection.get(:path => '/error')
|
76
64
|
end
|
77
65
|
rescue
|
78
66
|
end
|
79
67
|
|
80
|
-
|
81
|
-
assert_equal
|
82
|
-
http_trace = traces.first
|
68
|
+
spans = ::Instana.processor.queued_spans
|
69
|
+
assert_equal 3, spans.length
|
83
70
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
first_span = spans[0]
|
88
|
-
second_span = spans[1]
|
71
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
72
|
+
excon_span = find_first_span_by_name(spans, :excon)
|
73
|
+
sdk_span = find_first_span_by_name(spans, :'excon-test')
|
89
74
|
|
90
|
-
|
91
|
-
assert_equal :sdk, first_span[:n]
|
92
|
-
assert_equal :"excon-test", first_span[:data][:sdk][:name]
|
93
|
-
assert_equal :excon, second_span[:n]
|
75
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :intermediate})
|
94
76
|
|
95
|
-
|
96
|
-
assert_equal
|
97
|
-
|
98
|
-
# data keys/values
|
99
|
-
refute_nil second_span.key?(:data)
|
100
|
-
refute_nil second_span[:data].key?(:http)
|
101
|
-
assert_equal "http://127.0.0.1:6500/", second_span[:data][:http][:url]
|
102
|
-
assert_equal nil, second_span[:data][:http][:status]
|
77
|
+
assert_equal sdk_span[:s], excon_span[:p]
|
78
|
+
assert_equal excon_span[:s], rack_span[:p]
|
103
79
|
|
104
|
-
|
105
|
-
|
80
|
+
assert_equal :excon, excon_span[:n]
|
81
|
+
refute_nil excon_span.key?(:data)
|
82
|
+
refute_nil excon_span[:data].key?(:http)
|
83
|
+
assert_equal "http://127.0.0.1:6511/error", excon_span[:data][:http][:url]
|
84
|
+
assert_equal 500, excon_span[:data][:http][:status]
|
106
85
|
|
107
86
|
# error validation
|
108
|
-
assert_equal true,
|
109
|
-
|
87
|
+
assert_equal true, excon_span[:error]
|
88
|
+
assert_equal 1, excon_span[:ec]
|
110
89
|
end
|
111
90
|
|
112
91
|
def test_pipelined_requests
|
@@ -125,47 +104,44 @@ class ExconTest < Minitest::Test
|
|
125
104
|
connection.requests([request, request, request])
|
126
105
|
end
|
127
106
|
|
128
|
-
|
129
|
-
assert_equal
|
130
|
-
http_trace = traces[3]
|
131
|
-
|
132
|
-
# Excon validation
|
133
|
-
assert_equal 4, http_trace.spans.length
|
134
|
-
spans = http_trace.spans.to_a
|
135
|
-
first_span = spans[0]
|
136
|
-
second_span = spans[1]
|
137
|
-
third_span = spans[2]
|
138
|
-
fourth_span = spans[3]
|
139
|
-
|
140
|
-
# Span name validation
|
141
|
-
assert_equal :sdk, first_span[:n]
|
142
|
-
assert_equal :"excon-test", first_span[:data][:sdk][:name]
|
143
|
-
assert_equal :excon, second_span[:n]
|
144
|
-
assert_equal :excon, third_span[:n]
|
145
|
-
assert_equal :excon, fourth_span[:n]
|
146
|
-
|
147
|
-
# first_span is the parent of second/third/fourth_span
|
148
|
-
assert_equal first_span.id, second_span[:p]
|
149
|
-
assert_equal first_span.id, third_span[:p]
|
150
|
-
assert_equal first_span.id, fourth_span[:p]
|
107
|
+
spans = ::Instana.processor.queued_spans
|
108
|
+
assert_equal 7, spans.length
|
151
109
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
110
|
+
rack_spans = find_spans_by_name(spans, :rack)
|
111
|
+
excon_spans = find_spans_by_name(spans, :excon)
|
112
|
+
sdk_span = find_first_span_by_name(spans, :'excon-test')
|
113
|
+
|
114
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :intermediate})
|
115
|
+
|
116
|
+
assert_equal 3, rack_spans.length
|
117
|
+
assert_equal 3, excon_spans.length
|
118
|
+
|
119
|
+
# ::Instana::Util.pry!
|
120
|
+
|
121
|
+
for rack_span in rack_spans
|
122
|
+
# data keys/values
|
123
|
+
refute_nil rack_span.key?(:data)
|
124
|
+
refute_nil rack_span[:data].key?(:http)
|
125
|
+
assert_equal "/", rack_span[:data][:http][:url]
|
126
|
+
assert_equal 200, rack_span[:data][:http][:status]
|
127
|
+
assert !rack_span.key?(:stack)
|
128
|
+
|
129
|
+
# Make sure a parent is specified and that we have it
|
130
|
+
refute_nil rack_span[:p]
|
131
|
+
excon_span = find_span_by_id(spans, rack_span[:p])
|
132
|
+
assert_equal :excon, excon_span[:n]
|
133
|
+
|
134
|
+
refute_nil excon_span.key?(:data)
|
135
|
+
refute_nil excon_span[:data].key?(:http)
|
136
|
+
assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
|
137
|
+
assert_equal 200, excon_span[:data][:http][:status]
|
138
|
+
assert !excon_span.key?(:stack)
|
139
|
+
|
140
|
+
# walk up the line
|
141
|
+
refute_nil excon_span[:p]
|
142
|
+
grandparent_span = find_span_by_id(spans, excon_span[:p])
|
143
|
+
assert_nil grandparent_span[:p]
|
144
|
+
assert_equal :sdk, grandparent_span[:n]
|
145
|
+
end
|
170
146
|
end
|
171
147
|
end
|
@@ -5,39 +5,8 @@ class GrpcTest < Minitest::Test
|
|
5
5
|
PingPongService::Stub.new('127.0.0.1:50051', :this_channel_is_insecure)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
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.length
|
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]
|
8
|
+
def assert_client_span(client_span, call: '', call_type: '', error: nil)
|
9
|
+
data = client_span[:data]
|
41
10
|
assert_equal '127.0.0.1:50051', data[:rpc][:host]
|
42
11
|
assert_equal :grpc, data[:rpc][:flavor]
|
43
12
|
assert_equal call, data[:rpc][:call]
|
@@ -49,14 +18,11 @@ class GrpcTest < Minitest::Test
|
|
49
18
|
end
|
50
19
|
end
|
51
20
|
|
52
|
-
def
|
53
|
-
assert_equal 1, server_trace.spans.length
|
54
|
-
span = server_trace.spans.to_a.first
|
55
|
-
|
21
|
+
def assert_server_span(server_span, call: '', call_type: '', error: nil)
|
56
22
|
# Span name validation
|
57
|
-
assert_equal :'rpc-server',
|
23
|
+
assert_equal :'rpc-server', server_span[:n]
|
58
24
|
|
59
|
-
data =
|
25
|
+
data = server_span[:data]
|
60
26
|
assert_equal :grpc, data[:rpc][:flavor]
|
61
27
|
assert_equal call, data[:rpc][:call]
|
62
28
|
assert_equal call_type, data[:rpc][:call_type]
|
@@ -83,22 +49,31 @@ class GrpcTest < Minitest::Test
|
|
83
49
|
# Pause for a split second to allow traces to be queued
|
84
50
|
sleep 0.2
|
85
51
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
)
|
52
|
+
spans = ::Instana.processor.queued_spans
|
53
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
54
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
55
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
56
|
+
|
57
|
+
validate_sdk_span(sdk_span)
|
90
58
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
59
|
+
assert_client_span(
|
60
|
+
client_span,
|
61
|
+
call: '/PingPongService/Ping',
|
62
|
+
call_type: :request_response
|
95
63
|
)
|
96
64
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
65
|
+
assert_server_span(
|
66
|
+
server_span,
|
67
|
+
call: '/PingPongService/Ping',
|
68
|
+
call_type: :request_response
|
101
69
|
)
|
70
|
+
|
71
|
+
trace_id = sdk_span[:t]
|
72
|
+
assert_equal trace_id, client_span[:t]
|
73
|
+
assert_equal trace_id, server_span[:t]
|
74
|
+
|
75
|
+
assert_equal server_span[:p], client_span[:s]
|
76
|
+
assert_equal client_span[:p], sdk_span[:s]
|
102
77
|
end
|
103
78
|
|
104
79
|
def test_client_streamer
|
@@ -119,22 +94,31 @@ class GrpcTest < Minitest::Test
|
|
119
94
|
# Pause for a split second to allow traces to be queued
|
120
95
|
sleep 0.2
|
121
96
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
)
|
97
|
+
spans = ::Instana.processor.queued_spans
|
98
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
99
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
100
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
126
101
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
102
|
+
validate_sdk_span(sdk_span)
|
103
|
+
|
104
|
+
assert_client_span(
|
105
|
+
client_span,
|
106
|
+
call: '/PingPongService/PingWithClientStream',
|
107
|
+
call_type: :client_streamer
|
131
108
|
)
|
132
109
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
110
|
+
assert_server_span(
|
111
|
+
server_span,
|
112
|
+
call: '/PingPongService/PingWithClientStream',
|
113
|
+
call_type: :client_streamer
|
137
114
|
)
|
115
|
+
|
116
|
+
trace_id = sdk_span[:t]
|
117
|
+
assert_equal trace_id, client_span[:t]
|
118
|
+
assert_equal trace_id, server_span[:t]
|
119
|
+
|
120
|
+
assert_equal server_span[:p], client_span[:s]
|
121
|
+
assert_equal client_span[:p], sdk_span[:s]
|
138
122
|
end
|
139
123
|
|
140
124
|
def test_server_streamer
|
@@ -151,22 +135,31 @@ class GrpcTest < Minitest::Test
|
|
151
135
|
# Pause for a split second to allow traces to be queued
|
152
136
|
sleep 0.2
|
153
137
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
)
|
138
|
+
spans = ::Instana.processor.queued_spans
|
139
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
140
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
141
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
158
142
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
143
|
+
validate_sdk_span(sdk_span)
|
144
|
+
|
145
|
+
assert_client_span(
|
146
|
+
client_span,
|
147
|
+
call: '/PingPongService/PingWithServerStream',
|
148
|
+
call_type: :server_streamer
|
163
149
|
)
|
164
150
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
151
|
+
assert_server_span(
|
152
|
+
server_span,
|
153
|
+
call: '/PingPongService/PingWithServerStream',
|
154
|
+
call_type: :server_streamer
|
169
155
|
)
|
156
|
+
|
157
|
+
trace_id = sdk_span[:t]
|
158
|
+
assert_equal trace_id, client_span[:t]
|
159
|
+
assert_equal trace_id, server_span[:t]
|
160
|
+
|
161
|
+
assert_equal server_span[:p], client_span[:s]
|
162
|
+
assert_equal client_span[:p], sdk_span[:s]
|
170
163
|
end
|
171
164
|
|
172
165
|
def test_bidi_streamer
|
@@ -187,22 +180,31 @@ class GrpcTest < Minitest::Test
|
|
187
180
|
# Pause for a split second to allow traces to be queued
|
188
181
|
sleep 0.2
|
189
182
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
)
|
183
|
+
spans = ::Instana.processor.queued_spans
|
184
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
185
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
186
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
194
187
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
188
|
+
validate_sdk_span(sdk_span)
|
189
|
+
|
190
|
+
assert_client_span(
|
191
|
+
client_span,
|
192
|
+
call: '/PingPongService/PingWithBidiStream',
|
193
|
+
call_type: :bidi_streamer
|
199
194
|
)
|
200
195
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
196
|
+
assert_server_span(
|
197
|
+
server_span,
|
198
|
+
call: '/PingPongService/PingWithBidiStream',
|
199
|
+
call_type: :bidi_streamer
|
205
200
|
)
|
201
|
+
|
202
|
+
trace_id = sdk_span[:t]
|
203
|
+
assert_equal trace_id, client_span[:t]
|
204
|
+
assert_equal trace_id, server_span[:t]
|
205
|
+
|
206
|
+
assert_equal server_span[:p], client_span[:s]
|
207
|
+
assert_equal client_span[:p], sdk_span[:s]
|
206
208
|
end
|
207
209
|
|
208
210
|
def test_request_response_failure
|
@@ -217,23 +219,32 @@ class GrpcTest < Minitest::Test
|
|
217
219
|
# Pause for a split second to allow traces to be queued
|
218
220
|
sleep 0.2
|
219
221
|
|
220
|
-
|
221
|
-
|
222
|
-
|
222
|
+
spans = ::Instana.processor.queued_spans
|
223
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
224
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
225
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
226
|
+
|
227
|
+
validate_sdk_span(sdk_span)
|
228
|
+
|
229
|
+
assert_client_span(
|
230
|
+
client_span,
|
231
|
+
call: '/PingPongService/FailToPing',
|
232
|
+
call_type: :request_response,
|
233
|
+
error: 'Unexpected failed'
|
223
234
|
)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
error: 'Unexpected failed'
|
230
|
-
)
|
231
|
-
assert_server_trace(
|
232
|
-
server_trace,
|
233
|
-
call: '/PingPongService/FailToPing',
|
234
|
-
call_type: :request_response,
|
235
|
-
error: 'Unexpected failed'
|
235
|
+
assert_server_span(
|
236
|
+
server_span,
|
237
|
+
call: '/PingPongService/FailToPing',
|
238
|
+
call_type: :request_response,
|
239
|
+
error: 'Unexpected failed'
|
236
240
|
)
|
241
|
+
|
242
|
+
trace_id = sdk_span[:t]
|
243
|
+
assert_equal trace_id, client_span[:t]
|
244
|
+
assert_equal trace_id, server_span[:t]
|
245
|
+
|
246
|
+
assert_equal server_span[:p], client_span[:s]
|
247
|
+
assert_equal client_span[:p], sdk_span[:s]
|
237
248
|
end
|
238
249
|
|
239
250
|
def test_client_streamer_failure
|
@@ -252,24 +263,33 @@ class GrpcTest < Minitest::Test
|
|
252
263
|
# Pause for a split second to allow traces to be queued
|
253
264
|
sleep 0.2
|
254
265
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
)
|
266
|
+
spans = ::Instana.processor.queued_spans
|
267
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
268
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
269
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
270
|
+
|
271
|
+
validate_sdk_span(sdk_span)
|
259
272
|
|
260
|
-
|
261
|
-
|
273
|
+
assert_client_span(
|
274
|
+
client_span,
|
262
275
|
call: '/PingPongService/FailToPingWithClientStream',
|
263
276
|
call_type: :client_streamer,
|
264
277
|
error: 'Unexpected failed'
|
265
278
|
)
|
266
279
|
|
267
|
-
|
268
|
-
|
280
|
+
assert_server_span(
|
281
|
+
server_span,
|
269
282
|
call: '/PingPongService/FailToPingWithClientStream',
|
270
283
|
call_type: :client_streamer,
|
271
284
|
error: 'Unexpected failed'
|
272
285
|
)
|
286
|
+
|
287
|
+
trace_id = sdk_span[:t]
|
288
|
+
assert_equal trace_id, client_span[:t]
|
289
|
+
assert_equal trace_id, server_span[:t]
|
290
|
+
|
291
|
+
assert_equal server_span[:p], client_span[:s]
|
292
|
+
assert_equal client_span[:p], sdk_span[:s]
|
273
293
|
end
|
274
294
|
|
275
295
|
def test_server_streamer_failure
|
@@ -286,23 +306,32 @@ class GrpcTest < Minitest::Test
|
|
286
306
|
# Pause for a split second to allow traces to be queued
|
287
307
|
sleep 0.2
|
288
308
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
)
|
309
|
+
spans = ::Instana.processor.queued_spans
|
310
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
311
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
312
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
313
|
+
|
314
|
+
validate_sdk_span(sdk_span)
|
293
315
|
|
294
|
-
|
295
|
-
|
316
|
+
assert_client_span(
|
317
|
+
client_span,
|
296
318
|
call: '/PingPongService/FailToPingWithServerStream',
|
297
319
|
call_type: :server_streamer
|
298
320
|
)
|
299
321
|
|
300
|
-
|
301
|
-
|
322
|
+
assert_server_span(
|
323
|
+
server_span,
|
302
324
|
call: '/PingPongService/FailToPingWithServerStream',
|
303
325
|
call_type: :server_streamer,
|
304
326
|
error: 'Unexpected failed'
|
305
327
|
)
|
328
|
+
|
329
|
+
trace_id = sdk_span[:t]
|
330
|
+
assert_equal trace_id, client_span[:t]
|
331
|
+
assert_equal trace_id, server_span[:t]
|
332
|
+
|
333
|
+
assert_equal server_span[:p], client_span[:s]
|
334
|
+
assert_equal client_span[:p], sdk_span[:s]
|
306
335
|
end
|
307
336
|
|
308
337
|
def test_bidi_streamer_failure
|
@@ -318,22 +347,31 @@ class GrpcTest < Minitest::Test
|
|
318
347
|
# Pause for a split second to allow traces to be queued
|
319
348
|
sleep 0.2
|
320
349
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
)
|
350
|
+
spans = ::Instana.processor.queued_spans
|
351
|
+
sdk_span = find_spans_by_name(spans, :rpctests).first
|
352
|
+
client_span = find_spans_by_name(spans, :'rpc-client').first
|
353
|
+
server_span = find_spans_by_name(spans, :'rpc-server').first
|
325
354
|
|
326
|
-
|
327
|
-
|
355
|
+
validate_sdk_span(sdk_span)
|
356
|
+
|
357
|
+
assert_client_span(
|
358
|
+
client_span,
|
328
359
|
call: '/PingPongService/FailToPingWithBidiStream',
|
329
360
|
call_type: :bidi_streamer
|
330
361
|
)
|
331
362
|
|
332
|
-
|
333
|
-
|
363
|
+
assert_server_span(
|
364
|
+
server_span,
|
334
365
|
call: '/PingPongService/FailToPingWithBidiStream',
|
335
366
|
call_type: :bidi_streamer,
|
336
367
|
error: 'Unexpected failed'
|
337
368
|
)
|
369
|
+
|
370
|
+
trace_id = sdk_span[:t]
|
371
|
+
assert_equal trace_id, client_span[:t]
|
372
|
+
assert_equal trace_id, server_span[:t]
|
373
|
+
|
374
|
+
assert_equal server_span[:p], client_span[:s]
|
375
|
+
assert_equal client_span[:p], sdk_span[:s]
|
338
376
|
end
|
339
377
|
end
|