safely_block 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -6
- data/LICENSE.txt +1 -1
- data/README.md +13 -7
- data/lib/safely/core.rb +5 -6
- data/lib/safely/services.rb +53 -0
- data/lib/safely/version.rb +1 -1
- data/lib/safely_block.rb +1 -1
- metadata +11 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9718e09578683dc5b503a61269db28485c4f051f433d799a2696e01ae079df6d
|
4
|
+
data.tar.gz: b79ada309186f1a78c47f9f255148e12a635a9bcaa798a36507d4a846fa57f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e32e5d526b3b4464e1141ef6e1a001e6e46c033d753c4377344292e5c2971a1faa72684f503ff7e08273deba056a42f184414f862b89d35e54805005fcc2fb54
|
7
|
+
data.tar.gz: fc30341cdd15f537dc69ad8e7b16e3aa76579d5a9e2a247e51338a035ef15aa07ce3479573d76f4eb98cbeb6edbd97c5920d2b3ea6cd1389b8cff6c7065cb487
|
data/CHANGELOG.md
CHANGED
@@ -1,28 +1,37 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.4.1 (2024-09-04)
|
2
|
+
|
3
|
+
- Added support for Datadog
|
4
|
+
|
5
|
+
## 0.4.0 (2023-05-07)
|
6
|
+
|
7
|
+
- Added exception reporting from [Errbase](https://github.com/ankane/errbase)
|
8
|
+
- Dropped support for Ruby < 3
|
9
|
+
|
10
|
+
## 0.3.0 (2019-10-28)
|
2
11
|
|
3
12
|
- Made `safely` method private to behave like `Kernel` methods
|
4
13
|
|
5
|
-
## 0.2.2
|
14
|
+
## 0.2.2 (2019-08-06)
|
6
15
|
|
7
16
|
- Added `context` option
|
8
17
|
|
9
|
-
## 0.2.1
|
18
|
+
## 0.2.1 (2018-02-25)
|
10
19
|
|
11
20
|
- Tag exceptions reported with `report_exception`
|
12
21
|
|
13
|
-
## 0.2.0
|
22
|
+
## 0.2.0 (2017-02-21)
|
14
23
|
|
15
24
|
- Added `tag` option to `safely` method
|
16
25
|
- Switched to keyword arguments
|
17
26
|
- Fixed frozen string error
|
18
27
|
- Fixed tagging with custom error handler
|
19
28
|
|
20
|
-
## 0.1.1
|
29
|
+
## 0.1.1 (2016-05-14)
|
21
30
|
|
22
31
|
- Added `Safely.safely` to not pollute when included in gems
|
23
32
|
- Added `throttle` option
|
24
33
|
|
25
|
-
## 0.1.0
|
34
|
+
## 0.1.0 (2015-03-15)
|
26
35
|
|
27
36
|
- Added `tag` option and tag exception message by default
|
28
37
|
- Added `except` option
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -12,14 +12,14 @@ In development and test environments, exceptions are raised so you can fix them.
|
|
12
12
|
|
13
13
|
[Read more](https://ankane.org/safely-pattern)
|
14
14
|
|
15
|
-
[![Build Status](https://
|
15
|
+
[![Build Status](https://github.com/ankane/safely/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/safely/actions)
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
19
|
Add this line to your application’s Gemfile:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem
|
22
|
+
gem "safely_block"
|
23
23
|
```
|
24
24
|
|
25
25
|
## Use It Everywhere
|
@@ -34,11 +34,11 @@ safely { track_search(params) }
|
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
users.each do |user|
|
37
|
-
safely { update_recommendations(user) }
|
37
|
+
safely(context: {user_id: user.id}) { update_recommendations(user) }
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
41
|
-
Also aliased as `yolo
|
41
|
+
Also aliased as `yolo`
|
42
42
|
|
43
43
|
## Features
|
44
44
|
|
@@ -94,25 +94,31 @@ end
|
|
94
94
|
|
95
95
|
## Reporting
|
96
96
|
|
97
|
-
Reports exceptions to a variety of services out of the box
|
97
|
+
Reports exceptions to a variety of services out of the box.
|
98
98
|
|
99
99
|
- [Airbrake](https://airbrake.io/)
|
100
100
|
- [Appsignal](https://appsignal.com/)
|
101
101
|
- [Bugsnag](https://bugsnag.com/)
|
102
|
+
- [Datadog](https://www.datadoghq.com/product/error-tracking/)
|
102
103
|
- [Exception Notification](https://github.com/smartinez87/exception_notification)
|
103
104
|
- [Google Stackdriver](https://cloud.google.com/stackdriver/)
|
104
105
|
- [Honeybadger](https://www.honeybadger.io/)
|
105
|
-
- [
|
106
|
+
- [New Relic](https://newrelic.com/)
|
106
107
|
- [Raygun](https://raygun.io/)
|
107
108
|
- [Rollbar](https://rollbar.com/)
|
109
|
+
- [Scout APM](https://scoutapm.com/)
|
108
110
|
- [Sentry](https://getsentry.com/)
|
109
111
|
|
112
|
+
**Note:** Context is not supported with Google Stackdriver and Scout APM
|
113
|
+
|
110
114
|
Customize reporting with:
|
111
115
|
|
112
116
|
```ruby
|
113
117
|
Safely.report_exception_method = ->(e) { Rollbar.error(e) }
|
114
118
|
```
|
115
119
|
|
120
|
+
With Rails, you can add this in an initializer.
|
121
|
+
|
116
122
|
By default, exception messages are prefixed with `[safely]`. This makes it easier to spot rescued exceptions. Turn this off with:
|
117
123
|
|
118
124
|
```ruby
|
@@ -160,5 +166,5 @@ To get started with development and testing:
|
|
160
166
|
git clone https://github.com/ankane/safely.git
|
161
167
|
cd safely
|
162
168
|
bundle install
|
163
|
-
rake test
|
169
|
+
bundle exec rake test
|
164
170
|
```
|
data/lib/safely/core.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
require "errbase"
|
1
|
+
# stdlib
|
3
2
|
require "digest"
|
4
3
|
|
4
|
+
# modules
|
5
|
+
require_relative "services"
|
6
|
+
require_relative "version"
|
7
|
+
|
5
8
|
module Safely
|
6
9
|
class << self
|
7
10
|
attr_accessor :raise_envs, :tag, :report_exception_method, :throttle_counter
|
@@ -35,10 +38,6 @@ module Safely
|
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
DEFAULT_EXCEPTION_METHOD = proc do |e, context|
|
39
|
-
Errbase.report(e, context)
|
40
|
-
end
|
41
|
-
|
42
41
|
self.tag = true
|
43
42
|
self.report_exception_method = DEFAULT_EXCEPTION_METHOD
|
44
43
|
self.raise_envs = %w(development test)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Safely
|
2
|
+
DEFAULT_EXCEPTION_METHOD = proc do |e, info|
|
3
|
+
begin
|
4
|
+
Airbrake.notify(e, info) if defined?(Airbrake)
|
5
|
+
|
6
|
+
if defined?(Appsignal)
|
7
|
+
if Appsignal::VERSION.to_i >= 3
|
8
|
+
Appsignal.send_error(e) do |transaction|
|
9
|
+
transaction.set_tags(info)
|
10
|
+
end
|
11
|
+
else
|
12
|
+
Appsignal.send_error(e, info)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if defined?(Bugsnag)
|
17
|
+
Bugsnag.notify(e) do |report|
|
18
|
+
report.add_tab(:info, info) if info.any?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if defined?(Datadog::Tracing)
|
23
|
+
Datadog::Tracing.active_span&.set_tags(info)
|
24
|
+
Datadog::Tracing.active_span&.set_error(e)
|
25
|
+
end
|
26
|
+
|
27
|
+
ExceptionNotifier.notify_exception(e, data: info) if defined?(ExceptionNotifier)
|
28
|
+
|
29
|
+
# TODO add info
|
30
|
+
Google::Cloud::ErrorReporting.report(e) if defined?(Google::Cloud::ErrorReporting)
|
31
|
+
|
32
|
+
Honeybadger.notify(e, context: info) if defined?(Honeybadger)
|
33
|
+
|
34
|
+
NewRelic::Agent.notice_error(e, custom_params: info) if defined?(NewRelic::Agent)
|
35
|
+
|
36
|
+
Raven.capture_exception(e, extra: info) if defined?(Raven)
|
37
|
+
|
38
|
+
Raygun.track_exception(e, custom_data: info) if defined?(Raygun)
|
39
|
+
|
40
|
+
Rollbar.error(e, info) if defined?(Rollbar)
|
41
|
+
|
42
|
+
if defined?(ScoutApm::Error)
|
43
|
+
# no way to add context for a single call
|
44
|
+
# ScoutApm::Context.add(info)
|
45
|
+
ScoutApm::Error.capture(e)
|
46
|
+
end
|
47
|
+
|
48
|
+
Sentry.capture_exception(e, extra: info) if defined?(Sentry)
|
49
|
+
rescue => e
|
50
|
+
$stderr.puts "[safely] Error reporting exception: #{e.class.name}: #{e.message}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/safely/version.rb
CHANGED
data/lib/safely_block.rb
CHANGED
metadata
CHANGED
@@ -1,73 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safely_block
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
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: minitest
|
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
|
-
description:
|
70
|
-
email: andrew@chartkick.com
|
11
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: andrew@ankane.org
|
71
15
|
executables: []
|
72
16
|
extensions: []
|
73
17
|
extra_rdoc_files: []
|
@@ -76,13 +20,14 @@ files:
|
|
76
20
|
- LICENSE.txt
|
77
21
|
- README.md
|
78
22
|
- lib/safely/core.rb
|
23
|
+
- lib/safely/services.rb
|
79
24
|
- lib/safely/version.rb
|
80
25
|
- lib/safely_block.rb
|
81
26
|
homepage: https://github.com/ankane/safely
|
82
27
|
licenses:
|
83
28
|
- MIT
|
84
29
|
metadata: {}
|
85
|
-
post_install_message:
|
30
|
+
post_install_message:
|
86
31
|
rdoc_options: []
|
87
32
|
require_paths:
|
88
33
|
- lib
|
@@ -90,15 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
35
|
requirements:
|
91
36
|
- - ">="
|
92
37
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
38
|
+
version: '3'
|
94
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
40
|
requirements:
|
96
41
|
- - ">="
|
97
42
|
- !ruby/object:Gem::Version
|
98
43
|
version: '0'
|
99
44
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
45
|
+
rubygems_version: 3.5.11
|
46
|
+
signing_key:
|
102
47
|
specification_version: 4
|
103
48
|
summary: Rescue and report exceptions in non-critical code
|
104
49
|
test_files: []
|