airbrake_notifying_threads 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +2 -0
- data/airbrake_notifying_threads.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/airbrake_notifying_threads.rb +18 -0
- data/lib/airbrake_notifying_threads/version.rb +3 -0
- data/lib/notifying_thread.rb +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 153fdca170bd3339d17b25b831c48a7361e00ee5
|
4
|
+
data.tar.gz: 1fa2d17af16dda8292b8db6b0750473cfc0c3bc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b957734c39a28f55e1de964e88bcd599232500cd24be7062e214392252afe8d7be724dd96cbcdb0f74617207dbfc341e11d01612b76d8a166d862f8e3c27719
|
7
|
+
data.tar.gz: 333c368176f1170c6d94a708d3c3619ad3f23697a0e4b35006995db6aa9163d52828f23803fb21b50e931170314ee50126015bef149ee232dcafc3a13ed83589
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 alekseyl
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# AirbrakeNotifyingThreads
|
2
|
+
Threads with exception rescue and airbrake notice delivering ( You need to configure airbrake for you application previously ).
|
3
|
+
Add the original stack to the notice, not the thread clear stack.
|
4
|
+
|
5
|
+
Suitable for handling simple one liners, like email.deliver, or some external calls which can be async.
|
6
|
+
|
7
|
+
Do not use it if you are dealing with thread unsafe code.
|
8
|
+
|
9
|
+
# AirbrakeNotifyingThreads (рус)
|
10
|
+
Небольшой инструментик для исполнения коротких асинхронных методов с ловлей эксепшенов и доставкой их через Airbrake.
|
11
|
+
Не стоит использовать, если код не thread safe. Потому что внутри это Thread.
|
12
|
+
|
13
|
+
См. примеры использования.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'airbrake_notifying_threads'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install airbrake_notifying_threads
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class User
|
36
|
+
# Using NotifyingThread class Ex:
|
37
|
+
# devise async mail delivering with threads
|
38
|
+
def send_devise_notification(notification, *args)
|
39
|
+
# don't forget email not sended without deliver
|
40
|
+
message = devise_mailer.send(notification, self, *args)
|
41
|
+
|
42
|
+
# this is the params you want to anylise whgen something crashes here
|
43
|
+
add_to_airbrake_notice = attributes.slice('email', 'name', 'surname', 'cell', 'id')
|
44
|
+
|
45
|
+
# run message delivering
|
46
|
+
NotifyingThread.run_async_with_rescue(add_to_airbrake_notice) { message.deliver }
|
47
|
+
end
|
48
|
+
|
49
|
+
#Using AirbrakeNotifyingThreads module
|
50
|
+
include AirbrakeNotifyingThreads
|
51
|
+
|
52
|
+
# making some external call async, for example push some data in SalesForce app
|
53
|
+
def send_to_sf
|
54
|
+
# sf_params - is the params you want to anylise whgen something crashes here, in this case it's params sended to SF app
|
55
|
+
run_async_with_rescue(sf_params) { send_sf_raw }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
```
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
65
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'airbrake_notifying_threads/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "airbrake_notifying_threads"
|
8
|
+
spec.version = AirbrakeNotifyingThreads::VERSION
|
9
|
+
spec.authors = ["alekseyl"]
|
10
|
+
spec.email = ["leshchuk@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Thread actions with Airbrake notofication.}
|
13
|
+
spec.description = %q{Thread actions with Airbrake notofication.}
|
14
|
+
spec.homepage = "https://github.com/alekseyl/airbrake_notifying_threads"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'airbrake', '>=4'
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "airbrake_notifying_threads"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "airbrake_notifying_threads/version"
|
2
|
+
require 'notifying_thread'
|
3
|
+
require 'airbrake'
|
4
|
+
|
5
|
+
module AirbrakeNotifyingThreads
|
6
|
+
def run_async_with_rescue( airbrake_params = {} )
|
7
|
+
bcktrc = Kernel.caller
|
8
|
+
Thread.new {
|
9
|
+
begin
|
10
|
+
yield
|
11
|
+
rescue => e
|
12
|
+
e.set_backtrace( bcktrc )
|
13
|
+
notice = Airbrake.build_notice(e, airbrake_params)
|
14
|
+
Airbrake.notify(notice) if notice
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: airbrake_notifying_threads
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alekseyl
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: airbrake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
55
|
+
description: Thread actions with Airbrake notofication.
|
56
|
+
email:
|
57
|
+
- leshchuk@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".idea/.name"
|
64
|
+
- ".idea/airbrake_notifying_threads.iml"
|
65
|
+
- ".idea/misc.xml"
|
66
|
+
- ".idea/modules.xml"
|
67
|
+
- ".idea/vcs.xml"
|
68
|
+
- ".idea/workspace.xml"
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- airbrake_notifying_threads.gemspec
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- lib/airbrake_notifying_threads.rb
|
77
|
+
- lib/airbrake_notifying_threads/version.rb
|
78
|
+
- lib/notifying_thread.rb
|
79
|
+
homepage: https://github.com/alekseyl/airbrake_notifying_threads
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata:
|
83
|
+
allowed_push_host: https://rubygems.org
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.5.1
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Thread actions with Airbrake notofication.
|
104
|
+
test_files: []
|