lightstep 0.13.0 → 0.15.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
- SHA256:
3
- metadata.gz: 412b678787b505c5c97155f3d702adf01e8ebd60254fb793a07e8ae4da2cd7fa
4
- data.tar.gz: bdd33820334d2306ce78b7e84928e4be5193211d0c359bba02b4032ed3c6fc42
2
+ SHA1:
3
+ metadata.gz: 3dd55736997047494f81d964b3af41ae7d46df3d
4
+ data.tar.gz: 2cb5bd4f73f16d8a7ec05347f73574c660b57bde
5
5
  SHA512:
6
- metadata.gz: 8d1395123221d74ce722e748dc21951f8462103dd505edc42f3f04c32f3f9eed524358a684085cb8ba55acd35dc3909102447cb0133700f8b91016687bf0ba00
7
- data.tar.gz: 597593ee87d988b10f9c79fc80ddfa5e4b3f05290e5033873aeb1e7655d6562dacb5f81410a3d0db62d2a418958e9165557e17f062f188db4602c2e3c09a0b44
6
+ metadata.gz: 3cd1f14fc114101da63e675f0e5e5e3317b09ded56822d2a65bafafd1666ab44205c5e1759287ce6887bd8e48ea6b62547aff747e57c62d86da4fd3feb9bb002
7
+ data.tar.gz: cd21715f9042383212e30701971ce48bae5954427786ad57adfecabecf1d27795b46a33877e2adfa179736f985278a9f39d827b93f870921d9ee36d6b62f27a1
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ coverage/
9
9
  *~
10
10
  lightstep-tracer*.gem
11
11
  lightstep*.gem
12
+ .idea/
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Added
9
+ - A Changelog
10
+ - Now supports Span#log_kv
11
+ - Updated to opentracing-ruby 0.5.0
12
+ - Now delegates Lightstep#active_span to the tracer
13
+ - Now supports passing a block to #start_span
14
+ - The block forms of #start_span and #start active_span now return the result of executing the block
15
+
16
+ ### Changed
17
+ - Tracer#extract now supports symbols in carrier
18
+
19
+ ### Deprecated
20
+ - Span#log (reflecting deprecation in opentracing 0.4.0)
21
+
22
+ ### Removed
23
+
24
+ ### Fixed
25
+ - Fix handling of non-string tag values in `start_span`.
26
+
27
+ ### Security
28
+
@@ -1,35 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lightstep (0.13.0)
4
+ lightstep (0.15.0)
5
5
  concurrent-ruby (~> 1.0)
6
- opentracing (~> 0.4.1)
6
+ opentracing (~> 0.5.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  bump (0.6.1)
12
- concurrent-ruby (1.0.5)
12
+ concurrent-ruby (1.1.5)
13
13
  diff-lcs (1.3)
14
- docile (1.3.1)
15
- json (2.1.0)
16
- opentracing (0.4.1)
17
- rack (2.0.5)
14
+ docile (1.3.2)
15
+ json (2.2.0)
16
+ opentracing (0.5.0)
17
+ rack (2.0.7)
18
18
  rake (11.3.0)
19
- rspec (3.7.0)
20
- rspec-core (~> 3.7.0)
21
- rspec-expectations (~> 3.7.0)
22
- rspec-mocks (~> 3.7.0)
23
- rspec-core (3.7.1)
24
- rspec-support (~> 3.7.0)
25
- rspec-expectations (3.7.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.2)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.4)
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.7.0)
28
- rspec-mocks (3.7.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.1)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.7.0)
31
- rspec-support (3.7.1)
32
- simplecov (0.16.1)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.2)
32
+ simplecov (0.17.0)
33
33
  docile (~> 1.1)
34
34
  json (>= 1.8, < 3)
35
35
  simplecov-html (~> 0.10.0)
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  timecop (~> 0.8.0)
50
50
 
51
51
  BUNDLED WITH
52
- 1.16.6
52
+ 2.0.2
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")'
17
+ ruby -e 'require "bump"; Bump::Bump.run("$(RELEASE_TYPE)")'
18
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
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # lightstep-tracer-ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/lightstep-tracer.svg)](https://badge.fury.io/rb/lightstep-tracer) [![Circle CI](https://circleci.com/gh/lightstep/lightstep-tracer-ruby.svg?style=shield)](https://circleci.com/gh/lightstep/lightstep-tracer-ruby) [![MIT license](http://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT) [![Code Climate](https://codeclimate.com/github/lightstep/lightstep-tracer-ruby/badges/gpa.svg)](https://codeclimate.com/github/lightstep/lightstep-tracer-ruby)
3
+ [![Gem Version](https://badge.fury.io/rb/lightstep.svg)](https://badge.fury.io/rb/lightstep) [![Circle CI](https://circleci.com/gh/lightstep/lightstep-tracer-ruby.svg?style=shield)](https://circleci.com/gh/lightstep/lightstep-tracer-ruby) [![MIT license](http://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT) [![Code Climate](https://codeclimate.com/github/lightstep/lightstep-tracer-ruby/badges/gpa.svg)](https://codeclimate.com/github/lightstep/lightstep-tracer-ruby)
4
4
 
5
5
  The LightStep distributed tracing library for Ruby.
6
6
 
@@ -15,6 +15,8 @@ module LightStep
15
15
 
16
16
  def_delegator :instance, :configure
17
17
  def_delegator :instance, :start_span
18
+ def_delegator :instance, :start_active_span
19
+ def_delegator :instance, :active_span
18
20
  def_delegator :instance, :disable
19
21
  def_delegator :instance, :enable
20
22
  def_delegator :instance, :flush
@@ -42,7 +42,7 @@ module LightStep
42
42
  )
43
43
 
44
44
  @tags = Concurrent::Hash.new
45
- @tags.update(tags) unless tags.nil?
45
+ @tags.update(tags.each { |k, v| tags[k] = v.to_s }) unless tags.nil?
46
46
  @log_records = Concurrent::Array.new
47
47
  @dropped_logs = Concurrent::AtomicFixnum.new
48
48
  @max_log_records = max_log_records
@@ -105,22 +105,35 @@ module LightStep
105
105
  context.baggage[key]
106
106
  end
107
107
 
108
+ # @deprecated Use {#log_kv} instead.
108
109
  # Add a log entry to this span
109
110
  # @param event [String] event name for the log
110
111
  # @param timestamp [Time] time of the log
111
- # @param fields [Hash] Additional information to log
112
+ # @param fields [Hash{Symbol=>Object}] Additional information to log
112
113
  def log(event: nil, timestamp: Time.now, **fields)
114
+ warn 'Span#log is deprecated. Please use Span#log_kv instead.'
113
115
  return unless tracer.enabled?
114
116
 
115
117
  fields = {} if fields.nil?
116
118
  unless event.nil?
117
119
  fields[:event] = event.to_s
118
120
  end
121
+
122
+ log_kv(timestamp: timestamp, **fields)
123
+ end
124
+
125
+ # Add a log entry to this span
126
+ # @param timestamp [Time] time of the log
127
+ # @param fields [Hash{Symbol=>Object}] Additional information to log
128
+ def log_kv(timestamp: Time.now, **fields)
129
+ return unless tracer.enabled?
130
+
131
+ fields = {} if fields.nil?
119
132
  record = {
120
133
  timestamp_micros: LightStep.micros(timestamp),
121
- fields: fields.to_a.map {|key, value|
122
- {Key: key.to_s, Value: value.to_s}
123
- },
134
+ fields: fields.to_a.map do |key, value|
135
+ { Key: key.to_s, Value: value.to_s }
136
+ end
124
137
  }
125
138
 
126
139
  log_records.push(record)
@@ -83,10 +83,12 @@ module LightStep
83
83
  # References#CHILD_OF reference to the ScopeManager#active.
84
84
  # @param finish_on_close [Boolean] whether span should automatically be
85
85
  # finished when Scope#close is called
86
- # @yield [Scope] If an optional block is passed to start_active it will
86
+ # @yield [Scope] If an optional block is passed to start_active_span it will
87
87
  # yield the newly-started Scope. If `finish_on_close` is true then the
88
88
  # Span will be finished automatically after the block is executed.
89
- # @return [Scope] The newly-started and activated Scope
89
+ # @return [Scope, Object] If passed an optional block, start_active_span
90
+ # returns the block's return value, otherwise it returns the newly-started
91
+ # and activated Scope
90
92
  def start_active_span(operation_name,
91
93
  child_of: nil,
92
94
  references: nil,
@@ -109,8 +111,9 @@ module LightStep
109
111
 
110
112
  scope_manager.activate(span: span, finish_on_close: finish_on_close).tap do |scope|
111
113
  if block_given?
112
- yield scope
113
- scope.close
114
+ return yield(scope).tap do
115
+ scope.close
116
+ end
114
117
  end
115
118
  end
116
119
  end
@@ -138,13 +141,19 @@ module LightStep
138
141
  # @param tags [Hash] Tags to assign to the Span at start time
139
142
  # @param ignore_active_scope [Boolean] whether to create an implicit
140
143
  # References#CHILD_OF reference to the ScopeManager#active.
141
- # @return [Span]
144
+ # @yield [Span] If passed an optional block, start_span will yield the
145
+ # newly-created span to the block. The span will be finished automatically
146
+ # after the block is executed.
147
+ # @return [Span, Object] If passed an optional block, start_span will return
148
+ # the block's return value, otherwise it returns the newly-started Span
149
+ # instance, which has not been automatically registered via the
150
+ # ScopeManager
142
151
  def start_span(operation_name, child_of: nil, references: nil, start_time: nil, tags: nil, ignore_active_scope: false)
143
152
  if child_of.nil? && references.nil? && !ignore_active_scope
144
153
  child_of = active_span
145
154
  end
146
155
 
147
- Span.new(
156
+ span_options = {
148
157
  tracer: self,
149
158
  operation_name: operation_name,
150
159
  child_of: child_of,
@@ -152,7 +161,15 @@ module LightStep
152
161
  start_micros: start_time.nil? ? LightStep.micros(Time.now) : LightStep.micros(start_time),
153
162
  tags: tags,
154
163
  max_log_records: max_log_records,
155
- )
164
+ }
165
+
166
+ Span.new(span_options).tap do |span|
167
+ if block_given?
168
+ return yield(span).tap do
169
+ span.finish
170
+ end
171
+ end
172
+ end
156
173
  end
157
174
 
158
175
  # Inject a SpanContext into the given carrier
@@ -311,7 +328,7 @@ module LightStep
311
328
  def extract_from_rack(env)
312
329
  extract_from_text_map(env.reduce({}){|memo, tuple|
313
330
  raw_header, value = tuple
314
- header = raw_header.gsub(/^HTTP_/, '').tr('_', '-').downcase
331
+ header = raw_header.to_s.gsub(/^HTTP_/, '').tr('_', '-').downcase
315
332
 
316
333
  memo[header] = value if header.start_with?(CARRIER_TRACER_STATE_PREFIX, CARRIER_BAGGAGE_PREFIX)
317
334
  memo
@@ -4,12 +4,7 @@ require 'lightstep/transport/base'
4
4
  module LightStep
5
5
  module Transport
6
6
  # HTTPJSON is a transport that sends reports via HTTP in JSON format.
7
- # It is thread-safe, however it is *not* fork-safe. When forking, all items
8
- # in the queue will be copied and sent in duplicate.
9
- #
10
- # When forking, you should first `disable` the tracer, then `enable` it from
11
- # within the fork (and in the parent post-fork). See
12
- # `examples/fork_children/main.rb` for an example.
7
+ # It is thread-safe.
13
8
  class HTTPJSON < Base
14
9
  LIGHTSTEP_HOST = 'collector.lightstep.com'.freeze
15
10
  LIGHTSTEP_PORT = 443
@@ -1,3 +1,3 @@
1
1
  module LightStep
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.15.0'.freeze
3
3
  end
@@ -6,7 +6,7 @@ require 'lightstep/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'lightstep'
8
8
  spec.version = LightStep::VERSION
9
- spec.authors = ['bcronin']
9
+ spec.authors = ['lightstep']
10
10
  spec.email = ['support@lightstep.com']
11
11
 
12
12
  spec.summary = 'LightStep OpenTracing Ruby bindings'
@@ -16,8 +16,12 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.require_paths = ['lib']
18
18
 
19
+ spec.metadata = {
20
+ "changelog_uri" => "https://github.com/lightstep/lightstep-tracer-ruby/blob/master/CHANGELOG.md",
21
+ }
22
+
19
23
  spec.add_dependency 'concurrent-ruby', '~> 1.0'
20
- spec.add_dependency 'opentracing', '~> 0.4.1'
24
+ spec.add_dependency 'opentracing', '~> 0.5.0'
21
25
  spec.add_development_dependency 'rake', '~> 11.3'
22
26
  spec.add_development_dependency 'rack', '~> 2.0'
23
27
  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.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
- - bcronin
7
+ - lightstep
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2019-09-04 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.4.1
33
+ version: 0.5.0
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.4.1
40
+ version: 0.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +133,7 @@ files:
133
133
  - ".gitignore"
134
134
  - ".rspec"
135
135
  - ".rubocop.yml"
136
+ - CHANGELOG.md
136
137
  - Gemfile
137
138
  - Gemfile.lock
138
139
  - LICENSE.txt
@@ -167,7 +168,8 @@ files:
167
168
  homepage: https://github.com/lightstep/lightstep-tracer-ruby
168
169
  licenses:
169
170
  - MIT
170
- metadata: {}
171
+ metadata:
172
+ changelog_uri: https://github.com/lightstep/lightstep-tracer-ruby/blob/master/CHANGELOG.md
171
173
  post_install_message:
172
174
  rdoc_options: []
173
175
  require_paths:
@@ -184,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
186
  version: '0'
185
187
  requirements: []
186
188
  rubyforge_project:
187
- rubygems_version: 2.7.6
189
+ rubygems_version: 2.5.2.3
188
190
  signing_key:
189
191
  specification_version: 4
190
192
  summary: LightStep OpenTracing Ruby bindings