appsignal 0.10.0.beta.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,12 @@
6
6
  * Use Appsignal.monitor_transaction to instrument and log errors for
7
7
  custom actions
8
8
  * Add option to ignore a specific action
9
- * Use a Mutex in agent instead of Thread.exclusive
9
+
10
+ # 0.9.6
11
+ * Convert to primitives before sending through pipe
12
+
13
+ # 0.9.5
14
+ Yanked
10
15
 
11
16
  # 0.9.4
12
17
  * Log Rails and Sinatra version
@@ -66,7 +71,7 @@ Yanked
66
71
  * Alias tag_request to tag_job, for background jobs
67
72
  * Skip sanitization of env if env is nil
68
73
  * Small bugfix in forking logic
69
- * Don't send params if send_params is off in config
74
+ * Don't send params if send_params is off in config
70
75
  * Remove --repository option in CLI
71
76
  * Name option in appsignal notify_of_deploy CLI
72
77
  * Don't call to_hash on ENV
@@ -2,8 +2,8 @@ module Appsignal
2
2
  class Agent
3
3
  ACTION = 'log_entries'.freeze
4
4
 
5
- attr_accessor :aggregator, :mutex, :thread, :master_pid, :pid, :active,
6
- :sleep_time, :transmitter, :subscriber, :paused
5
+ attr_accessor :aggregator, :thread, :master_pid, :pid, :active, :sleep_time,
6
+ :transmitter, :subscriber, :paused
7
7
 
8
8
  def initialize
9
9
  return unless Appsignal.active?
@@ -16,7 +16,6 @@ module Appsignal
16
16
  @pid = @master_pid
17
17
  @aggregator = Aggregator.new
18
18
  @transmitter = Transmitter.new(ACTION)
19
- @mutex = Mutex.new
20
19
  subscribe
21
20
  start_thread
22
21
  Appsignal.logger.info('Started Appsignal agent')
@@ -94,7 +93,7 @@ module Appsignal
94
93
  # Replace aggregator while making sure no thread
95
94
  # is adding to it's queue
96
95
  aggregator_to_be_sent = nil
97
- mutex.synchronize do
96
+ Thread.exclusive do
98
97
  aggregator_to_be_sent = aggregator
99
98
  @aggregator = Aggregator.new
100
99
  end
@@ -113,7 +112,7 @@ module Appsignal
113
112
  Appsignal.logger.debug('Clearing queue')
114
113
  # Replace aggregator while making sure no thread
115
114
  # is adding to it's queue
116
- mutex.synchronize do
115
+ Thread.exclusive do
117
116
  @aggregator = Aggregator.new
118
117
  end
119
118
  end
@@ -121,7 +120,7 @@ module Appsignal
121
120
  def forked!
122
121
  Appsignal.logger.info('Forked worker process')
123
122
  @pid = Process.pid
124
- mutex.synchronize do
123
+ Thread.exclusive do
125
124
  @aggregator = Aggregator.new
126
125
  end
127
126
  resubscribe
@@ -131,7 +130,7 @@ module Appsignal
131
130
  def shutdown(send_current_queue=false, reason=nil)
132
131
  Appsignal.logger.info("Shutting down agent (#{reason})")
133
132
  unsubscribe
134
- Thread.kill(thread) if thread
133
+ stop_thread
135
134
  send_queue if send_current_queue && @aggregator.has_transactions?
136
135
  end
137
136
 
@@ -85,7 +85,7 @@
85
85
  end
86
86
 
87
87
  def exception?
88
- !!exception
88
+ !! exception
89
89
  end
90
90
 
91
91
  def slow_request?
@@ -98,20 +98,32 @@
98
98
  end
99
99
 
100
100
  def truncate!
101
+ return if truncated?
101
102
  process_action_event.payload.clear
102
103
  events.clear
103
104
  tags.clear
104
105
  sanitized_environment.clear
105
106
  sanitized_session_data.clear
106
107
  @env = nil
108
+ @truncated = true
109
+ end
110
+
111
+ def truncated?
112
+ !! @truncated
107
113
  end
108
114
 
109
115
  def convert_values_to_primitives!
116
+ return if have_values_been_converted_to_primitives?
110
117
  Appsignal::Transaction::ParamsSanitizer.sanitize!(@process_action_event.payload) if @process_action_event
111
118
  @events.map do |o|
112
119
  Appsignal::Transaction::ParamsSanitizer.sanitize(o.payload)
113
120
  end
114
121
  add_sanitized_context!
122
+ @have_values_been_converted_to_primitives = true
123
+ end
124
+
125
+ def have_values_been_converted_to_primitives?
126
+ !! @have_values_been_converted_to_primitives
115
127
  end
116
128
 
117
129
  def type
@@ -129,6 +141,7 @@
129
141
  Appsignal.transactions.delete(@request_id)
130
142
  if process_action_event || exception?
131
143
  if Appsignal::Pipe.current
144
+ convert_values_to_primitives!
132
145
  Appsignal.logger.debug("Writing transaction to pipe: #{@request_id}")
133
146
  Appsignal::Pipe.current.write(self)
134
147
  else
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.10.0.beta.0'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -10,12 +10,6 @@ describe Appsignal::Agent do
10
10
 
11
11
  let(:transaction) { regular_transaction }
12
12
 
13
- context "supporting objects" do
14
- its(:mutex) { should be_a(Mutex) }
15
- its(:aggregator) { should be_a(Appsignal::Aggregator) }
16
- its(:transmitter) { should be_a(Appsignal::Transmitter) }
17
- end
18
-
19
13
  context "pid" do
20
14
  its(:master_pid) { should == Process.pid }
21
15
  its(:pid) { should == Process.pid }
@@ -61,7 +55,7 @@ describe Appsignal::Agent do
61
55
  subject.should_receive(:send_queue).at_least(:twice)
62
56
 
63
57
  subject.start_thread
64
- sleep 1
58
+ sleep 2
65
59
  end
66
60
  end
67
61
 
@@ -234,6 +234,15 @@ describe Appsignal::Transaction do
234
234
  subject.process_action_event.payload.should be_empty
235
235
  subject.events.should be_empty
236
236
  subject.tags.should be_empty
237
+ subject.truncated?.should be_true
238
+ end
239
+
240
+ it "should not truncate twice" do
241
+ subject.process_action_event.payload.should_receive(:clear).once
242
+ subject.events.should_receive(:clear).once
243
+
244
+ subject.truncate!
245
+ subject.truncate!
237
246
  end
238
247
  end
239
248
 
@@ -282,6 +291,14 @@ describe Appsignal::Transaction do
282
291
  subject
283
292
  event_payload.should == before
284
293
  end
294
+
295
+ it "should not covert to primitives twice" do
296
+ transaction.convert_values_to_primitives!
297
+ transaction.have_values_been_converted_to_primitives?.should be_true
298
+
299
+ Appsignal::Transaction::ParamsSanitizer.should_not_receive(:sanitize!)
300
+ transaction.convert_values_to_primitives!
301
+ end
285
302
  end
286
303
  end
287
304
 
@@ -355,12 +372,20 @@ describe Appsignal::Transaction do
355
372
 
356
373
  context 'when using pipes' do
357
374
  let(:pipe) { double }
358
- before { Appsignal::Pipe.stub(:current => pipe) }
375
+ before do
376
+ Appsignal::Pipe.stub(:current => pipe)
377
+ pipe.stub(:write => true)
378
+ transaction.stub(:convert_values_to_primitives! => true)
379
+ end
359
380
 
360
381
  it "should send itself trough the pipe" do
361
382
  pipe.should_receive(:write).with(transaction)
362
383
  end
363
384
 
385
+ it "should convert itself to primitives" do
386
+ transaction.should_receive(:convert_values_to_primitives!)
387
+ end
388
+
364
389
  after { transaction.complete! }
365
390
  end
366
391
  end
@@ -40,25 +40,18 @@ describe Appsignal::Transmitter do
40
40
  end
41
41
 
42
42
  describe "#http_post" do
43
- it "calls Net::HTTP.post_form with the correct params" do
44
- post = double(:post)
45
- post.should_receive(:[]=).with(
46
- 'Content-Type',
47
- 'application/json; charset=UTF-8'
48
- )
49
- post.should_receive(:[]=).with(
50
- 'Content-Encoding',
51
- 'gzip'
52
- )
53
- post.should_receive(:body=).with(
54
- Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED)
55
- )
43
+ before do
56
44
  Socket.stub(:gethostname => 'app1.local')
45
+ end
46
+
47
+ subject { instance.send(:http_post, 'the' => 'payload') }
48
+
49
+ its(:body) { should == Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED) }
50
+ its(:path) { should == instance.uri.request_uri }
57
51
 
58
- Net::HTTP::Post.should_receive(:new).with(
59
- instance.uri.request_uri
60
- ).and_return(post)
61
- instance.send(:http_post, :the => :payload)
52
+ it "should have the correct headers" do
53
+ subject['Content-Type'].should == 'application/json; charset=UTF-8'
54
+ subject['Content-Encoding'].should == 'gzip'
62
55
  end
63
56
  end
64
57
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.beta.0
4
+ version: 0.10.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Robert Beekman
@@ -12,104 +13,118 @@ authors:
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2014-08-05 00:00:00.000000000 Z
16
+ date: 2014-08-13 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: rack
19
20
  requirement: !ruby/object:Gem::Requirement
21
+ none: false
20
22
  requirements:
21
- - - ">="
23
+ - - ! '>='
22
24
  - !ruby/object:Gem::Version
23
25
  version: '0'
24
26
  type: :runtime
25
27
  prerelease: false
26
28
  version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
27
30
  requirements:
28
- - - ">="
31
+ - - ! '>='
29
32
  - !ruby/object:Gem::Version
30
33
  version: '0'
31
34
  - !ruby/object:Gem::Dependency
32
35
  name: thread_safe
33
36
  requirement: !ruby/object:Gem::Requirement
37
+ none: false
34
38
  requirements:
35
- - - ">="
39
+ - - ! '>='
36
40
  - !ruby/object:Gem::Version
37
41
  version: '0'
38
42
  type: :runtime
39
43
  prerelease: false
40
44
  version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
41
46
  requirements:
42
- - - ">="
47
+ - - ! '>='
43
48
  - !ruby/object:Gem::Version
44
49
  version: '0'
45
50
  - !ruby/object:Gem::Dependency
46
51
  name: rake
47
52
  requirement: !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
- - - ">="
55
+ - - ! '>='
50
56
  - !ruby/object:Gem::Version
51
57
  version: '0'
52
58
  type: :development
53
59
  prerelease: false
54
60
  version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
55
62
  requirements:
56
- - - ">="
63
+ - - ! '>='
57
64
  - !ruby/object:Gem::Version
58
65
  version: '0'
59
66
  - !ruby/object:Gem::Dependency
60
67
  name: rspec
61
68
  requirement: !ruby/object:Gem::Requirement
69
+ none: false
62
70
  requirements:
63
- - - "~>"
71
+ - - ~>
64
72
  - !ruby/object:Gem::Version
65
73
  version: 2.14.1
66
74
  type: :development
67
75
  prerelease: false
68
76
  version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
69
78
  requirements:
70
- - - "~>"
79
+ - - ~>
71
80
  - !ruby/object:Gem::Version
72
81
  version: 2.14.1
73
82
  - !ruby/object:Gem::Dependency
74
83
  name: pry
75
84
  requirement: !ruby/object:Gem::Requirement
85
+ none: false
76
86
  requirements:
77
- - - ">="
87
+ - - ! '>='
78
88
  - !ruby/object:Gem::Version
79
89
  version: '0'
80
90
  type: :development
81
91
  prerelease: false
82
92
  version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
83
94
  requirements:
84
- - - ">="
95
+ - - ! '>='
85
96
  - !ruby/object:Gem::Version
86
97
  version: '0'
87
98
  - !ruby/object:Gem::Dependency
88
99
  name: timecop
89
100
  requirement: !ruby/object:Gem::Requirement
101
+ none: false
90
102
  requirements:
91
- - - ">="
103
+ - - ! '>='
92
104
  - !ruby/object:Gem::Version
93
105
  version: '0'
94
106
  type: :development
95
107
  prerelease: false
96
108
  version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
97
110
  requirements:
98
- - - ">="
111
+ - - ! '>='
99
112
  - !ruby/object:Gem::Version
100
113
  version: '0'
101
114
  - !ruby/object:Gem::Dependency
102
115
  name: webmock
103
116
  requirement: !ruby/object:Gem::Requirement
117
+ none: false
104
118
  requirements:
105
- - - ">="
119
+ - - ! '>='
106
120
  - !ruby/object:Gem::Version
107
121
  version: '0'
108
122
  type: :development
109
123
  prerelease: false
110
124
  version_requirements: !ruby/object:Gem::Requirement
125
+ none: false
111
126
  requirements:
112
- - - ">="
127
+ - - ! '>='
113
128
  - !ruby/object:Gem::Version
114
129
  version: '0'
115
130
  description: The official appsignal.com gem
@@ -120,8 +135,8 @@ executables:
120
135
  extensions: []
121
136
  extra_rdoc_files: []
122
137
  files:
123
- - ".gitignore"
124
- - ".travis.yml"
138
+ - .gitignore
139
+ - .travis.yml
125
140
  - CHANGELOG.md
126
141
  - Gemfile
127
142
  - LICENSE
@@ -224,26 +239,27 @@ files:
224
239
  homepage: https://github.com/appsignal/appsignal
225
240
  licenses:
226
241
  - MIT
227
- metadata: {}
228
242
  post_install_message:
229
243
  rdoc_options: []
230
244
  require_paths:
231
245
  - lib
232
246
  required_ruby_version: !ruby/object:Gem::Requirement
247
+ none: false
233
248
  requirements:
234
- - - ">="
249
+ - - ! '>='
235
250
  - !ruby/object:Gem::Version
236
251
  version: 1.9.3
237
252
  required_rubygems_version: !ruby/object:Gem::Requirement
253
+ none: false
238
254
  requirements:
239
- - - ">"
255
+ - - ! '>='
240
256
  - !ruby/object:Gem::Version
241
- version: 1.3.1
257
+ version: '0'
242
258
  requirements: []
243
259
  rubyforge_project:
244
- rubygems_version: 2.2.2
260
+ rubygems_version: 1.8.23
245
261
  signing_key:
246
- specification_version: 4
262
+ specification_version: 3
247
263
  summary: Logs performance and exception data from your app to appsignal.com
248
264
  test_files:
249
265
  - spec/lib/appsignal/agent_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: eaaf7d6c75bf0cacbef11b40c1931a2cca2c9121
4
- data.tar.gz: 1b7b1151ffbde430bc17267d93c7272a224c105d
5
- SHA512:
6
- metadata.gz: 050ba5e12ac07e9f160e6be7711395f18424e4ba7a9ebb4a28cff887db5483d3762a9e70dc693d3bd7be8501663024f5e1f7e01fb67caf338976300d44acd95b
7
- data.tar.gz: 05cd41d9e8f821244902433f910be5c42be51174f3d7e42572d84524beefee4e9e2a40bf85a28d876bbe338c89daa0a87e809d18b44a6e17abff406c3585c2b4