appsignal 0.8.2 → 0.8.3.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +3 -0
- data/lib/appsignal/agent.rb +6 -6
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/agent_spec.rb +27 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjI5MDhiMzVjMGUyYzUyNWViOTkzYTQ2YmIzYWU1YjVmNGVjOGU5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWVhNmFiZTFkMjkzOWZlNjg5MDY4ZmNiYWJhN2UzZGY3OTQzMDQ3Zg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzZiZDQ1YzcwZDk1NjkxYWVjMGFhMDFiNzBmYWVhNjZmMzU0MWI1ZTgzMDRh
|
10
|
+
OGIyN2NhNDRiNDgyYTkzM2RlNTI4MzVmYmRlMDg1NWM0ZDRkYzE5NjM4YmIw
|
11
|
+
N2U5NjFkOTNhMDQ0ZDkyNDkyNTc3MGNjZmM0MTg4NTFlMDhiODk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTAzNDY1NjY1ZDRjYjg3OTNmMjVlZWJhODQ2Njg0MjUwMTRjMWIyNWVhNTQy
|
14
|
+
Y2Q0NzZlMTdkMWQ5YzdhYjVhYmViN2QwOGM5ZWI2YmZlNzljYjBhYTc3MTVj
|
15
|
+
YTllZmMxNTNjYTIxOWYxZWQ1Yjc3NDc4Njg3NzQ3YTEzMzI5MDI=
|
data/CHANGELOG.md
CHANGED
data/lib/appsignal/agent.rb
CHANGED
@@ -2,7 +2,8 @@ module Appsignal
|
|
2
2
|
class Agent
|
3
3
|
ACTION = 'log_entries'.freeze
|
4
4
|
|
5
|
-
attr_accessor :aggregator, :thread, :
|
5
|
+
attr_accessor :aggregator, :thread, :master_pid, :pid, :active, :sleep_time,
|
6
|
+
:transmitter, :subscriber
|
6
7
|
|
7
8
|
def initialize
|
8
9
|
return unless Appsignal.active?
|
@@ -11,6 +12,8 @@ module Appsignal
|
|
11
12
|
else
|
12
13
|
@sleep_time = 60.0
|
13
14
|
end
|
15
|
+
@master_pid = Process.pid
|
16
|
+
@pid = @master_pid
|
14
17
|
@aggregator = Aggregator.new
|
15
18
|
@transmitter = Transmitter.new(ACTION)
|
16
19
|
subscribe
|
@@ -56,6 +59,7 @@ module Appsignal
|
|
56
59
|
def enqueue(transaction)
|
57
60
|
Appsignal.logger.debug('Enqueueing transaction')
|
58
61
|
aggregator.add(transaction)
|
62
|
+
forked! if @pid != Process.pid
|
59
63
|
end
|
60
64
|
|
61
65
|
def send_queue
|
@@ -89,17 +93,13 @@ module Appsignal
|
|
89
93
|
|
90
94
|
def forked!
|
91
95
|
Appsignal.logger.debug('Forked worker process')
|
92
|
-
@
|
96
|
+
@pid = Process.pid
|
93
97
|
Thread.exclusive do
|
94
98
|
@aggregator = Aggregator.new
|
95
99
|
end
|
96
100
|
restart_thread
|
97
101
|
end
|
98
102
|
|
99
|
-
def forked?
|
100
|
-
@forked ||= false
|
101
|
-
end
|
102
|
-
|
103
103
|
def shutdown(send_current_queue=false)
|
104
104
|
Appsignal.logger.info('Shutting down agent')
|
105
105
|
ActiveSupport::Notifications.unsubscribe(subscriber)
|
data/lib/appsignal/version.rb
CHANGED
@@ -10,6 +10,11 @@ describe Appsignal::Agent do
|
|
10
10
|
|
11
11
|
let(:transaction) { regular_transaction }
|
12
12
|
|
13
|
+
context "pid" do
|
14
|
+
its(:master_pid) { should == Process.pid }
|
15
|
+
its(:pid) { should == Process.pid }
|
16
|
+
end
|
17
|
+
|
13
18
|
describe "#sleep_time" do
|
14
19
|
subject { Appsignal::Agent.new.sleep_time }
|
15
20
|
|
@@ -134,9 +139,21 @@ describe Appsignal::Agent do
|
|
134
139
|
end
|
135
140
|
|
136
141
|
describe "#enqueue" do
|
142
|
+
subject { Appsignal.agent }
|
143
|
+
|
137
144
|
it "forwards to the aggregator" do
|
138
145
|
subject.aggregator.should respond_to(:add)
|
139
146
|
subject.aggregator.should_receive(:add).with(:foo)
|
147
|
+
subject.should_not_receive(:forked!)
|
148
|
+
end
|
149
|
+
|
150
|
+
context "if we have been forked" do
|
151
|
+
before { Process.stub(:pid => 9000000002) }
|
152
|
+
|
153
|
+
it "should call forked!" do
|
154
|
+
subject.aggregator.should_receive(:add).with(:foo)
|
155
|
+
subject.should_receive(:forked!)
|
156
|
+
end
|
140
157
|
end
|
141
158
|
|
142
159
|
after { subject.enqueue(:foo) }
|
@@ -191,17 +208,23 @@ describe Appsignal::Agent do
|
|
191
208
|
end
|
192
209
|
|
193
210
|
describe "#forked!" do
|
194
|
-
|
211
|
+
subject { Appsignal.agent }
|
195
212
|
|
196
|
-
it "should create a new aggregator and restart the thread" do
|
197
|
-
|
213
|
+
it "should create a new aggregator, set the new pid and restart the thread" do
|
214
|
+
master_pid = subject.master_pid
|
215
|
+
subject.pid.should == master_pid
|
216
|
+
|
217
|
+
Process.stub(:pid => 9000000001)
|
198
218
|
subject.should_receive(:restart_thread)
|
219
|
+
previous_aggregator = subject.aggregator
|
199
220
|
|
200
221
|
subject.forked!
|
201
222
|
|
202
|
-
subject.forked?.should be_true
|
203
223
|
subject.aggregator.should_not == previous_aggregator
|
204
224
|
subject.aggregator.should be_a Appsignal::Aggregator
|
225
|
+
|
226
|
+
subject.master_pid.should == master_pid
|
227
|
+
subject.pid.should == 9000000001
|
205
228
|
end
|
206
229
|
end
|
207
230
|
|
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: 0.8.
|
4
|
+
version: 0.8.3.beta.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-01-
|
15
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: 1.9.3
|
238
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
|
-
- - ! '
|
240
|
+
- - ! '>'
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
242
|
+
version: 1.3.1
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
245
|
rubygems_version: 2.0.3
|