safely_block 0.5.0 → 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: 6f5740153a2f9f0229fdd5cede2b3944d35af16915785d66b57aa2aaa3b904a1
4
- data.tar.gz: d5d01f34bf00ddb1a83ead7cc8b8e7f54bc5d0c91e2885928bfc68268eaea08b
3
+ metadata.gz: 41561aad94651ace9d75c8aa81d8dba46a0c07b2a9e180022719d3f575b3f90b
4
+ data.tar.gz: '08ee6e2e7d88734f9d9ca677a6bd31d3fc812ba261a34b9bc9459e35288fcba5'
5
5
  SHA512:
6
- metadata.gz: 5ce8c85904830e4602aab2d69f0cb029eca3252c01670a614f311cf1697979bef3ec22de2f3b95832a138347127126d7215ef06be3e3a2ee2ac1e323e65be07f
7
- data.tar.gz: aeb6b97f81efc9d526923c3d05d87201a9a4ddde99222d1dab31f6a3e9d9183ccf32c3b9f2f4de874541140cc2dc206e42b446973859ee7c26a863f4697916d1
6
+ metadata.gz: 5e1b36ba993e278a61fbe59283e32e59b514b9202a35ef61ac47f7f56be265236774178b70b50c909bd2f265afa8014c1324c6960b8914029baf8a01fe41391f
7
+ data.tar.gz: 8f08c6ba30769717525cfd81e8a9645a975b765da819aae42287d6a75715b57a76fea0169c15ff31956ebad084c070fb4d70b3cc67599f6d545b77106985943a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  ## 0.5.0 (2025-05-26)
2
9
 
3
10
  - Dropped support for Ruby < 3.2
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2025 Andrew Kane
1
+ Copyright (c) 2014-2026 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
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.5.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safely_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -32,14 +32,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '3.2'
35
+ version: '3.3'
36
36
  required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubygems_version: 3.6.7
42
+ rubygems_version: 4.0.6
43
43
  specification_version: 4
44
44
  summary: Rescue and report exceptions in non-critical code
45
45
  test_files: []