safely_block 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffb5e297c082239df9675faa3fb796e46e59c4409754738d3209c791961487a5
4
- data.tar.gz: 56cb3d1229faf04817dbf6d8cfdb210cd91171bbfb65379362a98647b6283441
3
+ metadata.gz: 39809689c7a5c7570d0fd1703d0211a4b677fb8c84bcad78659677eb9077b4ba
4
+ data.tar.gz: c575e5971423655a45aaf7977e00ea71c5f172e33dd27004dd8d00da21507570
5
5
  SHA512:
6
- metadata.gz: 67c689e80de505ba63395e611868074213860b740f470098e6ceb6fdf2bf1768740397905dbf0e31f5000514400562901cfe842b3326556c612ca24edba8215a
7
- data.tar.gz: 5db94cbe2670b3b362646ee84a78872206753adf65e0afd7f85dc9dbe44277defac662afa11bca3318de06ceb5dd4cb03409f8c7d49f85c79b4df8dac7c5b819
6
+ metadata.gz: 5dc08f81d8ebd8246577f9d01cd25a4685d7b005fc54186847f137e34af1bca21aaa73dc020bd94127ed018e6cb9cba49580ce29397e40b4f5fcf1be028491ce
7
+ data.tar.gz: f7eb244c765e0fec4f1c4f2f1d4771258cbc6969c15e00596602a8cfa00bf8f9e4911b80ca72cb333c8d3df05dde1fa2ddc8757729389268202b5c14f0ff283e
data/CHANGELOG.md CHANGED
@@ -1,28 +1,33 @@
1
- ## 0.3.0
1
+ ## 0.4.0 (2023-05-07)
2
+
3
+ - Added exception reporting from [Errbase](https://github.com/ankane/errbase)
4
+ - Dropped support for Ruby < 3
5
+
6
+ ## 0.3.0 (2019-10-28)
2
7
 
3
8
  - Made `safely` method private to behave like `Kernel` methods
4
9
 
5
- ## 0.2.2
10
+ ## 0.2.2 (2019-08-06)
6
11
 
7
12
  - Added `context` option
8
13
 
9
- ## 0.2.1
14
+ ## 0.2.1 (2018-02-25)
10
15
 
11
16
  - Tag exceptions reported with `report_exception`
12
17
 
13
- ## 0.2.0
18
+ ## 0.2.0 (2017-02-21)
14
19
 
15
20
  - Added `tag` option to `safely` method
16
21
  - Switched to keyword arguments
17
22
  - Fixed frozen string error
18
23
  - Fixed tagging with custom error handler
19
24
 
20
- ## 0.1.1
25
+ ## 0.1.1 (2016-05-14)
21
26
 
22
27
  - Added `Safely.safely` to not pollute when included in gems
23
28
  - Added `throttle` option
24
29
 
25
- ## 0.1.0
30
+ ## 0.1.0 (2015-03-15)
26
31
 
27
32
  - Added `tag` option and tag exception message by default
28
33
  - Added `except` option
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2019 Andrew Kane
1
+ Copyright (c) 2014-2023 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
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://travis-ci.org/ankane/safely.svg?branch=master)](https://travis-ci.org/ankane/safely)
15
+ [![Build Status](https://github.com/ankane/safely/workflows/build/badge.svg?branch=master)](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 'safely_block'
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,7 +94,7 @@ end
94
94
 
95
95
  ## Reporting
96
96
 
97
- Reports exceptions to a variety of services out of the box thanks to [Errbase](https://github.com/ankane/errbase).
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/)
@@ -102,17 +102,22 @@ Reports exceptions to a variety of services out of the box thanks to [Errbase](h
102
102
  - [Exception Notification](https://github.com/smartinez87/exception_notification)
103
103
  - [Google Stackdriver](https://cloud.google.com/stackdriver/)
104
104
  - [Honeybadger](https://www.honeybadger.io/)
105
- - [Opbeat](https://opbeat.com/)
105
+ - [New Relic](https://newrelic.com/)
106
106
  - [Raygun](https://raygun.io/)
107
107
  - [Rollbar](https://rollbar.com/)
108
+ - [Scout APM](https://scoutapm.com/)
108
109
  - [Sentry](https://getsentry.com/)
109
110
 
111
+ **Note:** Context is not supported with Google Stackdriver and Scout APM
112
+
110
113
  Customize reporting with:
111
114
 
112
115
  ```ruby
113
116
  Safely.report_exception_method = ->(e) { Rollbar.error(e) }
114
117
  ```
115
118
 
119
+ With Rails, you can add this in an initializer.
120
+
116
121
  By default, exception messages are prefixed with `[safely]`. This makes it easier to spot rescued exceptions. Turn this off with:
117
122
 
118
123
  ```ruby
@@ -160,5 +165,5 @@ To get started with development and testing:
160
165
  git clone https://github.com/ankane/safely.git
161
166
  cd safely
162
167
  bundle install
163
- rake test
168
+ bundle exec rake test
164
169
  ```
data/lib/safely/core.rb CHANGED
@@ -1,7 +1,10 @@
1
- require "safely/version"
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,48 @@
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
+ ExceptionNotifier.notify_exception(e, data: info) if defined?(ExceptionNotifier)
23
+
24
+ # TODO add info
25
+ Google::Cloud::ErrorReporting.report(e) if defined?(Google::Cloud::ErrorReporting)
26
+
27
+ Honeybadger.notify(e, context: info) if defined?(Honeybadger)
28
+
29
+ NewRelic::Agent.notice_error(e, custom_params: info) if defined?(NewRelic::Agent)
30
+
31
+ Raven.capture_exception(e, extra: info) if defined?(Raven)
32
+
33
+ Raygun.track_exception(e, custom_data: info) if defined?(Raygun)
34
+
35
+ Rollbar.error(e, info) if defined?(Rollbar)
36
+
37
+ if defined?(ScoutApm::Error)
38
+ # no way to add context for a single call
39
+ # ScoutApm::Context.add(info)
40
+ ScoutApm::Error.capture(e)
41
+ end
42
+
43
+ Sentry.capture_exception(e, extra: info) if defined?(Sentry)
44
+ rescue => e
45
+ $stderr.puts "[safely] Error reporting exception: #{e.class.name}: #{e.message}"
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module Safely
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/safely_block.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "safely/core"
1
+ require_relative "safely/core"
2
2
 
3
3
  Object.include Safely::Methods
4
4
  Object.send :private, :safely, :yolo
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.3.0
4
+ version: 0.4.0
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: 2019-10-28 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: errbase
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: 2023-05-08 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: '2.4'
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.0.3
101
- signing_key:
45
+ rubygems_version: 3.4.10
46
+ signing_key:
102
47
  specification_version: 4
103
48
  summary: Rescue and report exceptions in non-critical code
104
49
  test_files: []