lightstep 0.11.2 → 0.12.0

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
- SHA1:
3
- metadata.gz: 5baac354178b4bd23591043b41ad66d8cd21c2d2
4
- data.tar.gz: 1ece9648e050abfcc7dc7b8b7639fc1340c1fc07
2
+ SHA256:
3
+ metadata.gz: 4061236d2e72a5a8af39a92ee36074193a9dfe0bd48032cdecdfcc3d01054557
4
+ data.tar.gz: ff20651fafa157cfeeecc789c73fb4a0c5dc4abbe910ef048625a39286251f6f
5
5
  SHA512:
6
- metadata.gz: 1ea01d361841e64157522f2cda2e4de75de0b1c53a4e1a4576a7ddb2d8aee3ec333e6619d6d3ff5d17cad4f5766d091b6ede1ce9efd93ae0683c3ca69fd6bfb3
7
- data.tar.gz: 7c193e9ddf4828401cce47e514c01f3a6009c908cceba06b2b2893b90307edb357a0f8cd6f907a7922bbe1a1e9d004e7f00a389dec142b9482cb0fbf2924e047
6
+ metadata.gz: 0f7b6a24656af8708d935b7afa2e47f5f7ee3fcd768518679450326140b6ead0ef1191718a487f3bed035eec99f8a263edc1d04b1fb18ea9c05b126ad23a0f88
7
+ data.tar.gz: 23bb222bae518baa0bf4151883b9cc525cc6226d485fff7bce7cc13c12b4d7ea3a41821ba30bec0f7a19438b1a2bed039aabed27a947799613f9cf91e8eaff6b
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # Specify your gem's dependencies in lightstep.gemspec
3
4
  gemspec
data/Makefile CHANGED
@@ -14,10 +14,10 @@ benchmark:
14
14
  ruby benchmark/threading/thread_test.rb
15
15
 
16
16
  bump-version:
17
- ruby -e 'require "bump"; Bump::Bump.run("patch")'
18
- make build # rebuild after version increment
17
+ # ruby -e 'require "bump"; Bump::Bump.run("minor")'
18
+ # make build # rebuild after version increment
19
19
  git tag `ruby scripts/version.rb`
20
- git push
20
+ # git push
21
21
  git push --tags
22
22
 
23
23
  publish: build test benchmark bump-version
@@ -53,7 +53,7 @@ Benchmark.bm(32) do |x|
53
53
  span = tracer.start_span('my_span')
54
54
  for i in 0..10_000
55
55
  carrier = {}
56
- tracer.inject(span.span_context, LightStep::Tracer::FORMAT_TEXT_MAP, carrier)
56
+ tracer.inject(span.span_context, OpenTracing::FORMAT_TEXT_MAP, carrier)
57
57
  end
58
58
  span.finish
59
59
  end
@@ -16,7 +16,7 @@ watchThread = Thread.new do
16
16
  sleep(0.5)
17
17
  mutex.lock
18
18
  time_per_span = (1e6 * (total_time.to_f / span_count.to_f)).round(2)
19
- puts "#{span_count} spans #{percent_done}% done #{total_time.round(2)} seconds (#{time_per_span} us/span)"
19
+ puts "#{span_count} spans #{percent_done}% done #{total_time.round(2)} seconds (#{time_per_span} µs/span)"
20
20
  is_done = done
21
21
  mutex.unlock
22
22
  Thread.exit if is_done
@@ -1,5 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'lightstep'
3
+ require 'opentracing'
3
4
 
4
5
  require 'rack'
5
6
  require 'rack/server'
@@ -19,7 +20,7 @@ class Router
19
20
 
20
21
  client = Net::HTTP.new("localhost", "9002")
21
22
  req = Net::HTTP::Post.new("/")
22
- @tracer.inject(span.span_context, LightStep::Tracer::FORMAT_RACK, req)
23
+ @tracer.inject(span.span_context, OpenTracing::FORMAT_RACK, req)
23
24
  res = client.request(req)
24
25
 
25
26
  span.log(event: "application_response", response: res.to_s)
@@ -36,7 +37,7 @@ class App
36
37
  end
37
38
 
38
39
  def call(env)
39
- wire_ctx = @tracer.extract(LightStep::Tracer::FORMAT_RACK, env)
40
+ wire_ctx = @tracer.extract(OpenTracing::FORMAT_RACK, env)
40
41
  span = @tracer.start_span("app_call", child_of: wire_ctx)
41
42
  puts "child #{span.to_h[:trace_guid]}"
42
43
  span.log(event: "application", env: env)
@@ -19,6 +19,10 @@ module LightStep
19
19
  # @param operation_name [String] the operation name of this span. If it's
20
20
  # not a String it will be encoded with to_s.
21
21
  # @param child_of [SpanContext] the parent SpanContext (per child_of)
22
+ # @param references [Array<SpanContext>] An array of SpanContexts
23
+ # that identify what Spans this Span follows from causally. Presently
24
+ # only one reference is supported, and cannot be provided in addition to
25
+ # a child_of.
22
26
  # @param start_micros [Numeric] start time of the span in microseconds
23
27
  # @param tags [Hash] initial key:value tags (per set_tag) for the Span
24
28
  # @param max_log_records [Numeric] maximum allowable number of log records
@@ -28,11 +32,11 @@ module LightStep
28
32
  tracer:,
29
33
  operation_name:,
30
34
  child_of: nil,
35
+ references: [],
31
36
  start_micros:,
32
37
  tags: nil,
33
38
  max_log_records:
34
39
  )
35
- child_of = child_of.span_context if (Span === child_of)
36
40
  @tags = Concurrent::Hash.new
37
41
  @tags.update(tags) unless tags.nil?
38
42
  @log_records = Concurrent::Array.new
@@ -43,12 +47,16 @@ module LightStep
43
47
  self.operation_name = operation_name.to_s
44
48
  self.start_micros = start_micros
45
49
 
46
- trace_id = (SpanContext === child_of ? child_of.trace_id : LightStep.guid)
47
- @span_context = SpanContext.new(id: LightStep.guid, trace_id: trace_id)
50
+ ref = child_of ? child_of : references
51
+ ref = ref[0] if (Array === ref)
52
+ ref = ref.span_context if (Span === ref)
48
53
 
49
- if SpanContext === child_of
50
- set_baggage(child_of.baggage)
51
- set_tag(:parent_span_guid, child_of.id)
54
+ if SpanContext === ref
55
+ @span_context = SpanContext.new(id: LightStep.guid, trace_id: ref.trace_id)
56
+ set_baggage(ref.baggage)
57
+ set_tag(:parent_span_guid, ref.id)
58
+ else
59
+ @span_context = SpanContext.new(id: LightStep.guid, trace_id: LightStep.guid)
52
60
  end
53
61
  end
54
62
 
@@ -1,6 +1,8 @@
1
1
  require 'json'
2
2
  require 'concurrent'
3
3
 
4
+ require 'opentracing'
5
+
4
6
  require 'lightstep/span'
5
7
  require 'lightstep/reporter'
6
8
  require 'lightstep/transport/http_json'
@@ -9,10 +11,6 @@ require 'lightstep/transport/callback'
9
11
 
10
12
  module LightStep
11
13
  class Tracer
12
- FORMAT_TEXT_MAP = 1
13
- FORMAT_BINARY = 2
14
- FORMAT_RACK = 3
15
-
16
14
  class Error < LightStep::Error; end
17
15
  class ConfigurationError < LightStep::Tracer::Error; end
18
16
 
@@ -61,14 +59,19 @@ module LightStep
61
59
  # @param child_of [SpanContext] SpanContext that acts as a parent to
62
60
  # the newly-started Span. If a Span instance is provided, its
63
61
  # .span_context is automatically substituted.
62
+ # @param references [Array<SpanContext>] An array of SpanContexts that
63
+ # identify any parent SpanContexts of newly-started Span. If Spans
64
+ # are provided, their .span_context is automatically substituted.
64
65
  # @param start_time [Time] When the Span started, if not now
65
66
  # @param tags [Hash] Tags to assign to the Span at start time
66
67
  # @return [Span]
67
- def start_span(operation_name, child_of: nil, start_time: nil, tags: nil)
68
+ def start_span(operation_name, child_of: nil, references: [], start_time: nil, tags: nil)
69
+
68
70
  Span.new(
69
71
  tracer: self,
70
72
  operation_name: operation_name,
71
73
  child_of: child_of,
74
+ references: references,
72
75
  start_micros: start_time.nil? ? LightStep.micros(Time.now) : LightStep.micros(start_time),
73
76
  tags: tags,
74
77
  max_log_records: max_log_records,
@@ -78,16 +81,15 @@ module LightStep
78
81
  # Inject a SpanContext into the given carrier
79
82
  #
80
83
  # @param spancontext [SpanContext]
81
- # @param format [LightStep::Tracer::FORMAT_TEXT_MAP, LightStep::Tracer::FORMAT_BINARY]
82
- # @param carrier [Hash]
84
+ # @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY]
85
+ # @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
83
86
  def inject(span_context, format, carrier)
84
- child_of = child_of.span_context if (Span === child_of)
85
87
  case format
86
- when LightStep::Tracer::FORMAT_TEXT_MAP
88
+ when OpenTracing::FORMAT_TEXT_MAP
87
89
  inject_to_text_map(span_context, carrier)
88
- when LightStep::Tracer::FORMAT_BINARY
90
+ when OpenTracing::FORMAT_BINARY
89
91
  warn 'Binary inject format not yet implemented'
90
- when LightStep::Tracer::FORMAT_RACK
92
+ when OpenTracing::FORMAT_RACK
91
93
  inject_to_rack(span_context, carrier)
92
94
  else
93
95
  warn 'Unknown inject format'
@@ -95,17 +97,17 @@ module LightStep
95
97
  end
96
98
 
97
99
  # Extract a SpanContext from a carrier
98
- # @param format [LightStep::Tracer::FORMAT_TEXT_MAP, LightStep::Tracer::FORMAT_BINARY]
99
- # @param carrier [Hash]
100
+ # @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
101
+ # @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
100
102
  # @return [SpanContext] the extracted SpanContext or nil if none could be found
101
103
  def extract(format, carrier)
102
104
  case format
103
- when LightStep::Tracer::FORMAT_TEXT_MAP
105
+ when OpenTracing::FORMAT_TEXT_MAP
104
106
  extract_from_text_map(carrier)
105
- when LightStep::Tracer::FORMAT_BINARY
107
+ when OpenTracing::FORMAT_BINARY
106
108
  warn 'Binary join format not yet implemented'
107
109
  nil
108
- when LightStep::Tracer::FORMAT_RACK
110
+ when OpenTracing::FORMAT_RACK
109
111
  extract_from_rack(carrier)
110
112
  else
111
113
  warn 'Unknown join format'
@@ -151,7 +153,10 @@ module LightStep
151
153
  raise ConfigurationError, "component_name must be a string" unless String === component_name
152
154
  raise ConfigurationError, "component_name cannot be blank" if component_name.empty?
153
155
 
154
- transport = Transport::HTTPJSON.new(access_token: access_token) if !access_token.nil?
156
+ if transport.nil? and !access_token.nil?
157
+ transport = Transport::HTTPJSON.new(access_token: access_token)
158
+ end
159
+
155
160
  raise ConfigurationError, "you must provide an access token or a transport" if transport.nil?
156
161
  raise ConfigurationError, "#{transport} is not a LightStep transport class" if !(LightStep::Transport::Base === transport)
157
162
 
@@ -1,3 +1,3 @@
1
1
  module LightStep
2
- VERSION = '0.11.2'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
 
19
19
  spec.add_dependency 'concurrent-ruby', '~> 1.0'
20
- spec.add_dependency 'opentracing', '~> 0.2'
20
+ spec.add_dependency 'opentracing', '~> 0.3'
21
21
  spec.add_development_dependency 'rake', '~> 11.3'
22
22
  spec.add_development_dependency 'rack', '~> 2.0'
23
23
  spec.add_development_dependency 'rspec', '~> 3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bcronin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '0.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements: []
181
181
  rubyforge_project:
182
- rubygems_version: 2.5.1
182
+ rubygems_version: 2.7.6
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: LightStep OpenTracing Ruby bindings