airbrake_handler 0.2.1 → 0.3.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.
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/{README.markdown → README.md} +14 -2
- data/airbrake_handler.gemspec +1 -1
- data/lib/airbrake_handler.rb +10 -3
- data/test/airbrake_notifier_test.rb +50 -2
- metadata +10 -11
- data/.document +0 -5
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Airbrake handler for Chef
|
2
2
|
|
3
|
-
Report [Chef](http://www.opscode.com/chef) exceptions to [Airbrake](http://
|
3
|
+
Report [Chef](http://www.opscode.com/chef) exceptions to [Airbrake](http://airbrake.io)
|
4
4
|
|
5
5
|
Works fine with chef versions: 0.9.x and 0.10.x
|
6
6
|
|
@@ -23,10 +23,22 @@ 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
|
+
If you want to ignore specific exceptions, you can do this like that:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
airbrake_handler = AirbrakeHandler.new(:api_key => "your-airbrake-api-key", :framework_env => "production")
|
30
|
+
airbrake_handler.ignore << {:class => "SystemExit"}
|
31
|
+
airbrake_handler.ignore << {:class => "Errno::ECONNRESET", :message => /Connection reset by peer/}
|
32
|
+
```
|
33
|
+
|
26
34
|
## Continuous Integration
|
27
35
|
|
28
36
|
[](http://travis-ci.org/morgoth/airbrake_handler)
|
29
37
|
|
38
|
+
## Contributors
|
39
|
+
|
40
|
+
* [Anton Mironov](https://github.com/mironov)
|
41
|
+
|
30
42
|
## Copyright
|
31
43
|
|
32
|
-
Copyright (c)
|
44
|
+
Copyright (c) 2012 Adam Jacob, Wojciech Wnętrzak See LICENSE for details.
|
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.3.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,23 +20,30 @@ require "chef/handler"
|
|
20
20
|
require "toadhopper"
|
21
21
|
|
22
22
|
class AirbrakeHandler < Chef::Handler
|
23
|
-
VERSION = "0.
|
23
|
+
VERSION = "0.3.0"
|
24
24
|
|
25
|
-
attr_accessor :options, :api_key
|
25
|
+
attr_accessor :options, :api_key, :ignore
|
26
26
|
|
27
27
|
def initialize(options={})
|
28
28
|
@api_key = options.delete(:api_key)
|
29
|
+
@ignore = options.delete(:ignore) || []
|
29
30
|
@options = options
|
30
31
|
end
|
31
32
|
|
32
33
|
def report
|
33
|
-
if run_status.failed?
|
34
|
+
if run_status.failed? && !ignore_exception?(run_status.exception)
|
34
35
|
Chef::Log.error("Creating Airbrake exception report")
|
35
36
|
|
36
37
|
client.post!(run_status.exception, airbrake_params)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
def ignore_exception?(exception)
|
42
|
+
ignore.any? do |ignore_case|
|
43
|
+
ignore_case[:class] == exception.class.name && (!ignore_case.key?(:message) || !!ignore_case[:message].match(exception.message))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
40
47
|
def airbrake_params
|
41
48
|
{
|
42
49
|
:notifier_name => "Chef Airbrake Notifier", :notifier_version => VERSION, :notifier_url => "https://github.com/morgoth/airbrake_handler",
|
@@ -17,17 +17,65 @@ describe AirbrakeHandler do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should report exception using client" do
|
20
|
-
|
20
|
+
exception = Exception.new
|
21
|
+
run_status = stub(:failed? => true, :exception => exception)
|
21
22
|
client = mock
|
22
23
|
handler = AirbrakeHandler.new(:api_key => "fake")
|
23
24
|
handler.stubs(:run_status).returns(run_status)
|
24
25
|
handler.stubs(:client).returns(client)
|
25
26
|
handler.stubs(:airbrake_params).returns({})
|
26
27
|
|
27
|
-
client.expects(:post!).with(
|
28
|
+
client.expects(:post!).with(exception, {})
|
28
29
|
handler.report
|
29
30
|
end
|
30
31
|
|
32
|
+
it "should not report ignored exception" do
|
33
|
+
run_status = stub(:failed? => true, :exception => Exception.new)
|
34
|
+
client = mock
|
35
|
+
handler = AirbrakeHandler.new(:api_key => "fake")
|
36
|
+
handler.ignore << {:class => "Exception"}
|
37
|
+
handler.stubs(:run_status).returns(run_status)
|
38
|
+
handler.stubs(:client).returns(client)
|
39
|
+
handler.stubs(:airbrake_params).returns({})
|
40
|
+
|
41
|
+
client.expects(:post!).never
|
42
|
+
handler.report
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not report ignored exception with specific message" do
|
46
|
+
run_status = stub(:failed? => true, :exception => Exception.new("error"))
|
47
|
+
client = mock
|
48
|
+
handler = AirbrakeHandler.new(:api_key => "fake")
|
49
|
+
handler.ignore << {:class => "Exception", :message => /error/}
|
50
|
+
handler.stubs(:run_status).returns(run_status)
|
51
|
+
handler.stubs(:client).returns(client)
|
52
|
+
handler.stubs(:airbrake_params).returns({})
|
53
|
+
|
54
|
+
client.expects(:post!).never
|
55
|
+
handler.report
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should report exception if its message doesn't match any message of ignored exceptions" do
|
59
|
+
run_status = stub(:failed? => true, :exception => Exception.new("important error"))
|
60
|
+
client = mock
|
61
|
+
handler = AirbrakeHandler.new(:api_key => "fake")
|
62
|
+
handler.ignore << {:class => "Exception", :message => /not important error/}
|
63
|
+
handler.ignore << {:class => "Exception", :message => /some error/}
|
64
|
+
handler.stubs(:run_status).returns(run_status)
|
65
|
+
handler.stubs(:client).returns(client)
|
66
|
+
handler.stubs(:airbrake_params).returns({})
|
67
|
+
|
68
|
+
client.expects(:post!).once
|
69
|
+
handler.report
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should ignore exception by message regexp" do
|
73
|
+
handler = AirbrakeHandler.new(:api_key => "fake")
|
74
|
+
handler.ignore << {:class => "Exception", :message => /catch me if you can/}
|
75
|
+
|
76
|
+
assert handler.ignore_exception?(Exception.new("catch me if you can"))
|
77
|
+
end
|
78
|
+
|
31
79
|
it "should return Airbrake params" do
|
32
80
|
node = stub(:name => "node-name", :run_list => "cookbook::recipe")
|
33
81
|
run_status = stub(:node => node, :start_time => Time.mktime(2011,1,1),
|
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.3.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:
|
13
|
+
date: 2012-01-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
17
|
-
requirement: &
|
17
|
+
requirement: &72635450 !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: *72635450
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: toadhopper
|
28
|
-
requirement: &
|
28
|
+
requirement: &72634600 !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: *72634600
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: mocha
|
39
|
-
requirement: &
|
39
|
+
requirement: &72634200 !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: *72634200
|
48
48
|
description: Chef handler for sending exceptions to Airbrake
|
49
49
|
email:
|
50
50
|
- w.wnetrzak@gmail.com
|
@@ -52,12 +52,11 @@ executables: []
|
|
52
52
|
extensions: []
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
|
-
- .document
|
56
55
|
- .gitignore
|
57
56
|
- .travis.yml
|
58
57
|
- Gemfile
|
59
58
|
- LICENSE
|
60
|
-
- README.
|
59
|
+
- README.md
|
61
60
|
- Rakefile
|
62
61
|
- airbrake_handler.gemspec
|
63
62
|
- lib/airbrake_handler.rb
|
@@ -83,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
82
|
version: '0'
|
84
83
|
requirements: []
|
85
84
|
rubyforge_project: airbrake_handler
|
86
|
-
rubygems_version: 1.8.
|
85
|
+
rubygems_version: 1.8.15
|
87
86
|
signing_key:
|
88
87
|
specification_version: 3
|
89
88
|
summary: Chef handler for sending exceptions to Airbrake
|