instana 1.193.5 → 1.195.3

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -2
  3. data/Appraisals +17 -1
  4. data/docker-compose.yml +20 -0
  5. data/gemfiles/aws_30.gemfile +21 -0
  6. data/gemfiles/excon_021.gemfile +18 -0
  7. data/gemfiles/excon_079.gemfile +18 -0
  8. data/gemfiles/shoryuken_50.gemfile +19 -0
  9. data/lib/instana/activators/aws_sdk_dynamodb.rb +20 -0
  10. data/lib/instana/activators/aws_sdk_s3.rb +20 -0
  11. data/lib/instana/activators/aws_sdk_sns.rb +20 -0
  12. data/lib/instana/activators/aws_sdk_sqs.rb +20 -0
  13. data/lib/instana/activators/excon.rb +1 -1
  14. data/lib/instana/activators/shoryuken.rb +24 -0
  15. data/lib/instana/config.rb +3 -0
  16. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +48 -0
  17. data/lib/instana/instrumentation/aws_sdk_s3.rb +55 -0
  18. data/lib/instana/instrumentation/aws_sdk_sns.rb +29 -0
  19. data/lib/instana/instrumentation/aws_sdk_sqs.rb +98 -0
  20. data/lib/instana/instrumentation/excon.rb +10 -4
  21. data/lib/instana/instrumentation/instrumented_request.rb +64 -7
  22. data/lib/instana/instrumentation/net-http.rb +10 -3
  23. data/lib/instana/instrumentation/rack.rb +35 -15
  24. data/lib/instana/instrumentation/shoryuken.rb +44 -0
  25. data/lib/instana/instrumentation/sidekiq-client.rb +1 -1
  26. data/lib/instana/instrumentation/sidekiq-worker.rb +1 -1
  27. data/lib/instana/secrets.rb +2 -2
  28. data/lib/instana/tracer.rb +14 -11
  29. data/lib/instana/tracing/span.rb +9 -3
  30. data/lib/instana/tracing/span_context.rb +25 -1
  31. data/lib/instana/version.rb +1 -1
  32. data/test/instrumentation/aws_test.rb +161 -0
  33. data/test/instrumentation/excon_test.rb +1 -0
  34. data/test/instrumentation/net_http_test.rb +18 -0
  35. data/test/instrumentation/rack_instrumented_request_test.rb +50 -3
  36. data/test/instrumentation/rack_test.rb +141 -0
  37. data/test/instrumentation/shoryuken_test.rb +47 -0
  38. data/test/tracing/opentracing_test.rb +3 -3
  39. metadata +21 -3
  40. data/Dockerfile +0 -16
@@ -10,7 +10,7 @@ module Instana
10
10
  return str unless secret_values
11
11
 
12
12
  url = URI(str)
13
- params = CGI.parse(url.query || '')
13
+ params = url.scheme ? CGI.parse(url.query || '') : CGI.parse(url.to_s)
14
14
 
15
15
  redacted = params.map do |k, v|
16
16
  needs_redaction = secret_values['list']
@@ -19,7 +19,7 @@ module Instana
19
19
  end
20
20
 
21
21
  url.query = URI.encode_www_form(redacted)
22
- CGI.unescape(url.to_s)
22
+ url.scheme ? CGI.unescape(url.to_s) : CGI.unescape(url.query)
23
23
  end
24
24
 
25
25
  private
@@ -38,8 +38,8 @@ module Instana
38
38
  # :level specifies data collection level (optional)
39
39
  #
40
40
  def start_or_continue_trace(name, kvs = {}, incoming_context = nil, &block)
41
- log_start_or_continue(name, kvs, incoming_context)
42
- yield
41
+ span = log_start_or_continue(name, kvs, incoming_context)
42
+ yield(span)
43
43
  rescue Exception => e
44
44
  log_error(e)
45
45
  raise
@@ -59,8 +59,8 @@ module Instana
59
59
  # @param kvs [Hash] list of key values to be reported in this new span
60
60
  #
61
61
  def trace(name, kvs = {}, &block)
62
- log_entry(name, kvs)
63
- yield
62
+ span = log_entry(name, kvs)
63
+ yield(span)
64
64
  rescue Exception => e
65
65
  log_error(e)
66
66
  raise
@@ -91,7 +91,15 @@ module Instana
91
91
  if incoming_context
92
92
  if incoming_context.is_a?(Hash)
93
93
  if !incoming_context.empty?
94
- parent_context = SpanContext.new(incoming_context[:trace_id], incoming_context[:span_id], incoming_context[:level])
94
+ parent_context = SpanContext.new(
95
+ incoming_context[:trace_id],
96
+ incoming_context[:span_id],
97
+ incoming_context[:level],
98
+ {
99
+ external_trace_id: incoming_context[:external_trace_id],
100
+ external_state: incoming_context[:external_state]
101
+ }
102
+ )
95
103
  end
96
104
  else
97
105
  parent_context = incoming_context
@@ -103,12 +111,7 @@ module Instana
103
111
  else
104
112
  self.current_span = Span.new(name)
105
113
  end
106
-
107
- if incoming_context.is_a?(Hash) && incoming_context[:correlation] && !incoming_context[:correlation].empty?
108
- self.current_span[:crid] = incoming_context[:correlation][:id]
109
- self.current_span[:crtp] = incoming_context[:correlation][:type]
110
- end
111
-
114
+
112
115
  self.current_span.set_tags(kvs) unless kvs.empty?
113
116
  self.current_span
114
117
  end
@@ -6,10 +6,10 @@ module Instana
6
6
  REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
7
7
  :memcache, :'net-http', :rack, :render, :'rpc-client',
8
8
  :'rpc-server', :'sidekiq-client', :'sidekiq-worker',
9
- :redis, :'resque-client', :'resque-worker', :'graphql.server' ].freeze
10
- ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze
9
+ :redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs ].freeze
10
+ ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs ].freeze
11
11
  EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
12
- :'rpc-client', :'sidekiq-client', :redis ].freeze
12
+ :'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs ].freeze
13
13
  HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
14
14
 
15
15
  attr_accessor :parent
@@ -289,6 +289,12 @@ module Instana
289
289
  @data.inspect
290
290
  end
291
291
 
292
+ # Check to see if the current span indicates an exit from application
293
+ # code and into an external service
294
+ def exit_span?
295
+ EXIT_SPANS.include?(@data[:n])
296
+ end
297
+
292
298
  #############################################################
293
299
  # OpenTracing Compatibility Methods
294
300
  #############################################################
@@ -6,6 +6,7 @@ module Instana
6
6
  attr_accessor :trace_id
7
7
  attr_accessor :span_id
8
8
  attr_accessor :baggage
9
+ attr_reader :level
9
10
 
10
11
  # Create a new SpanContext
11
12
  #
@@ -18,7 +19,7 @@ module Instana
18
19
  @trace_id = tid
19
20
  @span_id = sid
20
21
  @level = level
21
- @baggage = baggage
22
+ @baggage = baggage || {}
22
23
  end
23
24
 
24
25
  def trace_id_header
@@ -29,8 +30,31 @@ module Instana
29
30
  ::Instana::Util.id_to_header(@span_id)
30
31
  end
31
32
 
33
+ def trace_parent_header
34
+ return '' unless valid?
35
+
36
+ trace = (@baggage[:external_trace_id] || @trace_id).rjust(32, '0')
37
+ parent = @span_id.rjust(16, '0')
38
+ flags = @level == 1 ? "01" : "00"
39
+
40
+ "00-#{trace}-#{parent}-#{flags}"
41
+ end
42
+
43
+ def trace_state_header
44
+ return '' unless valid?
45
+
46
+ state = ["in=#{trace_id_header};#{span_id_header}", @baggage[:external_state]]
47
+ state.compact.join(',')
48
+ end
49
+
32
50
  def to_hash
33
51
  { :trace_id => @trace_id, :span_id => @span_id }
34
52
  end
53
+
54
+ private
55
+
56
+ def valid?
57
+ @baggage && @trace_id && @span_id
58
+ end
35
59
  end
36
60
  end
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.193.5"
5
+ VERSION = "1.195.3"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -0,0 +1,161 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ require 'test_helper'
5
+
6
+ class AwsTest < Minitest::Test
7
+ def setup
8
+ clear_all!
9
+ end
10
+
11
+ def test_dynamo_db
12
+ dynamo = Aws::DynamoDB::Client.new(
13
+ region: "local",
14
+ access_key_id: "placeholder",
15
+ secret_access_key: "placeholder",
16
+ endpoint: "http://localhost:8000"
17
+ )
18
+
19
+ assert_raises Aws::DynamoDB::Errors::ResourceNotFoundException do
20
+ Instana::Tracer.start_or_continue_trace(:dynamo_test, {}) do
21
+ dynamo.get_item(
22
+ table_name: 'sample_table',
23
+ key: { s: 'sample_item' }
24
+ )
25
+ end
26
+ end
27
+
28
+ spans = ::Instana.processor.queued_spans
29
+ dynamo_span, entry_span, *rest = spans
30
+
31
+ assert rest.empty?
32
+ assert_equal entry_span[:s], dynamo_span[:p]
33
+ assert_equal :dynamodb, dynamo_span[:n]
34
+ assert_equal 'get', dynamo_span[:data][:dynamodb][:op]
35
+ assert_equal 'sample_table', dynamo_span[:data][:dynamodb][:table]
36
+ end
37
+
38
+ def test_s3
39
+ dynamo = Aws::S3::Client.new(
40
+ region: "local",
41
+ access_key_id: "minioadmin",
42
+ secret_access_key: "minioadmin",
43
+ endpoint: "http://localhost:9000"
44
+ )
45
+
46
+ assert_raises Aws::S3::Errors::NoSuchBucket do
47
+ Instana::Tracer.start_or_continue_trace(:s3_test, {}) do
48
+ dynamo.get_object(
49
+ bucket: 'sample_bucket',
50
+ key: 'sample_key'
51
+ )
52
+ end
53
+ end
54
+
55
+ spans = ::Instana.processor.queued_spans
56
+ s3_span, entry_span, *rest = spans
57
+
58
+ assert rest.empty?
59
+ assert_equal entry_span[:s], s3_span[:p]
60
+ assert_equal :s3, s3_span[:n]
61
+ assert_equal 'get', s3_span[:data][:s3][:op]
62
+ assert_equal 'sample_bucket', s3_span[:data][:s3][:bucket]
63
+ assert_equal 'sample_key', s3_span[:data][:s3][:key]
64
+ end
65
+
66
+ def test_sns_publish
67
+ sns = Aws::SNS::Client.new(
68
+ region: "local",
69
+ access_key_id: "test",
70
+ secret_access_key: "test",
71
+ endpoint: "http://localhost:9911"
72
+ )
73
+
74
+ assert_raises Aws::SNS::Errors::NotFound do
75
+ Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
76
+ sns.publish(
77
+ topic_arn: 'topic:arn',
78
+ target_arn: 'target:arn',
79
+ phone_number: '555-0100',
80
+ subject: 'Test Subject',
81
+ message: 'Test Message'
82
+ )
83
+ end
84
+ end
85
+
86
+ spans = ::Instana.processor.queued_spans
87
+ aws_span, entry_span, *rest = spans
88
+
89
+ assert rest.empty?
90
+ assert_equal entry_span[:s], aws_span[:p]
91
+ assert_equal :sns, aws_span[:n]
92
+ assert_equal 'topic:arn', aws_span[:data][:sns][:topic]
93
+ assert_equal 'target:arn', aws_span[:data][:sns][:target]
94
+ assert_equal '555-0100', aws_span[:data][:sns][:phone]
95
+ assert_equal 'Test Subject', aws_span[:data][:sns][:subject]
96
+ end
97
+
98
+ def test_sns_other
99
+ sns = Aws::SNS::Client.new(
100
+ region: "local",
101
+ access_key_id: "test",
102
+ secret_access_key: "test",
103
+ endpoint: "http://localhost:9911"
104
+ )
105
+
106
+ Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
107
+ sns.list_subscriptions
108
+ end
109
+
110
+ spans = ::Instana.processor.queued_spans
111
+ aws_span, entry_span, *rest = spans
112
+
113
+ assert rest.empty?
114
+ assert_equal entry_span[:s], aws_span[:p]
115
+ assert_equal :"net-http", aws_span[:n]
116
+ end
117
+
118
+ def test_sqs
119
+ sqs = Aws::SQS::Client.new(
120
+ region: "local",
121
+ access_key_id: "test",
122
+ secret_access_key: "test",
123
+ endpoint: "http://localhost:9324"
124
+ )
125
+
126
+ create_response = nil
127
+ get_url_response = nil
128
+
129
+ Instana::Tracer.start_or_continue_trace(:sqs_test, {}) do
130
+ create_response = sqs.create_queue(queue_name: 'test')
131
+ get_url_response = sqs.get_queue_url(queue_name: 'test')
132
+ sqs.send_message(queue_url: create_response.queue_url, message_body: 'Sample')
133
+ end
134
+
135
+ received = sqs.receive_message(
136
+ queue_url: create_response.queue_url,
137
+ message_attribute_names: ['All']
138
+ )
139
+ sqs.delete_queue(queue_url: create_response.queue_url)
140
+ message = received.messages.first
141
+ create_span, get_span, send_span, _root = ::Instana.processor.queued_spans
142
+
143
+ assert_equal :sqs, create_span[:n]
144
+ assert_equal create_response.queue_url, create_span[:data][:sqs][:queue]
145
+ assert_equal 'exit', create_span[:data][:sqs][:sort]
146
+ assert_equal 'create.queue', create_span[:data][:sqs][:type]
147
+
148
+ assert_equal :sqs, get_span[:n]
149
+ assert_equal get_url_response.queue_url, get_span[:data][:sqs][:queue]
150
+ assert_equal 'exit', get_span[:data][:sqs][:sort]
151
+ assert_equal 'get.queue', get_span[:data][:sqs][:type]
152
+
153
+ assert_equal :sqs, send_span[:n]
154
+ assert_equal get_url_response.queue_url, send_span[:data][:sqs][:queue]
155
+ assert_equal 'exit', send_span[:data][:sqs][:sort]
156
+ assert_equal 'single.sync', send_span[:data][:sqs][:type]
157
+ assert_equal send_span[:t], message.message_attributes['X_INSTANA_T'].string_value
158
+ assert_equal send_span[:s], message.message_attributes['X_INSTANA_S'].string_value
159
+ assert_equal 'Sample', message.body
160
+ end
161
+ end
@@ -40,6 +40,7 @@ class ExconTest < Minitest::Test
40
40
  refute_nil excon_span[:data].key?(:http)
41
41
  assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
42
42
  assert_equal 200, excon_span[:data][:http][:status]
43
+ assert_equal 'basic_get', excon_span[:data][:http][:params]
43
44
 
44
45
  # excon backtrace not included by default check
45
46
  assert !excon_span.key?(:stack)
@@ -11,6 +11,24 @@ class NetHTTPTest < Minitest::Test
11
11
  assert_equal true, ::Instana.config[:nethttp][:enabled]
12
12
  end
13
13
 
14
+ def test_get_with_query
15
+ clear_all!
16
+ WebMock.allow_net_connect!
17
+
18
+ Instana.tracer.start_or_continue_trace(:"net-http-test") do
19
+ Net::HTTP.get(URI('http://127.0.0.1:6511/?query_value=true'))
20
+ end
21
+
22
+ spans = ::Instana.processor.queued_spans
23
+ assert_equal 3, spans.length
24
+
25
+ http_span = find_first_span_by_name(spans, :'net-http')
26
+ assert_equal "http://127.0.0.1:6511/", http_span[:data][:http][:url]
27
+ assert_equal "query_value=true", http_span[:data][:http][:params]
28
+
29
+ WebMock.disable_net_connect!
30
+ end
31
+
14
32
  def test_block_request
15
33
  clear_all!
16
34
  WebMock.allow_net_connect!
@@ -18,7 +18,7 @@ class RackInstrumentedRequestTest < Minitest::Test
18
18
  refute req.skip_trace?
19
19
  end
20
20
 
21
- def test_incomming_context
21
+ def test_incoming_context
22
22
  id = Instana::Util.generate_id
23
23
  req = Instana::InstrumentedRequest.new(
24
24
  'HTTP_X_INSTANA_L' => '1',
@@ -33,6 +33,51 @@ class RackInstrumentedRequestTest < Minitest::Test
33
33
  }
34
34
 
35
35
  assert_equal expected, req.incoming_context
36
+ refute req.continuing_from_trace_parent?
37
+ end
38
+
39
+ def test_incoming_w3_content
40
+ req = Instana::InstrumentedRequest.new(
41
+ 'HTTP_X_INSTANA_L' => '1',
42
+ 'HTTP_TRACEPARENT' => '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
43
+ )
44
+
45
+ expected = {
46
+ external_trace_id: '4bf92f3577b34da6a3ce929d0e0e4736',
47
+ external_state: nil,
48
+ trace_id: 'a3ce929d0e0e4736',
49
+ span_id: '00f067aa0ba902b7',
50
+ level: '1'
51
+ }
52
+
53
+ assert_equal expected, req.incoming_context
54
+ assert req.continuing_from_trace_parent?
55
+ end
56
+
57
+ def test_incoming_invalid_w3_content
58
+ req = Instana::InstrumentedRequest.new(
59
+ 'HTTP_X_INSTANA_L' => '1',
60
+ 'HTTP_TRACEPARENT' => '00-XXa3ce929d0e0e4736-00f67aa0ba902b7-01'
61
+ )
62
+
63
+ expected = {
64
+ level: '1'
65
+ }
66
+
67
+ assert_equal expected, req.incoming_context
68
+ end
69
+
70
+ def test_incoming_w3_state
71
+ req = Instana::InstrumentedRequest.new(
72
+ 'HTTP_TRACESTATE' => 'a=12345,in=123;abe,c=[+]'
73
+ )
74
+
75
+ expected = {
76
+ t: '123',
77
+ p: 'abe'
78
+ }
79
+
80
+ assert_equal expected, req.instana_ancestor
36
81
  end
37
82
 
38
83
  def test_request_tags
@@ -41,7 +86,8 @@ class RackInstrumentedRequestTest < Minitest::Test
41
86
  'HTTP_HOST' => 'example.com',
42
87
  'REQUEST_METHOD' => 'GET',
43
88
  'HTTP_X_CAPTURE_THIS' => 'that',
44
- 'PATH_INFO' => '/'
89
+ 'PATH_INFO' => '/',
90
+ 'QUERY_STRING' => 'test=true'
45
91
  )
46
92
 
47
93
  expected = {
@@ -50,7 +96,8 @@ class RackInstrumentedRequestTest < Minitest::Test
50
96
  host: 'example.com',
51
97
  header: {
52
98
  "X-Capture-This": 'that'
53
- }
99
+ },
100
+ params: 'test=true'
54
101
  }
55
102
 
56
103
  assert_equal expected, req.request_tags
@@ -15,6 +15,24 @@ class RackTest < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
+ class ErrorApp
19
+ def call(_env)
20
+ raise 'An Error'
21
+ end
22
+ end
23
+
24
+ class FiveZeroOneApp
25
+ def call(_env)
26
+ [501, {}, ['No']]
27
+ end
28
+ end
29
+
30
+ class NoHeadersApp
31
+ def call(_env)
32
+ [501, nil, ['No']]
33
+ end
34
+ end
35
+
18
36
  def app
19
37
  @app = Rack::Builder.new do
20
38
  use Rack::CommonLogger
@@ -22,6 +40,8 @@ class RackTest < Minitest::Test
22
40
  use Instana::Rack
23
41
  map("/mrlobster") { run Rack::Lobster.new }
24
42
  map("/path_tpl") { run PathTemplateApp.new }
43
+ map("/error") { run ErrorApp.new }
44
+ map("/five_zero_one") { run FiveZeroOneApp.new }
25
45
  end
26
46
  end
27
47
 
@@ -49,6 +69,10 @@ class RackTest < Minitest::Test
49
69
  assert last_response.headers.key?("Server-Timing")
50
70
  assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
51
71
 
72
+ # W3 Trace Context
73
+ assert_equal "00-#{rack_span[:t].rjust(32, '0')}-#{rack_span[:s]}-01", last_response.headers["Traceparent"]
74
+ assert_equal "in=#{rack_span[:t]};#{rack_span[:s]}", last_response.headers["Tracestate"]
75
+
52
76
  assert rack_span.key?(:data)
53
77
  assert rack_span[:data].key?(:http)
54
78
  assert_equal "GET", rack_span[:data][:http][:method]
@@ -272,4 +296,121 @@ class RackTest < Minitest::Test
272
296
  assert_equal :rack, rack_span[:n]
273
297
  assert_equal 'sample_template', rack_span[:data][:http][:path_tpl]
274
298
  end
299
+
300
+ def test_basic_get_with_x_instana_synthetic
301
+ header 'X-INSTANA-SYNTHETIC', '1'
302
+
303
+ clear_all!
304
+ get '/mrlobster'
305
+ assert last_response.ok?
306
+
307
+ spans = ::Instana.processor.queued_spans
308
+
309
+ # Span validation
310
+ assert_equal 1, spans.count
311
+
312
+ first_span = spans.first
313
+ assert_equal true, first_span[:sy]
314
+ end
315
+
316
+ def test_basic_get_with_w3_trace
317
+ clear_all!
318
+
319
+ header 'TRACEPARENT', '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
320
+
321
+ get '/mrlobster'
322
+ assert last_response.ok?
323
+
324
+ spans = ::Instana.processor.queued_spans
325
+ assert_equal 1, spans.count
326
+
327
+ first_span = spans.first
328
+ assert_equal :rack, first_span[:n]
329
+ assert_equal 'a3ce929d0e0e4736', first_span[:t]
330
+ assert_equal '00f067aa0ba902b7', first_span[:p]
331
+ assert_equal '4bf92f3577b34da6a3ce929d0e0e4736', first_span[:lt]
332
+ assert_nil first_span[:ia]
333
+ assert first_span[:tp]
334
+ end
335
+
336
+ def test_basic_get_with_w3_disabled
337
+ clear_all!
338
+ ::Instana.config[:w3_trace_correlation] = false
339
+
340
+ header 'TRACEPARENT', '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
341
+
342
+ get '/mrlobster'
343
+ assert last_response.ok?
344
+
345
+ spans = ::Instana.processor.queued_spans
346
+ assert_equal 1, spans.count
347
+
348
+ first_span = spans.first
349
+ assert_equal :rack, first_span[:n]
350
+ refute first_span[:tp]
351
+ ::Instana.config[:w3_trace_correlation] = true
352
+ end
353
+
354
+ def test_skip_trace
355
+ clear_all!
356
+ header 'X_INSTANA_L', '0;junk'
357
+
358
+ get '/mrlobster'
359
+ assert last_response.ok?
360
+
361
+ spans = ::Instana.processor.queued_spans
362
+ assert_equal 0, spans.count
363
+ end
364
+
365
+ def test_disable_trace
366
+ clear_all!
367
+ ::Instana.config[:tracing][:enabled] = false
368
+
369
+ get '/mrlobster'
370
+ assert last_response.ok?
371
+
372
+ spans = ::Instana.processor.queued_spans
373
+ assert_equal 0, spans.count
374
+ ::Instana.config[:tracing][:enabled] = true
375
+ end
376
+
377
+ def test_error_trace
378
+ clear_all!
379
+
380
+ get '/error'
381
+ refute last_response.ok?
382
+
383
+ spans = ::Instana.processor.queued_spans
384
+ assert_equal 1, spans.count
385
+
386
+ first_span = spans.first
387
+ assert_equal :rack, first_span[:n]
388
+ assert_equal 1, first_span[:ec]
389
+ end
390
+
391
+ def test_disable_trace_with_error
392
+ clear_all!
393
+ ::Instana.config[:tracing][:enabled] = false
394
+
395
+ get '/error'
396
+ refute last_response.ok?
397
+
398
+ spans = ::Instana.processor.queued_spans
399
+ assert_equal 0, spans.count
400
+ ::Instana.config[:tracing][:enabled] = true
401
+ end
402
+
403
+ def test_five_zero_x_trace
404
+ clear_all!
405
+
406
+ get '/five_zero_one'
407
+ refute last_response.ok?
408
+
409
+ spans = ::Instana.processor.queued_spans
410
+ assert_equal 1, spans.count
411
+
412
+ first_span = spans.first
413
+ assert_equal :rack, first_span[:n]
414
+ assert_equal 1, first_span[:ec]
415
+ end
275
416
  end