instana 0.15.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,6 +21,24 @@ module Instana
21
21
  end
22
22
  end
23
23
 
24
+ # Calls on target_class to 'extend' cls
25
+ #
26
+ # @param target_cls [Object] the class/module to do the 'extending'
27
+ # @param cls [Object] the class/module to be 'extended'
28
+ #
29
+ def send_extend(target_cls, cls)
30
+ target_cls.send(:extend, cls) if defined?(target_cls)
31
+ end
32
+
33
+ # Calls on <target_cls> to include <cls> into itself.
34
+ #
35
+ # @param target_cls [Object] the class/module to do the 'including'
36
+ # @param cls [Object] the class/module to be 'included'
37
+ #
38
+ def send_include(target_cls, cls)
39
+ target_cls.send(:include, cls) if defined?(target_cls)
40
+ end
41
+
24
42
  # Take two hashes, and make sure candidate does not have
25
43
  # any of the same values as `last`. We only report
26
44
  # when values change.
@@ -145,6 +163,65 @@ module Instana
145
163
  process[:report_pid] = nil
146
164
  process
147
165
  end
166
+
167
+ # Get the current time in milliseconds
168
+ #
169
+ # @return [Integer] the current time in milliseconds
170
+ #
171
+ def ts_now
172
+ (Time.now.to_f * 1000).floor
173
+ end
174
+
175
+ # Convert a Time value to milliseconds
176
+ #
177
+ # @param time [Time]
178
+ #
179
+ def time_to_ms(time = Time.now)
180
+ (time.to_f * 1000).floor
181
+ end
182
+
183
+ # Generate a random 64bit ID
184
+ #
185
+ # @return [Integer] a random 64bit integer
186
+ #
187
+ def generate_id
188
+ # Max value is 9223372036854775807 (signed long in Java)
189
+ rand(-2**63..2**63-1)
190
+ end
191
+
192
+ # Convert an ID to a value appropriate to pass in a header.
193
+ #
194
+ # @param id [Integer] the id to be converted
195
+ #
196
+ # @return [String]
197
+ #
198
+ def id_to_header(id)
199
+ unless id.is_a?(Integer) || id.is_a?(String)
200
+ Instana.logger.debug "id_to_header received a #{id.class}: returning empty string"
201
+ return String.new
202
+ end
203
+ [id.to_i].pack('q>').unpack('H*')[0]
204
+ rescue => e
205
+ Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
206
+ Instana.logger.debug e.backtrace.join("\r\n")
207
+ end
208
+
209
+ # Convert a received header value into a valid ID
210
+ #
211
+ # @param header_id [String] the header value to be converted
212
+ #
213
+ # @return [Integer]
214
+ #
215
+ def header_to_id(header_id)
216
+ if !header_id.is_a?(String)
217
+ Instana.logger.debug "header_to_id received a #{header_id.class}: returning 0"
218
+ return 0
219
+ end
220
+ [header_id].pack("H*").unpack("q>")[0]
221
+ rescue => e
222
+ Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
223
+ Instana.logger.debug e.backtrace.join("\r\n")
224
+ end
148
225
  end
149
226
  end
150
227
  end
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "0.15.0"
2
+ VERSION = "1.0.1"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
@@ -0,0 +1,6 @@
1
+ require "instana/opentracing/tracer"
2
+ require "instana/opentracing/carrier"
3
+
4
+ # Set the global tracer to our OT tracer
5
+ # which supports the OT specificiation
6
+ OpenTracing.global_tracer = ::Instana.tracer
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: 0.15.0
4
+ version: 1.0.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: 2016-12-28 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,6 +124,7 @@ files:
124
124
  - README.md
125
125
  - Rakefile
126
126
  - Tracing.md
127
+ - Troubleshooting.md
127
128
  - bin/console
128
129
  - bin/setup
129
130
  - examples/tracing.rb
@@ -149,15 +150,19 @@ files:
149
150
  - lib/instana/instrumentation/rack.rb
150
151
  - lib/instana/instrumentation/rest-client.rb
151
152
  - lib/instana/logger.rb
153
+ - lib/instana/opentracing/carrier.rb
154
+ - lib/instana/opentracing/tracer.rb
152
155
  - lib/instana/rack.rb
153
156
  - lib/instana/setup.rb
154
157
  - lib/instana/thread_local.rb
155
158
  - lib/instana/tracer.rb
156
159
  - lib/instana/tracing/processor.rb
157
160
  - lib/instana/tracing/span.rb
161
+ - lib/instana/tracing/span_context.rb
158
162
  - lib/instana/tracing/trace.rb
159
163
  - lib/instana/util.rb
160
164
  - lib/instana/version.rb
165
+ - lib/opentracing.rb
161
166
  homepage: https://www.instana.com/
162
167
  licenses: []
163
168
  metadata: {}
@@ -177,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
182
  version: '0'
178
183
  requirements: []
179
184
  rubyforge_project:
180
- rubygems_version: 2.5.1
185
+ rubygems_version: 2.5.2
181
186
  signing_key:
182
187
  specification_version: 4
183
188
  summary: Ruby sensor for Instana