resque-sentry 0.1.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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 GoCardless
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # resque-sentry
2
+
3
+ A Resque failure backend that sends errors to [Sentry](https://getsentry.com).
4
+
5
+ ### Installation
6
+
7
+ ```console
8
+ $ gem install resque-sentry
9
+ ```
10
+
11
+ ### Usage
12
+
13
+ Add the following to an initializer:
14
+
15
+ ```ruby
16
+ require 'resque-sentry'
17
+
18
+ Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Sentry]
19
+ Resque::Failure.backend = Resque::Failure::Multiple
20
+ ```
21
+
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'raven'
3
+ rescue LoadError
4
+ raise "Can't find 'sentry-raven' gem. Please add it to your Gemfile or install it."
5
+ end
6
+
7
+ module Resque
8
+ module Failure
9
+ # Failure backend for Sentry (using the raven client gem for Sentry).
10
+ # Similar to the Airbrake backend, this sends exceptions raised in Resque
11
+ # jobs to Sentry. To use, add the following to an initializer:
12
+ #
13
+ # require 'resque/failure/sentry'
14
+ #
15
+ # Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Sentry]
16
+ # Resque::Failure.backend = Resque::Failure::Multiple
17
+ #
18
+ class Sentry < Base
19
+ def save
20
+ event = Raven::Event.capture_exception(exception)
21
+ Raven.send(event) if event
22
+ end
23
+
24
+ def self.count
25
+ # We can't get the total # of errors from Sentry so we fake it by
26
+ # asking Resque how many errors it has seen.
27
+ Stat[:failed]
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1 @@
1
+ require 'resque/failure/sentry'
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'resque-sentry'
3
+ gem.version = '0.1.0'
4
+ gem.authors = ['Harry Marr']
5
+ gem.email = ['harry@gocardless.com']
6
+ gem.summary = 'A failure backend for Resque that sends events to Sentry'
7
+ gem.homepage = 'https://github.com/gocardless/resque-sentry'
8
+
9
+ gem.add_dependency 'resque', '>= 1.18.0'
10
+ gem.add_dependency 'sentry-raven', '>= 0.1'
11
+ gem.add_development_dependency 'rspec', '~> 2.6'
12
+ gem.add_development_dependency 'mocha', '~> 0.11.0'
13
+
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- spec/*`.split("\n")
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Resque::Failure::Sentry do
4
+ it "sends errors to Sentry" do
5
+ exception = StandardError.new("Test Error")
6
+ worker = Resque::Worker.new(:test)
7
+ queue = "test"
8
+ payload = {'class' => Object, 'args' => 1}
9
+
10
+ event = mock
11
+ Raven::Event.expects(:capture_exception).with(exception).returns(event)
12
+ Raven.expects(:send).with(event)
13
+
14
+ backend = Resque::Failure::Sentry.new(exception, worker, queue, payload)
15
+ backend.save
16
+ end
17
+ end
18
+
@@ -0,0 +1,8 @@
1
+ require 'mocha'
2
+ require 'resque'
3
+ require 'resque-sentry'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :mocha
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-sentry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Harry Marr
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: resque
16
+ requirement: &70212326189100 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.18.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70212326189100
25
+ - !ruby/object:Gem::Dependency
26
+ name: sentry-raven
27
+ requirement: &70212326188460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0.1'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70212326188460
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70212326168260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.6'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70212326168260
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: &70212326167340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70212326167340
58
+ description:
59
+ email:
60
+ - harry@gocardless.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - lib/resque-sentry.rb
70
+ - lib/resque/failure/sentry.rb
71
+ - resque-sentry.gemspec
72
+ - spec/sentry_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/gocardless/resque-sentry
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.15
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: A failure backend for Resque that sends events to Sentry
98
+ test_files:
99
+ - spec/sentry_spec.rb
100
+ - spec/spec_helper.rb