oopsie-ruby 0.1.0 → 0.2.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 +4 -4
- data/README.md +26 -5
- data/lib/oopsie/configuration.rb +5 -1
- data/lib/oopsie/railtie.rb +23 -0
- data/lib/oopsie/sidekiq.rb +13 -0
- data/lib/oopsie/version.rb +1 -1
- data/lib/oopsie.rb +15 -0
- metadata +45 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2d2a794e9071d4d51fcf774f4c6e596cd6186e39a7caef5cf7c47e0a005a95b
|
|
4
|
+
data.tar.gz: df721ee268f129ecb9763a6ae279b8dcde65b13e549f424c1828ccf38d7313c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ba4ab51bc0aa284367646fb2c64f0fc1e92d0bc431fb38aed5e62113a37ff0de8f29dac30934f2bae426b08e977093b4462d70df66c51833ff7718100a7f6ff
|
|
7
|
+
data.tar.gz: 1549f750e8df50b2c034a466fb6e648fa9c2119b15929db992e81586a756671807ed2653cdea7b170a2a60bcadd230f094b9be74c103e50f1e2fdc54b39b6a6d
|
data/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Lightweight Ruby gem that reports exceptions to an [Oopsie](https://github.com/jacobespersen/oopsie) instance.
|
|
4
4
|
|
|
5
5
|
- Zero runtime dependencies (uses Ruby stdlib)
|
|
6
|
-
-
|
|
6
|
+
- Automatic error capture in Rails and Rack apps
|
|
7
|
+
- Sidekiq integration for background job errors
|
|
7
8
|
- Manual `Oopsie.report(e)` API
|
|
8
9
|
- Silent failures with optional `on_error` callback
|
|
9
10
|
|
|
@@ -28,6 +29,9 @@ Oopsie.configure do |config|
|
|
|
28
29
|
config.api_key = ENV["OOPSIE_API_KEY"]
|
|
29
30
|
config.endpoint = "https://your-oopsie-instance.com"
|
|
30
31
|
|
|
32
|
+
# Optional: exceptions to ignore (subclasses are also ignored)
|
|
33
|
+
config.ignored_exceptions = [ActiveRecord::RecordNotFound, ActionController::RoutingError]
|
|
34
|
+
|
|
31
35
|
# Optional: called when error reporting itself fails
|
|
32
36
|
config.on_error = ->(e) { Rails.logger.warn("Oopsie error: #{e.message}") }
|
|
33
37
|
end
|
|
@@ -44,22 +48,39 @@ Oopsie.configure do |config|
|
|
|
44
48
|
end
|
|
45
49
|
```
|
|
46
50
|
|
|
51
|
+
## Rails
|
|
52
|
+
|
|
53
|
+
In Rails apps, the gem automatically:
|
|
54
|
+
|
|
55
|
+
- Inserts Rack middleware to capture unhandled exceptions
|
|
56
|
+
- Subscribes to `process_action.action_controller` notifications to capture errors handled by `rescue_from` in controllers and GraphQL schemas
|
|
57
|
+
|
|
58
|
+
No manual middleware setup needed — just add the gem and configure it.
|
|
59
|
+
|
|
47
60
|
## Rack Middleware
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
For non-Rails Rack apps, add the middleware manually:
|
|
50
63
|
|
|
51
64
|
```ruby
|
|
52
65
|
# config.ru
|
|
53
66
|
use Oopsie::Middleware
|
|
54
67
|
```
|
|
55
68
|
|
|
56
|
-
|
|
69
|
+
The middleware reports the error and re-raises it, so your existing error handling is unaffected.
|
|
70
|
+
|
|
71
|
+
## Sidekiq
|
|
72
|
+
|
|
73
|
+
To capture Sidekiq job errors, add the error handler in your Sidekiq server config:
|
|
57
74
|
|
|
58
75
|
```ruby
|
|
59
|
-
|
|
76
|
+
require "oopsie/sidekiq"
|
|
77
|
+
|
|
78
|
+
Sidekiq.configure_server do |config|
|
|
79
|
+
config.error_handlers << Oopsie::Sidekiq::ErrorHandler.new
|
|
80
|
+
end
|
|
60
81
|
```
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
This reports on every job failure attempt, not just when retries are exhausted. Requires Sidekiq 7+.
|
|
63
84
|
|
|
64
85
|
## Manual Reporting
|
|
65
86
|
|
data/lib/oopsie/configuration.rb
CHANGED
|
@@ -4,9 +4,13 @@ module Oopsie
|
|
|
4
4
|
class ConfigurationError < StandardError; end
|
|
5
5
|
|
|
6
6
|
class Configuration
|
|
7
|
-
attr_accessor :api_key, :on_error
|
|
7
|
+
attr_accessor :api_key, :on_error, :ignored_exceptions
|
|
8
8
|
attr_reader :endpoint
|
|
9
9
|
|
|
10
|
+
def initialize
|
|
11
|
+
@ignored_exceptions = []
|
|
12
|
+
end
|
|
13
|
+
|
|
10
14
|
def endpoint=(value)
|
|
11
15
|
@endpoint = value&.chomp('/')
|
|
12
16
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/railtie'
|
|
4
|
+
require 'active_support/isolated_execution_state'
|
|
5
|
+
require 'active_support/notifications'
|
|
6
|
+
|
|
7
|
+
module Oopsie
|
|
8
|
+
class Railtie < Rails::Railtie
|
|
9
|
+
initializer 'oopsie.middleware' do |app|
|
|
10
|
+
unless app.middleware.include?(Oopsie::Middleware)
|
|
11
|
+
app.middleware.insert_before ActionDispatch::ShowExceptions, Oopsie::Middleware
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
initializer 'oopsie.subscribe' do
|
|
16
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |event|
|
|
17
|
+
if (exception = event.payload[:exception_object])
|
|
18
|
+
Oopsie.report(exception)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/oopsie/version.rb
CHANGED
data/lib/oopsie.rb
CHANGED
|
@@ -4,6 +4,7 @@ require_relative 'oopsie/version'
|
|
|
4
4
|
require_relative 'oopsie/configuration'
|
|
5
5
|
require_relative 'oopsie/client'
|
|
6
6
|
require_relative 'oopsie/middleware'
|
|
7
|
+
require_relative 'oopsie/railtie' if defined?(Rails::Railtie)
|
|
7
8
|
|
|
8
9
|
module Oopsie
|
|
9
10
|
class << self
|
|
@@ -20,6 +21,9 @@ module Oopsie
|
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def report(exception)
|
|
24
|
+
return if skip_report?(exception)
|
|
25
|
+
|
|
26
|
+
tag_reported(exception)
|
|
23
27
|
configuration.validate!
|
|
24
28
|
Client.new(configuration).send_error(
|
|
25
29
|
error_class: exception.class.name,
|
|
@@ -32,6 +36,17 @@ module Oopsie
|
|
|
32
36
|
|
|
33
37
|
private
|
|
34
38
|
|
|
39
|
+
def skip_report?(exception)
|
|
40
|
+
configuration.ignored_exceptions.any? { |klass| exception.is_a?(klass) } ||
|
|
41
|
+
exception.instance_variable_get(:@_oopsie_reported)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def tag_reported(exception)
|
|
45
|
+
exception.instance_variable_set(:@_oopsie_reported, true)
|
|
46
|
+
rescue FrozenError
|
|
47
|
+
# Frozen exceptions can't be tagged — skip dedup, proceed with reporting
|
|
48
|
+
end
|
|
49
|
+
|
|
35
50
|
def safely_notify_error(error)
|
|
36
51
|
configuration.on_error&.call(error)
|
|
37
52
|
rescue StandardError
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oopsie-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oopsie
|
|
@@ -9,6 +9,34 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: actionpack
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '7.1'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '7.1'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: activesupport
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '7.1'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '7.1'
|
|
12
40
|
- !ruby/object:Gem::Dependency
|
|
13
41
|
name: bundler
|
|
14
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -37,6 +65,20 @@ dependencies:
|
|
|
37
65
|
- - "~>"
|
|
38
66
|
- !ruby/object:Gem::Version
|
|
39
67
|
version: '2.1'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: railties
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '7.1'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '7.1'
|
|
40
82
|
- !ruby/object:Gem::Dependency
|
|
41
83
|
name: rake
|
|
42
84
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -105,6 +147,8 @@ files:
|
|
|
105
147
|
- lib/oopsie/client.rb
|
|
106
148
|
- lib/oopsie/configuration.rb
|
|
107
149
|
- lib/oopsie/middleware.rb
|
|
150
|
+
- lib/oopsie/railtie.rb
|
|
151
|
+
- lib/oopsie/sidekiq.rb
|
|
108
152
|
- lib/oopsie/version.rb
|
|
109
153
|
homepage: https://github.com/jacobespersen/oopsie-ruby
|
|
110
154
|
licenses:
|