instana 1.214.4 → 1.215.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 424b7ef31ac74b0ba82b7c010fe21074ccf6851670b18efe98fdf2d01360b71f
4
- data.tar.gz: eabcd2216cc6c209444ba2e9400a4b446fdd31933c462b300d7f3e6fcdb7ee02
3
+ metadata.gz: 7087be480ee9027905afc8e29781253aa34e13fda02dec5607840d61cb4699c0
4
+ data.tar.gz: c73ad67e15ec9a21051f888ac443f35a39f2e9e9e7c1efeb3bd0824a41bdaad3
5
5
  SHA512:
6
- metadata.gz: 166f7c5dbf87cbec5ad22690ad848be4fbd2a02d37514c57ca9fc560f4d98248749fb9894f07567fe4d4fdabe2750c703df86136b1c2cb9f773a97c016d36a90
7
- data.tar.gz: ad43e911090d2e4cc107157a6bf052428a610dac4911c7c843de99e4770c926a80ccc92517378ec41d4a836cfbc584c133027cf58f6f3f1bbaea538b098e9c2b
6
+ metadata.gz: 2d09eb59acb9156a0cd5bbd85390406b7da1a72e9bc8692b2084feee186b6c723de72f34218520909226b0b7aa48eeb96708673fd514f8e7ebdc9ad24c84542a
7
+ data.tar.gz: 1b79ce75d861bcb005ccf46d18d61673faa194be298e5cbfb95ce6fb0a9f503a60c4709fed85b5ab295468c19674005d3ec7e3afda57a03704ab89788013999d
@@ -8,19 +8,19 @@
8
8
  },
9
9
  {
10
10
  "Package name": "Rack",
11
- "Support Policy": "0-day",
11
+ "Support Policy": "45-days",
12
12
  "Beta version": "No",
13
13
  "Cloud Native": "No"
14
14
  },
15
15
  {
16
16
  "Package name": "Rails",
17
- "Support Policy": "30-days",
17
+ "Support Policy": "45-days",
18
18
  "Beta version": "No",
19
19
  "Cloud Native": "No"
20
20
  },
21
21
  {
22
22
  "Package name": "Rails::API",
23
- "Support Policy": "30-days",
23
+ "Support Policy": "45-days",
24
24
  "Beta version": "No",
25
25
  "Cloud Native": "No"
26
26
  },
@@ -32,61 +32,61 @@
32
32
  },
33
33
  {
34
34
  "Package name": "Roda",
35
- "Support Policy": "30-days",
35
+ "Support Policy": "45-days",
36
36
  "Beta version": "No",
37
37
  "Cloud Native": "No"
38
38
  },
39
39
  {
40
40
  "Package name": "Sinatra",
41
- "Support Policy": "30-days",
41
+ "Support Policy": "45-days",
42
42
  "Beta version": "No",
43
43
  "Cloud Native": "No"
44
44
  },
45
45
  {
46
46
  "Package name": "Excon",
47
- "Support Policy": "30-days",
47
+ "Support Policy": "45-days",
48
48
  "Beta version": "No",
49
49
  "Cloud Native": "Yes"
50
50
  },
51
51
  {
52
52
  "Package name": "gRPC",
53
- "Support Policy": "30-days",
53
+ "Support Policy": "45-days",
54
54
  "Beta version": "No",
55
55
  "Cloud Native": "No"
56
56
  },
57
57
  {
58
58
  "Package name": "Net::HTTP",
59
59
  "Support Policy": "0-day",
60
- "Beta version": "No",
60
+ "Beta version": "Yes",
61
61
  "Cloud Native": "No"
62
62
  },
63
63
  {
64
64
  "Package name": "Rest-Client",
65
- "Support Policy": "30-days",
65
+ "Support Policy": "45-days",
66
66
  "Beta version": "No",
67
67
  "Cloud Native": "No"
68
68
  },
69
69
  {
70
70
  "Package name": "Dalli",
71
- "Support Policy": "30-days",
71
+ "Support Policy": "45-days",
72
72
  "Beta version": "No",
73
73
  "Cloud Native": "No"
74
74
  },
75
75
  {
76
76
  "Package name": "Resque",
77
- "Support Policy": "30-days",
77
+ "Support Policy": "45-days",
78
78
  "Beta version": "No",
79
79
  "Cloud Native": "Yes"
80
80
  },
81
81
  {
82
82
  "Package name": "Sidekiq",
83
- "Support Policy": "30-days",
83
+ "Support Policy": "45-days",
84
84
  "Beta version": "No",
85
85
  "Cloud Native": "Yes"
86
86
  },
87
87
  {
88
88
  "Package name": "GraphQL",
89
- "Support Policy": "30-days",
89
+ "Support Policy": "45-days",
90
90
  "Beta version": "No",
91
91
  "Cloud Native": "Yes"
92
92
  }
data/instana.gemspec CHANGED
@@ -40,7 +40,9 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "appraisal"
41
41
  spec.add_development_dependency "fakefs"
42
42
 
43
+ spec.add_runtime_dependency('base64', '>= 0.1')
43
44
  spec.add_runtime_dependency('concurrent-ruby', '>= 1.1')
45
+ spec.add_runtime_dependency('csv', '>= 0.1')
44
46
  spec.add_runtime_dependency('sys-proctable', '>= 1.2.2')
45
47
  spec.add_runtime_dependency('oj', '>=3.0.11') unless RUBY_PLATFORM =~ /java/i
46
48
  end
@@ -28,7 +28,11 @@ module Instana
28
28
 
29
29
  def announce
30
30
  @client = until_not_nil { HostAgentLookup.new.call }
31
- @discovery.delete_observers
31
+ begin
32
+ @discovery.send(:observers)&.send(:notify_and_delete_observers, Time.now, nil, nil)
33
+ ensure
34
+ @discovery.delete_observers
35
+ end
32
36
  @discovery
33
37
  .with_observer(HostAgentActivationObserver.new(@client, @discovery))
34
38
  .with_observer(HostAgentReportingObserver.new(@client, @discovery))
@@ -27,6 +27,9 @@ module Instana
27
27
  # Enable/disable tracing (default: enabled)
28
28
  @config[:tracing] = { :enabled => true }
29
29
 
30
+ # Enable/disable tracing exit spans as root spans
31
+ @config[:allow_exit_as_root] = ENV['INSTANA_ALLOW_EXIT_AS_ROOT'] == '1'
32
+
30
33
  # Enable/Disable logging
31
34
  @config[:logging] = { :enabled => true }
32
35
 
@@ -78,8 +78,10 @@ module Instana
78
78
  private
79
79
 
80
80
  def traceable?
81
- ::Instana.tracer.tracing? &&
82
- (!Instana.tracer.current_span.exit_span? || Instana.tracer.current_span.name == :excon)
81
+ ::Instana.tracer.tracing? && ::Instana.tracer.current_span.nil? ||
82
+ !::Instana.tracer.current_span.nil? &&
83
+ (!Instana.tracer.current_span.exit_span? ||
84
+ Instana.tracer.current_span.exit_span? && Instana.tracer.current_span.name == :excon)
83
85
  end
84
86
  end
85
87
  end
@@ -7,7 +7,7 @@ module Instana
7
7
  module Instrumentation
8
8
  module NetHTTPInstrumentation
9
9
  def request(*args, &block)
10
- if !Instana.tracer.tracing? || Instana.tracer.current_span.exit_span? || !started?
10
+ if skip_instrumentation?
11
11
  do_skip = true
12
12
  return super(*args, &block)
13
13
  end
@@ -64,6 +64,12 @@ module Instana
64
64
  ensure
65
65
  ::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
66
66
  end
67
+
68
+ def skip_instrumentation?
69
+ dnt_spans = [:dynamodb, :sqs, :sns, :s3]
70
+ !Instana.tracer.tracing? || !started? || !Instana.config[:nethttp][:enabled] ||
71
+ (!::Instana.tracer.current_span.nil? && dnt_spans.include?(::Instana.tracer.current_span.name))
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -59,7 +59,7 @@ module Instana
59
59
 
60
60
  def skip_instrumentation?
61
61
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
62
- !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
62
+ !Instana.tracer.tracing? || (!::Instana.tracer.current_span.nil? && dnt_spans.include?(::Instana.tracer.current_span.name)) || !Instana.config[:redis][:enabled]
63
63
  end
64
64
 
65
65
  def call_with_instana(command, original_super, args, kwargs, &block)
@@ -133,12 +133,12 @@ module Instana
133
133
  # @param kvs [Hash] list of key values to be reported in the span
134
134
  #
135
135
  def log_entry(name, kvs = nil, start_time = ::Instana::Util.now_in_ms, child_of = nil)
136
- return unless self.current_span || child_of
136
+ return unless tracing? || child_of
137
137
 
138
- new_span = if child_of.is_a?(::Instana::Span) || child_of.is_a?(::Instana::SpanContext)
139
- Span.new(name, parent_ctx: child_of, start_time: start_time)
140
- else
138
+ new_span = if child_of.nil? && !self.current_span.nil?
141
139
  Span.new(name, parent_ctx: self.current_span, start_time: start_time)
140
+ else
141
+ Span.new(name, parent_ctx: child_of, start_time: start_time)
142
142
  end
143
143
  new_span.set_tags(kvs) if kvs
144
144
  self.current_span = new_span
@@ -218,7 +218,7 @@ module Instana
218
218
  # :span_id => 12345
219
219
  #
220
220
  def log_async_entry(name, kvs)
221
- return unless self.current_span
221
+ return unless tracing?
222
222
 
223
223
  new_span = Span.new(name, parent_ctx: self.current_span)
224
224
  new_span.set_tags(kvs) unless kvs.empty?
@@ -268,7 +268,8 @@ module Instana
268
268
  # The non-nil value of this instance variable
269
269
  # indicates if we are currently tracing
270
270
  # in this thread or not.
271
- self.current_span ? true : false
271
+ (self.current_span ? true : false) ||
272
+ (::Instana.config[:allow_exit_as_root] && ::Instana.config[:tracing][:enabled])
272
273
  end
273
274
 
274
275
  # Indicates if we're tracing and the current span name matches
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.214.4"
5
+ VERSION = "1.215.1"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -32,6 +32,8 @@ class HostAgentTest < Minitest::Test
32
32
 
33
33
  discovery = Minitest::Mock.new
34
34
  discovery.expect(:delete_observers, discovery, [])
35
+ discovery.expect(:observers, discovery, [])
36
+ discovery.expect(:notify_and_delete_observers, discovery, [Object, nil, nil])
35
37
  discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentActivationObserver])
36
38
  discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentReportingObserver])
37
39
  discovery.expect(:swap, discovery, [])
@@ -9,6 +9,10 @@ class DalliTest < Minitest::Test
9
9
  @dc = Dalli::Client.new(@memcached_host, :namespace => "instana_test")
10
10
  end
11
11
 
12
+ def teardown
13
+ ::Instana.config[:allow_exit_as_root] = false
14
+ end
15
+
12
16
  def test_config_defaults
13
17
  assert ::Instana.config[:dalli].is_a?(Hash)
14
18
  assert ::Instana.config[:dalli].key?(:enabled)
@@ -50,6 +54,35 @@ class DalliTest < Minitest::Test
50
54
  assert_equal @memcached_host, second_span[:data][:memcache][:server]
51
55
  end
52
56
 
57
+ def test_basic_get_as_root_exit_span
58
+ clear_all!
59
+ @dc.set(:instana, :boom)
60
+
61
+ ::Instana.config[:allow_exit_as_root] = true
62
+ result = @dc.get(:instana)
63
+
64
+ assert_equal :boom, result
65
+
66
+ spans = ::Instana.processor.queued_spans
67
+ assert_equal 1, spans.length
68
+
69
+ first_span = spans[0]
70
+
71
+ assert_equal :memcache, first_span[:n]
72
+ assert_equal false, first_span.key?(:error)
73
+ assert_nil first_span[:p]
74
+ assert first_span[:t] == first_span[:s]
75
+ assert first_span[:data].key?(:memcache)
76
+ assert first_span[:data][:memcache].key?(:command)
77
+ assert_equal :get, first_span[:data][:memcache][:command]
78
+ assert first_span[:data][:memcache].key?(:key)
79
+ assert_equal :instana, first_span[:data][:memcache][:key]
80
+ assert first_span[:data][:memcache].key?(:namespace)
81
+ assert_equal 'instana_test', first_span[:data][:memcache][:namespace]
82
+ assert first_span[:data][:memcache].key?(:server)
83
+ assert_equal @memcached_host, first_span[:data][:memcache][:server]
84
+ end
85
+
53
86
  def test_basic_set
54
87
  clear_all!
55
88
 
@@ -5,6 +5,10 @@ require 'test_helper'
5
5
  require 'support/apps/http_endpoint/boot'
6
6
 
7
7
  class ExconTest < Minitest::Test
8
+ def teardown
9
+ ::Instana.config[:allow_exit_as_root] = false
10
+ end
11
+
8
12
  def test_config_defaults
9
13
  assert ::Instana.config[:excon].is_a?(Hash)
10
14
  assert ::Instana.config[:excon].key?(:enabled)
@@ -52,6 +56,42 @@ class ExconTest < Minitest::Test
52
56
  assert_equal excon_span[:p], sdk_span[:s]
53
57
  end
54
58
 
59
+ def test_basic_get_as_root_exit_span
60
+ clear_all!
61
+
62
+ # A slight hack but webmock chokes with pipelined requests.
63
+ # Delete their excon middleware
64
+ Excon.defaults[:middlewares].delete ::WebMock::HttpLibAdapters::ExconAdapter
65
+ Excon.defaults[:middlewares].delete ::Excon::Middleware::Mock
66
+
67
+ url = "http://127.0.0.1:6511"
68
+
69
+ ::Instana.config[:allow_exit_as_root] = true
70
+ connection = Excon.new(url)
71
+ connection.get(:path => '/?basic_get')
72
+
73
+ spans = ::Instana.processor.queued_spans
74
+ assert_equal 2, spans.length
75
+
76
+ excon_span = find_first_span_by_name(spans, :excon)
77
+ rack_span = find_first_span_by_name(spans, :rack)
78
+
79
+ # data keys/values
80
+ refute_nil excon_span.key?(:data)
81
+ refute_nil excon_span[:data].key?(:http)
82
+ assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
83
+ assert_equal 200, excon_span[:data][:http][:status]
84
+ assert_equal 'basic_get', excon_span[:data][:http][:params]
85
+
86
+ # excon backtrace not included by default check
87
+ assert !excon_span.key?(:stack)
88
+
89
+ assert_equal rack_span[:t], excon_span[:t]
90
+
91
+ assert_equal rack_span[:p], excon_span[:s]
92
+ assert_nil excon_span[:p]
93
+ end
94
+
55
95
  def test_basic_get_with_error
56
96
  clear_all!
57
97
 
@@ -83,6 +83,10 @@ class GraphqlTest < Minitest::Test
83
83
  mutation MutationType
84
84
  end
85
85
 
86
+ def teardown
87
+ ::Instana.config[:allow_exit_as_root] = false
88
+ end
89
+
86
90
  def test_it_works
87
91
  assert defined?(GraphQL)
88
92
  end
@@ -127,6 +131,43 @@ class GraphqlTest < Minitest::Test
127
131
  assert_equal expected_data, query_span[:data][:graphql]
128
132
  end
129
133
 
134
+ def test_query_as_root_exit_span
135
+ clear_all!
136
+
137
+ query = "query FirstTwoTaskSamples {
138
+ tasks(after: \"\", first: 2) {
139
+ nodes {
140
+ action
141
+ }
142
+ }
143
+ }"
144
+
145
+ expected_data = {
146
+ :operationName => "FirstTwoTaskSamples",
147
+ :operationType => "query",
148
+ :arguments => { "tasks" => ["after", "first"] },
149
+ :fields => { "tasks" => ["nodes"], "nodes" => ["action"] }
150
+ }
151
+ expected_results = {
152
+ "data" => {
153
+ "tasks" => {
154
+ "nodes" => [{"action" => "Sample 00"}, {"action" => "Sample 01"}]
155
+ }
156
+ }
157
+ }
158
+
159
+ ::Instana.config[:allow_exit_as_root] = true
160
+ results = Schema.execute(query)
161
+ ::Instana.config[:allow_exit_as_root] = false
162
+ queued_spans = Instana.processor.queued_spans
163
+ assert_equal 1, queued_spans.length
164
+ query_span = queued_spans[0]
165
+
166
+ assert_equal expected_results, results.to_h
167
+ assert_equal :'graphql.server', query_span[:n]
168
+ assert_equal expected_data, query_span[:data][:graphql]
169
+ end
170
+
130
171
  def test_query_with_fragment
131
172
  clear_all!
132
173
 
@@ -4,11 +4,15 @@
4
4
  require 'test_helper'
5
5
  require 'support/apps/grpc/boot'
6
6
 
7
- class GrpcTest < Minitest::Test
7
+ class GrpcTest < Minitest::Test # rubocop:disable Metrics/ClassLength
8
8
  def client_stub
9
9
  PingPongService::Stub.new('127.0.0.1:50051', :this_channel_is_insecure)
10
10
  end
11
11
 
12
+ def teardown
13
+ ::Instana.config[:allow_exit_as_root] = false
14
+ end
15
+
12
16
  def assert_client_span(client_span, call: '', call_type: '', error: nil)
13
17
  data = client_span[:data]
14
18
  assert_equal '127.0.0.1:50051', data[:rpc][:host]
@@ -80,6 +84,41 @@ class GrpcTest < Minitest::Test
80
84
  assert_equal client_span[:p], sdk_span[:s]
81
85
  end
82
86
 
87
+ def test_request_response_as_root_exit_span
88
+ clear_all!
89
+ ::Instana.config[:allow_exit_as_root] = true
90
+
91
+ response = client_stub.ping(
92
+ PingPongService::PingRequest.new(message: 'Hello World')
93
+ )
94
+ sleep 1
95
+
96
+ assert 'Hello World', response.message
97
+
98
+ # Pause for a split second to allow traces to be queued
99
+ sleep 0.2
100
+
101
+ spans = ::Instana.processor.queued_spans
102
+ client_span = find_spans_by_name(spans, :'rpc-client').first
103
+ server_span = find_spans_by_name(spans, :'rpc-server').first
104
+
105
+ assert_client_span(
106
+ client_span,
107
+ call: '/PingPongService/Ping',
108
+ call_type: :request_response
109
+ )
110
+
111
+ assert_server_span(
112
+ server_span,
113
+ call: '/PingPongService/Ping',
114
+ call_type: :request_response
115
+ )
116
+
117
+ assert_equal client_span[:t], server_span[:t]
118
+ assert_equal client_span[:s], server_span[:p]
119
+ assert_nil client_span[:p]
120
+ end
121
+
83
122
  def test_client_streamer
84
123
  clear_all!
85
124
  response = nil
@@ -8,6 +8,10 @@ class MongoTest < Minitest::Test
8
8
  clear_all!
9
9
  end
10
10
 
11
+ def teardown
12
+ ::Instana.config[:allow_exit_as_root] = false
13
+ end
14
+
11
15
  def test_mongo
12
16
  Instana.tracer.start_or_continue_trace(:'mongo-test') do
13
17
  client = Mongo::Client.new('mongodb://127.0.0.1:27017/instana')
@@ -34,4 +38,31 @@ class MongoTest < Minitest::Test
34
38
  assert_equal insert_data[:peer], {hostname: "127.0.0.1", port: 27017}
35
39
  assert insert_data[:json].include?("insert")
36
40
  end
41
+
42
+ def test_mongo_as_root_exit_span
43
+ ::Instana.config[:allow_exit_as_root] = true
44
+
45
+ client = Mongo::Client.new('mongodb://127.0.0.1:27017/instana')
46
+ client[:people].delete_many({ name: /$S*/ })
47
+ client[:people].insert_many([{ _id: 1, name: "Stan" }])
48
+
49
+ spans = ::Instana.processor.queued_spans
50
+ delete_span, insert_span, = spans
51
+
52
+ delete_data = delete_span[:data][:mongo]
53
+ insert_data = insert_span[:data][:mongo]
54
+
55
+ assert_equal delete_span[:n], :mongo
56
+ assert_equal insert_span[:n], :mongo
57
+
58
+ assert_equal delete_data[:namespace], "instana"
59
+ assert_equal delete_data[:command], "delete"
60
+ assert_equal delete_data[:peer], {hostname: "127.0.0.1", port: 27017}
61
+ assert delete_data[:json].include?("delete")
62
+
63
+ assert_equal insert_data[:namespace], "instana"
64
+ assert_equal insert_data[:command], "insert"
65
+ assert_equal insert_data[:peer], {hostname: "127.0.0.1", port: 27017}
66
+ assert insert_data[:json].include?("insert")
67
+ end
37
68
  end
@@ -5,6 +5,10 @@ require 'test_helper'
5
5
  require 'support/apps/http_endpoint/boot'
6
6
 
7
7
  class NetHTTPTest < Minitest::Test
8
+ def teardown
9
+ ::Instana.config[:allow_exit_as_root] = false
10
+ end
11
+
8
12
  def test_config_defaults
9
13
  assert ::Instana.config[:nethttp].is_a?(Hash)
10
14
  assert ::Instana.config[:nethttp].key?(:enabled)
@@ -47,6 +51,22 @@ class NetHTTPTest < Minitest::Test
47
51
  WebMock.disable_net_connect!
48
52
  end
49
53
 
54
+ def test_get_without_query_as_root_exit_span
55
+ clear_all!
56
+ ::Instana.config[:allow_exit_as_root] = true
57
+ WebMock.allow_net_connect!
58
+ Net::HTTP.get(URI('http://127.0.0.1:6511/'))
59
+
60
+ spans = ::Instana.processor.queued_spans
61
+ assert_equal 2, spans.length # 1 rack span from the endpoint is generated extra
62
+
63
+ http_span = find_first_span_by_name(spans, :'net-http')
64
+ assert_equal "http://127.0.0.1:6511/", http_span[:data][:http][:url]
65
+ assert_equal "200", http_span[:data][:http][:status]
66
+
67
+ WebMock.disable_net_connect!
68
+ end
69
+
50
70
  def test_block_request
51
71
  clear_all!
52
72
  WebMock.allow_net_connect!
@@ -34,6 +34,10 @@ class RailsActionMailerTest < Minitest::Test
34
34
  clear_all!
35
35
  end
36
36
 
37
+ def teardown
38
+ ::Instana.config[:allow_exit_as_root] = false
39
+ end
40
+
37
41
  def test_mailer
38
42
  Instana.tracer.start_or_continue_trace(:test) do
39
43
  TestMailer.sample_email.deliver_now
@@ -45,4 +49,18 @@ class RailsActionMailerTest < Minitest::Test
45
49
  assert_equal 'RailsActionMailerTest::TestMailer', mail_span[:data][:actionmailer][:class]
46
50
  assert_equal 'sample_email', mail_span[:data][:actionmailer][:method]
47
51
  end
52
+
53
+ def test_mailer_as_root_exit_span
54
+ ::Instana.config[:allow_exit_as_root] = true
55
+ TestMailer.sample_email.deliver_now
56
+ ::Instana.config[:allow_exit_as_root] = false
57
+
58
+ queued_spans = Instana.processor.queued_spans
59
+ assert_equal 1, queued_spans.length
60
+ mail_span = queued_spans[0]
61
+
62
+ assert_equal :"mail.actionmailer", mail_span[:n]
63
+ assert_equal 'RailsActionMailerTest::TestMailer', mail_span[:data][:actionmailer][:class]
64
+ assert_equal 'sample_email', mail_span[:data][:actionmailer][:method]
65
+ end
48
66
  end
@@ -23,6 +23,29 @@ class RedisTest < Minitest::Test
23
23
  assert_redis_trace('SET')
24
24
  end
25
25
 
26
+ def test_normal_call_as_root_exit_span
27
+ clear_all!
28
+
29
+ ::Instana.config[:allow_exit_as_root] = true
30
+
31
+ @redis_client.set('hello', 'world')
32
+
33
+ spans = ::Instana.processor.queued_spans
34
+ assert_equal 1, spans.length
35
+ redis_span = spans[0]
36
+
37
+ # first_span is the parent of second_span
38
+ assert_equal :redis, redis_span[:n]
39
+
40
+ data = redis_span[:data]
41
+
42
+ uri = URI.parse(@redis_url)
43
+ assert_equal "#{uri.host}:#{uri.port}", data[:redis][:connection]
44
+
45
+ assert_equal "0", data[:redis][:db]
46
+ assert_equal "SET", data[:redis][:command]
47
+ end
48
+
26
49
  def test_georadius
27
50
  clear_all!
28
51
 
@@ -15,6 +15,7 @@ class ResqueClientTest < Minitest::Test
15
15
  end
16
16
 
17
17
  def teardown
18
+ ::Instana.config[:allow_exit_as_root] = false
18
19
  end
19
20
 
20
21
  def test_enqueue
@@ -40,6 +41,26 @@ class ResqueClientTest < Minitest::Test
40
41
  assert_equal resque_job.args.first['span_id'], resque_span[:s]
41
42
  end
42
43
 
44
+ def test_enqueue_as_root_exit_span
45
+ ::Instana.config[:allow_exit_as_root] = true
46
+ ::Resque.enqueue(FastJob)
47
+ ::Instana.config[:allow_exit_as_root] = false
48
+
49
+ resque_job = Resque.reserve('critical')
50
+ spans = ::Instana.processor.queued_spans
51
+ assert_equal 1, spans.length
52
+
53
+ resque_span = spans[0]
54
+
55
+ assert_equal :"resque-client", resque_span[:n]
56
+ assert_equal "FastJob", resque_span[:data][:'resque-client'][:job]
57
+ assert_equal :critical, resque_span[:data][:'resque-client'][:queue]
58
+ assert_equal false, resque_span[:data][:'resque-client'].key?(:error)
59
+
60
+ assert_equal resque_job.args.first['trace_id'], resque_span[:t]
61
+ assert_equal resque_job.args.first['span_id'], resque_span[:s]
62
+ end
63
+
43
64
  def test_enqueue_to
44
65
  ::Instana.tracer.start_or_continue_trace(:'resque-client_test') do
45
66
  ::Resque.enqueue_to(:critical, FastJob)
@@ -10,6 +10,10 @@ class RestClientTest < Minitest::Test
10
10
  OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers] = OpenSSL::SSL::SSLContext.new.ciphers
11
11
  end
12
12
 
13
+ def teardown
14
+ ::Instana.config[:allow_exit_as_root] = false
15
+ end
16
+
13
17
  def test_config_defaults
14
18
  assert ::Instana.config[:'rest-client'].is_a?(Hash)
15
19
  assert ::Instana.config[:'rest-client'].key?(:enabled)
@@ -61,4 +65,43 @@ class RestClientTest < Minitest::Test
61
65
 
62
66
  WebMock.disable_net_connect!
63
67
  end
68
+
69
+ def test_basic_get_as_root_exit_span
70
+ clear_all!
71
+ ::Instana.config[:allow_exit_as_root] = true
72
+ WebMock.allow_net_connect!
73
+
74
+ url = "http://127.0.0.1:6511/"
75
+
76
+ RestClient.get url
77
+
78
+ spans = ::Instana.processor.queued_spans
79
+ assert_equal 3, spans.length
80
+
81
+ rack_span = find_first_span_by_name(spans, :rack)
82
+ rest_span = find_first_span_by_name(spans, :'rest-client')
83
+ net_span = find_first_span_by_name(spans, :'net-http')
84
+
85
+ # Span name validation
86
+ assert_equal :rack, rack_span[:n]
87
+ assert_equal :sdk, rest_span[:n]
88
+ assert_equal :"net-http", net_span[:n]
89
+
90
+ # Trace IDs and relationships
91
+ trace_id = net_span[:t]
92
+ assert_equal trace_id, rest_span[:t]
93
+ assert_equal trace_id, rack_span[:t]
94
+
95
+ assert_nil rest_span[:p]
96
+ assert_equal rest_span[:s], net_span[:p]
97
+ assert_equal net_span[:s], rack_span[:p]
98
+
99
+ # data keys/values
100
+ refute_nil net_span.key?(:data)
101
+ refute_nil net_span[:data].key?(:http)
102
+ assert_equal "http://127.0.0.1:6511/", net_span[:data][:http][:url]
103
+ assert_equal "200", net_span[:data][:http][:status]
104
+
105
+ WebMock.disable_net_connect!
106
+ end
64
107
  end
@@ -9,6 +9,10 @@ class SidekiqClientTest < Minitest::Test
9
9
  ::Sidekiq::Queue.new('some_random_queue').clear
10
10
  end
11
11
 
12
+ def teardown
13
+ ::Instana.config[:allow_exit_as_root] = false
14
+ end
15
+
12
16
  def test_config_defaults
13
17
  assert ::Instana.config[:'sidekiq-client'].is_a?(Hash)
14
18
  assert ::Instana.config[:'sidekiq-client'].key?(:enabled)
@@ -35,6 +39,36 @@ class SidekiqClientTest < Minitest::Test
35
39
  assert_normal_trace_recorded(job)
36
40
  end
37
41
 
42
+ def test_enqueue_as_root_exit_span
43
+ clear_all!
44
+ ::Instana.config[:allow_exit_as_root] = true
45
+ disable_redis_instrumentation
46
+ ::Sidekiq::Client.push(
47
+ 'queue' => 'some_random_queue',
48
+ 'class' => ::SidekiqJobOne,
49
+ 'args' => [1, 2, 3],
50
+ 'retry' => false
51
+ )
52
+ ::Instana.config[:allow_exit_as_root] = false
53
+ enable_redis_instrumentation
54
+
55
+ queue = ::Sidekiq::Queue.new('some_random_queue')
56
+ job = queue.first
57
+
58
+ assert_job_enqueued(job)
59
+ spans = ::Instana.processor.queued_spans
60
+ assert_equal 1, spans.length
61
+
62
+ first_span = spans[0]
63
+
64
+ assert_equal :'sidekiq-client', first_span[:n]
65
+ assert_equal 'some_random_queue', first_span[:data][:'sidekiq-client'][:queue]
66
+ assert_equal 'SidekiqJobOne', first_span[:data][:'sidekiq-client'][:job]
67
+ assert_equal "false", first_span[:data][:'sidekiq-client'][:retry]
68
+ assert first_span[:data][:'sidekiq-client'][:'redis-url']
69
+ assert_equal job['jid'], first_span[:data][:'sidekiq-client'][:job_id]
70
+ end
71
+
38
72
  def test_enqueue_failure
39
73
  clear_all!
40
74
 
@@ -68,8 +102,8 @@ class SidekiqClientTest < Minitest::Test
68
102
  assert_equal 'SidekiqJobOne', job_message['class']
69
103
  assert_equal [1, 2, 3], job_message['args']
70
104
  assert_equal false, job_message['retry']
71
- assert_equal false, job_message['X-Instana-T'].nil?
72
- assert_equal false, job_message['X-Instana-S'].nil?
105
+ refute_nil job_message['X-Instana-T']
106
+ refute_nil job_message['X-Instana-S']
73
107
  end
74
108
 
75
109
  def assert_normal_trace_recorded(job)
@@ -102,7 +136,7 @@ class SidekiqClientTest < Minitest::Test
102
136
 
103
137
  assert_equal :'sidekiq-client', second_span[:n]
104
138
  assert_equal true, second_span[:error]
105
- assert_equal false, second_span[:stack].nil?
139
+ refute_nil second_span[:stack]
106
140
 
107
141
  assert_equal 'some_random_queue', second_span[:data][:'sidekiq-client'][:queue]
108
142
  assert_equal 'SidekiqJobTwo', second_span[:data][:'sidekiq-client'][:job]
@@ -156,7 +156,7 @@ class SidekiqServerTest < Minitest::Test
156
156
  assert_equal 'important', worker_span[:data][:'sidekiq-worker'][:queue]
157
157
  assert_equal 'SidekiqJobOne', worker_span[:data][:'sidekiq-worker'][:job]
158
158
  assert worker_span[:data][:'sidekiq-worker'][:'redis-url']
159
- assert_equal false, worker_span[:data][:'sidekiq-worker'][:job_id].nil?
159
+ refute_nil worker_span[:data][:'sidekiq-worker'][:job_id]
160
160
  end
161
161
 
162
162
  def assert_failed_worker_span(worker_span)
@@ -165,7 +165,7 @@ class SidekiqServerTest < Minitest::Test
165
165
  assert_equal 'important', worker_span[:data][:'sidekiq-worker'][:queue]
166
166
  assert_equal 'SidekiqJobTwo', worker_span[:data][:'sidekiq-worker'][:job]
167
167
  assert worker_span[:data][:'sidekiq-worker'][:'redis-url']
168
- assert_equal false, worker_span[:data][:'sidekiq-worker'][:job_id].nil?
168
+ refute_nil worker_span[:data][:'sidekiq-worker'][:job_id]
169
169
 
170
170
  assert_equal true, worker_span[:data][:'sidekiq-worker'][:error]
171
171
  assert_equal 'Fail to execute the job', worker_span[:data][:log][:message]
data/test/secrets_test.rb CHANGED
@@ -94,7 +94,7 @@ class SecretsTest < Minitest::Test
94
94
  "list"=>["stan"]
95
95
  }
96
96
 
97
- assert_equal @subject.remove_from_query(nil, sample_config), nil
97
+ assert_nil @subject.remove_from_query(nil, sample_config)
98
98
  end
99
99
 
100
100
  private
@@ -9,8 +9,8 @@ class SpanTest < Minitest::Test
9
9
 
10
10
  assert_equal span[:s], span.id
11
11
  assert_equal span[:t], span.trace_id
12
- assert_equal span[:p], span.parent_id
13
- assert_equal span[:d], span.duration
12
+ assert_nil span[:p] # parent_id of a root span is nil
13
+ assert_nil span[:d] # duration of an open span is nil
14
14
 
15
15
  span.parent_id = 'test'
16
16
  assert_equal 'test', span.parent_id
@@ -51,9 +51,7 @@ class TracerTest < Minitest::Test
51
51
 
52
52
  assert_equal false, ::Instana.tracer.tracing?
53
53
 
54
- require 'resolv'
55
- r = Resolv::DNS.new
56
- ipv4 = r.getaddress("www.pwpush.com")
54
+ ipv4 = '111.111.111.111'
57
55
 
58
56
  ::Instana.tracer.start_or_continue_trace(:rack, {:ipaddr => ipv4}) do
59
57
  assert_equal true, ::Instana.tracer.tracing?
@@ -121,7 +119,7 @@ class TracerTest < Minitest::Test
121
119
  sdk_span = find_first_span_by_name(spans, :sub_block)
122
120
 
123
121
  assert_equal rack_span[:n], :rack
124
- assert_equal rack_span[:p], nil
122
+ assert_nil rack_span[:p]
125
123
  assert_equal rack_span[:t], rack_span[:s]
126
124
  assert_equal rack_span[:data][:one], 1
127
125
 
@@ -151,7 +149,7 @@ class TracerTest < Minitest::Test
151
149
  assert_equal root_span[:data][:sdk][:name], :root_span
152
150
  assert_equal root_span[:data][:sdk][:type], :entry
153
151
  assert_equal root_span[:k], 1
154
- assert_equal root_span[:p], nil
152
+ assert_nil root_span[:p]
155
153
  assert_equal root_span[:t], root_span[:s]
156
154
  assert_equal root_span[:data][:sdk][:custom][:tags][:one], 1
157
155
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.214.4
4
+ version: 1.215.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: base64
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: concurrent-ruby
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: csv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0.1'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: sys-proctable
99
127
  requirement: !ruby/object:Gem::Requirement