appsignal 0.8.2 → 0.8.3.beta.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmFjYTM5Y2QzMmQwOWUwNWU4NDY0YzViZmM4NWIzNTlmMTFmMWY5Nw==
4
+ YjI5MDhiMzVjMGUyYzUyNWViOTkzYTQ2YmIzYWU1YjVmNGVjOGU5Nw==
5
5
  data.tar.gz: !binary |-
6
- OWUxNDdlYTM5NTdkYmFhOTQ3NzViNWVjYWFmNTRlMDUxMGIzYmNiMQ==
6
+ OWVhNmFiZTFkMjkzOWZlNjg5MDY4ZmNiYWJhN2UzZGY3OTQzMDQ3Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NWUwZGI2ZmUyODRhZDBlOTBmYzU1ZTQzMDM3YTNiN2M2NmRmMzk1MzUxYzRl
10
- OWQ5MDU0Nzg4ZjQzZDc3YmQwOTMzNTU2NmVjMTdlYzg4NzgyYjA5MmIyZDk4
11
- ZmJlMmQxNWUxMzBiOTdjY2I4YmNkM2FhMDE4OTkxMDAyN2JkZmI=
9
+ NzZiZDQ1YzcwZDk1NjkxYWVjMGFhMDFiNzBmYWVhNjZmMzU0MWI1ZTgzMDRh
10
+ OGIyN2NhNDRiNDgyYTkzM2RlNTI4MzVmYmRlMDg1NWM0ZDRkYzE5NjM4YmIw
11
+ N2U5NjFkOTNhMDQ0ZDkyNDkyNTc3MGNjZmM0MTg4NTFlMDhiODk=
12
12
  data.tar.gz: !binary |-
13
- M2I3ZTM2MzMyMzkxMWFlY2RkODMxOWQ0ZmVjZjg4NTU2ZDI0YzU4NWRkMDYw
14
- MTI0MjkyMDY1MWI3MDZkNzAzODI1ZmFkODExMDg3YTk2NzU2ZjE1NzAyYTJk
15
- YmY1OTc3ODRlOThiMjQ3YTYxNmUxZjdhNDBmMzI0N2E4NzU2Mzg=
13
+ MTAzNDY1NjY1ZDRjYjg3OTNmMjVlZWJhODQ2Njg0MjUwMTRjMWIyNWVhNTQy
14
+ Y2Q0NzZlMTdkMWQ5YzdhYjVhYmViN2QwOGM5ZWI2YmZlNzljYjBhYTc3MTVj
15
+ YTllZmMxNTNjYTIxOWYxZWQ1Yjc3NDc4Njg3NzQ3YTEzMzI5MDI=
@@ -1,3 +1,6 @@
1
+ # 0.8.3
2
+ * Restart thread when we've been forked
3
+
1
4
  # 0.8.2
2
5
  * Bugfix in Delayed Job integration
3
6
  * appsignal prefix when logging to stdout
@@ -2,7 +2,8 @@ module Appsignal
2
2
  class Agent
3
3
  ACTION = 'log_entries'.freeze
4
4
 
5
- attr_accessor :aggregator, :thread, :active, :sleep_time, :transmitter, :subscriber
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
- @forked = true
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)
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.3.beta.0'
3
3
  end
@@ -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
- its(:forked?) { should be_false }
211
+ subject { Appsignal.agent }
195
212
 
196
- it "should create a new aggregator and restart the thread" do
197
- previous_aggregator = subject.aggregator
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.2
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-07 00:00:00.000000000 Z
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: '0'
242
+ version: 1.3.1
243
243
  requirements: []
244
244
  rubyforge_project:
245
245
  rubygems_version: 2.0.3