brokepoint 0.0.0 → 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 +18 -0
- data/lib/brokepoint/middleware.rb +36 -0
- 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 +6 -31
- metadata +45 -15
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
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative './lib/brokepoint/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'brokepoint'
|
5
|
+
s.version = Brokepoint::VERSION
|
6
|
+
s.summary = "Use this gem to capture errors, exceptions, and logs and send them to your Brokepoint install"
|
7
|
+
s.authors = ["Shane P"]
|
8
|
+
s.email = 'shane@shane.computer'
|
9
|
+
s.files = Dir['lib/**/*.rb', '*.gemspec']
|
10
|
+
s.homepage = 'https://rubygems.org/gems/brokepoint'
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.license = nil
|
13
|
+
|
14
|
+
s.metadata = { "rubygems_mfa_required" => "true" }
|
15
|
+
|
16
|
+
s.add_dependency 'zeitwerk', '~> 2.0'
|
17
|
+
s.add_dependency 'railties', '~> 8.0'
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Brokepoint
|
6
|
+
class Middleware
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
|
10
|
+
@notifier = Brokepoint::Notifier.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
begin
|
15
|
+
status, headers, response = @app.call(env)
|
16
|
+
rescue Exception => e
|
17
|
+
send_message_to_brokepoint(e, env)
|
18
|
+
|
19
|
+
raise e
|
20
|
+
end
|
21
|
+
|
22
|
+
[status, headers, response]
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def send_message_to_brokepoint(exception, env)
|
28
|
+
return unless @notifier.should_notify?
|
29
|
+
|
30
|
+
Rails.logger.debug("exception has been noted; #{exception.inspect}")
|
31
|
+
|
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:)
|
34
|
+
end
|
35
|
+
end
|
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
@@ -1,35 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'uri'
|
3
|
-
require 'json'
|
1
|
+
require 'zeitwerk'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
@app = app
|
8
|
-
end
|
3
|
+
loader = Zeitwerk::Loader.for_gem
|
4
|
+
loader.setup
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
status, headers, response = @app.call(env)
|
13
|
-
rescue Exception => e
|
14
|
-
Rails.logger.debug("exception has been noted")
|
15
|
-
send_message_to_brokepoint(e.message, e.full_message)
|
16
|
-
raise e
|
17
|
-
end
|
6
|
+
require_relative "./brokepoint/version"
|
7
|
+
require_relative "./brokepoint/railtie"
|
18
8
|
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def send_message_to_brokepoint(message, stacktrace)
|
25
|
-
brokepoint_installation_address = URI.parse("#{ENV.fetch('BROKEPOINT_URL')}/events")
|
26
|
-
headers = {'Content-Type': 'application/json'}
|
27
|
-
|
28
|
-
error = {
|
29
|
-
title: message,
|
30
|
-
raw_body: stacktrace
|
31
|
-
}
|
32
|
-
|
33
|
-
Net::HTTP.post(brokepoint_installation_address, { event: error }.to_json, headers)
|
34
|
-
end
|
9
|
+
module Brokepoint
|
35
10
|
end
|
metadata
CHANGED
@@ -1,28 +1,58 @@
|
|
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
|
-
- Shane
|
8
|
-
autorequire:
|
7
|
+
- Shane P
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
date: 2025-07-28 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: zeitwerk
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '2.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
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'
|
40
|
+
email: shane@shane.computer
|
16
41
|
executables: []
|
17
42
|
extensions: []
|
18
43
|
extra_rdoc_files: []
|
19
44
|
files:
|
45
|
+
- brokepoint.gemspec
|
20
46
|
- lib/brokepoint.rb
|
21
|
-
|
47
|
+
- lib/brokepoint/middleware.rb
|
48
|
+
- lib/brokepoint/notifier.rb
|
49
|
+
- lib/brokepoint/railtie.rb
|
50
|
+
- lib/brokepoint/version.rb
|
51
|
+
homepage: https://rubygems.org/gems/brokepoint
|
22
52
|
licenses:
|
23
|
-
-
|
24
|
-
metadata:
|
25
|
-
|
53
|
+
-
|
54
|
+
metadata:
|
55
|
+
rubygems_mfa_required: 'true'
|
26
56
|
rdoc_options: []
|
27
57
|
require_paths:
|
28
58
|
- lib
|
@@ -37,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
67
|
- !ruby/object:Gem::Version
|
38
68
|
version: '0'
|
39
69
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
-
signing_key:
|
70
|
+
rubygems_version: 3.6.1
|
42
71
|
specification_version: 4
|
43
|
-
summary:
|
72
|
+
summary: Use this gem to capture errors, exceptions, and logs and send them to your
|
73
|
+
Brokepoint install
|
44
74
|
test_files: []
|