instana 1.11.3 → 1.11.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,14 +7,15 @@ module Instana
7
7
  def setup_environment
8
8
  # Set defaults if not set
9
9
  ENV['MEMCACHED_HOST'] ||= '127.0.0.1:11211'
10
- ENV['TRAVIS_PSQL_HOST'] ||= "127.0.0.1"
11
- ENV['TRAVIS_PSQL_USER'] ||= "postgres"
10
+ ENV['POSTGRES_HOST'] ||= "127.0.0.1"
11
+ ENV['POSTGRES_USER'] ||= "stan"
12
+ ENV['POSTGRES_PASSWORD'] ||= "stanlikesdata"
12
13
  ENV['TRAVIS_MYSQL_HOST'] ||= "127.0.0.1"
13
14
  ENV['TRAVIS_MYSQL_USER'] ||= "root"
14
15
 
15
16
  if !ENV.key?('DATABASE_URL')
16
17
  if ENV['DB_FLAVOR'] == 'postgresql'
17
- ENV['DATABASE_URL'] = "postgresql://#{ENV['TRAVIS_PSQL_USER']}:#{ENV['TRAVIS_PSQL_PASS']}@#{ENV['TRAVIS_PSQL_HOST']}:5432/travis_ci_test"
18
+ ENV['DATABASE_URL'] = "postgresql://#{ENV['POSTGRES_USER']}:#{ENV['POSTGRES_PASSWORD']}@#{ENV['POSTGRES_HOST']}:5432/#{ENV['POSTGRES_USER']}"
18
19
  elsif ENV['DB_FLAVOR'] == 'mysql'
19
20
  ENV['DATABASE_URL'] = "mysql://#{ENV['TRAVIS_MYSQL_USER']}:#{ENV['TRAVIS_MYSQL_PASS']}@#{ENV['TRAVIS_MYSQL_HOST']}:3306/travis_ci_test"
20
21
  else
@@ -26,7 +26,7 @@ module Instana
26
26
  # Will start a new trace or continue an on-going one (such as
27
27
  # from incoming remote requests with context headers).
28
28
  #
29
- # @param name [String] the name of the span to start
29
+ # @param name [String, Symbol] the name of the span to start
30
30
  # @param kvs [Hash] list of key values to be reported in the span
31
31
  # @param incoming_context [Hash] specifies the incoming context. At a
32
32
  # minimum, it should specify :trace_id and :span_id from the following:
@@ -52,7 +52,7 @@ module Instana
52
52
  # @db.select(1)
53
53
  # end
54
54
  #
55
- # @param name [String] the name of the span to start
55
+ # @param name [String, Symbol] the name of the span to start
56
56
  # @param kvs [Hash] list of key values to be reported in this new span
57
57
  #
58
58
  def trace(name, kvs = {}, &block)
@@ -72,7 +72,7 @@ module Instana
72
72
  # Will start a new trace or continue an on-going one (such as
73
73
  # from incoming remote requests with context headers).
74
74
  #
75
- # @param name [String] the name of the span to start
75
+ # @param name [String, Symbol] the name of the span to start
76
76
  # @param kvs [Hash] list of key values to be reported in the span
77
77
  # @param incoming_context [SpanContext or Hash] specifies the incoming context. At a
78
78
  # minimum, it should specify :trace_id and :span_id from the following:
@@ -107,7 +107,7 @@ module Instana
107
107
  # Will establish a new span as a child of the current span
108
108
  # in an existing trace
109
109
  #
110
- # @param name [String] the name of the span to create
110
+ # @param name [String, Symbol] the name of the span to create
111
111
  # @param kvs [Hash] list of key values to be reported in the span
112
112
  #
113
113
  def log_entry(name, kvs = nil, start_time = ::Instana::Util.now_in_ms, child_of = nil)
@@ -145,7 +145,7 @@ module Instana
145
145
  # @note `name` isn't really required but helps keep sanity that
146
146
  # we're closing out the span that we really want to close out.
147
147
  #
148
- # @param name [String] the name of the span to exit (close out)
148
+ # @param name [String, Symbol] the name of the span to exit (close out)
149
149
  # @param kvs [Hash] list of key values to be reported in the span
150
150
  #
151
151
  def log_exit(name, kvs = {})
@@ -263,6 +263,27 @@ module Instana
263
263
  new_span
264
264
  end
265
265
 
266
+ # Start a new span which is the child of the current span
267
+ #
268
+ # @param operation_name [String] The name of the operation represented by the span
269
+ # @param child_of [Span] A span to be used as the ChildOf reference
270
+ # @param start_time [Time] the start time of the span
271
+ # @param tags [Hash] Starting tags for the span
272
+ #
273
+ # @return [Span]
274
+ #
275
+ def start_active_span(operation_name, child_of: self.current_span, start_time: ::Instana::Util.now_in_ms, tags: nil)
276
+ self.current_span = start_span(operation_name, child_of: child_of, start_time: start_time, tags: tags)
277
+ end
278
+
279
+ # Returns the currently active span
280
+ #
281
+ # @return [Span]
282
+ #
283
+ def active_span
284
+ self.current_span
285
+ end
286
+
266
287
  # Inject a span into the given carrier
267
288
  #
268
289
  # @param span_context [SpanContext]
@@ -303,6 +303,15 @@ module Instana
303
303
  # a String, Numeric, or Boolean it will be encoded with to_s
304
304
  #
305
305
  def set_tag(key, value)
306
+ if ![Symbol, String].include?(key.class)
307
+ key = key.to_s
308
+ end
309
+
310
+ # If <value> is not a Symbol, String, Array, Hash or Numeric - convert to string
311
+ if ![Symbol, String, Array, TrueClass, FalseClass, Hash].include?(value.class) && !value.is_a?(Numeric)
312
+ value = value.to_s
313
+ end
314
+
306
315
  if custom?
307
316
  @data[:data][:sdk][:custom] ||= {}
308
317
  @data[:data][:sdk][:custom][:tags] ||= {}
@@ -176,10 +176,14 @@ module Instana
176
176
  end
177
177
 
178
178
  if defined?(::Resque)
179
+ # Just because Resque is defined doesn't mean this is a resque process necessarily
180
+ # Check arguments for a match
179
181
  if ($0 =~ /resque-#{Resque::Version}/)
180
182
  return "Resque Worker"
181
183
  elsif ($0 =~ /resque-pool-master/)
182
184
  return "Resque Pool Master"
185
+ elsif ($0 =~ /resque-scheduler/)
186
+ return "Resque Scheduler"
183
187
  end
184
188
  end
185
189
 
@@ -187,10 +191,20 @@ module Instana
187
191
  return Rails.application.class.to_s.split('::')[0]
188
192
  end
189
193
 
190
- return File.basename($0)
194
+ if $0.to_s.empty?
195
+ return "Ruby"
196
+ end
197
+
198
+ exe = File.basename($0)
199
+ if exe == "rake"
200
+ return "Rake"
201
+ end
202
+
203
+ return exe
191
204
  rescue Exception => e
192
205
  Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
193
206
  Instana.logger.debug { e.backtrace.join("\r\n") }
207
+ return "Ruby"
194
208
  end
195
209
 
196
210
  # Get the current time in milliseconds from the epoch
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.11.3"
2
+ VERSION = "1.11.8"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
@@ -29,23 +29,33 @@ class RackTest < Minitest::Test
29
29
  # Span validation
30
30
  assert_equal 1, spans.count
31
31
 
32
- first_span = spans.first
33
- assert_equal :rack, first_span[:n]
34
- assert first_span.key?(:data)
35
- assert first_span[:data].key?(:http)
36
- assert_equal "GET", first_span[:data][:http][:method]
37
- assert_equal "/mrlobster", first_span[:data][:http][:url]
38
- assert_equal 200, first_span[:data][:http][:status]
39
- assert_equal 'example.org', first_span[:data][:http][:host]
40
- assert first_span.key?(:f)
41
- assert first_span[:f].key?(:e)
42
- assert first_span[:f].key?(:h)
43
- assert_equal ::Instana.agent.agent_uuid, first_span[:f][:h]
32
+ rack_span = spans.first
33
+ assert_equal :rack, rack_span[:n]
34
+
35
+ assert last_response.headers.key?("X-Instana-T")
36
+ assert last_response.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
37
+ assert last_response.headers.key?("X-Instana-S")
38
+ assert last_response.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
39
+ assert last_response.headers.key?("X-Instana-L")
40
+ assert last_response.headers["X-Instana-L"] == '1'
41
+ assert last_response.headers.key?("Server-Timing")
42
+ assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
43
+
44
+ assert rack_span.key?(:data)
45
+ assert rack_span[:data].key?(:http)
46
+ assert_equal "GET", rack_span[:data][:http][:method]
47
+ assert_equal "/mrlobster", rack_span[:data][:http][:url]
48
+ assert_equal 200, rack_span[:data][:http][:status]
49
+ assert_equal 'example.org', rack_span[:data][:http][:host]
50
+ assert rack_span.key?(:f)
51
+ assert rack_span[:f].key?(:e)
52
+ assert rack_span[:f].key?(:h)
53
+ assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
44
54
 
45
55
  # Backtrace fingerprint validation
46
- assert first_span.key?(:stack)
47
- assert_equal 2, first_span[:stack].count
48
- refute_nil first_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
56
+ assert rack_span.key?(:stack)
57
+ assert_equal 2, rack_span[:stack].count
58
+ refute_nil rack_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
49
59
 
50
60
  # Restore to default
51
61
  ::Instana.config[:collect_backtraces] = false
@@ -63,8 +73,8 @@ class RackTest < Minitest::Test
63
73
  # Span validation
64
74
  assert_equal 1, spans.count
65
75
 
66
- first_span = spans.first
67
- assert_equal 'WalterBishop', first_span[:data][:service]
76
+ rack_span = spans.first
77
+ assert_equal 'WalterBishop', rack_span[:data][:service]
68
78
 
69
79
  ENV.delete('INSTANA_SERVICE_NAME')
70
80
  end
@@ -78,17 +88,27 @@ class RackTest < Minitest::Test
78
88
 
79
89
  # Span validation
80
90
  assert_equal 1, spans.count
81
- first_span = spans.first
82
- assert_equal :rack, first_span[:n]
83
- assert first_span.key?(:data)
84
- assert first_span[:data].key?(:http)
85
- assert_equal "POST", first_span[:data][:http][:method]
86
- assert_equal "/mrlobster", first_span[:data][:http][:url]
87
- assert_equal 200, first_span[:data][:http][:status]
88
- assert first_span.key?(:f)
89
- assert first_span[:f].key?(:e)
90
- assert first_span[:f].key?(:h)
91
- assert_equal ::Instana.agent.agent_uuid, first_span[:f][:h]
91
+ rack_span = spans.first
92
+ assert_equal :rack, rack_span[:n]
93
+
94
+ assert last_response.headers.key?("X-Instana-T")
95
+ assert last_response.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
96
+ assert last_response.headers.key?("X-Instana-S")
97
+ assert last_response.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
98
+ assert last_response.headers.key?("X-Instana-L")
99
+ assert last_response.headers["X-Instana-L"] == '1'
100
+ assert last_response.headers.key?("Server-Timing")
101
+ assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
102
+
103
+ assert rack_span.key?(:data)
104
+ assert rack_span[:data].key?(:http)
105
+ assert_equal "POST", rack_span[:data][:http][:method]
106
+ assert_equal "/mrlobster", rack_span[:data][:http][:url]
107
+ assert_equal 200, rack_span[:data][:http][:status]
108
+ assert rack_span.key?(:f)
109
+ assert rack_span[:f].key?(:e)
110
+ assert rack_span[:f].key?(:h)
111
+ assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
92
112
  end
93
113
 
94
114
  def test_basic_put
@@ -100,17 +120,27 @@ class RackTest < Minitest::Test
100
120
 
101
121
  # Span validation
102
122
  assert_equal 1, spans.count
103
- first_span = spans.first
104
- assert_equal :rack, first_span[:n]
105
- assert first_span.key?(:data)
106
- assert first_span[:data].key?(:http)
107
- assert_equal "PUT", first_span[:data][:http][:method]
108
- assert_equal "/mrlobster", first_span[:data][:http][:url]
109
- assert_equal 200, first_span[:data][:http][:status]
110
- assert first_span.key?(:f)
111
- assert first_span[:f].key?(:e)
112
- assert first_span[:f].key?(:h)
113
- assert_equal ::Instana.agent.agent_uuid, first_span[:f][:h]
123
+ rack_span = spans.first
124
+ assert_equal :rack, rack_span[:n]
125
+
126
+ assert last_response.headers.key?("X-Instana-T")
127
+ assert last_response.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
128
+ assert last_response.headers.key?("X-Instana-S")
129
+ assert last_response.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
130
+ assert last_response.headers.key?("X-Instana-L")
131
+ assert last_response.headers["X-Instana-L"] == '1'
132
+ assert last_response.headers.key?("Server-Timing")
133
+ assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
134
+
135
+ assert rack_span.key?(:data)
136
+ assert rack_span[:data].key?(:http)
137
+ assert_equal "PUT", rack_span[:data][:http][:method]
138
+ assert_equal "/mrlobster", rack_span[:data][:http][:url]
139
+ assert_equal 200, rack_span[:data][:http][:status]
140
+ assert rack_span.key?(:f)
141
+ assert rack_span[:f].key?(:e)
142
+ assert rack_span[:f].key?(:h)
143
+ assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
114
144
  end
115
145
 
116
146
  def test_context_continuation
@@ -125,23 +155,33 @@ class RackTest < Minitest::Test
125
155
 
126
156
  # Span validation
127
157
  assert_equal 1, spans.count
128
- first_span = spans.first
129
- assert_equal :rack, first_span[:n]
130
- assert first_span.key?(:data)
131
- assert first_span[:data].key?(:http)
132
- assert_equal "GET", first_span[:data][:http][:method]
133
- assert_equal "/mrlobster", first_span[:data][:http][:url]
134
- assert_equal 200, first_span[:data][:http][:status]
135
- assert first_span.key?(:f)
136
- assert first_span[:f].key?(:e)
137
- assert first_span[:f].key?(:h)
138
- assert_equal ::Instana.agent.agent_uuid, first_span[:f][:h]
158
+ rack_span = spans.first
159
+ assert_equal :rack, rack_span[:n]
160
+
161
+ assert last_response.headers.key?("X-Instana-T")
162
+ assert last_response.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
163
+ assert last_response.headers.key?("X-Instana-S")
164
+ assert last_response.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
165
+ assert last_response.headers.key?("X-Instana-L")
166
+ assert last_response.headers["X-Instana-L"] == '1'
167
+ assert last_response.headers.key?("Server-Timing")
168
+ assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
169
+
170
+ assert rack_span.key?(:data)
171
+ assert rack_span[:data].key?(:http)
172
+ assert_equal "GET", rack_span[:data][:http][:method]
173
+ assert_equal "/mrlobster", rack_span[:data][:http][:url]
174
+ assert_equal 200, rack_span[:data][:http][:status]
175
+ assert rack_span.key?(:f)
176
+ assert rack_span[:f].key?(:e)
177
+ assert rack_span[:f].key?(:h)
178
+ assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
139
179
 
140
180
  # Context validation
141
181
  # The first span should have the passed in trace ID
142
182
  # and specify the passed in span ID as it's parent.
143
- assert_equal 1234, first_span[:t]
144
- assert_equal 4321, first_span[:p]
183
+ assert_equal 1234, rack_span[:t]
184
+ assert_equal 4321, rack_span[:p]
145
185
  end
146
186
 
147
187
  def test_instana_response_headers
@@ -181,17 +221,17 @@ class RackTest < Minitest::Test
181
221
 
182
222
  # Span validation
183
223
  assert_equal 1, spans.count
184
- first_span = spans.first
224
+ rack_span = spans.first
185
225
 
186
- assert first_span[:data][:http].key?(:header)
187
- assert first_span[:data][:http][:header].key?(:"X-Capture-This")
188
- assert !first_span[:data][:http][:header].key?(:"X-Capture-That")
189
- assert_equal "ThereYouGo", first_span[:data][:http][:header][:"X-Capture-This"]
226
+ assert rack_span[:data][:http].key?(:header)
227
+ assert rack_span[:data][:http][:header].key?(:"X-Capture-This")
228
+ assert !rack_span[:data][:http][:header].key?(:"X-Capture-That")
229
+ assert_equal "ThereYouGo", rack_span[:data][:http][:header][:"X-Capture-This"]
190
230
 
191
231
  # Backtrace fingerprint validation
192
- assert first_span.key?(:stack)
193
- assert_equal 2, first_span[:stack].count
194
- refute_nil first_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
232
+ assert rack_span.key?(:stack)
233
+ assert_equal 2, rack_span[:stack].count
234
+ refute_nil rack_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
195
235
 
196
236
  # Restore to default
197
237
  ::Instana.config[:collect_backtraces] = false
@@ -190,7 +190,7 @@ class ActionViewTest < Minitest::Test
190
190
  assert_equal :partial, fourth_span[:data][:render][:type]
191
191
  assert_equal 'syntax_error', fourth_span[:data][:render][:name]
192
192
  assert fourth_span[:data][:log].key?(:message)
193
- assert_equal "SyntaxError", fourth_span[:data][:log][:parameters]
193
+ assert(fourth_span[:data][:log][:parameters].include?("SyntaxError"))
194
194
  assert fourth_span[:error]
195
195
  assert fourth_span[:stack]
196
196
  end
@@ -1,4 +1,4 @@
1
-
1
+ require 'sinatra'
2
2
  if defined?(::Sinatra)
3
3
  require 'test_helper'
4
4
  require File.expand_path(File.dirname(__FILE__) + '/../apps/sinatra')
@@ -17,28 +17,36 @@ if defined?(::Sinatra)
17
17
  r = get '/'
18
18
  assert last_response.ok?
19
19
 
20
- assert r.headers.key?("X-Instana-T")
21
- assert r.headers.key?("X-Instana-S")
22
20
 
23
21
  spans = ::Instana.processor.queued_spans
24
22
  assert_equal 1, spans.count
25
23
 
26
- first_span = spans.first
27
- assert_equal :rack, first_span[:n]
28
- assert first_span.key?(:data)
29
- assert first_span[:data].key?(:http)
30
-
31
- assert first_span[:data][:http].key?(:method)
32
- assert_equal "GET", first_span[:data][:http][:method]
24
+ rack_span = spans.first
25
+ assert_equal :rack, rack_span[:n]
26
+ # ::Instana::Util.pry!
33
27
 
34
- assert first_span[:data][:http].key?(:url)
35
- assert_equal "/", first_span[:data][:http][:url]
36
-
37
- assert first_span[:data][:http].key?(:status)
38
- assert_equal 200, first_span[:data][:http][:status]
39
-
40
- assert first_span[:data][:http].key?(:host)
41
- assert_equal "example.org", first_span[:data][:http][:host]
28
+ assert r.headers.key?("X-Instana-T")
29
+ assert r.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
30
+ assert r.headers.key?("X-Instana-S")
31
+ assert r.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
32
+ assert r.headers.key?("X-Instana-L")
33
+ assert r.headers["X-Instana-L"] == '1'
34
+ assert r.headers.key?("Server-Timing")
35
+ assert r.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
36
+
37
+ assert rack_span.key?(:data)
38
+ assert rack_span[:data].key?(:http)
39
+ assert rack_span[:data][:http].key?(:method)
40
+ assert_equal "GET", rack_span[:data][:http][:method]
41
+
42
+ assert rack_span[:data][:http].key?(:url)
43
+ assert_equal "/", rack_span[:data][:http][:url]
44
+
45
+ assert rack_span[:data][:http].key?(:status)
46
+ assert_equal 200, rack_span[:data][:http][:status]
47
+
48
+ assert rack_span[:data][:http].key?(:host)
49
+ assert_equal "example.org", rack_span[:data][:http][:host]
42
50
  end
43
51
  end
44
52
  end
@@ -14,7 +14,7 @@ class GrpcTest < Minitest::Test
14
14
 
15
15
  if error
16
16
  assert_equal true, data[:rpc][:error]
17
- assert_equal "2:RuntimeError: #{error}", data[:log][:message]
17
+ assert data[:log][:message].include?("2:RuntimeError: #{error}")
18
18
  end
19
19
  end
20
20
 
@@ -1,40 +1,44 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class RedisTest < Minitest::Test
4
+ def setup
5
+ if ENV.key?('REDIS_URL')
6
+ @redis_url = ENV['REDIS_URL']
7
+ else
8
+ @redis_url = "redis://localhost:6379"
9
+ end
10
+ @redis_client = Redis.new(url: @redis_url)
11
+ end
12
+
4
13
  def test_normal_call
5
14
  clear_all!
6
- redis_client = create_redis_client
7
15
 
8
16
  Instana.tracer.start_or_continue_trace(:redis_test) do
9
- redis_client.set('hello', 'world')
17
+ @redis_client.set('hello', 'world')
10
18
  end
11
- redis_client.disconnect!
12
19
 
13
20
  assert_redis_trace('SET')
14
21
  end
15
22
 
16
23
  def test_normal_call_with_error
17
24
  clear_all!
18
- redis_client = create_redis_client
19
25
 
20
26
  Instana.tracer.start_or_continue_trace(:redis_test) do
21
27
  begin
22
- redis_client.zadd('hello', 'invalid', 'value')
28
+ @redis_client.zadd('hello', 'invalid', 'value')
23
29
  rescue; end
24
30
  end
25
- redis_client.disconnect!
26
31
 
27
32
  assert_redis_trace('ZADD', with_error: 'ERR value is not a valid float')
28
33
  end
29
34
 
30
35
  def test_pipeline_call
31
36
  clear_all!
32
- redis_client = create_redis_client
33
37
 
34
38
  Instana.tracer.start_or_continue_trace(:redis_test) do
35
- redis_client.pipelined do
36
- redis_client.set('hello', 'world')
37
- redis_client.set('other', 'world')
39
+ @redis_client.pipelined do
40
+ @redis_client.set('hello', 'world')
41
+ @redis_client.set('other', 'world')
38
42
  end
39
43
  end
40
44
 
@@ -43,13 +47,12 @@ class RedisTest < Minitest::Test
43
47
 
44
48
  def test_pipeline_call_with_error
45
49
  clear_all!
46
- redis_client = create_redis_client
47
50
 
48
51
  Instana.tracer.start_or_continue_trace(:redis_test) do
49
52
  begin
50
- redis_client.pipelined do
51
- redis_client.set('other', 'world')
52
- redis_client.call('invalid')
53
+ @redis_client.pipelined do
54
+ @redis_client.set('other', 'world')
55
+ @redis_client.call('invalid')
53
56
  end
54
57
  rescue; end
55
58
  end
@@ -59,12 +62,11 @@ class RedisTest < Minitest::Test
59
62
 
60
63
  def test_multi_call
61
64
  clear_all!
62
- redis_client = create_redis_client
63
65
 
64
66
  Instana.tracer.start_or_continue_trace(:redis_test) do
65
- redis_client.multi do
66
- redis_client.set('hello', 'world')
67
- redis_client.set('other', 'world')
67
+ @redis_client.multi do
68
+ @redis_client.set('hello', 'world')
69
+ @redis_client.set('other', 'world')
68
70
  end
69
71
  end
70
72
 
@@ -73,13 +75,12 @@ class RedisTest < Minitest::Test
73
75
 
74
76
  def test_multi_call_with_error
75
77
  clear_all!
76
- redis_client = create_redis_client
77
78
 
78
79
  Instana.tracer.start_or_continue_trace(:redis_test) do
79
80
  begin
80
- redis_client.multi do
81
- redis_client.set('other', 'world')
82
- redis_client.call('invalid')
81
+ @redis_client.multi do
82
+ @redis_client.set('other', 'world')
83
+ @redis_client.call('invalid')
83
84
  end
84
85
  rescue; end
85
86
  end
@@ -89,10 +90,6 @@ class RedisTest < Minitest::Test
89
90
 
90
91
  private
91
92
 
92
- def create_redis_client
93
- Redis.new(url: ENV['I_REDIS_URL'])
94
- end
95
-
96
93
  def assert_redis_trace(command, with_error: nil)
97
94
  spans = ::Instana.processor.queued_spans
98
95
  assert_equal 2, spans.length
@@ -105,10 +102,10 @@ class RedisTest < Minitest::Test
105
102
 
106
103
  data = second_span[:data]
107
104
 
108
- uri = URI.parse(ENV['I_REDIS_URL'])
105
+ uri = URI.parse(@redis_url)
109
106
  assert_equal "#{uri.host}:#{uri.port}", data[:redis][:connection]
110
107
 
111
- assert_equal 0, data[:redis][:db]
108
+ assert_equal "0", data[:redis][:db]
112
109
  assert_equal command, data[:redis][:command]
113
110
 
114
111
  if with_error