airbrake_handler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/README.md +6 -0
- data/airbrake_handler.gemspec +1 -1
- data/lib/airbrake_handler.rb +5 -4
- data/test/airbrake_notifier_test.rb +16 -8
- metadata +10 -9
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -23,6 +23,11 @@ You can pass more options to AirbrakeHander initializer, i.e:
|
|
23
23
|
AirbrakeHandler.new(:api_key => "your-airbrake-api-key", :framework_env => "production")
|
24
24
|
```
|
25
25
|
|
26
|
+
Toadhopper options:
|
27
|
+
|
28
|
+
* :api_key
|
29
|
+
* :notify_host
|
30
|
+
|
26
31
|
If you want to ignore specific exceptions, you can do this like that:
|
27
32
|
|
28
33
|
```ruby
|
@@ -38,6 +43,7 @@ airbrake_handler.ignore << {:class => "Errno::ECONNRESET", :message => /Connecti
|
|
38
43
|
## Contributors
|
39
44
|
|
40
45
|
* [Anton Mironov](https://github.com/mironov)
|
46
|
+
* [Benedikt Böhm](https://github.com/hollow)
|
41
47
|
|
42
48
|
## Copyright
|
43
49
|
|
data/airbrake_handler.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "airbrake_handler"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.4.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Adam Jacob", "Wojciech Wnętrzak"]
|
9
9
|
s.email = ["w.wnetrzak@gmail.com"]
|
data/lib/airbrake_handler.rb
CHANGED
@@ -20,13 +20,14 @@ require "chef/handler"
|
|
20
20
|
require "toadhopper"
|
21
21
|
|
22
22
|
class AirbrakeHandler < Chef::Handler
|
23
|
-
VERSION = "0.
|
23
|
+
VERSION = "0.4.0"
|
24
24
|
|
25
|
-
attr_accessor :options, :api_key, :ignore
|
25
|
+
attr_accessor :options, :api_key, :ignore, :notify_host
|
26
26
|
|
27
27
|
def initialize(options={})
|
28
28
|
@api_key = options.delete(:api_key)
|
29
|
-
@
|
29
|
+
@notify_host = options.delete(:notify_host) || nil
|
30
|
+
@ignore = options.delete(:ignore) || []
|
30
31
|
@options = options
|
31
32
|
end
|
32
33
|
|
@@ -59,6 +60,6 @@ class AirbrakeHandler < Chef::Handler
|
|
59
60
|
|
60
61
|
def client
|
61
62
|
raise ArgumentError.new("You must specify Airbrake api key") unless api_key
|
62
|
-
Toadhopper.new(api_key)
|
63
|
+
Toadhopper.new(api_key, :notify_host => @notify_host)
|
63
64
|
end
|
64
65
|
end
|
@@ -5,18 +5,24 @@ describe AirbrakeHandler do
|
|
5
5
|
Chef::Log.stubs(:error)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
# initalization
|
9
|
+
|
10
|
+
it "raises error when api_key is not specified" do
|
9
11
|
assert_raises ArgumentError do
|
10
12
|
AirbrakeHandler.new.client
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
# options
|
17
|
+
|
18
|
+
it "sets options" do
|
15
19
|
handler = AirbrakeHandler.new(:framework_env => "staging")
|
16
20
|
assert_equal "staging", handler.options[:framework_env]
|
17
21
|
end
|
18
22
|
|
19
|
-
|
23
|
+
# exceptions
|
24
|
+
|
25
|
+
it "reports exception using client" do
|
20
26
|
exception = Exception.new
|
21
27
|
run_status = stub(:failed? => true, :exception => exception)
|
22
28
|
client = mock
|
@@ -29,7 +35,7 @@ describe AirbrakeHandler do
|
|
29
35
|
handler.report
|
30
36
|
end
|
31
37
|
|
32
|
-
it "
|
38
|
+
it "does not report ignored exception" do
|
33
39
|
run_status = stub(:failed? => true, :exception => Exception.new)
|
34
40
|
client = mock
|
35
41
|
handler = AirbrakeHandler.new(:api_key => "fake")
|
@@ -42,7 +48,7 @@ describe AirbrakeHandler do
|
|
42
48
|
handler.report
|
43
49
|
end
|
44
50
|
|
45
|
-
it "
|
51
|
+
it "does not report ignored exception with specific message" do
|
46
52
|
run_status = stub(:failed? => true, :exception => Exception.new("error"))
|
47
53
|
client = mock
|
48
54
|
handler = AirbrakeHandler.new(:api_key => "fake")
|
@@ -55,7 +61,7 @@ describe AirbrakeHandler do
|
|
55
61
|
handler.report
|
56
62
|
end
|
57
63
|
|
58
|
-
it "
|
64
|
+
it "reports exception if its message doesn't match any message of ignored exceptions" do
|
59
65
|
run_status = stub(:failed? => true, :exception => Exception.new("important error"))
|
60
66
|
client = mock
|
61
67
|
handler = AirbrakeHandler.new(:api_key => "fake")
|
@@ -69,14 +75,16 @@ describe AirbrakeHandler do
|
|
69
75
|
handler.report
|
70
76
|
end
|
71
77
|
|
72
|
-
it "
|
78
|
+
it "ignores exception by message regexp" do
|
73
79
|
handler = AirbrakeHandler.new(:api_key => "fake")
|
74
80
|
handler.ignore << {:class => "Exception", :message => /catch me if you can/}
|
75
81
|
|
76
82
|
assert handler.ignore_exception?(Exception.new("catch me if you can"))
|
77
83
|
end
|
78
84
|
|
79
|
-
|
85
|
+
# params
|
86
|
+
|
87
|
+
it "returns Airbrake params" do
|
80
88
|
node = stub(:name => "node-name", :run_list => "cookbook::recipe")
|
81
89
|
run_status = stub(:node => node, :start_time => Time.mktime(2011,1,1),
|
82
90
|
:end_time => Time.mktime(2011,1,2), :elapsed_time => Time.mktime(2011,1,3))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
17
|
-
requirement: &
|
17
|
+
requirement: &83704960 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.9.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *83704960
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: toadhopper
|
28
|
-
requirement: &
|
28
|
+
requirement: &83704720 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *83704720
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: mocha
|
39
|
-
requirement: &
|
39
|
+
requirement: &83704530 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *83704530
|
48
48
|
description: Chef handler for sending exceptions to Airbrake
|
49
49
|
email:
|
50
50
|
- w.wnetrzak@gmail.com
|
@@ -54,6 +54,7 @@ extra_rdoc_files: []
|
|
54
54
|
files:
|
55
55
|
- .gitignore
|
56
56
|
- .travis.yml
|
57
|
+
- CHANGELOG.md
|
57
58
|
- Gemfile
|
58
59
|
- LICENSE
|
59
60
|
- README.md
|
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
requirements: []
|
84
85
|
rubyforge_project: airbrake_handler
|
85
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.16
|
86
87
|
signing_key:
|
87
88
|
specification_version: 3
|
88
89
|
summary: Chef handler for sending exceptions to Airbrake
|