appsignal 2.11.8 → 2.11.9

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: 8cb57893fb10d1d54593fcf13b4d2b13ac728e9d0c5c16f046580b1befb6048d
4
- data.tar.gz: ef465afb88df2f8f53015e84192159d464c4827e66a1ee19bed38b73712e810c
3
+ metadata.gz: 60535b76df01cdf84e0a7a0e018cb3822e56de610cbfd7694bdb10c06ba32b64
4
+ data.tar.gz: '092acba4f404fafd21333649bdd65c190da7b31507172f7da91c9a56debe2c5a'
5
5
  SHA512:
6
- metadata.gz: 663ba5e66fd1bad997a27c164d7e9845effb7d419b6b23a3b33a1f0f71f50d18071194f75216e347956f11e3ad2730f82e7c24fb4029b2c9daf4bd597c289450
7
- data.tar.gz: e7a8ba54779115a77703090837a9814e017884607d3b059b620a875cba9c52bc449fa56006ad443ecc076d1bf8bfc7b8c109bd7d61c811c8f5748e683b94f3d4
6
+ metadata.gz: 1e6a54ec292287cd2944032aa00af8d15505cb52c33e8b697d1659fa4ceaa8e89ffca68d6050ca2cad05a3b537838e5f6439cbfe4fd3301f220279fe266c4759
7
+ data.tar.gz: 843ccd65902958efcd641d09d8c65e9ec55ac0a908ac16651a4016fb99329bfa6b1c903472a59182e21f56f83ac738e7dd0eb03d957bbaed4bba550b8a8ce76b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # 2.11.9
4
+ - Fix and simplify Ruby method delegation for object method instrumentation in
5
+ the different Ruby versions. PR #706
6
+
3
7
  # 2.11.8
4
8
  - Mark minutely probe thread as fork-safe by @pixeltrix. PR #704
5
9
 
@@ -1,56 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Object
4
- if Appsignal::System.ruby_2_7_or_newer?
5
- def self.appsignal_instrument_class_method(method_name, options = {})
6
- singleton_class.send \
7
- :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
8
- singleton_class.send(:define_method, method_name) do |*args, **kwargs, &block|
9
- name = options.fetch(:name) do
10
- "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
11
- end
12
- Appsignal.instrument name do
13
- send "appsignal_uninstrumented_#{method_name}", *args, **kwargs, &block
14
- end
4
+ def self.appsignal_instrument_class_method(method_name, options = {})
5
+ singleton_class.send \
6
+ :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
7
+ singleton_class.send(:define_method, method_name) do |*args, &block|
8
+ name = options.fetch(:name) do
9
+ "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
15
10
  end
16
- end
17
-
18
- def self.appsignal_instrument_method(method_name, options = {})
19
- alias_method "appsignal_uninstrumented_#{method_name}", method_name
20
- define_method method_name do |*args, **kwargs, &block|
21
- name = options.fetch(:name) do
22
- "#{method_name}.#{appsignal_reverse_class_name}.other"
23
- end
24
- Appsignal.instrument name do
25
- send "appsignal_uninstrumented_#{method_name}", *args, **kwargs, &block
26
- end
11
+ Appsignal.instrument name do
12
+ send "appsignal_uninstrumented_#{method_name}", *args, &block
27
13
  end
28
14
  end
29
- else
30
- def self.appsignal_instrument_class_method(method_name, options = {})
31
- singleton_class.send \
32
- :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
33
- singleton_class.send(:define_method, method_name) do |*args, &block|
34
- name = options.fetch(:name) do
35
- "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
36
- end
37
- Appsignal.instrument name do
38
- send "appsignal_uninstrumented_#{method_name}", *args, &block
39
- end
40
- end
15
+ if singleton_class.respond_to?(:ruby2_keywords, true)
16
+ singleton_class.send(:ruby2_keywords, method_name)
41
17
  end
18
+ end
42
19
 
43
- def self.appsignal_instrument_method(method_name, options = {})
44
- alias_method "appsignal_uninstrumented_#{method_name}", method_name
45
- define_method method_name do |*args, &block|
46
- name = options.fetch(:name) do
47
- "#{method_name}.#{appsignal_reverse_class_name}.other"
48
- end
49
- Appsignal.instrument name do
50
- send "appsignal_uninstrumented_#{method_name}", *args, &block
51
- end
20
+ def self.appsignal_instrument_method(method_name, options = {})
21
+ alias_method "appsignal_uninstrumented_#{method_name}", method_name
22
+ define_method method_name do |*args, &block|
23
+ name = options.fetch(:name) do
24
+ "#{method_name}.#{appsignal_reverse_class_name}.other"
25
+ end
26
+ Appsignal.instrument name do
27
+ send "appsignal_uninstrumented_#{method_name}", *args, &block
52
28
  end
53
29
  end
30
+ ruby2_keywords method_name if respond_to?(:ruby2_keywords, true)
54
31
  end
55
32
 
56
33
  def self.appsignal_reverse_class_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.11.8".freeze
4
+ VERSION = "2.11.9".freeze
5
5
  end
@@ -30,12 +30,57 @@ describe Object do
30
30
  before do
31
31
  Appsignal.config = project_fixture_config
32
32
  expect(Appsignal::Transaction).to receive(:current).at_least(:once).and_return(transaction)
33
+ expect(Appsignal.active?).to be_truthy
33
34
  end
34
35
  after { Appsignal.config = nil }
35
36
 
37
+ context "with different kind of arguments" do
38
+ let(:klass) do
39
+ Class.new do
40
+ def positional_arguments(param1, param2)
41
+ [param1, param2]
42
+ end
43
+ appsignal_instrument_method :positional_arguments
44
+
45
+ def positional_arguments_splat(*params)
46
+ params
47
+ end
48
+ appsignal_instrument_method :positional_arguments_splat
49
+
50
+ def keyword_arguments(a: nil, b: nil)
51
+ [a, b]
52
+ end
53
+ appsignal_instrument_method :keyword_arguments
54
+
55
+ def keyword_arguments_splat(**kwargs)
56
+ kwargs
57
+ end
58
+ appsignal_instrument_method :keyword_arguments_splat
59
+
60
+ def splat(*args, **kwargs)
61
+ [args, kwargs]
62
+ end
63
+ appsignal_instrument_method :splat
64
+ end
65
+ end
66
+
67
+ it "instruments the method and calls it" do
68
+ expect(instance.positional_arguments("abc", "def")).to eq(["abc", "def"])
69
+ expect(instance.positional_arguments_splat("abc", "def")).to eq(["abc", "def"])
70
+ expect(instance.keyword_arguments(:a => "a", :b => "b")).to eq(["a", "b"])
71
+ expect(instance.keyword_arguments_splat(:a => "a", :b => "b"))
72
+ .to eq(:a => "a", :b => "b")
73
+
74
+ expect(instance.splat).to eq([[], {}])
75
+ expect(instance.splat(:a => "a", :b => "b")).to eq([[], { :a => "a", :b => "b" }])
76
+ expect(instance.splat("abc", "def")).to eq([["abc", "def"], {}])
77
+ expect(instance.splat("abc", "def", :a => "a", :b => "b"))
78
+ .to eq([["abc", "def"], { :a => "a", :b => "b" }])
79
+ end
80
+ end
81
+
36
82
  context "with anonymous class" do
37
83
  it "instruments the method and calls it" do
38
- expect(Appsignal.active?).to be_truthy
39
84
  expect(transaction).to receive(:start_event)
40
85
  expect(transaction).to receive(:finish_event).with \
41
86
  "foo.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -56,7 +101,6 @@ describe Object do
56
101
  let(:klass) { NamedClass }
57
102
 
58
103
  it "instruments the method and calls it" do
59
- expect(Appsignal.active?).to be_truthy
60
104
  expect(transaction).to receive(:start_event)
61
105
  expect(transaction).to receive(:finish_event).with \
62
106
  "foo.NamedClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -81,7 +125,6 @@ describe Object do
81
125
  let(:klass) { MyModule::NestedModule::NamedClass }
82
126
 
83
127
  it "instruments the method and calls it" do
84
- expect(Appsignal.active?).to be_truthy
85
128
  expect(transaction).to receive(:start_event)
86
129
  expect(transaction).to receive(:finish_event).with \
87
130
  "bar.NamedClass.NestedModule.MyModule.other", nil, nil,
@@ -101,7 +144,6 @@ describe Object do
101
144
  end
102
145
 
103
146
  it "instruments with custom name" do
104
- expect(Appsignal.active?).to be_truthy
105
147
  expect(transaction).to receive(:start_event)
106
148
  expect(transaction).to receive(:finish_event).with \
107
149
  "my_method.group", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -162,6 +204,51 @@ describe Object do
162
204
  end
163
205
  after { Appsignal.config = nil }
164
206
 
207
+ context "with different kind of arguments" do
208
+ let(:klass) do
209
+ Class.new do
210
+ def self.positional_arguments(param1, param2)
211
+ [param1, param2]
212
+ end
213
+ appsignal_instrument_class_method :positional_arguments
214
+
215
+ def self.positional_arguments_splat(*params)
216
+ params
217
+ end
218
+ appsignal_instrument_class_method :positional_arguments_splat
219
+
220
+ def self.keyword_arguments(a: nil, b: nil)
221
+ [a, b]
222
+ end
223
+ appsignal_instrument_class_method :keyword_arguments
224
+
225
+ def self.keyword_arguments_splat(**kwargs)
226
+ kwargs
227
+ end
228
+ appsignal_instrument_class_method :keyword_arguments_splat
229
+
230
+ def self.splat(*args, **kwargs)
231
+ [args, kwargs]
232
+ end
233
+ appsignal_instrument_class_method :splat
234
+ end
235
+ end
236
+
237
+ it "instruments the method and calls it" do
238
+ expect(klass.positional_arguments("abc", "def")).to eq(["abc", "def"])
239
+ expect(klass.positional_arguments_splat("abc", "def")).to eq(["abc", "def"])
240
+ expect(klass.keyword_arguments(:a => "a", :b => "b")).to eq(["a", "b"])
241
+ expect(klass.keyword_arguments_splat(:a => "a", :b => "b"))
242
+ .to eq(:a => "a", :b => "b")
243
+
244
+ expect(klass.splat).to eq([[], {}])
245
+ expect(klass.splat(:a => "a", :b => "b")).to eq([[], { :a => "a", :b => "b" }])
246
+ expect(klass.splat("abc", "def")).to eq([["abc", "def"], {}])
247
+ expect(klass.splat("abc", "def", :a => "a", :b => "b"))
248
+ .to eq([["abc", "def"], { :a => "a", :b => "b" }])
249
+ end
250
+ end
251
+
165
252
  context "with anonymous class" do
166
253
  it "instruments the method and calls it" do
167
254
  expect(Appsignal.active?).to be_truthy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.8
4
+ version: 2.11.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-02-18 00:00:00.000000000 Z
13
+ date: 2021-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack