skylight 5.0.0 → 5.0.1

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
2
  SHA256:
3
- metadata.gz: 66c646baeaeddece5a75140908f8c7d1aec447945903ff5681c1e4de58839e79
4
- data.tar.gz: a3fe10a6b05963038f40f4b82d77cd545c42fa546d63cd440a21eb3839280b71
3
+ metadata.gz: 76c9ece1445d480897ecc306024fe939dacb94c14a02e68f7e33f5d722955284
4
+ data.tar.gz: 839b19ed8b3846003b3a54e5d0f3e327b0f969f2672b267dcaf4d1aa27df6254
5
5
  SHA512:
6
- metadata.gz: ca6b42cfa51a39f1cccfc8f169a9bdc1560ec9774423c1ca335ec6fc26bd70d47f40c62d9e645ea626b00626e962a9ef3dbda49c693de0a56fef10bc04ab1d76
7
- data.tar.gz: ccb18fe7cc713c03544db2a0d1dc5c42d86fe5ee14c0db11e208884203b7141cd39032bdb75f5c7eaf341b1ded6e9c761e8529e1bf50d1c499b1bab85a545fcd
6
+ metadata.gz: 2cbbcfd4a159b6abfa976f9d8ad4a87317973955d058408b681b1564d6d54bacadcb0e60c4bbac9ea03383dfed6d9355ac953a0b636c50a60ff99e52bcb3c5a2
7
+ data.tar.gz: b338f0d0a22d0b904600d050f217758d3b07c28e66c88c6f5eb961cd8701750b58a7175e3e9e31dad604c6c58c2d1b22197517c239192f41b9579c5c08a9ca5b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.0.1 (March 11, 2021)
2
+ * [IMPROVEMENT] Use argument-forwarding (...) where available in custom instrumentation
3
+
1
4
  ## 5.0.0 (March 5, 2021)
2
5
 
3
6
  * [FEATURE] Add normalizer for Shrine events (thanks @janko!)
@@ -130,7 +130,7 @@ module Skylight
130
130
 
131
131
  private
132
132
 
133
- HAS_KW_ARGUMENT_FORWARDING = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
133
+ HAS_ARGUMENT_FORWARDING = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
134
134
 
135
135
  def __sk_instrument_method_on(klass, name, title, **opts)
136
136
  category = (opts[:category] || "app.method").to_s
@@ -145,13 +145,31 @@ module Skylight
145
145
  # source_file and source_line to be removed from the trace span before it is submitted.
146
146
  source_file, source_line = klass.instance_method(name).source_location
147
147
 
148
+ # We should strongly prefer using the new argument-forwarding syntax (...) where available.
149
+ # In Ruby 2.7, the following are known to be syntax errors:
150
+ #
151
+ # - mixing positional arguments with argument forwarding (e.g., send(:method_name, ...))
152
+ # - calling a setter method with multiple arguments, unless dispatched via send or public_send.
153
+ #
154
+ # So it is possible, though not recommended, to define setter methods that take multiple arguments,
155
+ # keywords, and/or blocks. Unfortunately, this means that for setters, we still need to explicitly
156
+ # forward the different argument types.
157
+ is_setter_method = name.to_s.end_with?("=")
158
+
148
159
  arg_string =
149
- if HAS_KW_ARGUMENT_FORWARDING
150
- "*args, **kwargs, &blk"
160
+ if HAS_ARGUMENT_FORWARDING
161
+ is_setter_method ? "*args, **kwargs, &blk" : "..."
151
162
  else
152
163
  "*args, &blk"
153
164
  end
154
165
 
166
+ original_method_dispatch =
167
+ if is_setter_method
168
+ "self.send(:before_instrument_#{name}, #{arg_string})"
169
+ else
170
+ "before_instrument_#{name}(#{arg_string})"
171
+ end
172
+
155
173
  klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
156
174
  alias_method :"before_instrument_#{name}", :"#{name}" # alias_method :"before_instrument_process", :"process"
157
175
  def #{name}(#{arg_string}) # def process(*args, **kwargs, &blk)
@@ -165,7 +183,7 @@ module Skylight
165
183
  meta = {} # meta = {}
166
184
  #
167
185
  begin # begin
168
- send(:before_instrument_#{name}, #{arg_string}) # send(:before_instrument_process, *args, **kwargs, &blk)
186
+ #{original_method_dispatch} # self.before_instrument_process(...)
169
187
  rescue Exception => e # rescue Exception => e
170
188
  meta[:exception_object] = e # meta[:exception_object] = e
171
189
  raise e # raise e
@@ -3,5 +3,5 @@ module Skylight
3
3
  # for compatibility with semver when it is parsed by the rust agent.
4
4
  # This string will be transformed in the gemspec to "5.0.0.alpha"
5
5
  # to conform with rubygems.
6
- VERSION = "5.0.0".freeze
6
+ VERSION = "5.0.1".freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport