bugsnag-em 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 51834c3e034113b30f503dd1df5dbc8842540f98
4
+ data.tar.gz: 1a9008edb7fc5c66584029033a44df87436280d2
5
+ SHA512:
6
+ metadata.gz: 8d27076021d987c26537e03f616b4f4a31678af0155691be58e36e011eb4032c78392b05d40c43cde2b92ebec33ad8f57105649f4ccd89ff596536d49e44ceda
7
+ data.tar.gz: 2563c80f85bfc86782527a06b39b49c160d0bc121af44dbe38a82abd04fcc859053749fee74a7364eb1460cd68663d4b9703ba2e7e52c0b5cbf9a83c006c1055
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Conrad Irwin <conrad@rapportive.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,100 @@
1
+ Bugsnag notifier for EventMachine
2
+ =================================
3
+
4
+ The Bugsnag notifier for EventMachine makes it easy to track errors and exceptions inside EventMachine, no matter how many callbacks or deferrables you're using!
5
+
6
+ How to Install
7
+ --------------
8
+
9
+ 1. Add the `bugsnag-em` gem to your `Gemfile`
10
+
11
+ ```ruby
12
+ gem "bugsnag-em"
13
+ ```
14
+
15
+ 2. Install the gem
16
+
17
+ ```shell
18
+ bundle install
19
+ ```
20
+
21
+ 3. Configure the Bugsnag module with your API key
22
+
23
+ ```ruby
24
+ Bugsnag.configure do |config|
25
+ config.api_key = "YOUR_API_KEY_HERE"
26
+ end
27
+ ```
28
+
29
+ If you don't configure the api_key, the Bugsnag module will read the
30
+ `BUGSNAG_API_KEY` environment variable.
31
+
32
+ Sending custom data with exceptions
33
+ -----------------------------------
34
+
35
+ The hardest part of handling asynchronous exceptions is to keep track of the context in which they are running. `bugsnag-em` uses [LSpace](https://github.com/ConradIrwin/lspace) under the hood to do so. This enables us to track which contexts callbacks happen in so we don't get muddled by concurrent requests.
36
+
37
+ To set data for a context, you can use `Bugsnag.with`
38
+
39
+ ```ruby
40
+ Bugsnag.with(user: {id: '123'}) do
41
+ http = EM::HttpRequest.new('http://google.com/').get
42
+ http.errback{ raise 'oops' }
43
+ ...
44
+ end
45
+ ```
46
+
47
+ The exception raised in the http callback will be sent to Bugsnag with the user id 123, so you can debug more easily.
48
+
49
+ Keeping the event loop alive
50
+ ----------------------------
51
+
52
+ By default EventMachine terminates the event loop on any unhandled exception. This is to avoid memory leaks caused by crashed connections that will never progress, and callbacks that will never be called.
53
+
54
+ If you would like to keep the event loop alive, and you are sure you can clean up from unhandled exceptions sufficiently, you can use LSpace to add your own exception handler. If you do this then you should either call `Bugsnag.notify` yourself, or re-raise the exception to ensure that the exception reaches Bugsnag.
55
+
56
+ ```ruby
57
+ LSpace.rescue do |e|
58
+ raise unless LSpace[:current_connection]
59
+ puts "Exception in #{LSpace[:session_id]}"
60
+ puts e
61
+ Bugsnag.notify e
62
+ cleanup_connection LSpace[:current_connection]
63
+ end
64
+ ```
65
+
66
+ Further details
67
+ ---------------
68
+
69
+ For further information about the Bugsnag ruby notifier, please see its [README](https://github.com/bugsnag/bugsnag-ruby)
70
+
71
+
72
+ Reporting Bugs or Feature Requests
73
+ ----------------------------------
74
+
75
+ Please report any bugs or feature requests on the github issues page for this
76
+ project here:
77
+
78
+ <https://github.com/bugsnag/bugsnag-em/issues>
79
+
80
+
81
+ Contributing
82
+ ------------
83
+
84
+ - [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-em)
85
+ - Commit and push until you are happy with your contribution
86
+ - Run the tests with `rake spec` and make sure they all pass
87
+ - [Make a pull request](https://help.github.com/articles/using-pull-requests)
88
+ - Thanks!
89
+
90
+
91
+ Build Status
92
+ ------------
93
+ [![Build Status](https://secure.travis-ci.org/bugsnag/bugsnag-em.png)](http://travis-ci.org/bugsnag/bugsnag-em)
94
+
95
+
96
+ License
97
+ -------
98
+
99
+ The Bugsnag EventMachine notifier is free software released under the MIT License.
100
+ See [LICENSE.TXT](https://github.com/bugsnag/bugsnag-em/blob/master/LICENSE.MIT) for details.
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'bugsnag-em'
3
+ gem.version = '0.1'
4
+
5
+ gem.summary = 'A Bugsnag notifier for Eventmachine'
6
+ gem.description = "Let's you rescue errors asynchronously while keeping track of context"
7
+
8
+ gem.authors = ['Conrad Irwin']
9
+ gem.email = %w(conrad@bugsnag.com)
10
+ gem.homepage = 'http://github.com/bugsnag/bugsnag-em'
11
+
12
+ gem.license = 'MIT'
13
+
14
+ gem.add_dependency 'eventmachine'
15
+ gem.add_dependency 'lspace', '>= 0.13'
16
+ gem.add_dependency 'bugsnag'
17
+
18
+ gem.add_development_dependency 'rspec'
19
+ gem.add_development_dependency "bundler"
20
+ gem.add_development_dependency "rake"
21
+ gem.add_development_dependency "pry"
22
+
23
+ gem.files = `git ls-files`.split("\n")
24
+ end
@@ -0,0 +1,13 @@
1
+ require 'bugsnag-em'
2
+
3
+ Bugsnag::configure do |config|
4
+ config.api_key = "066f5ad3590596f9aa8d601ea89af845"
5
+ end
6
+
7
+ EM::run do
8
+ Bugsnag.with(user: {id: 'conrad', email: 'conrad@bugsnag.com'}, details: {foo: :bar}) do
9
+ EM::next_tick do
10
+ raise 'oops'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ require 'bugsnag/em'
@@ -0,0 +1,46 @@
1
+ require 'eventmachine'
2
+ require 'lspace/eventmachine'
3
+ require 'bugsnag'
4
+
5
+ class << Bugsnag
6
+ # With let's you set parameters on future calls to Bugsnag.notify.
7
+ #
8
+ # It uses LSpace to track this data through asynchronous jumps (like
9
+ # making an HTTP request or setting a timer) so that it can be used
10
+ # in a fully eventmachine context.
11
+ #
12
+ # @param [Object] overrides. @see Bugsnag.notify
13
+ #
14
+ # @example
15
+ # Bugsnag.with(user: {id: 'max'}, connection: {remote_ip: '127.0.0.1'}) do
16
+ # EM::next_tick do
17
+ # raise 'oops'
18
+ # end
19
+ # end
20
+ #
21
+ def with(overrides, &block)
22
+ overrides = (LSpace[:bugsnag] || {}).merge overrides
23
+ LSpace.with(bugsnag: overrides, &block)
24
+ end
25
+
26
+ alias_method :notify_without_lspace, :notify
27
+ def notify(exception, overrides=nil, request_data=nil)
28
+ overrides = LSpace[:bugsnag].merge(overrides || {}) if LSpace[:bugsnag]
29
+ notify_without_lspace exception, overrides, request_data
30
+ end
31
+
32
+ alias_method :auto_notify_without_lspace, :notify
33
+ def auto_notify(exception, overrides=nil, request_data=nil)
34
+ overrides = LSpace[:bugsnag].merge(overrides || {}) if LSpace[:bugsnag]
35
+ auto_notify_without_lspace exception, overrides, request_data
36
+ end
37
+ end
38
+
39
+ if EM::reactor_running?
40
+ raise "Please require em-bugsnag before starting the reactor"
41
+ end
42
+
43
+ LSpace.rescue Exception do |e|
44
+ Bugsnag.auto_notify e
45
+ raise
46
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bugsnag-em
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Conrad Irwin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: eventmachine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: lspace
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bugsnag
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Let's you rescue errors asynchronously while keeping track of context
112
+ email:
113
+ - conrad@bugsnag.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.MIT
121
+ - README.md
122
+ - em-imap.gemspec
123
+ - example/example.rb
124
+ - lib/bugsnag-em.rb
125
+ - lib/bugsnag/em.rb
126
+ homepage: http://github.com/bugsnag/bugsnag-em
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.0.3
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: A Bugsnag notifier for Eventmachine
150
+ test_files: []
151
+ has_rdoc: