instana 1.7.3 → 1.7.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5365232626cec032868d014b49d9546ad3666054
4
- data.tar.gz: dd74cbb686e5ae9f1af30c0a5089fd9ef4ba5ffb
3
+ metadata.gz: 13bb5e402c5c26c740336cf7e2d8befcad0e51a3
4
+ data.tar.gz: bc4f70fd52e2b10f9201fb8b8d76a6f50810de68
5
5
  SHA512:
6
- metadata.gz: 8b4d5259417d9adedf6d8d50448a8c13ab85487c79d131e588c35cbc9ded33b11899830f2c4c78208789d72c61f2a51f383a4b07a812ba8b365642c293d84130
7
- data.tar.gz: 27ae34fecb6fa90360bc06ebfdb90df85e83bda16c1af39dc6e6985a1ced9f391c47799f9bb75c8d8359ace921b0f5c116bc5798c611b0723b60de2137c5d802
6
+ metadata.gz: 3a6aae1e10996b86988aa78c742cfd301b57d7afca23ef8d0361b2d6312b858517b7756d1254ff4f3e3ac6f308c3f4f8d2c7bd3c79257fe5d63d7e6985bb39fc
7
+ data.tar.gz: bf262a7804ab27694c86996be1c48b413775a4c9b18211d0930ed1fd968eab9cd35be2f91ee61b8e1b40acc075714a2d6af8c51a70541ec0ed4ed15fea480945
data/.travis.yml CHANGED
@@ -6,10 +6,10 @@ cache:
6
6
  - vendor/bundle
7
7
 
8
8
  rvm:
9
+ - 2.4.1
9
10
  - 2.3.3
10
11
  - 2.2.6
11
12
  - 2.1.9
12
- - ruby-2.0.0-p648
13
13
 
14
14
 
15
15
  before_install:
@@ -38,11 +38,8 @@ matrix:
38
38
  # Rails 5.0+ requires Ruby 2.2.2 or higher
39
39
  - rvm: 2.1.9
40
40
  gemfile: gemfiles/rails50.gemfile
41
- - rvm: ruby-2.0.0-p648
42
- gemfile: gemfiles/rails50.gemfile
43
- - rvm: ruby-2.0.0-p648
44
- gemfile: gemfiles/rails42.gemfile
45
- - rvm: ruby-2.0.0-p648
41
+ # Rails 3.2 doesn't work on Ruby 2.4.1
42
+ - rvm: 2.4.1
46
43
  gemfile: gemfiles/rails32.gemfile
47
44
 
48
45
  notifications:
data/Rakefile CHANGED
@@ -31,7 +31,8 @@ Rake::TestTask.new(:test) do |t|
31
31
  else
32
32
  t.test_files = FileList['test/agent/*_test.rb'] +
33
33
  FileList['test/tracing/*_test.rb'] +
34
- FileList['test/profiling/*_test.rb']
34
+ FileList['test/profiling/*_test.rb'] +
35
+ FileList['test/benchmarks/bench_*.rb']
35
36
  end
36
37
  end
37
38
 
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler"
3
+ Bundler.require(:default)
4
+
5
+ require "benchmark"
6
+
7
+ Benchmark.bm do |x|
8
+ x.report("start_span, finish: ") {
9
+ 50_000.times {
10
+ ::Instana.tracer.start_span(:blah).finish
11
+ }
12
+ }
13
+
14
+ x.report("start_span, set_tag(5x), finish:") {
15
+ 50_000.times {
16
+ span = ::Instana.tracer.start_span(:blah)
17
+ span.set_tag(:blah, 1)
18
+ span.set_tag(:dog, 1)
19
+ span.set_tag(:moon, "ok")
20
+ span.set_tag(:ape, 1)
21
+ span.set_tag(:blah, 1)
22
+ span.finish
23
+ }
24
+ }
25
+
26
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler"
3
+ Bundler.require(:default)
4
+
5
+ require "benchmark"
6
+
7
+ # Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
8
+
9
+ Benchmark.bm do |x|
10
+ x.report("Time.now: ") { 1_000_000.times { (Time.now.to_f * 1000).floor } }
11
+ x.report("get_clocktime:") { 1_000_000.times { Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) } }
12
+ end
@@ -33,7 +33,6 @@ end
33
33
  gem 'rails', '3.2.22.5'
34
34
  gem 'pg'
35
35
  gem 'mysql2', '~> 0.3.10'
36
- gem 'mysql'
37
36
 
38
37
  # Gems used only for assets and not required
39
38
  # in production environments by default.
@@ -30,7 +30,7 @@ group :development do
30
30
  end
31
31
  end
32
32
 
33
- gem 'rails', '4.2.7.1'
33
+ gem 'rails', '4.2.9'
34
34
  gem 'sqlite3'
35
35
  gem 'sass-rails', '~> 5.0'
36
36
  gem 'uglifier', '>= 1.3.0'
@@ -43,7 +43,6 @@ gem 'jbuilder', '~> 2.0'
43
43
  gem 'sdoc', '~> 0.4.0', group: :doc
44
44
  gem "pg"
45
45
  gem "mysql2"
46
- gem "mysql"
47
46
 
48
47
  # Include the Instana Ruby gem's base set of gems
49
48
  gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
data/instana.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
  spec.test_files = Dir.glob("{test}/**/*.rb")
21
21
 
22
- spec.required_ruby_version = '>= 2.0'
22
+ spec.required_ruby_version = '>= 2.1'
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.11"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -135,7 +135,7 @@ module Instana
135
135
  # @param name [String] the name of the span to end
136
136
  # @param kvs [Hash] list of key values to be reported in the span
137
137
  #
138
- def log_end(name, kvs = {}, end_time = Time.now)
138
+ def log_end(name, kvs = {}, end_time = ::Instana::Util.now_in_ms)
139
139
  return unless tracing?
140
140
 
141
141
  if ::Instana.debug? || ::Instana.test?
@@ -146,14 +146,16 @@ module Instana
146
146
 
147
147
  self.current_trace.finish(kvs, end_time)
148
148
 
149
- if !self.current_trace.has_async? ||
150
- (self.current_trace.has_async? && self.current_trace.complete?)
151
- Instana.processor.add(self.current_trace)
152
- else
153
- # This trace still has outstanding/uncompleted asynchronous spans.
154
- # Put it in the staging queue until the async span closes out or
155
- # 5 minutes has passed. Whichever comes first.
156
- Instana.processor.stage(self.current_trace)
149
+ if ::Instana.agent.ready?
150
+ if !self.current_trace.has_async? ||
151
+ (self.current_trace.has_async? && self.current_trace.complete?)
152
+ Instana.processor.add(self.current_trace)
153
+ else
154
+ # This trace still has outstanding/uncompleted asynchronous spans.
155
+ # Put it in the staging queue until the async span closes out or
156
+ # 5 minutes has passed. Whichever comes first.
157
+ Instana.processor.stage(self.current_trace)
158
+ end
157
159
  end
158
160
  self.current_trace = nil
159
161
  end
@@ -261,8 +263,8 @@ module Instana
261
263
  #
262
264
  # @return [Span]
263
265
  #
264
- def start_span(operation_name, child_of: nil, start_time: Time.now, tags: nil)
265
- return unless ::Instana.agent.ready?
266
+ def start_span(operation_name, child_of: nil, start_time: ::Instana::Util.now_in_ms, tags: nil)
267
+ # return unless ::Instana.agent.ready?
266
268
 
267
269
  if tracing?
268
270
  span = self.current_trace.new_span(operation_name, tags, start_time, child_of)
@@ -10,7 +10,7 @@ module Instana
10
10
  attr_accessor :parent
11
11
  attr_accessor :baggage
12
12
 
13
- def initialize(name, trace_id, parent_id: nil, start_time: Time.now)
13
+ def initialize(name, trace_id, parent_id: nil, start_time: ::Instana::Util.now_in_ms)
14
14
  @data = {}
15
15
  @data[:t] = trace_id # Trace ID
16
16
  @data[:s] = ::Instana::Util.generate_id # Span ID
@@ -22,7 +22,11 @@ module Instana
22
22
  @data[:f] = { :e => ::Instana.agent.report_pid,
23
23
  :h => ::Instana.agent.agent_uuid }
24
24
  # Start time
25
- @data[:ts] = ::Instana::Util.time_to_ms(start_time)
25
+ if start_time.is_a?(Time)
26
+ @data[:ts] = ::Instana::Util.time_to_ms(start_time)
27
+ else
28
+ @data[:ts] = start_time
29
+ end
26
30
 
27
31
  @baggage = {}
28
32
 
@@ -119,12 +123,13 @@ module Instana
119
123
  # @param end_time [Time] custom end time, if not now
120
124
  # @return [Span]
121
125
  #
122
- def close(end_time = Time.now)
123
- unless end_time.is_a?(Time)
124
- ::Instana.logger.debug "span.close: Passed #{end_time.class} instead of Time class"
126
+ def close(end_time = ::Instana::Util.now_in_ms)
127
+
128
+ if end_time.is_a?(Time)
129
+ end_time = ::Instana::Util.time_to_ms(end_time)
125
130
  end
126
131
 
127
- @data[:d] = (::Instana::Util.time_to_ms(end_time) - @data[:ts])
132
+ @data[:d] = end_time - @data[:ts]
128
133
  self
129
134
  end
130
135
 
@@ -349,11 +354,7 @@ module Instana
349
354
  #
350
355
  # @param end_time [Time] custom end time, if not now
351
356
  #
352
- def finish(end_time = Time.now)
353
- unless end_time.is_a?(Time)
354
- ::Instana.logger.debug "span.finish: Passed #{end_time.class} instead of Time class"
355
- end
356
-
357
+ def finish(end_time = ::Instana::Util.now_in_ms)
357
358
  if ::Instana.tracer.current_span.id != id
358
359
  ::Instana.logger.debug "Closing a span that isn't active. This will result in a broken trace: #{self.inspect}"
359
360
  end
@@ -17,7 +17,7 @@ module Instana
17
17
  # :span_id the ID of the parent span (must be an unsigned hex-string)
18
18
  # :level specifies data collection level (optional)
19
19
  #
20
- def initialize(name, kvs = nil, incoming_context = {}, start_time = Time.now)
20
+ def initialize(name, kvs = nil, incoming_context = {}, start_time = ::Instana::Util.now_in_ms)
21
21
  # The collection of spans that make
22
22
  # up this trace.
23
23
  @spans = Set.new
@@ -56,7 +56,7 @@ module Instana
56
56
  # @param name [String] the name of the span to start
57
57
  # @param kvs [Hash] list of key values to be reported in the span
58
58
  #
59
- def new_span(name, kvs = nil, start_time = Time.now, child_of = nil)
59
+ def new_span(name, kvs = nil, start_time = ::Instana::Util.now_in_ms, child_of = nil)
60
60
  return unless @current_span
61
61
 
62
62
  if child_of && child_of.is_a?(::Instana::Span)
@@ -104,21 +104,12 @@ module Instana
104
104
  #
105
105
  # @param kvs [Hash] list of key values to be reported in the span
106
106
  #
107
- def end_span(kvs = {}, end_time = Time.now)
107
+ def end_span(kvs = {}, end_time = ::Instana::Util.now_in_ms)
108
108
  @current_span.close(end_time)
109
109
  add_info(kvs) if kvs && !kvs.empty?
110
110
  @current_span = @current_span.parent unless @current_span.is_root?
111
111
  end
112
-
113
- # Closes out the final span in this trace and runs any finalizer
114
- # steps required.
115
- # This should be called only when on the root span to end the trace.
116
- #
117
- # @param kvs [Hash] list of key values to be reported in the span
118
- #
119
- def finish(kvs = {}, end_time = Time.now)
120
- end_span(kvs, end_time)
121
- end
112
+ alias finish end_span
122
113
 
123
114
  ###########################################################################
124
115
  # Asynchronous Methods
data/lib/instana/util.rb CHANGED
@@ -158,19 +158,21 @@ module Instana
158
158
  process
159
159
  end
160
160
 
161
- # Get the current time in milliseconds
161
+ # Get the current time in milliseconds from the epoch
162
162
  #
163
163
  # @return [Integer] the current time in milliseconds
164
164
  #
165
- def ts_now
166
- (Time.now.to_f * 1000).floor
165
+ def now_in_ms
166
+ Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
167
167
  end
168
+ # Prior method name support. To be deprecated when appropriate.
169
+ alias ts_now now_in_ms
168
170
 
169
171
  # Convert a Time value to milliseconds
170
172
  #
171
173
  # @param time [Time]
172
174
  #
173
- def time_to_ms(time = Time.now)
175
+ def time_to_ms(time)
174
176
  (time.to_f * 1000).floor
175
177
  end
176
178
 
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.7.3"
2
+ VERSION = "1.7.4"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
@@ -5,6 +5,7 @@ class BenchOpenTracing < Minitest::Benchmark
5
5
  assert_performance_constant do |input|
6
6
  10_000.times do
7
7
  span = ::Instana.tracer.start_span(:blah)
8
+ span.set_tag(:zero, 0)
8
9
  span.finish
9
10
  end
10
11
  end
data/test/test_helper.rb CHANGED
@@ -9,6 +9,7 @@ require "minitest/autorun"
9
9
  require "minitest/reporters"
10
10
  require "minitest/debugger" if ENV['DEBUG']
11
11
  require 'webmock/minitest'
12
+ require "minitest/benchmark"
12
13
 
13
14
  require "instana/test"
14
15
  ::Instana::Test.setup_environment
@@ -22,6 +22,11 @@ class CustomTracingTest < Minitest::Test
22
22
  first_span = t.spans.first
23
23
  assert_equal :sdk, first_span[:n]
24
24
 
25
+ assert first_span[:ts].is_a?(Integer)
26
+ assert first_span[:ts] > 0
27
+ assert first_span[:d].is_a?(Integer)
28
+ assert first_span[:d].between?(0, 5)
29
+
25
30
  assert first_span.key?(:data)
26
31
  assert first_span[:data].key?(:sdk)
27
32
  assert first_span[:data][:sdk].key?(:custom)
@@ -64,6 +69,11 @@ class CustomTracingTest < Minitest::Test
64
69
 
65
70
  first_span, second_span = t.spans.to_a
66
71
 
72
+ assert first_span[:ts].is_a?(Integer)
73
+ assert first_span[:ts] > 0
74
+ assert first_span[:d].is_a?(Integer)
75
+ assert first_span[:d].between?(0, 5)
76
+
67
77
  assert_equal :rack, first_span[:n]
68
78
  assert first_span.key?(:data)
69
79
  assert first_span[:data].key?(:on_trace_start)
@@ -117,6 +127,11 @@ class CustomTracingTest < Minitest::Test
117
127
 
118
128
  first_span, second_span = t.spans.to_a
119
129
 
130
+ assert first_span[:ts].is_a?(Integer)
131
+ assert first_span[:ts] > 0
132
+ assert first_span[:d].is_a?(Integer)
133
+ assert first_span[:d].between?(0, 5)
134
+
120
135
  assert_equal :rack, first_span[:n]
121
136
  assert first_span.key?(:data)
122
137
  assert first_span[:data].key?(:on_trace_start)
@@ -124,6 +139,11 @@ class CustomTracingTest < Minitest::Test
124
139
  assert first_span[:data].key?(:on_trace_end)
125
140
  assert_equal 1, first_span[:data][:on_trace_end]
126
141
 
142
+ assert second_span[:ts].is_a?(Integer)
143
+ assert second_span[:ts] > 0
144
+ assert second_span[:d].is_a?(Integer)
145
+ assert second_span[:d].between?(0, 5)
146
+
127
147
  assert_equal :sdk, second_span[:n]
128
148
  assert second_span.key?(:data)
129
149
  assert second_span[:data].key?(:sdk)
@@ -90,6 +90,10 @@ class OpenTracerTest < Minitest::Test
90
90
  first_span, second_span, third_span = trace.spans.to_a
91
91
 
92
92
  assert_equal :rack, first_span.name
93
+ assert first_span[:ts].is_a?(Integer)
94
+ assert first_span[:ts] > 0
95
+ assert first_span[:d].is_a?(Integer)
96
+ assert first_span[:d].between?(0, 5)
93
97
  assert first_span.key?(:data)
94
98
  assert first_span[:data].key?(:http)
95
99
  assert_equal "GET", first_span[:data][:http][:method]
@@ -160,6 +164,33 @@ class OpenTracerTest < Minitest::Test
160
164
  span.finish
161
165
  end
162
166
 
167
+ def test_start_span_with_custom_start_time
168
+ clear_all!
169
+ now = Time.now
170
+ now_in_ms = ::Instana::Util.time_to_ms(now)
171
+
172
+ span = OpenTracing.start_span('my_app_entry', :start_time => now)
173
+
174
+ assert span.is_a?(::Instana::Span)
175
+ assert_equal :my_app_entry, OpenTracing.current_trace.current_span.name
176
+
177
+ span.set_tag(:tag_integer, 1234)
178
+ span.set_tag(:tag_boolean, true)
179
+ span.set_tag(:tag_array, [1,2,3,4])
180
+ span.set_tag(:tag_string, "1234")
181
+
182
+ assert_equal 1234, span.tags(:tag_integer)
183
+ assert_equal true, span.tags(:tag_boolean)
184
+ assert_equal [1,2,3,4], span.tags(:tag_array)
185
+ assert_equal "1234", span.tags(:tag_string)
186
+ span.finish
187
+
188
+ assert span[:ts].is_a?(Integer)
189
+ assert_equal now_in_ms, span[:ts]
190
+ assert span[:d].is_a?(Integer)
191
+ assert span[:d].between?(0, 5)
192
+ end
193
+
163
194
  def test_span_kind_translation
164
195
  clear_all!
165
196
  span = OpenTracing.start_span('my_app_entry')
@@ -27,7 +27,7 @@ class TracerTest < Minitest::Test
27
27
 
28
28
  ::Instana.tracer.start_or_continue_trace(:rack, {:one => 1}) do
29
29
  assert_equal true, ::Instana.tracer.tracing?
30
- sleep 0.3
30
+ sleep 0.1
31
31
  end
32
32
 
33
33
  traces = ::Instana.processor.queued_traces
@@ -39,6 +39,9 @@ class TracerTest < Minitest::Test
39
39
  first_span = t.spans.first
40
40
  assert_equal :rack, first_span[:n]
41
41
  assert_equal :ruby, first_span[:ta]
42
+ assert first_span[:ts].is_a?(Integer)
43
+ assert first_span[:d].is_a?(Integer)
44
+ assert first_span[:d].between?(100, 130)
42
45
  assert first_span.key?(:data)
43
46
  assert_equal 1, first_span[:data][:one]
44
47
  assert first_span.key?(:f)
@@ -47,7 +50,7 @@ class TracerTest < Minitest::Test
47
50
  assert_equal ::Instana.agent.agent_uuid, first_span[:f][:h]
48
51
  end
49
52
 
50
- def test_errors_are_properly_propogated
53
+ def test_errors_are_properly_propagated
51
54
  clear_all!
52
55
  exception_raised = false
53
56
  begin
@@ -69,6 +72,10 @@ class TracerTest < Minitest::Test
69
72
  first_span = t.spans.first
70
73
  assert_equal :rack, first_span[:n]
71
74
  assert_equal :ruby, first_span[:ta]
75
+ assert first_span[:ts].is_a?(Integer)
76
+ assert first_span[:ts] > 0
77
+ assert first_span[:d].is_a?(Integer)
78
+ assert first_span[:d].between?(0, 5)
72
79
  assert first_span.key?(:data)
73
80
  assert_equal 1, first_span[:data][:one]
74
81
  assert first_span.key?(:f)
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.7.3
4
+ version: 1.7.4
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: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -172,6 +172,8 @@ files:
172
172
  - benchmarks/Gemfile
173
173
  - benchmarks/Gemfile.lock
174
174
  - benchmarks/id_generation.rb
175
+ - benchmarks/opentracing.rb
176
+ - benchmarks/time_processing.rb
175
177
  - bin/console
176
178
  - bin/setup
177
179
  - examples/tracing.rb
@@ -282,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
284
  requirements:
283
285
  - - ">="
284
286
  - !ruby/object:Gem::Version
285
- version: '2.0'
287
+ version: '2.1'
286
288
  required_rubygems_version: !ruby/object:Gem::Requirement
287
289
  requirements:
288
290
  - - ">="
@@ -290,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
292
  version: '0'
291
293
  requirements: []
292
294
  rubyforge_project:
293
- rubygems_version: 2.6.11
295
+ rubygems_version: 2.6.12
294
296
  signing_key:
295
297
  specification_version: 4
296
298
  summary: Ruby sensor for Instana