appsignal 2.11.8-java → 2.11.9-java

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: 1e1ba61246de44136e06c57be6f4a877be8cc714dbcdafd1c7c8eb9bd994cbc4
4
- data.tar.gz: ef465afb88df2f8f53015e84192159d464c4827e66a1ee19bed38b73712e810c
3
+ metadata.gz: df7fae0d072de1948a84fc6c546b15da9e76bfde32f70e28d4242ba2dbc98be2
4
+ data.tar.gz: '092acba4f404fafd21333649bdd65c190da7b31507172f7da91c9a56debe2c5a'
5
5
  SHA512:
6
- metadata.gz: '060922d22213fb4b53b3656221d5ae1da5624682f0765f6631a2ef6c041ec12239729a38b1db5df383a316952628912d9a63680a8742211d404df9836cf2877f'
7
- data.tar.gz: e7a8ba54779115a77703090837a9814e017884607d3b059b620a875cba9c52bc449fa56006ad443ecc076d1bf8bfc7b8c109bd7d61c811c8f5748e683b94f3d4
6
+ metadata.gz: e6f79d7c05a1504874bb7b86816d8c2c405e1499ff765839984db085d3b3bb26da03af7749c78e6a7013bf3afe52fc95badd66bc8787c5b7c0587f4d12b1ca70
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: java
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