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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/instana/agent.rb +19 -19
  3. data/lib/instana/agent/helpers.rb +2 -2
  4. data/lib/instana/agent/tasks.rb +2 -2
  5. data/lib/instana/collectors/gc.rb +1 -1
  6. data/lib/instana/collectors/memory.rb +1 -1
  7. data/lib/instana/collectors/thread.rb +1 -1
  8. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +1 -1
  9. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +1 -1
  10. data/lib/instana/helpers.rb +2 -2
  11. data/lib/instana/instrumentation.rb +1 -1
  12. data/lib/instana/instrumentation/excon.rb +8 -5
  13. data/lib/instana/instrumentation/rack.rb +2 -2
  14. data/lib/instana/instrumentation/resque.rb +3 -3
  15. data/lib/instana/tracer.rb +92 -117
  16. data/lib/instana/tracing/processor.rb +18 -133
  17. data/lib/instana/tracing/span.rb +40 -35
  18. data/lib/instana/tracing/span_context.rb +3 -1
  19. data/lib/instana/util.rb +5 -5
  20. data/lib/instana/version.rb +1 -1
  21. data/lib/opentracing.rb +1 -1
  22. data/test/frameworks/rack_test.rb +6 -11
  23. data/test/frameworks/rails/actioncontroller_test.rb +32 -62
  24. data/test/frameworks/rails/actionview5_test.rb +91 -132
  25. data/test/frameworks/rails/activerecord5_test.rb +14 -17
  26. data/test/instrumentation/dalli_test.rb +51 -72
  27. data/test/instrumentation/excon_test.rb +70 -94
  28. data/test/instrumentation/grpc_test.rb +164 -126
  29. data/test/instrumentation/net-http_test.rb +48 -57
  30. data/test/instrumentation/redis_test.rb +4 -6
  31. data/test/instrumentation/resque_test.rb +41 -41
  32. data/test/instrumentation/rest-client_test.rb +25 -31
  33. data/test/instrumentation/sidekiq-client_test.rb +12 -20
  34. data/test/instrumentation/sidekiq-worker_test.rb +48 -63
  35. data/test/jobs/resque_error_job.rb +7 -1
  36. data/test/jobs/resque_fast_job.rb +7 -1
  37. data/test/servers/sidekiq/worker.rb +1 -3
  38. data/test/test_helper.rb +58 -0
  39. data/test/tracing/custom_test.rb +11 -19
  40. data/test/tracing/opentracing_test.rb +48 -156
  41. data/test/tracing/trace_test.rb +67 -67
  42. data/test/tracing/tracer_async_test.rb +75 -175
  43. data/test/tracing/tracer_test.rb +75 -75
  44. metadata +4 -5
  45. data/lib/instana/tracing/trace.rb +0 -316
@@ -12,20 +12,13 @@ class ActionControllerTest < Minitest::Test
12
12
 
13
13
  Net::HTTP.get(URI.parse('http://localhost:3205/test/world'))
14
14
 
15
- traces = Instana.processor.queued_traces
16
- assert_equal 1, traces.length
17
- trace = traces.first
15
+ spans = ::Instana.processor.queued_spans
16
+ assert_equal 3, spans.length
18
17
 
19
- assert_equal 3, trace.spans.length
20
- spans = trace.spans.to_a
21
- first_span = spans[0]
22
- second_span = spans[1]
23
-
24
- assert_equal :rack, first_span.name
18
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
25
19
 
26
- assert_equal :actioncontroller, second_span.name
27
- assert_equal "TestController", second_span[:data][:actioncontroller][:controller]
28
- assert_equal "world", second_span[:data][:actioncontroller][:action]
20
+ assert_equal "TestController", ac_span[:data][:actioncontroller][:controller]
21
+ assert_equal "world", ac_span[:data][:actioncontroller][:action]
29
22
  end
30
23
 
31
24
  def test_controller_error
@@ -33,24 +26,17 @@ class ActionControllerTest < Minitest::Test
33
26
 
34
27
  Net::HTTP.get(URI.parse('http://localhost:3205/test/error'))
35
28
 
36
- traces = Instana.processor.queued_traces
37
- assert_equal 1, traces.length
38
- trace = traces.first
39
-
40
- assert_equal 2, trace.spans.length
41
- spans = trace.spans.to_a
42
- first_span = spans[0]
43
- second_span = spans[1]
29
+ spans = ::Instana.processor.queued_spans
30
+ assert_equal 2, spans.length
44
31
 
45
- assert_equal :rack, first_span.name
32
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
46
33
 
47
- assert_equal :actioncontroller, second_span.name
48
- assert_equal "TestController", second_span[:data][:actioncontroller][:controller]
49
- assert_equal "error", second_span[:data][:actioncontroller][:action]
50
- assert second_span.key?(:error)
51
- assert second_span.key?(:stack)
52
- assert_equal "Warning: This is a simulated Error", second_span[:data][:log][:message]
53
- assert_equal "Exception", second_span[:data][:log][:parameters]
34
+ assert_equal "TestController", ac_span[:data][:actioncontroller][:controller]
35
+ assert_equal "error", ac_span[:data][:actioncontroller][:action]
36
+ assert ac_span.key?(:error)
37
+ assert ac_span.key?(:stack)
38
+ assert_equal "Warning: This is a simulated Error", ac_span[:data][:log][:message]
39
+ assert_equal "Exception", ac_span[:data][:log][:parameters]
54
40
  end
55
41
 
56
42
  def test_api_controller_reporting
@@ -61,20 +47,14 @@ class ActionControllerTest < Minitest::Test
61
47
 
62
48
  Net::HTTP.get(URI.parse('http://localhost:3205/api/world'))
63
49
 
64
- traces = Instana.processor.queued_traces
65
- assert_equal 1, traces.length
66
- trace = traces.first
50
+ spans = ::Instana.processor.queued_spans
51
+ assert_equal 3, spans.length
67
52
 
68
- assert_equal 3, trace.spans.length
69
- spans = trace.spans.to_a
70
- first_span = spans[0]
71
- second_span = spans[1]
72
-
73
- assert_equal :rack, first_span.name
53
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
74
54
 
75
- assert_equal :actioncontroller, second_span.name
76
- assert_equal "SocketController", second_span[:data][:actioncontroller][:controller]
77
- assert_equal "world", second_span[:data][:actioncontroller][:action]
55
+ assert_equal :actioncontroller, ac_span[:n]
56
+ assert_equal "SocketController", ac_span[:data][:actioncontroller][:controller]
57
+ assert_equal "world", ac_span[:data][:actioncontroller][:action]
78
58
  end
79
59
 
80
60
  def test_api_controller_error
@@ -85,24 +65,17 @@ class ActionControllerTest < Minitest::Test
85
65
 
86
66
  Net::HTTP.get(URI.parse('http://localhost:3205/api/error'))
87
67
 
88
- traces = Instana.processor.queued_traces
89
- assert_equal 1, traces.length
90
- trace = traces.first
91
-
92
- assert_equal 2, trace.spans.length
93
- spans = trace.spans.to_a
94
- first_span = spans[0]
95
- second_span = spans[1]
68
+ spans = ::Instana.processor.queued_spans
69
+ assert_equal 2, spans.length
96
70
 
97
- assert_equal :rack, first_span.name
71
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
98
72
 
99
- assert_equal :actioncontroller, second_span.name
100
- assert_equal "SocketController", second_span[:data][:actioncontroller][:controller]
101
- assert_equal "error", second_span[:data][:actioncontroller][:action]
102
- assert second_span.key?(:error)
103
- assert second_span.key?(:stack)
104
- assert_equal "Warning: This is a simulated Socket API Error", second_span[:data][:log][:message]
105
- assert_equal "Exception", second_span[:data][:log][:parameters]
73
+ assert_equal "SocketController", ac_span[:data][:actioncontroller][:controller]
74
+ assert_equal "error", ac_span[:data][:actioncontroller][:action]
75
+ assert ac_span.key?(:error)
76
+ assert ac_span.key?(:stack)
77
+ assert_equal "Warning: This is a simulated Socket API Error", ac_span[:data][:log][:message]
78
+ assert_equal "Exception", ac_span[:data][:log][:parameters]
106
79
  end
107
80
 
108
81
  def test_404
@@ -110,14 +83,11 @@ class ActionControllerTest < Minitest::Test
110
83
 
111
84
  Net::HTTP.get(URI.parse('http://localhost:3205/test/404'))
112
85
 
113
- traces = Instana.processor.queued_traces
114
- assert_equal 1, traces.length
115
- trace = traces.first
86
+ spans = ::Instana.processor.queued_spans
87
+ assert_equal 1, spans.length
116
88
 
117
- assert_equal 1, trace.spans.length
118
- spans = trace.spans.to_a
119
89
  first_span = spans[0]
120
90
 
121
- assert_equal :rack, first_span.name
91
+ assert_equal :rack, first_span[:n]
122
92
  end
123
93
  end
@@ -12,19 +12,16 @@ class ActionViewTest < Minitest::Test
12
12
 
13
13
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_view'))
14
14
 
15
- traces = Instana.processor.queued_traces
16
- assert_equal 1, traces.length
17
- trace = traces.first
15
+ spans = ::Instana.processor.queued_spans
16
+ assert_equal 3, spans.length
18
17
 
19
- assert_equal 3, trace.spans.length
20
- spans = trace.spans.to_a
21
- first_span = spans[0]
18
+ first_span = spans[2]
22
19
  second_span = spans[1]
23
- third_span = spans[2]
20
+ third_span = spans[0]
24
21
 
25
- assert_equal :rack, first_span.name
26
- assert_equal :actioncontroller, second_span.name
27
- assert_equal :actionview, third_span.name
22
+ assert_equal :rack, first_span[:n]
23
+ assert_equal :actioncontroller, second_span[:n]
24
+ assert_equal :actionview, third_span[:n]
28
25
  end
29
26
 
30
27
  def test_render_nothing
@@ -32,20 +29,17 @@ class ActionViewTest < Minitest::Test
32
29
 
33
30
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_nothing'))
34
31
 
35
- traces = Instana.processor.queued_traces
36
- assert_equal 1, traces.length
37
- trace = traces.first
32
+ spans = ::Instana.processor.queued_spans
33
+ assert_equal 3, spans.length
38
34
 
39
- assert_equal 3, trace.spans.length
40
- spans = trace.spans.to_a
41
- first_span = spans[0]
35
+ first_span = spans[2]
42
36
  second_span = spans[1]
43
- third_span = spans[2]
37
+ third_span = spans[0]
44
38
 
45
- assert_equal :rack, first_span.name
46
- assert_equal :actioncontroller, second_span.name
39
+ assert_equal :rack, first_span[:n]
40
+ assert_equal :actioncontroller, second_span[:n]
47
41
  assert_equal "Nothing", third_span[:data][:actionview][:name]
48
- assert_equal :actionview, third_span.name
42
+ assert_equal :actionview, third_span[:n]
49
43
  end
50
44
 
51
45
  def test_render_file
@@ -53,20 +47,17 @@ class ActionViewTest < Minitest::Test
53
47
 
54
48
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_file'))
55
49
 
56
- traces = Instana.processor.queued_traces
57
- assert_equal 1, traces.length
58
- trace = traces.first
50
+ spans = ::Instana.processor.queued_spans
51
+ assert_equal 3, spans.length
59
52
 
60
- assert_equal 3, trace.spans.length
61
- spans = trace.spans.to_a
62
- first_span = spans[0]
53
+ first_span = spans[2]
63
54
  second_span = spans[1]
64
- third_span = spans[2]
55
+ third_span = spans[0]
65
56
 
66
- assert_equal :rack, first_span.name
67
- assert_equal :actioncontroller, second_span.name
57
+ assert_equal :rack, first_span[:n]
58
+ assert_equal :actioncontroller, second_span[:n]
68
59
  assert_equal "/etc/issue", third_span[:data][:actionview][:name]
69
- assert_equal :actionview, third_span.name
60
+ assert_equal :actionview, third_span[:n]
70
61
  end
71
62
 
72
63
  def test_render_json
@@ -74,20 +65,17 @@ class ActionViewTest < Minitest::Test
74
65
 
75
66
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_json'))
76
67
 
77
- traces = Instana.processor.queued_traces
78
- assert_equal 1, traces.length
79
- trace = traces.first
68
+ spans = ::Instana.processor.queued_spans
69
+ assert_equal 3, spans.length
80
70
 
81
- assert_equal 3, trace.spans.length
82
- spans = trace.spans.to_a
83
- first_span = spans[0]
71
+ first_span = spans[2]
84
72
  second_span = spans[1]
85
- third_span = spans[2]
73
+ third_span = spans[0]
86
74
 
87
- assert_equal :rack, first_span.name
88
- assert_equal :actioncontroller, second_span.name
75
+ assert_equal :rack, first_span[:n]
76
+ assert_equal :actioncontroller, second_span[:n]
89
77
  assert_equal "JSON", third_span[:data][:actionview][:name]
90
- assert_equal :actionview, third_span.name
78
+ assert_equal :actionview, third_span[:n]
91
79
  end
92
80
 
93
81
  def test_render_xml
@@ -95,20 +83,17 @@ class ActionViewTest < Minitest::Test
95
83
 
96
84
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_xml'))
97
85
 
98
- traces = Instana.processor.queued_traces
99
- assert_equal 1, traces.length
100
- trace = traces.first
86
+ spans = ::Instana.processor.queued_spans
87
+ assert_equal 3, spans.length
101
88
 
102
- assert_equal 3, trace.spans.length
103
- spans = trace.spans.to_a
104
- first_span = spans[0]
89
+ first_span = spans[2]
105
90
  second_span = spans[1]
106
- third_span = spans[2]
91
+ third_span = spans[0]
107
92
 
108
- assert_equal :rack, first_span.name
109
- assert_equal :actioncontroller, second_span.name
93
+ assert_equal :rack, first_span[:n]
94
+ assert_equal :actioncontroller, second_span[:n]
110
95
  assert_equal "XML", third_span[:data][:actionview][:name]
111
- assert_equal :actionview, third_span.name
96
+ assert_equal :actionview, third_span[:n]
112
97
  end
113
98
 
114
99
  def test_render_body
@@ -116,20 +101,16 @@ class ActionViewTest < Minitest::Test
116
101
 
117
102
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_rawbody'))
118
103
 
119
- traces = Instana.processor.queued_traces
120
- assert_equal 1, traces.length
121
- trace = traces.first
104
+ spans = ::Instana.processor.queued_spans
105
+ assert_equal 3, spans.length
122
106
 
123
- assert_equal 3, trace.spans.length
124
- spans = trace.spans.to_a
125
- first_span = spans[0]
126
- second_span = spans[1]
127
- third_span = spans[2]
107
+ rack_span = find_first_span_by_name(spans, :rack)
108
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
109
+ av_span = find_first_span_by_name(spans, :actionview)
128
110
 
129
- assert_equal :rack, first_span.name
130
- assert_equal :actioncontroller, second_span.name
131
- assert_equal "Raw", third_span[:data][:actionview][:name]
132
- assert_equal :actionview, third_span.name
111
+ assert_equal :actioncontroller, ac_span[:n]
112
+ assert_equal "Raw", av_span[:data][:actionview][:name]
113
+ assert_equal :actionview, av_span[:n]
133
114
  end
134
115
 
135
116
  def test_render_js
@@ -137,20 +118,17 @@ class ActionViewTest < Minitest::Test
137
118
 
138
119
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_js'))
139
120
 
140
- traces = Instana.processor.queued_traces
141
- assert_equal 1, traces.length
142
- trace = traces.first
121
+ spans = ::Instana.processor.queued_spans
122
+ assert_equal 3, spans.length
143
123
 
144
- assert_equal 3, trace.spans.length
145
- spans = trace.spans.to_a
146
- first_span = spans[0]
124
+ first_span = spans[2]
147
125
  second_span = spans[1]
148
- third_span = spans[2]
126
+ third_span = spans[0]
149
127
 
150
- assert_equal :rack, first_span.name
151
- assert_equal :actioncontroller, second_span.name
128
+ assert_equal :rack, first_span[:n]
129
+ assert_equal :actioncontroller, second_span[:n]
152
130
  assert_equal "Javascript", third_span[:data][:actionview][:name]
153
- assert_equal :actionview, third_span.name
131
+ assert_equal :actionview, third_span[:n]
154
132
  end
155
133
 
156
134
  def test_render_alternate_layout
@@ -158,20 +136,17 @@ class ActionViewTest < Minitest::Test
158
136
 
159
137
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_alternate_layout'))
160
138
 
161
- traces = Instana.processor.queued_traces
162
- assert_equal 1, traces.length
163
- trace = traces.first
139
+ spans = ::Instana.processor.queued_spans
140
+ assert_equal 3, spans.length
164
141
 
165
- assert_equal 3, trace.spans.length
166
- spans = trace.spans.to_a
167
- first_span = spans[0]
142
+ first_span = spans[2]
168
143
  second_span = spans[1]
169
- third_span = spans[2]
144
+ third_span = spans[0]
170
145
 
171
- assert_equal :rack, first_span.name
172
- assert_equal :actioncontroller, second_span.name
146
+ assert_equal :rack, first_span[:n]
147
+ assert_equal :actioncontroller, second_span[:n]
173
148
  assert_equal "layouts/mobile", third_span[:data][:actionview][:name]
174
- assert_equal :actionview, third_span.name
149
+ assert_equal :actionview, third_span[:n]
175
150
  end
176
151
 
177
152
  def test_render_partial
@@ -179,21 +154,18 @@ class ActionViewTest < Minitest::Test
179
154
 
180
155
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial'))
181
156
 
182
- traces = Instana.processor.queued_traces
183
- assert_equal 1, traces.length
184
- trace = traces.first
157
+ spans = ::Instana.processor.queued_spans
158
+ assert_equal 4, spans.length
185
159
 
186
- assert_equal 4, trace.spans.length
187
- spans = trace.spans.to_a
188
- first_span = spans[0]
189
- second_span = spans[1]
190
- third_span = spans[2]
191
- fourth_span = spans[3]
160
+ first_span = spans[3]
161
+ second_span = spans[2]
162
+ third_span = spans[1]
163
+ fourth_span = spans[0]
192
164
 
193
- assert_equal :rack, first_span.name
194
- assert_equal :actioncontroller, second_span.name
195
- assert_equal :actionview, third_span.name
196
- assert_equal :render, fourth_span.name
165
+ assert_equal :rack, first_span[:n]
166
+ assert_equal :actioncontroller, second_span[:n]
167
+ assert_equal :actionview, third_span[:n]
168
+ assert_equal :render, fourth_span[:n]
197
169
  assert_equal :partial, fourth_span[:data][:render][:type]
198
170
  assert_equal 'message', fourth_span[:data][:render][:name]
199
171
  end
@@ -203,21 +175,18 @@ class ActionViewTest < Minitest::Test
203
175
 
204
176
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial_that_errors'))
205
177
 
206
- traces = Instana.processor.queued_traces
207
- assert_equal 1, traces.length
208
- trace = traces.first
178
+ spans = ::Instana.processor.queued_spans
179
+ assert_equal 4, spans.length
209
180
 
210
- assert_equal 4, trace.spans.length
211
- spans = trace.spans.to_a
212
- first_span = spans[0]
213
- second_span = spans[1]
214
- third_span = spans[2]
215
- fourth_span = spans[3]
181
+ first_span = spans[3]
182
+ second_span = spans[2]
183
+ third_span = spans[1]
184
+ fourth_span = spans[0]
216
185
 
217
- assert_equal :rack, first_span.name
218
- assert_equal :actioncontroller, second_span.name
219
- assert_equal :actionview, third_span.name
220
- assert_equal :render, fourth_span.name
186
+ assert_equal :rack, first_span[:n]
187
+ assert_equal :actioncontroller, second_span[:n]
188
+ assert_equal :actionview, third_span[:n]
189
+ assert_equal :render, fourth_span[:n]
221
190
  assert_equal :partial, fourth_span[:data][:render][:type]
222
191
  assert_equal 'syntax_error', fourth_span[:data][:render][:name]
223
192
  assert fourth_span[:data][:log].key?(:message)
@@ -231,32 +200,22 @@ class ActionViewTest < Minitest::Test
231
200
 
232
201
  Net::HTTP.get(URI.parse('http://localhost:3205/test/render_collection'))
233
202
 
234
- traces = Instana.processor.queued_traces
235
- assert_equal 1, traces.length
236
- trace = traces.first
237
-
238
- assert_equal 5, trace.spans.length
239
- spans = trace.spans.to_a
240
- first_span = spans[0]
241
- second_span = spans[1]
242
- third_span = spans[2]
243
- fourth_span = spans[3]
244
- fifth_span = spans[4]
245
-
246
- assert_equal :rack, first_span.name
247
- assert_equal :actioncontroller, second_span.name
203
+ spans = ::Instana.processor.queued_spans
204
+ assert_equal 5, spans.length
248
205
 
206
+ rack_span = find_first_span_by_name(spans, :rack)
207
+ ac_span = find_first_span_by_name(spans, :actioncontroller)
208
+ ar_span = find_first_span_by_name(spans, :activerecord)
209
+ av_span = find_first_span_by_name(spans, :actionview)
210
+ render_span = find_first_span_by_name(spans, :render)
249
211
 
250
- if Rails::VERSION::STRING < '4.0'
251
- assert_equal :activerecord, third_span.name
252
- assert_equal :actionview, fourth_span.name
253
- else
254
- assert_equal :actionview, third_span.name
255
- assert_equal :activerecord, fourth_span.name
256
- end
212
+ assert_equal render_span[:p], av_span[:s]
213
+ assert_equal av_span[:p], ac_span[:s]
214
+ assert_equal ar_span[:p], av_span[:s]
215
+ assert_equal ac_span[:p], rack_span[:s]
257
216
 
258
- assert_equal :render, fifth_span.name
259
- assert_equal :collection, fifth_span[:data][:render][:type]
260
- assert_equal 'blocks/block', fifth_span[:data][:render][:name]
217
+ assert_equal :render, render_span[:n]
218
+ assert_equal :collection, render_span[:data][:render][:type]
219
+ assert_equal 'blocks/block', render_span[:data][:render][:name]
261
220
  end
262
221
  end