instana 1.11.4-java → 1.11.5-java

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: d0c2a0a2e14241032bcc9b77549f987e3fbcd7930af21de91d2c1a1611367574
4
- data.tar.gz: d2ee8fbd99013a433570f62f912adb9611fe0b76f1fb769315fb0d89e8f7ee90
3
+ metadata.gz: d68942800f8784f7d97e3c87e097147d939a244189d8761afc94eccbbf3f3142
4
+ data.tar.gz: 04f9cf75863a58351685f034a874d486aa730d013b967f455c2ed60828746c81
5
5
  SHA512:
6
- metadata.gz: 14ed1ee201a5f1ebe44524f1930d5d0a92d41407cb729516ef1eca3ad8975ddfec56cfe072acb00a953430f0dd6b34a25f50def6d6b2cc7b35a4036eb6296c93
7
- data.tar.gz: decbb81e1e57a2c5a862b63167906e2afcdbe1cef077c84b1f8bc2e0e053eb59879d3d52958a7d2df9b5a5177e05b922c1182ddb686c146cb9a39f25e97eb19b
6
+ metadata.gz: 0c2a64684bec1fc80d1f1c1f80ac3cb4ba97b3d4abee0d462436dc4fba5f6165bdc2090c2958c700ae591f4a4707e48ff26d2224c46e4d50ec850f6c0d0b7f11
7
+ data.tar.gz: e5704b2b7d33e93a6b4654b2c7152525b8d988cd70e6e8374b7e7774b9fcef63a4012ecfa20808827d846445fae75ac7a4b2c0f4f974ee13d484e77124ecd4f8
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="http://www.instana.com/wp-content/uploads/2016/11/Instana-Infrastructure-Map-1-1024x551.png"/>
2
+ <img src="https://disznc.s3.amazonaws.com/Ruby-Dashboard-2020-02-10-at-2.31.36-PM.png"/>
3
3
  </div>
4
4
 
5
5
  # Instana
@@ -1,47 +1,29 @@
1
- module Instana
2
- module Instrumentation
3
- class Redis
4
- def self.get_host(client)
5
- client.host
6
- end
7
-
8
- def self.get_port(client)
9
- client.port
10
- end
11
-
12
- def self.pipeline_command(pipeline)
13
- pipeline.is_a?(::Redis::Pipeline::Multi) ? 'MULTI' : 'PIPELINE'
14
- end
15
- end
16
- end
17
- end
18
-
19
1
  if defined?(::Redis) && ::Instana.config[:redis][:enabled]
20
2
  ::Redis::Client.class_eval do
21
3
  def call_with_instana(*args, &block)
22
4
  kv_payload = { redis: {} }
23
5
 
24
- if !Instana.tracer.tracing?
6
+ if !Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:redis)
25
7
  return call_without_instana(*args, &block)
26
8
  end
27
9
 
28
- host = ::Instana::Instrumentation::Redis.get_host(self)
29
- port = ::Instana::Instrumentation::Redis.get_port(self)
30
- kv_payload[:redis] = {
31
- connection: "#{host}:#{port}",
32
- db: db,
33
- command: args[0][0].to_s.upcase
34
- }
35
- ::Instana.tracer.log_entry(:redis, kv_payload)
10
+ ::Instana.tracer.log_entry(:redis)
11
+
12
+ begin
13
+ kv_payload[:redis][:connection] = "#{self.host}:#{self.port}"
14
+ kv_payload[:redis][:db] = db.to_s
15
+ kv_payload[:redis][:command] = args[0][0].to_s.upcase
16
+ rescue
17
+ nil
18
+ end
36
19
 
37
20
  call_without_instana(*args, &block)
38
21
  rescue => e
39
- kv_payload[:redis][:error] = true
40
- ::Instana.tracer.log_info(kv_payload)
22
+ ::Instana.tracer.log_info({ redis: {error: true} })
41
23
  ::Instana.tracer.log_error(e)
42
24
  raise
43
25
  ensure
44
- ::Instana.tracer.log_exit(:redis, {})
26
+ ::Instana.tracer.log_exit(:redis, kv_payload)
45
27
  end
46
28
 
47
29
  ::Instana.logger.debug "Instrumenting Redis"
@@ -52,28 +34,28 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
52
34
  def call_pipeline_with_instana(*args, &block)
53
35
  kv_payload = { redis: {} }
54
36
 
55
- if !Instana.tracer.tracing?
37
+ if !Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:redis)
56
38
  return call_pipeline_without_instana(*args, &block)
57
39
  end
58
40
 
41
+ ::Instana.tracer.log_entry(:redis)
42
+
59
43
  pipeline = args.first
60
- host = ::Instana::Instrumentation::Redis.get_host(self)
61
- port = ::Instana::Instrumentation::Redis.get_port(self)
62
- kv_payload[:redis] = {
63
- connection: "#{host}:#{port}",
64
- db: db,
65
- command: ::Instana::Instrumentation::Redis.pipeline_command(pipeline)
66
- }
67
- ::Instana.tracer.log_entry(:redis, kv_payload)
44
+ begin
45
+ kv_payload[:redis][:connection] = "#{self.host}:#{self.port}"
46
+ kv_payload[:redis][:db] = db.to_s
47
+ kv_payload[:redis][:command] = pipeline.is_a?(::Redis::Pipeline::Multi) ? 'MULTI' : 'PIPELINE'
48
+ rescue
49
+ nil
50
+ end
68
51
 
69
52
  call_pipeline_without_instana(*args, &block)
70
53
  rescue => e
71
- kv_payload[:redis][:error] = true
72
- ::Instana.tracer.log_info(kv_payload)
54
+ ::Instana.tracer.log_info({ redis: {error: true} })
73
55
  ::Instana.tracer.log_error(e)
74
56
  raise
75
57
  ensure
76
- ::Instana.tracer.log_exit(:redis, {})
58
+ ::Instana.tracer.log_exit(:redis, kv_payload)
77
59
  end
78
60
 
79
61
  alias call_pipeline_without_instana call_pipeline
@@ -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]
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.11.4"
2
+ VERSION = "1.11.5"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
@@ -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
@@ -1,6 +1,13 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class SidekiqClientTest < Minitest::Test
4
+ def setup
5
+ Sidekiq.configure_client do |config|
6
+ config.redis = { url: ENV["REDIS_URL"] }
7
+ end
8
+ ::Sidekiq::Queue.new('some_random_queue').clear
9
+ end
10
+
4
11
  def test_config_defaults
5
12
  assert ::Instana.config[:'sidekiq-client'].is_a?(Hash)
6
13
  assert ::Instana.config[:'sidekiq-client'].key?(:enabled)
@@ -1,6 +1,12 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class SidekiqServerTest < Minitest::Test
4
+ def setup
5
+ Sidekiq.configure_client do |config|
6
+ config.redis = { url: ENV["REDIS_URL"] }
7
+ end
8
+ end
9
+
4
10
  def test_config_defaults
5
11
  assert ::Instana.config[:'sidekiq-worker'].is_a?(Hash)
6
12
  assert ::Instana.config[:'sidekiq-worker'].key?(:enabled)
data/test/test_helper.rb CHANGED
@@ -56,10 +56,6 @@ when /libraries/
56
56
  require './test/servers/sidekiq/worker'
57
57
  end
58
58
 
59
- if defined?(::Redis)
60
- $redis = Redis.new(url: ENV['I_REDIS_URL'])
61
- end
62
-
63
59
  Minitest::Reporters.use! MiniTest::Reporters::SpecReporter.new
64
60
 
65
61
  # Used to reset the gem to boot state. It clears out any queued and/or staged
@@ -68,7 +64,6 @@ Minitest::Reporters.use! MiniTest::Reporters::SpecReporter.new
68
64
  def clear_all!
69
65
  ::Instana.processor.clear!
70
66
  ::Instana.tracer.clear!
71
- $redis.flushall if $redis
72
67
  nil
73
68
  end
74
69
 
@@ -332,4 +332,25 @@ class OpenTracerTest < Minitest::Test
332
332
  assert_equal({:my_bag=>1}, ac_span.context.baggage)
333
333
  assert_equal(nil, av_span.context.baggage)
334
334
  end
335
+
336
+ def test_start_active_span
337
+ clear_all!
338
+
339
+ span = OpenTracing.start_active_span(:rack)
340
+ assert_equal ::Instana::Tracer.current_span, span
341
+
342
+ sleep 0.1
343
+
344
+ span.finish
345
+
346
+ spans = ::Instana.processor.queued_spans
347
+ assert_equal 1, spans.length
348
+ end
349
+
350
+ def test_active_span
351
+ clear_all!
352
+
353
+ span = OpenTracing.start_active_span(:rack)
354
+ assert_equal OpenTracing.active_span, span
355
+ end
335
356
  end
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.11.4
4
+ version: 1.11.5
5
5
  platform: java
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement