bc-lightstep-ruby 2.4.0 → 2.6.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 +14 -0
- data/README.md +40 -1
- data/bc-lightstep-ruby.gemspec +4 -6
- data/lib/bigcommerce/lightstep/active_record/adapter.rb +13 -4
- data/lib/bigcommerce/lightstep/traceable.rb +12 -3
- data/lib/bigcommerce/lightstep/version.rb +1 -1
- metadata +22 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5690f617aac90d828163b980e6315bcf21a5f4c2e81d46c660e275f8e51df20
|
4
|
+
data.tar.gz: a89ce02ec2b20b0d716e63f5ac3c3251a7c437063e91a8a4ab729c512108375d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4beeba6a2d87513ac111a48319988f8a8c46542eb326b1ad179fa87802eb8d9a90ee1694e1ff676a33490ce7e9a4a962bbd6e5066589d8eaf98c7ae03cd256e1
|
7
|
+
data.tar.gz: 8695c5d8d79085eba12d1e1796990ac88f755826369cdce32283205f01580515f06a0ab164b629eb27646039a0794d987be60cee76c4f08361b485a1e9f2089d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@ Changelog for the bc-lightstep-ruby gem.
|
|
2
2
|
|
3
3
|
### Pending Release
|
4
4
|
|
5
|
+
### 2.6.0
|
6
|
+
|
7
|
+
* Add support for Rails/ActiveRecord 7
|
8
|
+
* Add test coverage for Ruby 3.2
|
9
|
+
|
10
|
+
### 2.5.x
|
11
|
+
|
12
|
+
* Drop support for Ruby 2
|
13
|
+
* Remove unused NullLogger dev dependency
|
14
|
+
|
15
|
+
### 2.4.1
|
16
|
+
|
17
|
+
* Support positional argument methods when using the `Traceable` trace method
|
18
|
+
|
5
19
|
### 2.4.0
|
6
20
|
|
7
21
|
* Add `::Bigcommerce::Lightstep::Traceable` module for tracing individual methods
|
data/README.md
CHANGED
@@ -114,7 +114,7 @@ class MyService
|
|
114
114
|
include ::Bigcommerce::Lightstep::Traceable
|
115
115
|
|
116
116
|
trace :call, 'operation.do-my-thing' do |span:, product:, options:|
|
117
|
-
span.set_tag('
|
117
|
+
span.set_tag('product_id', product.id)
|
118
118
|
end
|
119
119
|
# or, with no block:
|
120
120
|
trace :call, 'operation.do-my-thing'
|
@@ -125,6 +125,45 @@ class MyService
|
|
125
125
|
end
|
126
126
|
```
|
127
127
|
|
128
|
+
#### Tracing Positional Argument Methods
|
129
|
+
|
130
|
+
For positional argument methods, the behavior is a bit different. In your trace call, if tracing a method with
|
131
|
+
positional arguments, you'll need to have the block arguments be positional as well:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
class MyService
|
135
|
+
include ::Bigcommerce::Lightstep::Traceable
|
136
|
+
|
137
|
+
trace :positional, 'operation.do-my-thing' do |span, product, options|
|
138
|
+
span.set_tag('product_id', product.id)
|
139
|
+
end
|
140
|
+
def positional(product, options = {})
|
141
|
+
# ...
|
142
|
+
end
|
143
|
+
end
|
144
|
+
```
|
145
|
+
|
146
|
+
Note that any default values in the argument will not carry over into the trace block. Secondly, with positional
|
147
|
+
argument methods that have only a _single_ hash argument, since this library has no way to detect in that case if it
|
148
|
+
is keyword-arguments or a single hash argument, the library will simply add the `span` to the hash itself, and you'll
|
149
|
+
need to adjust the trace block accordingly:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
|
153
|
+
class MyService
|
154
|
+
include ::Bigcommerce::Lightstep::Traceable
|
155
|
+
|
156
|
+
trace :positional_single_hash_arg, 'operation.do-my-thing' do |my_hash|
|
157
|
+
my_hash[:span].set_tag('product_id', my_hash[:product_id])
|
158
|
+
end
|
159
|
+
def positional_single_hash_arg(my_hash)
|
160
|
+
# ...
|
161
|
+
end
|
162
|
+
end
|
163
|
+
```
|
164
|
+
|
165
|
+
It is recommended for this reason - and others - to never use single-hash positional arguments in Ruby.
|
166
|
+
|
128
167
|
## RSpec
|
129
168
|
|
130
169
|
This library comes with a built-in matcher for testing span blocks. In your rspec config:
|
data/bc-lightstep-ruby.gemspec
CHANGED
@@ -31,22 +31,20 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.files = Dir['README.md', 'CHANGELOG.md', 'CODE_OF_CONDUCT.md', 'lib/**/*', 'bc-lightstep-ruby.gemspec']
|
33
33
|
spec.require_paths = ['lib']
|
34
|
-
spec.required_ruby_version = '>=
|
34
|
+
spec.required_ruby_version = '>= 3.0'
|
35
35
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'activerecord', '> 4'
|
38
38
|
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
39
39
|
spec.add_development_dependency 'rake', '>= 12.0'
|
40
|
-
spec.add_development_dependency '
|
40
|
+
spec.add_development_dependency 'redis', '~> 4'
|
41
|
+
spec.add_development_dependency 'rspec', '>= 3.8'
|
41
42
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
|
42
|
-
spec.add_development_dependency 'rubocop', '
|
43
|
+
spec.add_development_dependency 'rubocop', '>= 1.0'
|
43
44
|
spec.add_development_dependency 'rubocop-performance', '>= 1.5'
|
44
45
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
45
46
|
spec.add_development_dependency 'pry', '>= 0.12'
|
46
47
|
|
47
|
-
spec.add_development_dependency 'null-logger', '~> 0.1'
|
48
|
-
spec.add_development_dependency 'redis', '~> 4'
|
49
|
-
|
50
48
|
spec.add_runtime_dependency 'activesupport', '>= 4'
|
51
49
|
spec.add_runtime_dependency 'lightstep', '~> 0.17.0'
|
52
50
|
spec.add_runtime_dependency 'faraday', ['>= 0.8', '< 2']
|
@@ -36,12 +36,21 @@ module Bigcommerce
|
|
36
36
|
end
|
37
37
|
|
38
38
|
##
|
39
|
-
# Note: we only support patching mysql2 gem at this point
|
39
|
+
# Note: we only support patching mysql2 gem at this point.
|
40
40
|
#
|
41
41
|
# @return [Boolean]
|
42
42
|
#
|
43
43
|
def self.enabled?
|
44
|
-
defined?(::ActiveRecord) && ::Bigcommerce::Lightstep.active_record
|
44
|
+
return false unless defined?(::ActiveRecord) && ::Bigcommerce::Lightstep.active_record
|
45
|
+
|
46
|
+
adapter_name = if ::ActiveRecord::Base.respond_to?(:connection_config) # rails 6
|
47
|
+
::ActiveRecord::Base.connection_config[:adapter].to_s
|
48
|
+
elsif ::ActiveRecord::Base.respond_to?(:connection_db_config) # rails 7
|
49
|
+
::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter].to_s
|
50
|
+
else
|
51
|
+
'unknown'
|
52
|
+
end
|
53
|
+
adapter_name.casecmp('mysql2')&.zero? == true
|
45
54
|
rescue StandardError => e
|
46
55
|
::Bigcommerce::Lightstep.logger&.warn "Failed to determine ActiveRecord database adapter in bc-lightstep-ruby initializer: #{e.message}"
|
47
56
|
false
|
@@ -51,9 +60,9 @@ module Bigcommerce
|
|
51
60
|
# @param [String] sql The raw sql query
|
52
61
|
# @param [String] name The type of sql query
|
53
62
|
#
|
54
|
-
def execute_with_inst(sql, name = 'SQL')
|
63
|
+
def execute_with_inst(sql, name = 'SQL', async: false)
|
55
64
|
# bail out early if not enabled. This should not get here, but is provided as a failsafe.
|
56
|
-
return execute_without_inst(sql, name) unless ::Bigcommerce::Lightstep.active_record
|
65
|
+
return execute_without_inst(sql, name, async: async) unless ::Bigcommerce::Lightstep.active_record
|
57
66
|
|
58
67
|
sanitized_sql = lightstep_sanitize_sql(sql)
|
59
68
|
name = 'QUERY' if name.to_s.strip.empty?
|
@@ -41,13 +41,22 @@ module Bigcommerce
|
|
41
41
|
def trace(method_name, operation_name, tags: nil, &span_block)
|
42
42
|
method_name = method_name.to_sym
|
43
43
|
mod = Module.new
|
44
|
-
mod.define_method(method_name) do
|
44
|
+
mod.define_method(method_name) do |*args, &block|
|
45
45
|
tracer = ::Bigcommerce::Lightstep::Tracer.instance
|
46
46
|
tracer.start_span(operation_name) do |span|
|
47
47
|
tags&.each { |k, v| span.set_tag(k.to_s, v) }
|
48
|
-
span_block&.send(:call, **args.merge(span: span))
|
49
48
|
begin
|
50
|
-
|
49
|
+
arg1 = args.first
|
50
|
+
# method has keyword argument signature (or single-hash positional argument)
|
51
|
+
if arg1.is_a?(Hash) && args.count == 1
|
52
|
+
# add span as a kwarg
|
53
|
+
span_block&.send(:call, **arg1.merge(span: span))
|
54
|
+
super(**arg1, &block)
|
55
|
+
else
|
56
|
+
# method has positional argument signature, so just add span to front
|
57
|
+
span_block&.send(:call, *([span] + args))
|
58
|
+
super(*args, &block)
|
59
|
+
end
|
51
60
|
rescue StandardError => e
|
52
61
|
span.set_tag('error', true)
|
53
62
|
span.set_tag('error.message', e.message)
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -53,17 +53,31 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '12.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: redis
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '3.8'
|
69
83
|
- !ruby/object:Gem::Dependency
|
@@ -84,14 +98,14 @@ dependencies:
|
|
84
98
|
name: rubocop
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '1.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '1.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
@@ -136,34 +150,6 @@ dependencies:
|
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0.12'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: null-logger
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0.1'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0.1'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: redis
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '4'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '4'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: activesupport
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -269,14 +255,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
255
|
requirements:
|
270
256
|
- - ">="
|
271
257
|
- !ruby/object:Gem::Version
|
272
|
-
version: '
|
258
|
+
version: '3.0'
|
273
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
260
|
requirements:
|
275
261
|
- - ">="
|
276
262
|
- !ruby/object:Gem::Version
|
277
263
|
version: '0'
|
278
264
|
requirements: []
|
279
|
-
rubygems_version: 3.
|
265
|
+
rubygems_version: 3.4.1
|
280
266
|
signing_key:
|
281
267
|
specification_version: 4
|
282
268
|
summary: Gem for lightstep distributed tracing
|