safely_block 0.4.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9718e09578683dc5b503a61269db28485c4f051f433d799a2696e01ae079df6d
4
- data.tar.gz: b79ada309186f1a78c47f9f255148e12a635a9bcaa798a36507d4a846fa57f2d
3
+ metadata.gz: 41561aad94651ace9d75c8aa81d8dba46a0c07b2a9e180022719d3f575b3f90b
4
+ data.tar.gz: '08ee6e2e7d88734f9d9ca677a6bd31d3fc812ba261a34b9bc9459e35288fcba5'
5
5
  SHA512:
6
- metadata.gz: e32e5d526b3b4464e1141ef6e1a001e6e46c033d753c4377344292e5c2971a1faa72684f503ff7e08273deba056a42f184414f862b89d35e54805005fcc2fb54
7
- data.tar.gz: fc30341cdd15f537dc69ad8e7b16e3aa76579d5a9e2a247e51338a035ef15aa07ce3479573d76f4eb98cbeb6edbd97c5920d2b3ea6cd1389b8cff6c7065cb487
6
+ metadata.gz: 5e1b36ba993e278a61fbe59283e32e59b514b9202a35ef61ac47f7f56be265236774178b70b50c909bd2f265afa8014c1324c6960b8914029baf8a01fe41391f
7
+ data.tar.gz: 8f08c6ba30769717525cfd81e8a9645a975b765da819aae42287d6a75715b57a76fea0169c15ff31956ebad084c070fb4d70b3cc67599f6d545b77106985943a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.0.0 (2026-04-01)
2
+
3
+ - Dropped support for `appsignal` < 3 gem
4
+ - Dropped support for `ddtrace` gem (use `datadog` instead)
5
+ - Dropped support for `sentry-raven` gem (use `sentry-ruby` instead)
6
+ - Dropped support for Ruby < 3.3
7
+
8
+ ## 0.5.0 (2025-05-26)
9
+
10
+ - Dropped support for Ruby < 3.2
11
+
1
12
  ## 0.4.1 (2024-09-04)
2
13
 
3
14
  - Added support for Datadog
@@ -36,3 +47,20 @@
36
47
  - Added `tag` option and tag exception message by default
37
48
  - Added `except` option
38
49
  - Added `silence` option
50
+
51
+ ## 0.0.4 (2015-03-11)
52
+
53
+ - Added fail-safe
54
+
55
+ ## 0.0.3 (2014-08-13)
56
+
57
+ - Added `safely` method
58
+
59
+ ## 0.0.2 (2014-08-12)
60
+
61
+ - Added `default` option
62
+ - Added `only` option
63
+
64
+ ## 0.0.1 (2014-08-12)
65
+
66
+ - First release
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2023 Andrew Kane
1
+ Copyright (c) 2014-2026 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -100,7 +100,7 @@ Reports exceptions to a variety of services out of the box.
100
100
  - [Appsignal](https://appsignal.com/)
101
101
  - [Bugsnag](https://bugsnag.com/)
102
102
  - [Datadog](https://www.datadoghq.com/product/error-tracking/)
103
- - [Exception Notification](https://github.com/smartinez87/exception_notification)
103
+ - [Exception Notification](https://github.com/kmcphillips/exception_notification)
104
104
  - [Google Stackdriver](https://cloud.google.com/stackdriver/)
105
105
  - [Honeybadger](https://www.honeybadger.io/)
106
106
  - [New Relic](https://newrelic.com/)
@@ -125,6 +125,12 @@ By default, exception messages are prefixed with `[safely]`. This makes it easie
125
125
  Safely.tag = false
126
126
  ```
127
127
 
128
+ By default, exceptions are raised in the development and test environments. Change this with:
129
+
130
+ ```ruby
131
+ Safely.raise_envs += ["staging"]
132
+ ```
133
+
128
134
  To report exceptions manually:
129
135
 
130
136
  ```ruby
data/lib/safely/core.rb CHANGED
@@ -1,6 +1,3 @@
1
- # stdlib
2
- require "digest"
3
-
4
1
  # modules
5
2
  require_relative "services"
6
3
  require_relative "version"
@@ -32,7 +29,10 @@ module Safely
32
29
 
33
30
  def throttled?(e, options)
34
31
  return false unless options
35
- key = "#{options[:key] || Digest::MD5.hexdigest([e.class.name, e.message, e.backtrace.join("\n")].join("/"))}/#{(Time.now.to_i / options[:period]) * options[:period]}"
32
+ key = [
33
+ options[:key] || [e.class.name, e.message, e.backtrace.join("\n")].hash,
34
+ (Time.now.to_i / options[:period]) * options[:period]
35
+ ]
36
36
  throttle_counter.clear if throttle_counter.size > 1000 # prevent from growing indefinitely
37
37
  (throttle_counter[key] += 1) > options[:limit]
38
38
  end
@@ -1,15 +1,13 @@
1
1
  module Safely
2
2
  DEFAULT_EXCEPTION_METHOD = proc do |e, info|
3
3
  begin
4
- Airbrake.notify(e, info) if defined?(Airbrake)
4
+ if defined?(Airbrake)
5
+ Airbrake.notify(e, info)
6
+ end
5
7
 
6
8
  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)
9
+ Appsignal.send_error(e) do |transaction|
10
+ transaction.set_tags(info)
13
11
  end
14
12
  end
15
13
 
@@ -24,20 +22,30 @@ module Safely
24
22
  Datadog::Tracing.active_span&.set_error(e)
25
23
  end
26
24
 
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)
25
+ if defined?(ExceptionNotifier)
26
+ ExceptionNotifier.notify_exception(e, data: info)
27
+ end
31
28
 
32
- Honeybadger.notify(e, context: info) if defined?(Honeybadger)
29
+ if defined?(Google::Cloud::ErrorReporting)
30
+ # TODO add info
31
+ Google::Cloud::ErrorReporting.report(e)
32
+ end
33
33
 
34
- NewRelic::Agent.notice_error(e, custom_params: info) if defined?(NewRelic::Agent)
34
+ if defined?(Honeybadger)
35
+ Honeybadger.notify(e, context: info)
36
+ end
35
37
 
36
- Raven.capture_exception(e, extra: info) if defined?(Raven)
38
+ if defined?(NewRelic::Agent)
39
+ NewRelic::Agent.notice_error(e, custom_params: info)
40
+ end
37
41
 
38
- Raygun.track_exception(e, custom_data: info) if defined?(Raygun)
42
+ if defined?(Raygun)
43
+ Raygun.track_exception(e, custom_data: info)
44
+ end
39
45
 
40
- Rollbar.error(e, info) if defined?(Rollbar)
46
+ if defined?(Rollbar)
47
+ Rollbar.error(e, info)
48
+ end
41
49
 
42
50
  if defined?(ScoutApm::Error)
43
51
  # no way to add context for a single call
@@ -45,7 +53,9 @@ module Safely
45
53
  ScoutApm::Error.capture(e)
46
54
  end
47
55
 
48
- Sentry.capture_exception(e, extra: info) if defined?(Sentry)
56
+ if defined?(Sentry)
57
+ Sentry.capture_exception(e, extra: info)
58
+ end
49
59
  rescue => e
50
60
  $stderr.puts "[safely] Error reporting exception: #{e.class.name}: #{e.message}"
51
61
  end
@@ -1,3 +1,3 @@
1
1
  module Safely
2
- VERSION = "0.4.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safely_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email: andrew@ankane.org
15
13
  executables: []
16
14
  extensions: []
@@ -27,7 +25,6 @@ homepage: https://github.com/ankane/safely
27
25
  licenses:
28
26
  - MIT
29
27
  metadata: {}
30
- post_install_message:
31
28
  rdoc_options: []
32
29
  require_paths:
33
30
  - lib
@@ -35,15 +32,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
32
  requirements:
36
33
  - - ">="
37
34
  - !ruby/object:Gem::Version
38
- version: '3'
35
+ version: '3.3'
39
36
  required_rubygems_version: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
40
  version: '0'
44
41
  requirements: []
45
- rubygems_version: 3.5.11
46
- signing_key:
42
+ rubygems_version: 4.0.6
47
43
  specification_version: 4
48
44
  summary: Rescue and report exceptions in non-critical code
49
45
  test_files: []