errplane 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,26 +9,15 @@ require "json" unless Hash.respond_to?(:to_json)
9
9
  require "errplane/version"
10
10
  require "errplane/logger"
11
11
  require "errplane/black_box"
12
+ require "errplane/max_queue"
12
13
  require "errplane/configuration"
13
14
  require "errplane/transmitter"
14
15
  require "errplane/backtrace"
16
+ require "errplane/worker"
15
17
  require "errplane/rack"
16
18
 
17
19
  require "errplane/railtie" if defined?(Rails::Railtie)
18
20
 
19
- class SafeQueue < Queue
20
- attr_accessor :max_depth
21
-
22
- def initialize(max_depth = 10_000)
23
- @max_depth = max_depth
24
- super()
25
- end
26
-
27
- def push_safely(data)
28
- push(data) if size < @max_depth
29
- end
30
- end
31
-
32
21
  module Errplane
33
22
  class << self
34
23
  include Logger
@@ -47,11 +36,11 @@ module Errplane
47
36
  end
48
37
 
49
38
  def queue
50
- @queue ||= SafeQueue.new(configuration.queue_maximum_depth)
39
+ @queue ||= MaxQueue.new(configuration.queue_maximum_depth)
51
40
  end
52
41
 
53
42
  def report(name, params = {})
54
- Errplane.queue.push_safely({
43
+ Errplane.queue.push_or_discard({
55
44
  :name => name,
56
45
  :source => "custom",
57
46
  :timestamp => current_timestamp
@@ -140,10 +129,10 @@ module Errplane
140
129
  e = e.continued_exception if e.respond_to?(:continued_exception)
141
130
  e = e.original_exception if e.respond_to?(:original_exception)
142
131
  opts = opts.merge(:exception => e)
132
+ opts[:environment_variables] = ENV.to_hash if configuration.include_environment_variables?
143
133
  black_box = BlackBox.new(opts)
144
134
  end
145
135
  end
146
136
  end
147
137
 
148
- require "errplane/instrumentation"
149
138
  require "errplane/sinatra" if defined?(Sinatra::Request)
@@ -19,6 +19,7 @@ module Errplane
19
19
  @request_url = params[:request_url]
20
20
  @user_agent = params[:user_agent]
21
21
  @custom_data = params[:custom_data] || {}
22
+ @environment_variables = params[:environment_variables] || {}
22
23
  end
23
24
 
24
25
  def to_json
@@ -33,10 +34,10 @@ module Errplane
33
34
  :exception_class => @exception.class.to_s,
34
35
  :language => "Ruby",
35
36
  :language_version => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
36
- :environment_variables => ENV.to_hash,
37
37
  :reporter => reporter,
38
38
  :custom_data => @custom_data
39
39
  }
40
+ payload[:environment_variables] = @environment_variables
40
41
 
41
42
  Errplane.configuration.add_custom_exception_data(self)
42
43
 
@@ -19,6 +19,7 @@ module Errplane
19
19
  attr_accessor :backtrace_filters
20
20
  attr_accessor :aggregated_exception_classes
21
21
  attr_accessor :environment_variables
22
+ attr_writer :include_environment_variables
22
23
 
23
24
  attr_accessor :instrumentation_enabled
24
25
  attr_accessor :debug
@@ -36,6 +37,7 @@ module Errplane
36
37
  ActionController::RoutingError},
37
38
  :ignored_environments => %w{test cucumber selenium},
38
39
  :ignored_user_agents => %w{GoogleBot},
40
+ :include_environment_variables => false,
39
41
  :backtrace_filters => [
40
42
  lambda { |line| line.gsub(/^\.\//, "") },
41
43
  lambda { |line|
@@ -58,6 +60,7 @@ module Errplane
58
60
  @ignored_environments = DEFAULTS[:ignored_environments].dup
59
61
  @ignored_user_agents = DEFAULTS[:ignored_user_agents].dup
60
62
  @backtrace_filters = DEFAULTS[:backtrace_filters].dup
63
+ @include_environment_variables = DEFAULTS[:include_environment_variables]
61
64
  @aggregated_exception_classes = []
62
65
  @debug = false
63
66
  @rescue_global_exceptions = false
@@ -72,6 +75,10 @@ module Errplane
72
75
  !!@debug
73
76
  end
74
77
 
78
+ def include_environment_variables?
79
+ @include_environment_variables
80
+ end
81
+
75
82
  def instrumentation_enabled?
76
83
  !!@instrumentation_enabled
77
84
  end
@@ -0,0 +1,14 @@
1
+ module Errplane
2
+ class MaxQueue < Queue
3
+ attr_accessor :max_depth
4
+
5
+ def initialize(max_depth = 10_000)
6
+ @max_depth = max_depth
7
+ super()
8
+ end
9
+
10
+ def push_or_discard(data)
11
+ push(data) if size < @max_depth
12
+ end
13
+ end
14
+ end
@@ -109,19 +109,17 @@ module Errplane
109
109
  :nid => id,
110
110
  :payload => payload,
111
111
  :source => "active_support"}
112
- Errplane.queue.push_safely(h)
112
+ Errplane.queue.push_or_discard(h)
113
113
  end
114
114
  end
115
115
  end
116
116
 
117
117
  if defined?(PhusionPassenger)
118
118
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
119
- if forked
120
- Errplane::Instrumentation.spawn_worker_threads()
121
- end
119
+ Errplane::Worker.spawn_threads() if forked
122
120
  end
123
121
  else
124
- Errplane::Instrumentation.spawn_worker_threads()
122
+ Errplane::Worker.spawn_threads()
125
123
  end
126
124
  end
127
125
  end
@@ -24,7 +24,7 @@ module Errplane
24
24
  :url => url,
25
25
  :source => "exception" }
26
26
 
27
- Errplane.queue.push_safely(exception)
27
+ Errplane.queue.push_or_discard(exception)
28
28
  end
29
29
 
30
30
  def deliver(data, url)
@@ -1,3 +1,3 @@
1
1
  module Errplane
2
- VERSION = "0.5.6"
2
+ VERSION = "0.5.7"
3
3
  end
@@ -4,7 +4,7 @@ require "uri"
4
4
  require "base64"
5
5
 
6
6
  module Errplane
7
- class Instrumentation
7
+ class Worker
8
8
  class << self
9
9
  include Errplane::Logger
10
10
 
@@ -37,7 +37,7 @@ module Errplane
37
37
  end
38
38
  end
39
39
 
40
- def spawn_worker_threads()
40
+ def spawn_threads()
41
41
  Errplane.configuration.queue_worker_threads.times do
42
42
  log :debug, "Spawning background worker thread."
43
43
  Thread.new do
@@ -2,23 +2,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  ENV["RAILS_ENV"] ||= "test"
4
4
 
5
- require 'rails/version'
6
-
7
- if Rails::VERSION::MAJOR > 2
8
- require 'rails'
9
- else
10
- module Rails
11
- class << self
12
- def vendor_rails?; return false; end
13
- end
14
-
15
- class Configuration
16
- def after_initialize; end
17
- end
18
- @@configuration = Configuration.new
19
- end
20
- require 'initializer'
21
- end
5
+ require 'rails'
22
6
 
23
7
  require 'bundler/setup'
24
8
  Bundler.require
@@ -29,16 +13,9 @@ FakeWeb.allow_net_connect = false
29
13
  if defined? Rails
30
14
  puts "Loading Rails v#{Rails.version}..."
31
15
 
32
- if Rails.version.to_f < 3.0
33
- RAILS_ROOT = "#{File.dirname(__FILE__)}/support/rails2"
34
- require "#{RAILS_ROOT}/config/environment"
35
- require "spec/rails"
36
- else
37
- require "support/rails3/app"
38
- require "rspec/rails"
39
- end
40
- end
41
-
42
- if defined? Sinatra
43
- require 'spec_helper_for_sinatra'
16
+ require "support/rails3/app"
17
+ require "rspec/rails"
18
+ else
19
+ puts "ERROR: Rails could not be loaded."
20
+ exit
44
21
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Errplane::MaxQueue do
4
+ it "should inherit from Queue" do
5
+ Errplane::MaxQueue.new.should be_a(Queue)
6
+ end
7
+
8
+ context "#new" do
9
+ it "should allow max_depth to be set" do
10
+ queue = Errplane::MaxQueue.new(500)
11
+ queue.max_depth.should == 500
12
+ end
13
+ end
14
+
15
+ context "#push_or_discard" do
16
+ it "should allow an item to be added if the queue is not full" do
17
+ queue = Errplane::MaxQueue.new(5)
18
+ queue.size.should be_zero
19
+ queue.push_or_discard(1)
20
+ queue.size.should == 1
21
+ end
22
+
23
+ it "should not allow items to be added if the queue is full" do
24
+ queue = Errplane::MaxQueue.new(5)
25
+ queue.size.should be_zero
26
+ 5.times { |n| queue.push_or_discard(n) }
27
+ queue.size.should == 5
28
+ queue.push_or_discard(6)
29
+ queue.size.should == 5
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Errplane::Transmitter do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Errplane::Worker do
4
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errplane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70113630104640 !ruby/object:Gem::Requirement
16
+ requirement: &70239459114500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70113630104640
24
+ version_requirements: *70239459114500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70113630104100 !ruby/object:Gem::Requirement
27
+ requirement: &70239459113860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.3.14
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70113630104100
35
+ version_requirements: *70239459113860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: actionpack
38
- requirement: &70113630103560 !ruby/object:Gem::Requirement
38
+ requirement: &70239459113180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.3.14
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70113630103560
46
+ version_requirements: *70239459113180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70113630103020 !ruby/object:Gem::Requirement
49
+ requirement: &70239459112620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70113630103020
57
+ version_requirements: *70239459112620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: fakeweb
60
- requirement: &70113630095780 !ruby/object:Gem::Requirement
60
+ requirement: &70239459112020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70113630095780
68
+ version_requirements: *70239459112020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard
71
- requirement: &70113630095220 !ruby/object:Gem::Requirement
71
+ requirement: &70239459111420 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70113630095220
79
+ version_requirements: *70239459111420
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: guard-rspec
82
- requirement: &70113630094680 !ruby/object:Gem::Requirement
82
+ requirement: &70239459110840 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70113630094680
90
+ version_requirements: *70239459110840
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &70113630094140 !ruby/object:Gem::Requirement
93
+ requirement: &70239459110220 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70113630094140
101
+ version_requirements: *70239459110220
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &70113630093660 !ruby/object:Gem::Requirement
104
+ requirement: &70239459109640 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70113630093660
112
+ version_requirements: *70239459109640
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &70113630093040 !ruby/object:Gem::Requirement
115
+ requirement: &70239459108840 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70113630093040
123
+ version_requirements: *70239459108840
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: tzinfo
126
- requirement: &70113630092320 !ruby/object:Gem::Requirement
126
+ requirement: &70239459107980 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70113630092320
134
+ version_requirements: *70239459107980
135
135
  description: This gem provides exception reporting with Errplane for Rails 3.x applications.
136
136
  email:
137
137
  - todd@errplane.com
@@ -155,8 +155,8 @@ files:
155
155
  - lib/errplane/black_box.rb
156
156
  - lib/errplane/capistrano.rb
157
157
  - lib/errplane/configuration.rb
158
- - lib/errplane/instrumentation.rb
159
158
  - lib/errplane/logger.rb
159
+ - lib/errplane/max_queue.rb
160
160
  - lib/errplane/rack.rb
161
161
  - lib/errplane/rails.rb
162
162
  - lib/errplane/rails/air_traffic_controller.rb
@@ -168,6 +168,7 @@ files:
168
168
  - lib/errplane/sinatra.rb
169
169
  - lib/errplane/transmitter.rb
170
170
  - lib/errplane/version.rb
171
+ - lib/errplane/worker.rb
171
172
  - lib/rails/generators/errplane/errplane_generator.rb
172
173
  - lib/rails/generators/errplane/templates/initializer.rb
173
174
  - spec/controllers/widgets_controller_spec.rb
@@ -180,6 +181,9 @@ files:
180
181
  - spec/unit/black_box_spec.rb
181
182
  - spec/unit/configuration_spec.rb
182
183
  - spec/unit/errplane_spec.rb
184
+ - spec/unit/max_queue_spec.rb
185
+ - spec/unit/transmitter_spec.rb
186
+ - spec/unit/worker_spec.rb
183
187
  homepage: http://errplane.com
184
188
  licenses:
185
189
  - MIT
@@ -201,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
205
  version: '0'
202
206
  requirements: []
203
207
  rubyforge_project: errplane
204
- rubygems_version: 1.8.15
208
+ rubygems_version: 1.8.17
205
209
  signing_key:
206
210
  specification_version: 3
207
211
  summary: Rails exception reporting for Errplane.
@@ -216,3 +220,6 @@ test_files:
216
220
  - spec/unit/black_box_spec.rb
217
221
  - spec/unit/configuration_spec.rb
218
222
  - spec/unit/errplane_spec.rb
223
+ - spec/unit/max_queue_spec.rb
224
+ - spec/unit/transmitter_spec.rb
225
+ - spec/unit/worker_spec.rb