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
@@ -22,24 +22,19 @@ class NetHTTPTest < Minitest::Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
spans = ::Instana.processor.queued_spans
|
26
|
+
assert_equal 3, spans.length
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# Net::HTTP trace validation
|
32
|
-
assert_equal 2, http_trace.spans.length
|
33
|
-
spans = http_trace.spans.to_a
|
34
|
-
first_span = spans[0]
|
35
|
-
second_span = spans[1]
|
28
|
+
rs_span = find_first_span_by_name(spans, :rack)
|
29
|
+
first_span = find_first_span_by_name(spans, :'net-http-test')
|
30
|
+
second_span = find_first_span_by_name(spans, :'net-http')
|
36
31
|
|
37
32
|
# Span name validation
|
38
33
|
assert_equal :sdk, first_span[:n]
|
39
34
|
assert_equal :'net-http', second_span[:n]
|
40
35
|
|
41
36
|
# first_span is the parent of second_span
|
42
|
-
assert_equal first_span
|
37
|
+
assert_equal first_span[:s], second_span[:p]
|
43
38
|
|
44
39
|
# data keys/values
|
45
40
|
refute_nil second_span.key?(:data)
|
@@ -48,14 +43,12 @@ class NetHTTPTest < Minitest::Test
|
|
48
43
|
assert_equal "200", second_span[:data][:http][:status]
|
49
44
|
assert !second_span.key?(:stack)
|
50
45
|
|
51
|
-
# Rack server trace validation
|
52
|
-
assert_equal 1, rs_trace.spans.length
|
53
|
-
rs_span = rs_trace.spans.to_a[0]
|
54
|
-
|
55
46
|
# Rack server trace should have the same trace ID
|
56
|
-
assert_equal
|
47
|
+
assert_equal rs_span[:t], first_span[:t]
|
48
|
+
assert_equal first_span[:t], second_span[:t]
|
49
|
+
|
57
50
|
# Rack server trace should have net-http has parent span
|
58
|
-
assert_equal second_span
|
51
|
+
assert_equal second_span[:s], rs_span[:p]
|
59
52
|
|
60
53
|
WebMock.disable_net_connect!
|
61
54
|
end
|
@@ -70,40 +63,33 @@ class NetHTTPTest < Minitest::Test
|
|
70
63
|
response = http.request(Net::HTTP::Post.new("/"))
|
71
64
|
end
|
72
65
|
|
73
|
-
|
66
|
+
spans = ::Instana.processor.queued_spans
|
67
|
+
assert_equal 3, spans.length
|
74
68
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# Net::HTTP trace validation
|
80
|
-
assert_equal 2, http_trace.spans.length
|
81
|
-
spans = http_trace.spans.to_a
|
82
|
-
first_span = spans[0]
|
83
|
-
second_span = spans[1]
|
69
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
70
|
+
sdk_span = find_first_span_by_name(spans, :'net-http-test')
|
71
|
+
http_span = find_first_span_by_name(spans, :'net-http')
|
84
72
|
|
85
73
|
# Span name validation
|
86
|
-
assert_equal :sdk,
|
87
|
-
assert_equal :'net-http',
|
74
|
+
assert_equal :sdk, sdk_span[:n]
|
75
|
+
assert_equal :'net-http', http_span[:n]
|
88
76
|
|
89
77
|
# first_span is the parent of second_span
|
90
|
-
assert_equal
|
78
|
+
assert_equal sdk_span[:s], http_span[:p]
|
91
79
|
|
92
80
|
# data keys/values
|
93
|
-
refute_nil
|
94
|
-
refute_nil
|
95
|
-
assert_equal "http://127.0.0.1:6511/",
|
96
|
-
assert_equal "200",
|
97
|
-
assert !
|
98
|
-
|
99
|
-
# Rack server trace validation
|
100
|
-
assert_equal 1, rs_trace.spans.length
|
101
|
-
rs_span = rs_trace.spans.to_a[0]
|
81
|
+
refute_nil http_span.key?(:data)
|
82
|
+
refute_nil http_span[:data].key?(:http)
|
83
|
+
assert_equal "http://127.0.0.1:6511/", http_span[:data][:http][:url]
|
84
|
+
assert_equal "200", http_span[:data][:http][:status]
|
85
|
+
assert !http_span.key?(:stack)
|
102
86
|
|
103
87
|
# Rack server trace should have the same trace ID
|
104
|
-
assert_equal
|
88
|
+
assert_equal rack_span[:t], sdk_span[:t]
|
89
|
+
assert_equal sdk_span[:t], http_span[:t]
|
90
|
+
|
105
91
|
# Rack server trace should have net-http has parent span
|
106
|
-
assert_equal
|
92
|
+
assert_equal http_span[:s], rack_span[:p]
|
107
93
|
|
108
94
|
WebMock.disable_net_connect!
|
109
95
|
end
|
@@ -121,16 +107,15 @@ class NetHTTPTest < Minitest::Test
|
|
121
107
|
nil
|
122
108
|
end
|
123
109
|
|
124
|
-
|
125
|
-
assert_equal 1,
|
126
|
-
|
127
|
-
|
128
|
-
assert t.has_error?
|
129
|
-
spans = t.spans.to_a
|
130
|
-
first_span = spans[0]
|
110
|
+
spans = ::Instana.processor.queued_spans
|
111
|
+
assert_equal 1, spans.length
|
112
|
+
|
113
|
+
first_span = spans.first
|
131
114
|
|
132
|
-
assert_equal :
|
133
|
-
|
115
|
+
assert_equal :sdk, first_span[:n]
|
116
|
+
assert_equal :'net-http-error-test', first_span[:data][:sdk][:name]
|
117
|
+
assert_equal true, first_span[:error]
|
118
|
+
assert_equal 1, first_span[:ec]
|
134
119
|
ts_key = first_span[:data][:sdk][:custom][:logs].keys.first
|
135
120
|
assert first_span[:data][:sdk][:custom][:logs].key?(ts_key)
|
136
121
|
assert first_span[:data][:sdk][:custom][:logs][ts_key].key?(:event)
|
@@ -149,20 +134,26 @@ class NetHTTPTest < Minitest::Test
|
|
149
134
|
response = http.request(Net::HTTP::Get.new("/error"))
|
150
135
|
end
|
151
136
|
|
152
|
-
|
153
|
-
assert_equal
|
137
|
+
spans = ::Instana.processor.queued_spans
|
138
|
+
assert_equal 3, spans.length
|
139
|
+
|
140
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
141
|
+
sdk_span = find_first_span_by_name(spans, :'net-http-error-test')
|
142
|
+
http_span = find_first_span_by_name(spans, :'net-http')
|
154
143
|
|
155
|
-
|
156
|
-
assert_equal
|
157
|
-
|
158
|
-
|
144
|
+
assert_equal :sdk, sdk_span[:n]
|
145
|
+
assert_equal :'net-http-error-test', sdk_span[:data][:sdk][:name]
|
146
|
+
assert_equal nil, sdk_span[:error]
|
147
|
+
assert_equal nil, sdk_span[:ec]
|
159
148
|
|
160
149
|
refute_nil http_span.key?(:data)
|
161
150
|
refute_nil http_span[:data].key?(:http)
|
162
151
|
assert_equal "http://127.0.0.1:6511/error", http_span[:data][:http][:url]
|
163
152
|
assert_equal "500", http_span[:data][:http][:status]
|
164
|
-
assert_equal :'net-http', http_span
|
153
|
+
assert_equal :'net-http', http_span[:n]
|
165
154
|
assert !http_span.key?(:stack)
|
155
|
+
assert_equal true, http_span[:error]
|
156
|
+
assert_equal 1, http_span[:ec]
|
166
157
|
|
167
158
|
WebMock.disable_net_connect!
|
168
159
|
end
|
@@ -94,14 +94,12 @@ class RedisTest < Minitest::Test
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def assert_redis_trace(command, with_error: nil)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
assert_equal 2, trace.spans.length
|
101
|
-
first_span, second_span = trace.spans.to_a
|
97
|
+
spans = ::Instana.processor.queued_spans
|
98
|
+
assert_equal 2, spans.length
|
99
|
+
first_span, second_span = spans.to_a.reverse
|
102
100
|
|
103
101
|
# first_span is the parent of second_span
|
104
|
-
assert_equal first_span
|
102
|
+
assert_equal first_span[:s], second_span[:p]
|
105
103
|
assert_equal :sdk, first_span[:n]
|
106
104
|
assert_equal :redis, second_span[:n]
|
107
105
|
|
@@ -5,6 +5,8 @@ require 'resque'
|
|
5
5
|
|
6
6
|
if ENV.key?('REDIS_URL')
|
7
7
|
::Resque.redis = ENV['REDIS_URL']
|
8
|
+
elsif ENV.key?('I_REDIS_URL')
|
9
|
+
::Resque.redis = ENV['I_REDIS_URL']
|
8
10
|
else
|
9
11
|
::Resque.redis = 'localhost:6379'
|
10
12
|
end
|
@@ -25,20 +27,21 @@ class ResqueClientTest < Minitest::Test
|
|
25
27
|
::Resque.enqueue(FastJob)
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
assert_equal
|
30
|
+
spans = ::Instana.processor.queued_spans
|
31
|
+
assert_equal 3, spans.length
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
sdk_span = find_first_span_by_name(spans, :'resque-client_test')
|
34
|
+
resque_span = find_first_span_by_name(spans, :'resque-client')
|
35
|
+
redis_span = find_first_span_by_name(spans, :redis)
|
33
36
|
|
34
|
-
assert_equal :'resque-client_test',
|
37
|
+
assert_equal :'resque-client_test', sdk_span[:data][:sdk][:name]
|
35
38
|
|
36
|
-
assert_equal :"resque-client",
|
37
|
-
assert_equal "FastJob",
|
38
|
-
assert_equal :critical,
|
39
|
-
assert_equal false,
|
39
|
+
assert_equal :"resque-client", resque_span[:n]
|
40
|
+
assert_equal "FastJob", resque_span[:data][:'resque-client'][:job]
|
41
|
+
assert_equal :critical, resque_span[:data][:'resque-client'][:queue]
|
42
|
+
assert_equal false, resque_span[:data][:'resque-client'].key?(:error)
|
40
43
|
|
41
|
-
assert_equal :redis,
|
44
|
+
assert_equal :redis, redis_span[:n]
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_enqueue_to
|
@@ -46,18 +49,19 @@ class ResqueClientTest < Minitest::Test
|
|
46
49
|
::Resque.enqueue_to(:critical, FastJob)
|
47
50
|
end
|
48
51
|
|
49
|
-
|
50
|
-
assert_equal
|
52
|
+
spans = ::Instana.processor.queued_spans
|
53
|
+
assert_equal 3, spans.length
|
51
54
|
|
52
|
-
|
53
|
-
|
55
|
+
sdk_span = find_first_span_by_name(spans, :'resque-client_test')
|
56
|
+
resque_span = find_first_span_by_name(spans, :'resque-client')
|
57
|
+
redis_span = find_first_span_by_name(spans, :redis)
|
54
58
|
|
55
|
-
assert_equal :'resque-client_test',
|
56
|
-
assert_equal :"resque-client",
|
57
|
-
assert_equal "FastJob",
|
58
|
-
assert_equal :critical,
|
59
|
-
assert_equal false,
|
60
|
-
assert_equal :redis,
|
59
|
+
assert_equal :'resque-client_test', sdk_span[:data][:sdk][:name]
|
60
|
+
assert_equal :"resque-client", resque_span[:n]
|
61
|
+
assert_equal "FastJob", resque_span[:data][:'resque-client'][:job]
|
62
|
+
assert_equal :critical, resque_span[:data][:'resque-client'][:queue]
|
63
|
+
assert_equal false, resque_span[:data][:'resque-client'].key?(:error)
|
64
|
+
assert_equal :redis, redis_span[:n]
|
61
65
|
end
|
62
66
|
|
63
67
|
def test_dequeue
|
@@ -65,33 +69,31 @@ class ResqueClientTest < Minitest::Test
|
|
65
69
|
::Resque.dequeue(FastJob, { :generate => :farfalla })
|
66
70
|
end
|
67
71
|
|
68
|
-
|
69
|
-
assert_equal
|
72
|
+
spans = ::Instana.processor.queued_spans
|
73
|
+
assert_equal 3, spans.length
|
70
74
|
|
71
|
-
|
72
|
-
|
75
|
+
sdk_span = find_first_span_by_name(spans, :'resque-client_test')
|
76
|
+
resque_span = find_first_span_by_name(spans, :'resque-client')
|
77
|
+
redis_span = find_first_span_by_name(spans, :redis)
|
73
78
|
|
74
|
-
assert_equal :'resque-client_test',
|
79
|
+
assert_equal :'resque-client_test', sdk_span[:data][:sdk][:name]
|
75
80
|
assert_equal :"resque-client", spans[1][:n]
|
76
|
-
assert_equal "FastJob",
|
77
|
-
assert_equal :critical,
|
78
|
-
assert_equal false,
|
79
|
-
assert_equal :redis,
|
81
|
+
assert_equal "FastJob", resque_span[:data][:'resque-client'][:job]
|
82
|
+
assert_equal :critical, resque_span[:data][:'resque-client'][:queue]
|
83
|
+
assert_equal false, resque_span[:data][:'resque-client'].key?(:error)
|
84
|
+
assert_equal :redis, redis_span[:n]
|
80
85
|
end
|
81
86
|
|
82
87
|
def test_worker_job
|
83
88
|
Resque::Job.create(:critical, FastJob)
|
84
89
|
@worker.work(0)
|
85
90
|
|
86
|
-
|
87
|
-
assert_equal
|
88
|
-
|
89
|
-
spans = traces[0].spans.to_a
|
90
|
-
assert_equal 3, spans.count
|
91
|
+
spans = ::Instana.processor.queued_spans
|
92
|
+
assert_equal 3, spans.length
|
91
93
|
|
92
|
-
resque_span = spans[
|
94
|
+
resque_span = spans[2]
|
93
95
|
redis1_span = spans[1]
|
94
|
-
redis2_span = spans[
|
96
|
+
redis2_span = spans[0]
|
95
97
|
|
96
98
|
assert_equal :'resque-worker', resque_span[:n]
|
97
99
|
assert_equal false, resque_span.key?(:error)
|
@@ -110,12 +112,10 @@ class ResqueClientTest < Minitest::Test
|
|
110
112
|
Resque::Job.create(:critical, ErrorJob)
|
111
113
|
@worker.work(0)
|
112
114
|
|
113
|
-
|
114
|
-
assert_equal
|
115
|
+
spans = ::Instana.processor.queued_spans
|
116
|
+
assert_equal 5, spans.length
|
115
117
|
|
116
|
-
|
117
|
-
resque_span = spans[0]
|
118
|
-
assert_equal 5, spans.count
|
118
|
+
resque_span = find_first_span_by_name(spans, :'resque-worker')
|
119
119
|
|
120
120
|
assert_equal :'resque-worker', resque_span[:n]
|
121
121
|
assert_equal true, resque_span.key?(:error)
|
@@ -17,44 +17,38 @@ class RestClientTest < Minitest::Test
|
|
17
17
|
RestClient.get url
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
spans = ::Instana.processor.queued_spans
|
21
|
+
assert_equal 4, spans.length
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
24
|
+
sdk_span = find_first_span_by_name(spans, :'restclient-test')
|
25
|
+
rest_span = find_first_span_by_name(spans, :'rest-client')
|
26
|
+
net_span = find_first_span_by_name(spans, :'net-http')
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
spans = http_trace.spans.to_a
|
29
|
-
first_span = spans[0]
|
30
|
-
second_span = spans[1]
|
31
|
-
third_span = spans[2]
|
28
|
+
validate_sdk_span(sdk_span, {:name => :'restclient-test', :type => :intermediate})
|
29
|
+
validate_sdk_span(rest_span, {:name => :'rest-client', :type => :intermediate})
|
32
30
|
|
33
31
|
# Span name validation
|
34
|
-
|
35
|
-
assert_equal :
|
36
|
-
assert_equal :
|
37
|
-
assert_equal :"net-http",
|
32
|
+
assert_equal :rack, rack_span[:n]
|
33
|
+
assert_equal :sdk, sdk_span[:n]
|
34
|
+
assert_equal :sdk, rest_span[:n]
|
35
|
+
assert_equal :"net-http", net_span[:n]
|
38
36
|
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
assert_equal
|
37
|
+
# Trace IDs and relationships
|
38
|
+
trace_id = sdk_span[:t]
|
39
|
+
assert_equal trace_id, rest_span[:t]
|
40
|
+
assert_equal trace_id, net_span[:t]
|
41
|
+
assert_equal trace_id, rack_span[:t]
|
42
|
+
|
43
|
+
assert_equal sdk_span[:s], rest_span[:p]
|
44
|
+
assert_equal rest_span[:s], net_span[:p]
|
45
|
+
assert_equal net_span[:s], rack_span[:p]
|
43
46
|
|
44
47
|
# data keys/values
|
45
|
-
refute_nil
|
46
|
-
refute_nil
|
47
|
-
assert_equal "http://127.0.0.1:6511/",
|
48
|
-
assert_equal "200",
|
49
|
-
|
50
|
-
# Rack server trace validation
|
51
|
-
assert_equal 1, rs_trace.spans.length
|
52
|
-
rs_span = rs_trace.spans.to_a[0]
|
53
|
-
|
54
|
-
# Rack server trace should have the same trace ID
|
55
|
-
assert_equal http_trace.id, rs_span[:t].to_i
|
56
|
-
# Rack server trace should have net-http has parent span
|
57
|
-
assert_equal third_span.id, rs_span[:p].to_i
|
48
|
+
refute_nil net_span.key?(:data)
|
49
|
+
refute_nil net_span[:data].key?(:http)
|
50
|
+
assert_equal "http://127.0.0.1:6511/", net_span[:data][:http][:url]
|
51
|
+
assert_equal "200", net_span[:data][:http][:status]
|
58
52
|
|
59
53
|
WebMock.disable_net_connect!
|
60
54
|
end
|
@@ -65,18 +65,14 @@ class SidekiqClientTest < Minitest::Test
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def assert_normal_trace_recorded(job)
|
68
|
-
|
69
|
-
|
68
|
+
spans = ::Instana.processor.queued_spans
|
69
|
+
assert_equal 2, spans.length
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
first_span = spans[0]
|
74
|
-
second_span = spans[1]
|
71
|
+
first_span = spans[1]
|
72
|
+
second_span = spans[0]
|
75
73
|
|
76
|
-
assert_equal :
|
77
|
-
|
78
|
-
|
79
|
-
assert_equal first_span.id, second_span[:p]
|
74
|
+
assert_equal first_span[:s], second_span[:p]
|
75
|
+
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :intermediate})
|
80
76
|
|
81
77
|
assert_equal :'sidekiq-client', second_span[:n]
|
82
78
|
assert_equal 'some_random_queue', second_span[:data][:'sidekiq-client'][:queue]
|
@@ -86,18 +82,14 @@ class SidekiqClientTest < Minitest::Test
|
|
86
82
|
end
|
87
83
|
|
88
84
|
def assert_failure_trace_recorded
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
assert_equal 2, client_trace.spans.length
|
93
|
-
spans = client_trace.spans.to_a
|
94
|
-
first_span = spans[0]
|
95
|
-
second_span = spans[1]
|
85
|
+
spans = ::Instana.processor.queued_spans
|
86
|
+
assert_equal 2, spans.length
|
96
87
|
|
97
|
-
|
98
|
-
|
88
|
+
first_span = spans[1]
|
89
|
+
second_span = spans[0]
|
99
90
|
|
100
|
-
assert_equal first_span
|
91
|
+
assert_equal first_span[:s], second_span[:p]
|
92
|
+
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :intermediate})
|
101
93
|
|
102
94
|
assert_equal :'sidekiq-client', second_span[:n]
|
103
95
|
assert_equal true, second_span[:error]
|
@@ -30,8 +30,9 @@ class SidekiqServerTest < Minitest::Test
|
|
30
30
|
enable_redis_instrumentation
|
31
31
|
sleep 1
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
spans = Instana.processor.queued_spans
|
34
|
+
worker_span = find_spans_by_name(spans, :'sidekiq-worker').first
|
35
|
+
assert_successful_worker_span(worker_span)
|
35
36
|
|
36
37
|
$sidekiq_mode = :client
|
37
38
|
end
|
@@ -59,8 +60,10 @@ class SidekiqServerTest < Minitest::Test
|
|
59
60
|
enable_redis_instrumentation
|
60
61
|
|
61
62
|
sleep 1
|
62
|
-
|
63
|
-
|
63
|
+
|
64
|
+
spans = Instana.processor.queued_spans
|
65
|
+
worker_span = find_spans_by_name(spans, :'sidekiq-worker').first
|
66
|
+
assert_failed_worker_span(worker_span)
|
64
67
|
|
65
68
|
$sidekiq_mode = :client
|
66
69
|
end
|
@@ -80,15 +83,20 @@ class SidekiqServerTest < Minitest::Test
|
|
80
83
|
enable_redis_instrumentation
|
81
84
|
end
|
82
85
|
sleep 1
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
)
|
87
|
-
|
88
|
-
|
86
|
+
spans = Instana.processor.queued_spans
|
87
|
+
|
88
|
+
sdk_span = find_spans_by_name(spans, :sidekiqtests).first
|
89
|
+
validate_sdk_span(sdk_span)
|
90
|
+
|
91
|
+
client_span = find_spans_by_name(spans, :'sidekiq-client').first
|
92
|
+
assert_client_span(client_span, ::SidekiqJobOne)
|
93
|
+
|
94
|
+
worker_span = find_spans_by_name(spans, :'sidekiq-worker').first
|
95
|
+
assert_successful_worker_span(worker_span)
|
89
96
|
|
90
97
|
# Worker trace and client trace are in the same trace
|
91
|
-
assert_equal
|
98
|
+
assert_equal worker_span[:t], client_span[:t]
|
99
|
+
assert_equal worker_span[:p], client_span[:s]
|
92
100
|
|
93
101
|
$sidekiq_mode = :client
|
94
102
|
end
|
@@ -108,15 +116,21 @@ class SidekiqServerTest < Minitest::Test
|
|
108
116
|
enable_redis_instrumentation
|
109
117
|
end
|
110
118
|
sleep 1
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
)
|
115
|
-
|
116
|
-
|
119
|
+
|
120
|
+
spans = Instana.processor.queued_spans
|
121
|
+
|
122
|
+
sdk_span = find_spans_by_name(spans, :sidekiqtests).first
|
123
|
+
validate_sdk_span(sdk_span)
|
124
|
+
|
125
|
+
client_span = find_spans_by_name(spans, :'sidekiq-client').first
|
126
|
+
assert_client_span(client_span, ::SidekiqJobTwo)
|
127
|
+
|
128
|
+
worker_span = find_spans_by_name(spans, :'sidekiq-worker').first
|
129
|
+
assert_failed_worker_span(worker_span)
|
117
130
|
|
118
131
|
# Worker trace and client trace are in the same trace
|
119
|
-
assert_equal
|
132
|
+
assert_equal worker_span[:t], client_span[:t]
|
133
|
+
assert_equal worker_span[:p], client_span[:s]
|
120
134
|
|
121
135
|
$sidekiq_mode = :client
|
122
136
|
end
|
@@ -132,57 +146,28 @@ class SidekiqServerTest < Minitest::Test
|
|
132
146
|
end
|
133
147
|
end
|
134
148
|
|
135
|
-
def
|
136
|
-
|
137
|
-
trying_server = traces[1]
|
138
|
-
|
139
|
-
try_successfully = trying_client.spans.any? do |span|
|
140
|
-
span.name == :'sidekiq-client'
|
141
|
-
end
|
149
|
+
def assert_successful_worker_span(worker_span)
|
150
|
+
assert_equal :'sidekiq-worker', worker_span[:n]
|
142
151
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
[trying_server, trying_client]
|
147
|
-
end
|
152
|
+
assert_equal 'important', worker_span[:data][:'sidekiq-worker'][:queue]
|
153
|
+
assert_equal 'SidekiqJobOne', worker_span[:data][:'sidekiq-worker'][:job]
|
154
|
+
assert_equal false, worker_span[:data][:'sidekiq-worker'][:job_id].nil?
|
148
155
|
end
|
149
156
|
|
150
|
-
def
|
151
|
-
assert_equal
|
152
|
-
span = worker_trace.spans.first
|
157
|
+
def assert_failed_worker_span(worker_span)
|
158
|
+
assert_equal :'sidekiq-worker', worker_span[:n]
|
153
159
|
|
154
|
-
assert_equal :'sidekiq-worker'
|
160
|
+
assert_equal 'important', worker_span[:data][:'sidekiq-worker'][:queue]
|
161
|
+
assert_equal 'SidekiqJobTwo', worker_span[:data][:'sidekiq-worker'][:job]
|
162
|
+
assert_equal false, worker_span[:data][:'sidekiq-worker'][:job_id].nil?
|
155
163
|
|
156
|
-
assert_equal
|
157
|
-
assert_equal '
|
158
|
-
assert_equal false, span[:data][:'sidekiq-worker'][:job_id].nil?
|
164
|
+
assert_equal true, worker_span[:data][:'sidekiq-worker'][:error]
|
165
|
+
assert_equal 'Fail to execute the job', worker_span[:data][:log][:message]
|
159
166
|
end
|
160
167
|
|
161
|
-
def
|
162
|
-
assert_equal
|
163
|
-
|
164
|
-
|
165
|
-
assert_equal :'sidekiq-worker', span[:n]
|
166
|
-
|
167
|
-
assert_equal 'important', span[:data][:'sidekiq-worker'][:queue]
|
168
|
-
assert_equal 'SidekiqJobTwo', span[:data][:'sidekiq-worker'][:job]
|
169
|
-
assert_equal false, span[:data][:'sidekiq-worker'][:job_id].nil?
|
170
|
-
|
171
|
-
assert_equal true, span[:data][:'sidekiq-worker'][:error]
|
172
|
-
assert_equal 'Fail to execute the job', span[:data][:log][:message]
|
173
|
-
end
|
174
|
-
|
175
|
-
def assert_client_trace(client_trace, job)
|
176
|
-
assert_equal 2, client_trace.spans.length
|
177
|
-
first_span, second_span = client_trace.spans.to_a
|
178
|
-
|
179
|
-
assert_equal :sdk, first_span[:n]
|
180
|
-
assert_equal :sidekiqtests, first_span[:data][:sdk][:name]
|
181
|
-
|
182
|
-
assert_equal first_span.id, second_span[:p]
|
183
|
-
|
184
|
-
assert_equal :'sidekiq-client', second_span[:n]
|
185
|
-
assert_equal 'important', second_span[:data][:'sidekiq-client'][:queue]
|
186
|
-
assert_equal job.name, second_span[:data][:'sidekiq-client'][:job]
|
168
|
+
def assert_client_span(client_span, job)
|
169
|
+
assert_equal :'sidekiq-client', client_span[:n]
|
170
|
+
assert_equal 'important', client_span[:data][:'sidekiq-client'][:queue]
|
171
|
+
assert_equal job.name, client_span[:data][:'sidekiq-client'][:job]
|
187
172
|
end
|
188
173
|
end
|