airbrake-extended 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ec52ddc9bb46636c71f9db08278c5af2fd78e11
4
+ data.tar.gz: 19ed9ca49c538bcfdc2bb890a80c8523f5d770cd
5
+ SHA512:
6
+ metadata.gz: 39b58075b9a7d09069e4ea437c68c45caf7052558124a01a588e5b4216159991e692590acc23b56cc117adafde44b3c1f3347b524253690694cc626459c11774
7
+ data.tar.gz: 300906efd699bc907976724ae16926a596961a9ba6e00e4e50f4275992dfd7c082747ccac73c58e886eb5b0ece66ae0b5b7346aeedb240bd788040cea05d3719
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ # gem "rails"
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ airbrake-extended (0.0.3)
5
+ delayed_job (~> 4.0, >= 4.0.0)
6
+ rails (~> 4.0, >= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.2.0)
12
+ actionpack (= 4.2.0)
13
+ actionview (= 4.2.0)
14
+ activejob (= 4.2.0)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ rails-dom-testing (~> 1.0, >= 1.0.5)
17
+ actionpack (4.2.0)
18
+ actionview (= 4.2.0)
19
+ activesupport (= 4.2.0)
20
+ rack (~> 1.6.0)
21
+ rack-test (~> 0.6.2)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
24
+ actionview (4.2.0)
25
+ activesupport (= 4.2.0)
26
+ builder (~> 3.1)
27
+ erubis (~> 2.7.0)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
30
+ activejob (4.2.0)
31
+ activesupport (= 4.2.0)
32
+ globalid (>= 0.3.0)
33
+ activemodel (4.2.0)
34
+ activesupport (= 4.2.0)
35
+ builder (~> 3.1)
36
+ activerecord (4.2.0)
37
+ activemodel (= 4.2.0)
38
+ activesupport (= 4.2.0)
39
+ arel (~> 6.0)
40
+ activesupport (4.2.0)
41
+ i18n (~> 0.7)
42
+ json (~> 1.7, >= 1.7.7)
43
+ minitest (~> 5.1)
44
+ thread_safe (~> 0.3, >= 0.3.4)
45
+ tzinfo (~> 1.1)
46
+ arel (6.0.0)
47
+ builder (3.2.2)
48
+ delayed_job (4.0.6)
49
+ activesupport (>= 3.0, < 5.0)
50
+ erubis (2.7.0)
51
+ globalid (0.3.0)
52
+ activesupport (>= 4.1.0)
53
+ hike (1.2.3)
54
+ i18n (0.7.0)
55
+ json (1.8.2)
56
+ loofah (2.0.1)
57
+ nokogiri (>= 1.5.9)
58
+ mail (2.6.3)
59
+ mime-types (>= 1.16, < 3)
60
+ mime-types (2.4.3)
61
+ mini_portile (0.6.2)
62
+ minitest (5.5.1)
63
+ multi_json (1.10.1)
64
+ nokogiri (1.6.6.2)
65
+ mini_portile (~> 0.6.0)
66
+ rack (1.6.0)
67
+ rack-test (0.6.3)
68
+ rack (>= 1.0)
69
+ rails (4.2.0)
70
+ actionmailer (= 4.2.0)
71
+ actionpack (= 4.2.0)
72
+ actionview (= 4.2.0)
73
+ activejob (= 4.2.0)
74
+ activemodel (= 4.2.0)
75
+ activerecord (= 4.2.0)
76
+ activesupport (= 4.2.0)
77
+ bundler (>= 1.3.0, < 2.0)
78
+ railties (= 4.2.0)
79
+ sprockets-rails
80
+ rails-deprecated_sanitizer (1.0.3)
81
+ activesupport (>= 4.2.0.alpha)
82
+ rails-dom-testing (1.0.5)
83
+ activesupport (>= 4.2.0.beta, < 5.0)
84
+ nokogiri (~> 1.6.0)
85
+ rails-deprecated_sanitizer (>= 1.0.1)
86
+ rails-html-sanitizer (1.0.1)
87
+ loofah (~> 2.0)
88
+ railties (4.2.0)
89
+ actionpack (= 4.2.0)
90
+ activesupport (= 4.2.0)
91
+ rake (>= 0.8.7)
92
+ thor (>= 0.18.1, < 2.0)
93
+ rake (10.4.2)
94
+ sprockets (2.12.3)
95
+ hike (~> 1.2)
96
+ multi_json (~> 1.0)
97
+ rack (~> 1.0)
98
+ tilt (~> 1.1, != 1.3.0)
99
+ sprockets-rails (2.2.4)
100
+ actionpack (>= 3.0)
101
+ activesupport (>= 3.0)
102
+ sprockets (>= 2.8, < 4.0)
103
+ thor (0.19.1)
104
+ thread_safe (0.3.4)
105
+ tilt (1.4.1)
106
+ tzinfo (1.2.2)
107
+ thread_safe (~> 0.1)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ airbrake-extended!
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Airbrake Extended
2
+
3
+ _Send instance variables from raised exceptions as parameters with Airbrake notifications._
4
+
5
+ ## Install
6
+
7
+ gem 'airbrake-extended'
8
+
9
+
10
+ ### Caveats
11
+
12
+ - Currently only wraps exceptions raised within DelayedJob jobs.
13
+ - Meant to be used in a Rails environment.
14
+
15
+
16
+ Made with ♥ by [@jfeldstein](http://twitter.com/jfeldstein).
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'airbrake-extended'
3
+ s.version = '0.0.3'
4
+ s.date = '2015-03-09'
5
+ s.summary = "Informative Airbrake parameters."
6
+ s.description = "Instance variables from the raised exception are included as parameters in the Airbrake notification. Currently only active in DelayedJob jobs. Meant to be used in a Rails environment."
7
+ s.authors = ["Jordan Feldstein", "@jfeldstein"]
8
+ s.email = 'jfeldstein+gem@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.homepage =
11
+ 'https://github.com/jfeldstein/airbrake-extended'
12
+ s.license = 'MIT'
13
+
14
+ s.add_dependency 'delayed_job', '~> 4.0', '>= 4.0.0'
15
+ s.add_dependency 'rails', '~> 4.0', '>= 4.0.0'
16
+ end
data/lib/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Airbrake Extended
2
+
3
+ _Send instance variables from raised exceptions as parameters with Airbrake notifications._
4
+
5
+ ## Install
6
+
7
+ gem 'airbrake-extended'
8
+
9
+ Automatically patches DelayedJob jobs with its custom notifier.
10
+
11
+
12
+ ### Caveats
13
+
14
+ - Currently only wraps exceptions raised within DelayedJob jobs.
15
+ - Meant to be used in a Rails environment.
16
+
17
+ ### To-Do
18
+
19
+ - Want to patch core Airbrake capture, so that parameters are sent with all errors, not just Delayed Job.
20
+
21
+
22
+ Made with ♥ by [@jfeldstein](http://twitter.com/jfeldstein).
@@ -0,0 +1,3 @@
1
+ require 'delayed_job'
2
+ require 'patches/standard_error'
3
+ require 'patches/delayed_plugin'
@@ -0,0 +1,46 @@
1
+ module Delayed::Plugins::AirbrakeExtended
2
+ class Plugin < ::Delayed::Plugin
3
+ module Notify
4
+ def error(job, exception)
5
+ # rescue if ExceptionNotifier fails for some reason
6
+ begin
7
+ # Default is to include the job_id
8
+ params = {job_id: job.id}
9
+
10
+ # But also include any instance variables set in the exception itself.
11
+ #
12
+ # The is the heart of things. I recommend using custom exception classes
13
+ # which take the objects being worked on when the erorr is raised, and
14
+ # stores them as instance variables. This means when an error occurs, you
15
+ # get to see exactly which instance of a model was being worked on, and
16
+ # exactly what that hash of updates consisted of. Much easier than just the
17
+ # line number and message, or having to write custom begin/rescue/notifiy's
18
+ # everywhere.
19
+ #
20
+ params.merge!(error.airbrake_params) if error.respond_to? :airbrake_params
21
+
22
+ Airbrake.notify_or_ignore(error, parameters: params)
23
+
24
+ rescue Exception => e
25
+ Rails.logger.error "ExceptionNotifier failed: #{e.class.name}: #{e.message}"
26
+
27
+ e.backtrace.each do |f|
28
+ Rails.logger.error " #{f}"
29
+ end
30
+
31
+ Rails.logger.flush
32
+ end
33
+
34
+ super if defined?(super)
35
+ end
36
+ end
37
+
38
+ callbacks do |lifecycle|
39
+ lifecycle.before(:invoke_job) do |job|
40
+ payload = job.payload_object
41
+ payload = payload.object if payload.is_a? Delayed::PerformableMethod
42
+ payload.extend Notify
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,24 @@
1
+ class StandardError
2
+ # Shortcut for .send(:notify_or_ignore, *e.airbrake_args)
3
+ def airbrake_args
4
+ [self, parameters: airbrake_params]
5
+ end
6
+
7
+ # Default is to report all instance variables to Airbrake.
8
+ def airbrake_params
9
+ params = {}
10
+
11
+ begin
12
+ instance_variables.each do |name|
13
+ params[name.to_s] = instance_variable_get(name).try(:as_json)
14
+ end
15
+ rescue StandardError => e
16
+ # In development or test, complain if this goes wrong.
17
+ # In production, don't crash, omitting params instead.
18
+ # Dear user: If your errors stop showing parameters, this may be why.
19
+ raise e if Rails.env.development?
20
+ end
21
+
22
+ params
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: airbrake-extended
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Feldstein
8
+ - '@jfeldstein'
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: delayed_job
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ - - '>='
22
+ - !ruby/object:Gem::Version
23
+ version: 4.0.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '4.0'
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: rails
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 4.0.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ version: '4.0'
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 4.0.0
54
+ description: Instance variables from the raised exception are included as parameters
55
+ in the Airbrake notification. Currently only active in DelayedJob jobs. Meant to
56
+ be used in a Rails environment.
57
+ email: jfeldstein+gem@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - airbrake-extended.gemspec
67
+ - lib/README.md
68
+ - lib/airbrake-extended.rb
69
+ - lib/patches/delayed_plugin.rb
70
+ - lib/patches/standard_error.rb
71
+ homepage: https://github.com/jfeldstein/airbrake-extended
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Informative Airbrake parameters.
95
+ test_files: []