appsignal 1.0.2.beta.3 → 1.0.2.beta.4
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 +1 -0
- data/lib/appsignal/subscriber.rb +8 -3
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/subscriber_spec.rb +40 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f93d8352dc9721ce4904f6babf14d2f373aa60f0
|
4
|
+
data.tar.gz: ad56ad53fe82568d2f560bbe7a9e0a1e1ef25314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf30299ffd79ca086305ad588a15094d039f23e481857dd0b5203d39ec517c6a29bd783489f974cca210b35ab40c910416ff07a8694795203293566649311765
|
7
|
+
data.tar.gz: c70e9386856293f12fa00ae9858c96df46cc054f4e0ffa60e6ff1b78b05c92166b4987f86a81af1bf868764c9290f85610ac2b1060a005463cb0edfaba289a99
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
* Rake integration file for backwards compatibility
|
5
5
|
* Don't instrument mongo-ruby-driver when transaction is not present
|
6
6
|
* Accept method calls on extension if it's not loaded
|
7
|
+
* Fix for duplicate notifications subscriptions when forking
|
7
8
|
|
8
9
|
# 1.0.1
|
9
10
|
* Fix for bug in gem initialization when using `safe_yaml` gem
|
data/lib/appsignal/subscriber.rb
CHANGED
@@ -2,6 +2,8 @@ module Appsignal
|
|
2
2
|
class Subscriber
|
3
3
|
BLANK = ''.freeze
|
4
4
|
|
5
|
+
attr_reader :as_subscriber
|
6
|
+
|
5
7
|
def initialize
|
6
8
|
subscribe
|
7
9
|
end
|
@@ -9,12 +11,15 @@ module Appsignal
|
|
9
11
|
def subscribe
|
10
12
|
Appsignal.logger.debug('Subscribing to notifications')
|
11
13
|
# Subscribe to notifications that don't start with a !
|
12
|
-
ActiveSupport::Notifications.subscribe(/^[^!]/, self)
|
14
|
+
@as_subscriber = ActiveSupport::Notifications.subscribe(/^[^!]/, self)
|
13
15
|
end
|
14
16
|
|
15
17
|
def unsubscribe
|
16
|
-
|
17
|
-
|
18
|
+
if @as_subscriber
|
19
|
+
Appsignal.logger.debug('Unsubscribing from notifications')
|
20
|
+
ActiveSupport::Notifications.unsubscribe(@as_subscriber)
|
21
|
+
@as_subscriber = nil
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def resubscribe
|
data/lib/appsignal/version.rb
CHANGED
@@ -6,43 +6,56 @@ describe Appsignal::Subscriber do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
before do
|
9
|
+
ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).clear
|
9
10
|
Thread.current[:appsignal_transaction] = nil
|
10
11
|
end
|
11
12
|
|
12
|
-
let(:subscriber) { Appsignal.
|
13
|
+
let(:subscriber) { Appsignal::Subscriber.new }
|
13
14
|
subject { subscriber }
|
14
15
|
|
15
16
|
context "initialization" do
|
17
|
+
before do
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
|
16
21
|
it "should be in the subscriber list" do
|
17
22
|
ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |s|
|
18
23
|
s.instance_variable_get(:@delegate).is_a?(Appsignal::Subscriber)
|
19
|
-
end.count == 1
|
24
|
+
end.count.should == 1
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
context "subscriptions" do
|
24
29
|
describe "subscribe" do
|
25
30
|
it "should subscribe" do
|
26
|
-
ActiveSupport::Notifications.should_receive(:subscribe).with(/^[^!]/, subject).at_least(:once)
|
27
|
-
|
28
31
|
subject.subscribe
|
32
|
+
subject.as_subscriber.should_not be_nil
|
33
|
+
|
34
|
+
ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |s|
|
35
|
+
s.instance_variable_get(:@delegate).is_a?(Appsignal::Subscriber)
|
36
|
+
end.count.should == 2
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
40
|
describe "#unsubscribe" do
|
33
41
|
it "should unsubscribe" do
|
34
|
-
ActiveSupport::Notifications.should_receive(:unsubscribe).with(subject).at_least(:once)
|
35
|
-
|
36
42
|
subject.unsubscribe
|
43
|
+
subject.as_subscriber.should be_nil
|
44
|
+
|
45
|
+
ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |s|
|
46
|
+
s.instance_variable_get(:@delegate).is_a?(Appsignal::Subscriber)
|
47
|
+
end.count.should == 0
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
51
|
describe "#resubscribe" do
|
41
52
|
it "should unsubscribe and subscribe" do
|
42
|
-
subject.should_receive(:unsubscribe).at_least(:once)
|
43
|
-
subject.should_receive(:subscribe)
|
44
|
-
|
45
53
|
subject.resubscribe
|
54
|
+
subject.as_subscriber.should_not be_nil
|
55
|
+
|
56
|
+
ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |s|
|
57
|
+
s.instance_variable_get(:@delegate).is_a?(Appsignal::Subscriber)
|
58
|
+
end.count.should == 1
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
@@ -56,6 +69,10 @@ describe Appsignal::Subscriber do
|
|
56
69
|
end
|
57
70
|
|
58
71
|
context "handling events using #start and #finish" do
|
72
|
+
before do
|
73
|
+
subscriber
|
74
|
+
end
|
75
|
+
|
59
76
|
it "should should not listen to events that start with a bang" do
|
60
77
|
subject.should_not_receive(:start)
|
61
78
|
subject.should_not_receive(:finish)
|
@@ -97,20 +114,20 @@ describe Appsignal::Subscriber do
|
|
97
114
|
end
|
98
115
|
|
99
116
|
it "should call finish with title and body if there is a formatter" do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
Appsignal::Extension.should_receive(:start_event).once
|
118
|
+
Appsignal::Extension.should_receive(:finish_event).with(
|
119
|
+
kind_of(Integer),
|
120
|
+
'request.net_http',
|
121
|
+
'GET http://www.google.com',
|
122
|
+
''
|
123
|
+
).once
|
124
|
+
|
125
|
+
ActiveSupport::Notifications.instrument(
|
126
|
+
'request.net_http',
|
127
|
+
:protocol => 'http',
|
128
|
+
:domain => 'www.google.com',
|
129
|
+
:method => 'GET'
|
130
|
+
)
|
114
131
|
end
|
115
132
|
|
116
133
|
context "when paused" do
|
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: 1.0.2.beta.
|
4
|
+
version: 1.0.2.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|