bc-lightstep-ruby 2.1.0 → 2.3.0
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 +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +1 -1
- data/bc-lightstep-ruby.gemspec +4 -5
- data/lib/bigcommerce/lightstep.rb +6 -0
- data/lib/bigcommerce/lightstep/active_record/tracer.rb +2 -2
- data/lib/bigcommerce/lightstep/configuration.rb +1 -1
- data/lib/bigcommerce/lightstep/errors.rb +1 -0
- data/lib/bigcommerce/lightstep/interceptors/env.rb +2 -1
- data/lib/bigcommerce/lightstep/middleware/faraday.rb +1 -1
- data/lib/bigcommerce/lightstep/redis/tracer.rb +1 -1
- data/lib/bigcommerce/lightstep/tracer.rb +18 -2
- data/lib/bigcommerce/lightstep/transport.rb +37 -18
- data/lib/bigcommerce/lightstep/version.rb +1 -1
- metadata +12 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08b3dfd38b99345cdd590559e482f4d4d311a64a4538f613ae747ef8b2f19163'
|
4
|
+
data.tar.gz: 6e6d9d623759b64a507b25e99836b73219ed77ac3fa3fe296d76bda44b5d4f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bfde25f2c8fd028f94b81bb0c96913da02db77d8b59fa2c14b550dcafebc2df83242d3f50983d4b532500c0736a952c5bd504f923aaee4f20a64c2659127b00
|
7
|
+
data.tar.gz: a8a27fb95a8f18c1f9f88bc2aaa6e548b2338d8825ce6fbc0a24515ebe37e91d153046c78ab49f8fdd4976e8152f9ecee5d877291f6b72aabb889b3b62833d0b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,25 @@ Changelog for the bc-lightstep-ruby gem.
|
|
2
2
|
|
3
3
|
### Pending Release
|
4
4
|
|
5
|
+
### 2.3.0
|
6
|
+
|
7
|
+
- Add support for Ruby 3
|
8
|
+
|
9
|
+
### 2.2.2
|
10
|
+
|
11
|
+
- Fix issue where parent span determination can be nil if lightstep is not initialized
|
12
|
+
- Add tests for Ruby 2.7
|
13
|
+
|
14
|
+
### 2.2.1
|
15
|
+
|
16
|
+
- Only set error tag in exceptions if not already set
|
17
|
+
- Update to Rubocop 1.0
|
18
|
+
|
19
|
+
### 2.1.1
|
20
|
+
|
21
|
+
- Bump lightstep gem to 0.16.0
|
22
|
+
- Bump faraday gem to <= 0.17.3
|
23
|
+
|
5
24
|
### 2.1.0
|
6
25
|
|
7
26
|
- Add support for automatically-generated mysql spans in tracing
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# bc-lightstep-ruby - LightStep distributed tracing
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/bigcommerce/bc-lightstep-ruby/tree/main) [](https://badge.fury.io/rb/bc-lightstep-ruby) [](http://inch-ci.org/github/bigcommerce/bc-lightstep-ruby)
|
4
4
|
|
5
5
|
Adds [LightStep](https://lightstep.com) tracing support for Ruby. This is an extension of the
|
6
6
|
[LightStep ruby gem](https://github.com/lightstep/lightstep-tracer-ruby) and adds extra functionality and resiliency.
|
data/bc-lightstep-ruby.gemspec
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
16
|
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
17
|
#
|
18
|
-
$:.push File.expand_path('
|
18
|
+
$:.push File.expand_path('lib', __dir__)
|
19
19
|
require 'bigcommerce/lightstep/version'
|
20
20
|
|
21
21
|
Gem::Specification.new do |spec|
|
@@ -34,12 +34,11 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.required_ruby_version = '>= 2.6'
|
35
35
|
|
36
36
|
spec.add_development_dependency 'activerecord', '> 4'
|
37
|
-
spec.add_development_dependency 'bundler', '~> 1.11'
|
38
37
|
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
39
38
|
spec.add_development_dependency 'rake', '>= 12.0'
|
40
39
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
41
40
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
|
42
|
-
spec.add_development_dependency 'rubocop', '~> 0
|
41
|
+
spec.add_development_dependency 'rubocop', '~> 1.0'
|
43
42
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
44
43
|
spec.add_development_dependency 'pry', '>= 0.12'
|
45
44
|
|
@@ -47,6 +46,6 @@ Gem::Specification.new do |spec|
|
|
47
46
|
spec.add_development_dependency 'redis', '~> 4'
|
48
47
|
|
49
48
|
spec.add_runtime_dependency 'activesupport', '>= 4'
|
50
|
-
spec.add_runtime_dependency 'lightstep', '~> 0.
|
51
|
-
spec.add_runtime_dependency 'faraday', ['>= 0.8', '<= 0.
|
49
|
+
spec.add_runtime_dependency 'lightstep', '~> 0.17.0'
|
50
|
+
spec.add_runtime_dependency 'faraday', ['>= 0.8', '<= 0.17.3']
|
52
51
|
end
|
@@ -42,6 +42,12 @@ module Bigcommerce
|
|
42
42
|
module Lightstep
|
43
43
|
extend Configuration
|
44
44
|
|
45
|
+
##
|
46
|
+
# Start the global tracer and configure LightStep
|
47
|
+
#
|
48
|
+
# @param [String] component_name
|
49
|
+
# @param [::Bigcommerce::Lightstep::TransportFactory] transport_factory
|
50
|
+
#
|
45
51
|
def self.start(component_name: nil, transport_factory: nil)
|
46
52
|
component_name ||= ::Bigcommerce::Lightstep.component_name
|
47
53
|
transport_factory ||= ::Bigcommerce::Lightstep::TransportFactory.new
|
@@ -32,7 +32,7 @@ module Bigcommerce
|
|
32
32
|
@tracer = tracer || ::Bigcommerce::Lightstep::Tracer.instance
|
33
33
|
@span_prefix = span_prefix || ::Bigcommerce::Lightstep.active_record_span_prefix
|
34
34
|
@span_name = span_name || 'mysql'
|
35
|
-
@allow_root_spans =
|
35
|
+
@allow_root_spans = allow_root_spans.nil? ? ::Bigcommerce::Lightstep.active_record_allow_root_spans : allow_root_spans
|
36
36
|
end
|
37
37
|
|
38
38
|
##
|
@@ -68,7 +68,7 @@ module Bigcommerce
|
|
68
68
|
# @return [String]
|
69
69
|
#
|
70
70
|
def key
|
71
|
-
|
71
|
+
@span_prefix.to_s.empty? ? 'mysql' : "#{@span_prefix}.mysql"
|
72
72
|
end
|
73
73
|
|
74
74
|
##
|
@@ -34,7 +34,7 @@ module Bigcommerce
|
|
34
34
|
}.freeze
|
35
35
|
|
36
36
|
PRESET_HOSTNAME = {
|
37
|
-
|
37
|
+
hostname: 'HOSTNAME'
|
38
38
|
}.freeze
|
39
39
|
|
40
40
|
##
|
@@ -43,6 +43,7 @@ module Bigcommerce
|
|
43
43
|
# @param [Array<Symbol>] presets Specify presets that automatically setup keys
|
44
44
|
#
|
45
45
|
def initialize(keys: nil, env: nil, presets: [])
|
46
|
+
super()
|
46
47
|
@keys = keys || {}
|
47
48
|
@presets = presets || []
|
48
49
|
@env = env || ENV
|
@@ -66,7 +66,7 @@ module Bigcommerce
|
|
66
66
|
result = yield inner_span
|
67
67
|
end
|
68
68
|
rescue StandardError
|
69
|
-
span.set_tag('error', true)
|
69
|
+
span.set_tag('error', true) unless span.tags.key?('error')
|
70
70
|
raise
|
71
71
|
ensure
|
72
72
|
# finish this span if the reporter is initialized
|
@@ -128,7 +128,7 @@ module Bigcommerce
|
|
128
128
|
def determine_parent(context:)
|
129
129
|
# first attempt to find parent from args, if not, use carrier (headers) to lookup parent
|
130
130
|
# 1 = FORMAT_TEXT_MAP (this constant is removed in future lightstep versions)
|
131
|
-
current_parent =
|
131
|
+
current_parent = extract_parent_from_context(context)
|
132
132
|
# if no passed in parent, use the active thread parent
|
133
133
|
current_parent = active_span if current_parent.nil?
|
134
134
|
current_parent
|
@@ -155,6 +155,22 @@ module Bigcommerce
|
|
155
155
|
def mark_root_span(span)
|
156
156
|
span.instance_variable_set(:@root_span, true)
|
157
157
|
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# @param [Hash|::LightStep::SpanContext] context
|
161
|
+
# @return [::LightStep::SpanContext]
|
162
|
+
# @return [NilClass]
|
163
|
+
#
|
164
|
+
def extract_parent_from_context(context)
|
165
|
+
return context if context.is_a?(::LightStep::SpanContext)
|
166
|
+
|
167
|
+
tracer.extract(1, context || {})
|
168
|
+
rescue StandardError => _e
|
169
|
+
# sometimes LightStep, when `start` is not run first, will error here. This protects this until the upstream
|
170
|
+
# library can be fixed. We essentially just want to silently no-op here, as this failing simply means there's
|
171
|
+
# no context to extract.
|
172
|
+
nil
|
173
|
+
end
|
158
174
|
end
|
159
175
|
end
|
160
176
|
end
|
@@ -34,6 +34,22 @@ module Bigcommerce
|
|
34
34
|
LIGHTSTEP_PORT = 443
|
35
35
|
REPORTS_API_ENDPOINT = '/api/v0/reports'
|
36
36
|
|
37
|
+
DEFAULT_OPEN_TIMEOUT = 20
|
38
|
+
DEFAULT_READ_TIMEOUT = 20
|
39
|
+
DEFAULT_KEEPALIVE_TIMEOUT = 2
|
40
|
+
DEFAULT_SSL_PORT = 443
|
41
|
+
|
42
|
+
##
|
43
|
+
# Verbosity levels for the transport
|
44
|
+
#
|
45
|
+
class Verbosity
|
46
|
+
FATAL = 0
|
47
|
+
ERROR = 1
|
48
|
+
WARN = 2
|
49
|
+
INFO = 3
|
50
|
+
DEBUG = 4
|
51
|
+
end
|
52
|
+
|
37
53
|
# Initialize the transport
|
38
54
|
# @param host [String] host of the domain to the endpoind to push data
|
39
55
|
# @param port [Numeric] port on which to connect
|
@@ -44,31 +60,34 @@ module Bigcommerce
|
|
44
60
|
# @return [Transport]
|
45
61
|
def initialize(
|
46
62
|
access_token:,
|
47
|
-
host:
|
48
|
-
port:
|
49
|
-
verbose:
|
50
|
-
encryption:
|
63
|
+
host: nil,
|
64
|
+
port: nil,
|
65
|
+
verbose: nil,
|
66
|
+
encryption: nil,
|
51
67
|
ssl_verify_peer: true,
|
52
|
-
|
53
|
-
|
68
|
+
ssl_port: nil,
|
69
|
+
open_timeout: nil,
|
70
|
+
read_timeout: nil,
|
54
71
|
continue_timeout: nil,
|
55
|
-
keep_alive_timeout:
|
72
|
+
keep_alive_timeout: nil,
|
56
73
|
logger: nil
|
57
74
|
)
|
58
|
-
@host = host
|
59
|
-
@port = port
|
60
|
-
@verbose = verbose
|
61
|
-
@encryption = encryption
|
75
|
+
@host = host || LIGHTSTEP_HOST
|
76
|
+
@port = port || LIGHTSTEP_PORT
|
77
|
+
@verbose = verbose || Verbosity::FATAL
|
78
|
+
@encryption = encryption || ENCRYPTION_TLS
|
62
79
|
@ssl_verify_peer = ssl_verify_peer
|
63
|
-
@
|
64
|
-
@
|
80
|
+
@ssl_port = (ssl_port || DEFAULT_SSL_PORT).to_i
|
81
|
+
@open_timeout = (open_timeout || DEFAULT_OPEN_TIMEOUT).to_i
|
82
|
+
@read_timeout = (read_timeout || DEFAULT_READ_TIMEOUT).to_i
|
65
83
|
@continue_timeout = continue_timeout
|
66
|
-
@keep_alive_timeout = keep_alive_timeout.to_i
|
84
|
+
@keep_alive_timeout = (keep_alive_timeout || DEFAULT_KEEPALIVE_TIMEOUT).to_i
|
67
85
|
@access_token = access_token.to_s
|
68
86
|
|
69
|
-
default_logger = ::Logger.new(
|
87
|
+
default_logger = ::Logger.new($stdout)
|
70
88
|
default_logger.level = ::Logger::INFO
|
71
89
|
@logger = logger || default_logger
|
90
|
+
super()
|
72
91
|
end
|
73
92
|
|
74
93
|
##
|
@@ -78,12 +97,12 @@ module Bigcommerce
|
|
78
97
|
# @return [NilClass]
|
79
98
|
#
|
80
99
|
def report(report)
|
81
|
-
@logger.info report if @verbose >=
|
100
|
+
@logger.info report if @verbose >= Verbosity::INFO
|
82
101
|
|
83
102
|
req = build_request(report)
|
84
103
|
res = connection.request(req)
|
85
104
|
|
86
|
-
@logger.info res.to_s if @verbose >=
|
105
|
+
@logger.info res.to_s if @verbose >= Verbosity::INFO
|
87
106
|
|
88
107
|
nil
|
89
108
|
end
|
@@ -109,7 +128,7 @@ module Bigcommerce
|
|
109
128
|
def connection
|
110
129
|
unless @connection
|
111
130
|
@connection = ::Net::HTTP.new(@host, @port)
|
112
|
-
if @port ==
|
131
|
+
if @port == @ssl_port
|
113
132
|
@connection.use_ssl = @encryption == ENCRYPTION_TLS
|
114
133
|
@connection.verify_mode = ::OpenSSL::SSL::VERIFY_NONE unless @ssl_verify_peer
|
115
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bc-lightstep-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.11'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.11'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler-audit
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +86,14 @@ dependencies:
|
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
89
|
+
version: '1.0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
96
|
+
version: '1.0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: simplecov
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +170,14 @@ dependencies:
|
|
184
170
|
requirements:
|
185
171
|
- - "~>"
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
173
|
+
version: 0.17.0
|
188
174
|
type: :runtime
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
178
|
- - "~>"
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
180
|
+
version: 0.17.0
|
195
181
|
- !ruby/object:Gem::Dependency
|
196
182
|
name: faraday
|
197
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,7 +187,7 @@ dependencies:
|
|
201
187
|
version: '0.8'
|
202
188
|
- - "<="
|
203
189
|
- !ruby/object:Gem::Version
|
204
|
-
version: 0.
|
190
|
+
version: 0.17.3
|
205
191
|
type: :runtime
|
206
192
|
prerelease: false
|
207
193
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -211,7 +197,7 @@ dependencies:
|
|
211
197
|
version: '0.8'
|
212
198
|
- - "<="
|
213
199
|
- !ruby/object:Gem::Version
|
214
|
-
version: 0.
|
200
|
+
version: 0.17.3
|
215
201
|
description: Gem for lightstep distributed tracing
|
216
202
|
email:
|
217
203
|
- shaun.mccormick@bigcommerce.com
|
@@ -245,7 +231,7 @@ homepage: https://github.com/bigcommerce/bc-lightstep-ruby
|
|
245
231
|
licenses:
|
246
232
|
- MIT
|
247
233
|
metadata: {}
|
248
|
-
post_install_message:
|
234
|
+
post_install_message:
|
249
235
|
rdoc_options: []
|
250
236
|
require_paths:
|
251
237
|
- lib
|
@@ -260,8 +246,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
246
|
- !ruby/object:Gem::Version
|
261
247
|
version: '0'
|
262
248
|
requirements: []
|
263
|
-
rubygems_version: 3.0.
|
264
|
-
signing_key:
|
249
|
+
rubygems_version: 3.0.9
|
250
|
+
signing_key:
|
265
251
|
specification_version: 4
|
266
252
|
summary: Gem for lightstep distributed tracing
|
267
253
|
test_files: []
|