lightstep 0.12.0 → 0.16.1

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.
@@ -2,9 +2,6 @@ module LightStep
2
2
  module Transport
3
3
  # Base Transport type
4
4
  class Base
5
- def initialize
6
- end
7
-
8
5
  def report(_report)
9
6
  nil
10
7
  end
@@ -4,53 +4,104 @@ 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
- LIGHTSTEP_HOST = "collector.lightstep.com"
9
+ LIGHTSTEP_HOST = 'collector.lightstep.com'.freeze
15
10
  LIGHTSTEP_PORT = 443
16
11
 
17
- ENCRYPTION_TLS = 'tls'
18
- ENCRYPTION_NONE = 'none'
12
+ ENCRYPTION_TLS = 'tls'.freeze
13
+ ENCRYPTION_NONE = 'none'.freeze
19
14
 
15
+ REPORTS_API_ENDPOINT = '/api/v0/reports'.freeze
16
+ HEADER_ACCESS_TOKEN = 'LightStep-Access-Token'.freeze
17
+
18
+ ##
20
19
  # Initialize the transport
21
- # @param host [String] host of the domain to the endpoind to push data
20
+ #
21
+ # @param host [String] host of the domain to the endpoint to push data
22
22
  # @param port [Numeric] port on which to connect
23
23
  # @param verbose [Numeric] verbosity level. Right now 0-3 are supported
24
24
  # @param encryption [ENCRYPTION_TLS, ENCRYPTION_NONE] kind of encryption to use
25
25
  # @param access_token [String] access token for LightStep server
26
- # @return [HTTPJSON]
27
- def initialize(host: LIGHTSTEP_HOST, port: LIGHTSTEP_PORT, verbose: 0, encryption: ENCRYPTION_TLS, access_token:)
26
+ # @param ssl_verify_peer [Boolean]
27
+ # @param open_timeout [Integer]
28
+ # @param read_timeout [Integer]
29
+ # @param continue_timeout [Integer]
30
+ # @param keep_alive_timeout [Integer]
31
+ # @param logger [Logger]
32
+ #
33
+ def initialize(
34
+ host: LIGHTSTEP_HOST,
35
+ port: LIGHTSTEP_PORT,
36
+ verbose: 0,
37
+ encryption: ENCRYPTION_TLS,
38
+ access_token:,
39
+ ssl_verify_peer: true,
40
+ open_timeout: 20,
41
+ read_timeout: 20,
42
+ continue_timeout: nil,
43
+ keep_alive_timeout: 2,
44
+ logger: nil
45
+ )
28
46
  @host = host
29
47
  @port = port
30
48
  @verbose = verbose
31
49
  @encryption = encryption
50
+ @ssl_verify_peer = ssl_verify_peer
51
+ @open_timeout = open_timeout.to_i
52
+ @read_timeout = read_timeout.to_i
53
+ @continue_timeout = continue_timeout
54
+ @keep_alive_timeout = keep_alive_timeout.to_i
32
55
 
33
- raise Tracer::ConfigurationError, "access_token must be a string" unless String === access_token
34
- raise Tracer::ConfigurationError, "access_token cannot be blank" if access_token.empty?
56
+ raise Tracer::ConfigurationError, 'access_token must be a string' unless access_token.is_a?(String)
57
+ raise Tracer::ConfigurationError, 'access_token cannot be blank' if access_token.empty?
35
58
  @access_token = access_token
59
+ @logger = logger || LightStep.logger
36
60
  end
37
61
 
62
+ ##
38
63
  # Queue a report for sending
64
+ #
39
65
  def report(report)
40
- p report if @verbose >= 3
66
+ @logger.info report if @verbose >= 3
67
+
68
+ req = build_request(report)
69
+ res = connection.request(req)
70
+
71
+ @logger.info res.to_s if @verbose >= 3
72
+
73
+ nil
74
+ end
75
+
76
+ private
41
77
 
42
- https = Net::HTTP.new(@host, @port)
43
- https.use_ssl = @encryption == ENCRYPTION_TLS
44
- req = Net::HTTP::Post.new('/api/v0/reports')
45
- req['LightStep-Access-Token'] = @access_token
78
+ ##
79
+ # @param [Hash] report
80
+ # @return [Net::HTTP::Post]
81
+ #
82
+ def build_request(report)
83
+ req = Net::HTTP::Post.new(REPORTS_API_ENDPOINT)
84
+ req[HEADER_ACCESS_TOKEN] = @access_token
46
85
  req['Content-Type'] = 'application/json'
47
86
  req['Connection'] = 'keep-alive'
48
87
  req.body = report.to_json
49
- res = https.request(req)
50
-
51
- puts res.to_s if @verbose >= 3
88
+ req
89
+ end
52
90
 
53
- nil
91
+ ##
92
+ # @return [Net::HTTP]
93
+ #
94
+ def connection
95
+ unless @connection
96
+ @connection = ::Net::HTTP.new(@host, @port)
97
+ @connection.use_ssl = @encryption == ENCRYPTION_TLS
98
+ @connection.verify_mode = ::OpenSSL::SSL::VERIFY_NONE unless @ssl_verify_peer
99
+ @connection.open_timeout = @open_timeout
100
+ @connection.read_timeout = @read_timeout
101
+ @connection.continue_timeout = @continue_timeout
102
+ @connection.keep_alive_timeout = @keep_alive_timeout
103
+ end
104
+ @connection
54
105
  end
55
106
  end
56
107
  end
@@ -1,3 +1,3 @@
1
1
  module LightStep
2
- VERSION = '0.12.0'.freeze
2
+ VERSION = '0.16.1'.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,12 +16,16 @@ 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.3'
21
- spec.add_development_dependency 'rake', '~> 11.3'
24
+ spec.add_dependency 'opentracing', '~> 0.5.0'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
22
26
  spec.add_development_dependency 'rack', '~> 2.0'
23
27
  spec.add_development_dependency 'rspec', '~> 3.0'
24
28
  spec.add_development_dependency 'bump', '~> 0.5'
25
- spec.add_development_dependency 'simplecov', '~> 0.12.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.16'
26
30
  spec.add_development_dependency 'timecop', '~> 0.8.0'
27
31
  end
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.12.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
- - bcronin
8
- autorequire:
7
+ - lightstep
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-30 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
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.3'
40
+ version: 0.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '11.3'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '11.3'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.12.0
103
+ version: '0.16'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.12.0
110
+ version: '0.16'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: timecop
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,16 +122,21 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.8.0
125
- description:
125
+ description:
126
126
  email:
127
127
  - support@lightstep.com
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".circleci/config.yml"
132
133
  - ".gitignore"
133
134
  - ".rspec"
135
+ - ".rubocop.yml"
136
+ - CHANGELOG.md
137
+ - CONTRIBUTING.md
134
138
  - Gemfile
139
+ - Gemfile.lock
135
140
  - LICENSE.txt
136
141
  - Makefile
137
142
  - README.md
@@ -141,14 +146,18 @@ files:
141
146
  - benchmark/threading/thread_test.rb
142
147
  - bin/console
143
148
  - bin/setup
144
- - circle.yml
145
149
  - example.rb
146
150
  - examples/fork_children/main.rb
147
151
  - examples/rack/hello.rb
148
152
  - examples/rack/inject_extract.rb
149
153
  - lib/lightstep.rb
150
154
  - lib/lightstep/global_tracer.rb
155
+ - lib/lightstep/propagation.rb
156
+ - lib/lightstep/propagation/b3_propagator.rb
157
+ - lib/lightstep/propagation/lightstep_propagator.rb
151
158
  - lib/lightstep/reporter.rb
159
+ - lib/lightstep/scope.rb
160
+ - lib/lightstep/scope_manager.rb
152
161
  - lib/lightstep/span.rb
153
162
  - lib/lightstep/span_context.rb
154
163
  - lib/lightstep/tracer.rb
@@ -162,8 +171,9 @@ files:
162
171
  homepage: https://github.com/lightstep/lightstep-tracer-ruby
163
172
  licenses:
164
173
  - MIT
165
- metadata: {}
166
- post_install_message:
174
+ metadata:
175
+ changelog_uri: https://github.com/lightstep/lightstep-tracer-ruby/blob/master/CHANGELOG.md
176
+ post_install_message:
167
177
  rdoc_options: []
168
178
  require_paths:
169
179
  - lib
@@ -178,9 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
188
  - !ruby/object:Gem::Version
179
189
  version: '0'
180
190
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.7.6
183
- signing_key:
191
+ rubygems_version: 3.0.3
192
+ signing_key:
184
193
  specification_version: 4
185
194
  summary: LightStep OpenTracing Ruby bindings
186
195
  test_files: []
data/circle.yml DELETED
@@ -1,3 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.2.3