brokepoint 0.0.1 → 0.0.2
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/brokepoint.gemspec +2 -1
- data/lib/brokepoint/middleware.rb +8 -16
- data/lib/brokepoint/notifier.rb +32 -0
- data/lib/brokepoint/railtie.rb +59 -0
- data/lib/brokepoint/version.rb +3 -0
- data/lib/brokepoint.rb +3 -1
- metadata +19 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '017953988634cfbc7d6a5fcabf22998b407d53a4bf7945469ddde5be8563a867'
|
|
4
|
+
data.tar.gz: b4443e8c305e985ea2131fcfca306acbbdaf6493ebaf7e0f6a836fb9867e8e00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b9f996c077a7b55a2b02f4a6972448dffa75bd12d00b439c9998004b140a290082b629f89bc08e8ad37577404aae016e3f0af9167386df4eaa07c13c0568271
|
|
7
|
+
data.tar.gz: 592a940c7b1d38907ac39db9dbbfaa0e9217e4911c6104412b478ca0dfaa758a796ad8d86b52fca68dc8d51d0d3f98ed46d81f6829266ec0f003030138bf3fe4
|
data/brokepoint.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative 'lib/brokepoint'
|
|
1
|
+
require_relative './lib/brokepoint/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = 'brokepoint'
|
|
@@ -14,4 +14,5 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
s.metadata = { "rubygems_mfa_required" => "true" }
|
|
15
15
|
|
|
16
16
|
s.add_dependency 'zeitwerk', '~> 2.0'
|
|
17
|
+
s.add_dependency 'railties', '~> 8.0'
|
|
17
18
|
end
|
|
@@ -6,16 +6,15 @@ module Brokepoint
|
|
|
6
6
|
class Middleware
|
|
7
7
|
def initialize(app)
|
|
8
8
|
@app = app
|
|
9
|
+
|
|
10
|
+
@notifier = Brokepoint::Notifier.new
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
def call(env)
|
|
12
14
|
begin
|
|
13
15
|
status, headers, response = @app.call(env)
|
|
14
16
|
rescue Exception => e
|
|
15
|
-
|
|
16
|
-
Rails.logger.debug("exception has been noted; #{e.inspect}")
|
|
17
|
-
send_message_to_brokepoint(e.message, e.full_message, env)
|
|
18
|
-
end
|
|
17
|
+
send_message_to_brokepoint(e, env)
|
|
19
18
|
|
|
20
19
|
raise e
|
|
21
20
|
end
|
|
@@ -25,20 +24,13 @@ module Brokepoint
|
|
|
25
24
|
|
|
26
25
|
private
|
|
27
26
|
|
|
28
|
-
def send_message_to_brokepoint(
|
|
29
|
-
|
|
30
|
-
headers = {'Content-Type': 'application/json'}
|
|
27
|
+
def send_message_to_brokepoint(exception, env)
|
|
28
|
+
return unless @notifier.should_notify?
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
name: message,
|
|
34
|
-
raw_body: stacktrace,
|
|
35
|
-
url: [env['rack.url_scheme'], '://', env['HTTP_HOST'], env['REQUEST_URI']].join
|
|
36
|
-
}
|
|
30
|
+
Rails.logger.debug("exception has been noted; #{exception.inspect}")
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
rescue Timeout::Error
|
|
32
|
+
url = [env['rack.url_scheme'], '://', env['HTTP_HOST'], env['REQUEST_URI']].join
|
|
33
|
+
@notifier.notify(name: exception.message, raw_body: exception.full_message, url:)
|
|
42
34
|
end
|
|
43
35
|
end
|
|
44
36
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
|
|
3
|
+
module Brokepoint
|
|
4
|
+
class Notifier
|
|
5
|
+
attr_reader :brokepoint_events_endpoint
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@brokepoint_events_endpoint = URI.parse("#{ENV['BROKEPOINT_URL']}/events")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def should_notify?
|
|
12
|
+
ENV.key?('BROKEPOINT_URL')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def notify(name:, raw_body:, url:)
|
|
16
|
+
return unless should_notify?
|
|
17
|
+
|
|
18
|
+
event = { name:, raw_body:, url: }
|
|
19
|
+
|
|
20
|
+
Timeout.timeout(1) {
|
|
21
|
+
Net::HTTP.post(brokepoint_events_endpoint, { event: }.to_json, default_headers)
|
|
22
|
+
}
|
|
23
|
+
rescue Timeout::Error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def default_headers
|
|
29
|
+
{'Content-Type': 'application/json'}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Brokepoint
|
|
2
|
+
class Railtie < Rails::Railtie
|
|
3
|
+
initializer "brokepoint.action_controller" do
|
|
4
|
+
notifier = Brokepoint::Notifier.new
|
|
5
|
+
|
|
6
|
+
ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*args|
|
|
7
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
|
8
|
+
|
|
9
|
+
if event.payload[:exception_object]
|
|
10
|
+
exception = event.payload[:exception_object]
|
|
11
|
+
|
|
12
|
+
notifier.notify(name: exception.message, raw_body: exception.full_message, url: event.payload[:request].original_url)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
initializer "brokepoint.action_job" do
|
|
18
|
+
notifier = Brokepoint::Notifier.new
|
|
19
|
+
|
|
20
|
+
ActiveSupport::Notifications.subscribe("perform.active_job") do |*args|
|
|
21
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
|
22
|
+
|
|
23
|
+
if event.payload[:exception_object]
|
|
24
|
+
exception = event.payload[:exception_object]
|
|
25
|
+
|
|
26
|
+
notifier.notify(name: exception.message, raw_body: exception.full_message, url: nil)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
initializer "brokepoint.action_job" do
|
|
32
|
+
notifier = Brokepoint::Notifier.new
|
|
33
|
+
|
|
34
|
+
ActiveSupport::Notifications.subscribe("perform.active_job") do |*args|
|
|
35
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
|
36
|
+
|
|
37
|
+
if event.payload[:exception_object]
|
|
38
|
+
exception = event.payload[:exception_object]
|
|
39
|
+
|
|
40
|
+
notifier.notify(name: exception.message, raw_body: exception.full_message, url: nil)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
initializer "brokepoint.action_cable" do
|
|
46
|
+
notifier = Brokepoint::Notifier.new
|
|
47
|
+
|
|
48
|
+
ActiveSupport::Notifications.subscribe("perform_action.action_cable") do |*args|
|
|
49
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
|
50
|
+
|
|
51
|
+
if event.payload[:exception_object]
|
|
52
|
+
exception = event.payload[:exception_object]
|
|
53
|
+
|
|
54
|
+
notifier.notify(name: exception.message, raw_body: exception.full_message, url: nil)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
data/lib/brokepoint.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brokepoint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane P
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-07-
|
|
10
|
+
date: 2025-07-28 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: zeitwerk
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '2.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: railties
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '8.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '8.0'
|
|
26
40
|
email: shane@shane.computer
|
|
27
41
|
executables: []
|
|
28
42
|
extensions: []
|
|
@@ -31,6 +45,9 @@ files:
|
|
|
31
45
|
- brokepoint.gemspec
|
|
32
46
|
- lib/brokepoint.rb
|
|
33
47
|
- lib/brokepoint/middleware.rb
|
|
48
|
+
- lib/brokepoint/notifier.rb
|
|
49
|
+
- lib/brokepoint/railtie.rb
|
|
50
|
+
- lib/brokepoint/version.rb
|
|
34
51
|
homepage: https://rubygems.org/gems/brokepoint
|
|
35
52
|
licenses:
|
|
36
53
|
-
|