contrast-exceptional 0.0.1 → 0.0.6
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.
- data/History.txt +6 -0
- data/Manifest +11 -5
- data/README +3 -3
- data/Rakefile +5 -6
- data/exceptional.gemspec +32 -32
- data/init.rb +1 -19
- data/lib/exceptional.rb +12 -223
- data/lib/exceptional/api.rb +108 -0
- data/lib/exceptional/bootstrap.rb +23 -0
- data/lib/exceptional/config.rb +74 -0
- data/lib/exceptional/exception_data.rb +2 -4
- data/lib/exceptional/integration/rails.rb +25 -13
- data/lib/exceptional/log.rb +50 -0
- data/lib/exceptional/remote.rb +75 -0
- data/lib/exceptional/version.rb +1 -1
- data/spec/api_spec.rb +211 -0
- data/spec/bootstrap_spec.rb +58 -0
- data/spec/config_spec.rb +110 -0
- data/spec/exceptional_rescue_from_spec.rb +41 -0
- data/spec/exceptional_spec.rb +16 -58
- data/spec/log_spec.rb +28 -0
- data/spec/remote_spec.rb +137 -0
- data/spec/spec_helper.rb +11 -0
- metadata +43 -25
- data/lib/exceptional/agent/worker.rb +0 -56
- data/lib/exceptional/deployed_environment.rb +0 -86
- data/lib/exceptional/rails.rb +0 -53
- data/spec/deployed_environment_spec.rb +0 -168
- data/spec/worker_spec.rb +0 -21
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
3
|
+
if ENV['RAILS_VER']
|
4
|
+
gem 'rails', "=#{ENV['RAILS_VER']}"
|
5
|
+
else
|
6
|
+
gem 'rails'
|
7
|
+
end
|
8
|
+
|
9
|
+
# TODO couple of different ways to test parts of exceptional with Rails (or a mock), reconcile them.
|
10
|
+
#require 'active_support'
|
11
|
+
# module Rails; end # Rails faker
|
12
|
+
|
2
13
|
require File.dirname(__FILE__) + '/../lib/exceptional'
|
metadata
CHANGED
@@ -1,57 +1,79 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contrast-exceptional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Paul Campbell
|
7
|
+
- Contrast
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date:
|
12
|
+
date: 2009-07-09 00:00:00 -07:00
|
14
13
|
default_executable:
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: json
|
17
|
+
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0
|
23
|
+
version: "0"
|
24
24
|
version:
|
25
25
|
description: Exceptional is the core Ruby library for communicating with http://getexceptional.com (hosted error tracking service)
|
26
|
-
email:
|
26
|
+
email: hello@contrast.ie
|
27
27
|
executables: []
|
28
28
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
-
-
|
33
|
-
-
|
32
|
+
- lib/exceptional/api.rb
|
33
|
+
- lib/exceptional/bootstrap.rb
|
34
|
+
- lib/exceptional/config.rb
|
35
|
+
- lib/exceptional/exception_data.rb
|
36
|
+
- lib/exceptional/integration/rails.rb
|
37
|
+
- lib/exceptional/log.rb
|
38
|
+
- lib/exceptional/remote.rb
|
39
|
+
- lib/exceptional/version.rb
|
40
|
+
- lib/exceptional.rb
|
34
41
|
- README
|
35
42
|
files:
|
36
|
-
- History.txt
|
37
|
-
- Manifest
|
38
|
-
- README
|
39
|
-
- Rakefile
|
40
43
|
- exceptional.gemspec
|
41
44
|
- exceptional.yml
|
45
|
+
- History.txt
|
42
46
|
- init.rb
|
43
47
|
- install.rb
|
44
|
-
- lib/exceptional/
|
45
|
-
- lib/exceptional/
|
48
|
+
- lib/exceptional/api.rb
|
49
|
+
- lib/exceptional/bootstrap.rb
|
50
|
+
- lib/exceptional/config.rb
|
46
51
|
- lib/exceptional/exception_data.rb
|
47
52
|
- lib/exceptional/integration/rails.rb
|
48
|
-
- lib/exceptional/
|
53
|
+
- lib/exceptional/log.rb
|
54
|
+
- lib/exceptional/remote.rb
|
49
55
|
- lib/exceptional/version.rb
|
50
56
|
- lib/exceptional.rb
|
57
|
+
- Manifest
|
58
|
+
- Rakefile
|
59
|
+
- README
|
60
|
+
- spec/api_spec.rb
|
61
|
+
- spec/bootstrap_spec.rb
|
62
|
+
- spec/config_spec.rb
|
63
|
+
- spec/exception_data_spec.rb
|
64
|
+
- spec/exceptional_rescue_from_spec.rb
|
65
|
+
- spec/exceptional_spec.rb
|
66
|
+
- spec/log_spec.rb
|
67
|
+
- spec/remote_spec.rb
|
68
|
+
- spec/spec_helper.rb
|
51
69
|
has_rdoc: true
|
52
|
-
homepage: http://
|
70
|
+
homepage: http://getexceptional.com/
|
53
71
|
post_install_message:
|
54
72
|
rdoc_options:
|
73
|
+
- --line-numbers
|
74
|
+
- --inline-source
|
75
|
+
- --title
|
76
|
+
- Exceptional
|
55
77
|
- --main
|
56
78
|
- README
|
57
79
|
require_paths:
|
@@ -66,18 +88,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
88
|
requirements:
|
67
89
|
- - ">="
|
68
90
|
- !ruby/object:Gem::Version
|
69
|
-
version: "
|
91
|
+
version: "1.2"
|
70
92
|
version:
|
71
93
|
requirements: []
|
72
94
|
|
73
|
-
rubyforge_project:
|
95
|
+
rubyforge_project: exceptional
|
74
96
|
rubygems_version: 1.2.0
|
75
97
|
signing_key:
|
76
98
|
specification_version: 2
|
77
99
|
summary: Exceptional is the core Ruby library for communicating with http://getexceptional.com (hosted error tracking service)
|
78
|
-
test_files:
|
79
|
-
|
80
|
-
- spec/exception_data_spec.rb
|
81
|
-
- spec/exceptional_spec.rb
|
82
|
-
- spec/spec_helper.rb
|
83
|
-
- spec/worker_spec.rb
|
100
|
+
test_files: []
|
101
|
+
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# The Worker is used by Exceptional when started in :queue mode
|
2
|
-
# It queues and sends exception data asynchronously.
|
3
|
-
|
4
|
-
module Exceptional::Agent
|
5
|
-
|
6
|
-
class Worker
|
7
|
-
|
8
|
-
attr_reader :log, :timeout, :exceptions
|
9
|
-
|
10
|
-
def initialize(log = Logger.new(STDERR))
|
11
|
-
@exceptions = []
|
12
|
-
@timeout = ::WORKER_TIMEOUT
|
13
|
-
@mutex = Mutex.new
|
14
|
-
@log = log
|
15
|
-
@log.info "Started Exceptional Worker."
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_exception(data)
|
19
|
-
@mutex.synchronize do
|
20
|
-
@exceptions << data
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
while(true) do
|
26
|
-
send_any_exception_data
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def exception_to_send
|
33
|
-
@mutex.synchronize do
|
34
|
-
return @exceptions.shift
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def send_any_exception_data
|
40
|
-
if @exceptions.empty?
|
41
|
-
sleep @timeout
|
42
|
-
return
|
43
|
-
end
|
44
|
-
|
45
|
-
data = exception_to_send
|
46
|
-
|
47
|
-
begin
|
48
|
-
Exceptional.post(data)
|
49
|
-
rescue Exception => e
|
50
|
-
@log.error "Error sending exception data: #{e}"
|
51
|
-
@log.debug e.backtrace.join("\n")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# This class is used to determine the server environment
|
2
|
-
module Exceptional
|
3
|
-
class DeployedEnvironment
|
4
|
-
|
5
|
-
attr_reader :server, :identifier, :hostname#, :environment
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@server = :unknown
|
9
|
-
@identifier = nil
|
10
|
-
|
11
|
-
@hostname = determine_host
|
12
|
-
# @environment = Exceptional.environment
|
13
|
-
# @application_root = Exceptional.application_root
|
14
|
-
|
15
|
-
servers = %w[webrick mongrel thin litespeed passenger]
|
16
|
-
while servers.any? && @identifier.nil?
|
17
|
-
send 'is_'+(servers.shift)+'?'
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def should_start_worker?
|
23
|
-
!identifier.nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
def determine_mode
|
27
|
-
@server == :passenger ? :direct : :queue
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_s
|
31
|
-
"#{@hostname}:#{@identifier} [#{@server}]"
|
32
|
-
end
|
33
|
-
|
34
|
-
def determine_host
|
35
|
-
Socket.gethostname
|
36
|
-
end
|
37
|
-
|
38
|
-
def is_webrick?
|
39
|
-
if defined?(OPTIONS) && defined?(DEFAULT_PORT) && OPTIONS.respond_to?(:fetch)
|
40
|
-
# OPTIONS is set by script/server if launching webrick
|
41
|
-
@identifier = OPTIONS.fetch :port, DEFAULT_PORT
|
42
|
-
@server = :webrick
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def is_mongrel?
|
47
|
-
if defined? Mongrel::HttpServer
|
48
|
-
ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel|
|
49
|
-
next unless mongrel.respond_to? :port
|
50
|
-
@server = :mongrel
|
51
|
-
@identifier = mongrel.port
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def is_thin?
|
57
|
-
if defined? Thin::Server
|
58
|
-
ObjectSpace.each_object(Thin::Server) do |thin_server|
|
59
|
-
@server = :thin
|
60
|
-
backend = thin_server.backend
|
61
|
-
if backend.respond_to? :port
|
62
|
-
@identifier = backend.port
|
63
|
-
elsif backend.respond_to? :socket
|
64
|
-
@identifier = backend.socket
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def is_litespeed?
|
71
|
-
if caller.pop =~ /fcgi-bin\/RailsRunner\.rb/
|
72
|
-
@server = :litespeed
|
73
|
-
@identifier = 'litespeed'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def is_passenger?
|
78
|
-
if defined? Passenger::AbstractServer
|
79
|
-
@server = :passenger
|
80
|
-
@identifier = 'passenger'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
data/lib/exceptional/rails.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module Exceptional
|
2
|
-
|
3
|
-
class Rails
|
4
|
-
|
5
|
-
def self.init
|
6
|
-
Exceptional.deployed_environment = DeployedEnvironment.new
|
7
|
-
# If no server environment detected, don't perform magic.
|
8
|
-
# Means rake, script/console etc perform as expected
|
9
|
-
return false unless Exceptional.deployed_environment.should_start_worker?
|
10
|
-
|
11
|
-
setup_log
|
12
|
-
Exceptional.log_config_info
|
13
|
-
|
14
|
-
if Exceptional.authenticate
|
15
|
-
|
16
|
-
if Exceptional.mode == :queue
|
17
|
-
Exceptional.worker = Agent::Worker.new(Exceptional.log)
|
18
|
-
Exceptional.worker_thread = Thread.new do
|
19
|
-
Exceptional.worker.run
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
require File.join(File.dirname(__FILE__), 'integration', 'rails')
|
24
|
-
|
25
|
-
|
26
|
-
at_exit do
|
27
|
-
if Exceptional.mode == :queue
|
28
|
-
Exceptional.worker_thread.terminate if Exceptional.worker_thread
|
29
|
-
end
|
30
|
-
end
|
31
|
-
else
|
32
|
-
Exceptional.log! "Plugin not authenticated, check your API Key"
|
33
|
-
Exceptional.log! "Disabling Plugin."
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.setup_log
|
38
|
-
log_file = "#{Exceptional.application_root}/log/exceptional.log"
|
39
|
-
|
40
|
-
@log = Logger.new log_file
|
41
|
-
@log.level = Logger::INFO
|
42
|
-
|
43
|
-
allowed_log_levels = ['debug', 'info', 'warn', 'error', 'fatal']
|
44
|
-
if Exceptional.log_level && allowed_log_levels.include?(Exceptional.log_level)
|
45
|
-
@log.level = eval("Logger::#{Exceptional.log_level.upcase}")
|
46
|
-
end
|
47
|
-
|
48
|
-
Exceptional.log = @log
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Exceptional::DeployedEnvironment do
|
4
|
-
|
5
|
-
describe "mongrel" do
|
6
|
-
|
7
|
-
before(:all) do
|
8
|
-
class << self
|
9
|
-
module ::Mongrel
|
10
|
-
class HttpServer
|
11
|
-
def port; 3000; end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Mongrel::HttpServer.new
|
17
|
-
@deployed_environment = Exceptional::DeployedEnvironment.new
|
18
|
-
end
|
19
|
-
|
20
|
-
it "server should be mongrel" do
|
21
|
-
@deployed_environment.server.should == :mongrel
|
22
|
-
end
|
23
|
-
|
24
|
-
it "identifier should be 3000" do
|
25
|
-
@deployed_environment.identifier.should == 3000
|
26
|
-
end
|
27
|
-
|
28
|
-
it "to_s should match" do
|
29
|
-
pending
|
30
|
-
@deployed_environment.to_s.should match(/(:3000 \[:mongrel\])/)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "mode should be queue" do
|
34
|
-
@deployed_environment.determine_mode.should == :queue
|
35
|
-
end
|
36
|
-
|
37
|
-
after(:all) do
|
38
|
-
ObjectSpace.garbage_collect
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "webrick" do
|
44
|
-
|
45
|
-
before(:all) do
|
46
|
-
class MockOptions
|
47
|
-
def fetch(*args)
|
48
|
-
3001
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class << self
|
53
|
-
::OPTIONS = MockOptions.new
|
54
|
-
::DEFAULT_PORT = 3000
|
55
|
-
end
|
56
|
-
@deployed_environment = Exceptional::DeployedEnvironment.new
|
57
|
-
end
|
58
|
-
|
59
|
-
it "server should be webrick" do
|
60
|
-
@deployed_environment.server.should == :webrick
|
61
|
-
end
|
62
|
-
|
63
|
-
it "identifier should be 3001" do
|
64
|
-
@deployed_environment.identifier.should == 3001
|
65
|
-
end
|
66
|
-
|
67
|
-
it "mode should be queue" do
|
68
|
-
@deployed_environment.determine_mode.should == :queue
|
69
|
-
end
|
70
|
-
|
71
|
-
after(:all) do
|
72
|
-
ObjectSpace.garbage_collect
|
73
|
-
Object.class_eval { remove_const :OPTIONS }
|
74
|
-
Object.class_eval { remove_const :DEFAULT_PORT }
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "thin" do
|
80
|
-
|
81
|
-
before(:all) do
|
82
|
-
class << self
|
83
|
-
module ::Thin
|
84
|
-
class Server
|
85
|
-
def backend; self; end
|
86
|
-
def socket; "/socket/file.000"; end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
Thin::Server.new
|
91
|
-
|
92
|
-
@deployed_environment = Exceptional::DeployedEnvironment.new
|
93
|
-
end
|
94
|
-
|
95
|
-
it "server should be thin" do
|
96
|
-
@deployed_environment.server.should == :thin
|
97
|
-
end
|
98
|
-
|
99
|
-
it "identifier should be the socket file" do
|
100
|
-
@deployed_environment.identifier.should == '/socket/file.000'
|
101
|
-
end
|
102
|
-
|
103
|
-
it "mode should be queue" do
|
104
|
-
@deployed_environment.determine_mode.should == :queue
|
105
|
-
end
|
106
|
-
|
107
|
-
after(:all) do
|
108
|
-
ObjectSpace.garbage_collect
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "litespeed" do
|
114
|
-
|
115
|
-
before(:all) do
|
116
|
-
@deployed_environment = Exceptional::DeployedEnvironment.new
|
117
|
-
end
|
118
|
-
|
119
|
-
# Hmmph, how to determine if we're running under litespeed...
|
120
|
-
it "server should be unknown" do
|
121
|
-
@deployed_environment.server.should == :unknown
|
122
|
-
end
|
123
|
-
|
124
|
-
it "identifier should be nil" do
|
125
|
-
@deployed_environment.identifier.should == nil
|
126
|
-
end
|
127
|
-
|
128
|
-
it "mode should be queue" do
|
129
|
-
@deployed_environment.determine_mode.should == :queue
|
130
|
-
end
|
131
|
-
|
132
|
-
after(:all) do
|
133
|
-
ObjectSpace.garbage_collect
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "passenger" do
|
139
|
-
|
140
|
-
before(:all) do
|
141
|
-
class << self
|
142
|
-
module ::Passenger
|
143
|
-
const_set "AbstractServer", 0
|
144
|
-
end
|
145
|
-
end
|
146
|
-
@deployed_environment = Exceptional::DeployedEnvironment.new
|
147
|
-
end
|
148
|
-
|
149
|
-
it "server should be passenger" do
|
150
|
-
@deployed_environment.server.should == :passenger
|
151
|
-
end
|
152
|
-
|
153
|
-
# Would be nicer to identify passenger by some
|
154
|
-
it "identifier should be passenger" do
|
155
|
-
@deployed_environment.identifier.should == 'passenger'
|
156
|
-
end
|
157
|
-
|
158
|
-
it "mode should be queue" do
|
159
|
-
@deployed_environment.determine_mode.should == :direct
|
160
|
-
end
|
161
|
-
|
162
|
-
after(:all) do
|
163
|
-
ObjectSpace.garbage_collect
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|