bugwatch-ruby 0.8.0 → 0.8.1
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 +4 -4
- data/README.md +2 -2
- data/lib/bugwatch/active_job_handler.rb +2 -0
- data/lib/bugwatch/controller_rescue_hook.rb +23 -0
- data/lib/bugwatch/error_subscriber.rb +2 -0
- data/lib/bugwatch/middleware.rb +10 -4
- data/lib/bugwatch/railtie.rb +6 -0
- data/lib/bugwatch/reported_exceptions.rb +19 -0
- data/lib/bugwatch/version.rb +1 -1
- data/lib/bugwatch.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7845d9912f5a403dec979a3457ab7e121a12fb3de870b978d864d8eafb71755
|
|
4
|
+
data.tar.gz: cc43de7851a77523328ca61f5e8b0cd0d4aaa0f9867b3229aa9e34fb04e45a1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d5479d1aa4ea0b1060c06328835f8c11b808389d83656a70121ab78e8ff30887caf828433edc27541d39e91ae76e43a568fa08bbf30e014a9c12246d5b88fb3
|
|
7
|
+
data.tar.gz: 3eb19a7f384614714730f68b07243d98064c4b90cca61b90a92b84a10a817cceabc1a520cf61ffdfcdc806a7deb64f0d7dc6157a7f9e0a9b0724ac809f243afb
|
data/README.md
CHANGED
|
@@ -257,8 +257,8 @@ Sensitive params (`password`, `token`, `secret`, `key`, `auth`, `credit`, `card`
|
|
|
257
257
|
## Publishing
|
|
258
258
|
|
|
259
259
|
```bash
|
|
260
|
-
cd /
|
|
260
|
+
cd gems/bugwatch-ruby
|
|
261
261
|
gem build bugwatch-ruby.gemspec
|
|
262
262
|
gem signin
|
|
263
|
-
gem push bugwatch-ruby-0.
|
|
263
|
+
gem push bugwatch-ruby-0.8.0.gem
|
|
264
264
|
```
|
|
@@ -3,6 +3,7 @@ module Bugwatch
|
|
|
3
3
|
def call(job, exception)
|
|
4
4
|
return if Bugwatch.configuration.ignore?(exception)
|
|
5
5
|
return unless Bugwatch.configuration.notify_for_release_stage?
|
|
6
|
+
return if ReportedExceptions.reported?(exception)
|
|
6
7
|
|
|
7
8
|
payload = ErrorBuilder.new(exception).build
|
|
8
9
|
payload[:context] = {
|
|
@@ -13,6 +14,7 @@ module Bugwatch
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
Notification.new(payload).deliver
|
|
17
|
+
ReportedExceptions.mark(exception)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
private
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Bugwatch
|
|
2
|
+
module ControllerRescueHook
|
|
3
|
+
def rescue_with_handler(exception, **kwargs)
|
|
4
|
+
handler = super
|
|
5
|
+
|
|
6
|
+
if handler && exception.is_a?(Exception) && !ReportedExceptions.reported?(exception)
|
|
7
|
+
begin
|
|
8
|
+
context = {
|
|
9
|
+
handled: true,
|
|
10
|
+
controller: self.class.name,
|
|
11
|
+
action: (action_name if respond_to?(:action_name))
|
|
12
|
+
}.compact
|
|
13
|
+
|
|
14
|
+
Bugwatch.notify(exception, context: context)
|
|
15
|
+
rescue StandardError
|
|
16
|
+
# Never let reporting break the host's rescue flow
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
handler
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -3,6 +3,7 @@ module Bugwatch
|
|
|
3
3
|
def report(error, handled:, severity:, context: {}, source: nil)
|
|
4
4
|
return if Bugwatch.configuration.ignore?(error)
|
|
5
5
|
return unless Bugwatch.configuration.notify_for_release_stage?
|
|
6
|
+
return if ReportedExceptions.reported?(error)
|
|
6
7
|
|
|
7
8
|
payload = ErrorBuilder.new(error).build
|
|
8
9
|
payload[:context] = context.merge(
|
|
@@ -12,6 +13,7 @@ module Bugwatch
|
|
|
12
13
|
).compact
|
|
13
14
|
|
|
14
15
|
Notification.new(payload).deliver
|
|
16
|
+
ReportedExceptions.mark(error)
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
end
|
data/lib/bugwatch/middleware.rb
CHANGED
|
@@ -12,6 +12,7 @@ module Bugwatch
|
|
|
12
12
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
13
13
|
BreadcrumbCollector.clear
|
|
14
14
|
UserContext.clear
|
|
15
|
+
ReportedExceptions.clear
|
|
15
16
|
|
|
16
17
|
config = Bugwatch.configuration
|
|
17
18
|
collecting = config.enable_db_tracking && (rand < config.db_sample_rate)
|
|
@@ -27,10 +28,15 @@ module Bugwatch
|
|
|
27
28
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
28
29
|
duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
begin
|
|
32
|
+
if !Bugwatch.configuration.ignore?(e) && !ReportedExceptions.reported?(e)
|
|
33
|
+
payload = ErrorBuilder.new(e, env).build
|
|
34
|
+
payload[:duration_ms] = duration_ms
|
|
35
|
+
Notification.new(payload).deliver
|
|
36
|
+
ReportedExceptions.mark(e)
|
|
37
|
+
end
|
|
38
|
+
rescue StandardError
|
|
39
|
+
# Never let reporting failures drop the original exception
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
record_transaction(env, 500, start)
|
data/lib/bugwatch/railtie.rb
CHANGED
|
@@ -40,6 +40,12 @@ module Bugwatch
|
|
|
40
40
|
Rails.error.subscribe(Bugwatch::ErrorSubscriber.new)
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
initializer "bugwatch.controller_rescue_hook" do
|
|
45
|
+
ActiveSupport.on_load(:action_controller) do
|
|
46
|
+
prepend Bugwatch::ControllerRescueHook
|
|
47
|
+
end
|
|
48
|
+
end
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
module ControllerMethods
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Bugwatch
|
|
2
|
+
module ReportedExceptions
|
|
3
|
+
THREAD_KEY = :bugwatch_reported_exceptions
|
|
4
|
+
|
|
5
|
+
def self.mark(exception)
|
|
6
|
+
return unless exception
|
|
7
|
+
(Thread.current[THREAD_KEY] ||= []) << exception.object_id
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.reported?(exception)
|
|
11
|
+
return false unless exception
|
|
12
|
+
(Thread.current[THREAD_KEY] || []).include?(exception.object_id)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.clear
|
|
16
|
+
Thread.current[THREAD_KEY] = nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/bugwatch/version.rb
CHANGED
data/lib/bugwatch.rb
CHANGED
|
@@ -6,6 +6,7 @@ require_relative "bugwatch/configuration"
|
|
|
6
6
|
require_relative "bugwatch/user_context"
|
|
7
7
|
require_relative "bugwatch/breadcrumb_collector"
|
|
8
8
|
require_relative "bugwatch/backtrace_cleaner"
|
|
9
|
+
require_relative "bugwatch/reported_exceptions"
|
|
9
10
|
require_relative "bugwatch/error_builder"
|
|
10
11
|
require_relative "bugwatch/report_builder"
|
|
11
12
|
require_relative "bugwatch/notification"
|
|
@@ -22,6 +23,7 @@ require_relative "bugwatch/feedback_helper"
|
|
|
22
23
|
require_relative "bugwatch/middleware"
|
|
23
24
|
require_relative "bugwatch/active_job_handler"
|
|
24
25
|
require_relative "bugwatch/error_subscriber"
|
|
26
|
+
require_relative "bugwatch/controller_rescue_hook"
|
|
25
27
|
require_relative "bugwatch/railtie" if defined?(Rails::Railtie)
|
|
26
28
|
|
|
27
29
|
module Bugwatch
|
|
@@ -37,10 +39,12 @@ module Bugwatch
|
|
|
37
39
|
def notify(exception, context: {})
|
|
38
40
|
return if configuration.ignore?(exception)
|
|
39
41
|
return unless configuration.notify_for_release_stage?
|
|
42
|
+
return if ReportedExceptions.reported?(exception)
|
|
40
43
|
|
|
41
44
|
payload = ErrorBuilder.new(exception).build
|
|
42
45
|
payload.merge!(context)
|
|
43
46
|
Notification.new(payload).deliver
|
|
47
|
+
ReportedExceptions.mark(exception)
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def report(title, category: "other", severity: "warning", tags: {})
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bugwatch-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BugWatch
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
10
|
+
date: 2026-04-22 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: railties
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- lib/bugwatch/backtrace_cleaner.rb
|
|
53
53
|
- lib/bugwatch/breadcrumb_collector.rb
|
|
54
54
|
- lib/bugwatch/configuration.rb
|
|
55
|
+
- lib/bugwatch/controller_rescue_hook.rb
|
|
55
56
|
- lib/bugwatch/db_query_buffer.rb
|
|
56
57
|
- lib/bugwatch/db_query_sender.rb
|
|
57
58
|
- lib/bugwatch/db_tracker.rb
|
|
@@ -66,6 +67,7 @@ files:
|
|
|
66
67
|
- lib/bugwatch/notification.rb
|
|
67
68
|
- lib/bugwatch/railtie.rb
|
|
68
69
|
- lib/bugwatch/report_builder.rb
|
|
70
|
+
- lib/bugwatch/reported_exceptions.rb
|
|
69
71
|
- lib/bugwatch/transaction_buffer.rb
|
|
70
72
|
- lib/bugwatch/transaction_sender.rb
|
|
71
73
|
- lib/bugwatch/user_context.rb
|