newshound 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/.rspec +3 -0
- data/.tool-versions +1 -0
- data/Gemfile +9 -3
- data/README.md +154 -75
- data/TRANSPORT_USAGE.md +117 -0
- data/lib/generators/newshound/install/install_generator.rb +40 -0
- data/lib/generators/newshound/install/templates/newshound.rb +32 -0
- data/lib/newshound/authorization.rb +46 -0
- data/lib/newshound/configuration.rb +12 -11
- data/lib/newshound/exception_reporter.rb +18 -8
- data/lib/newshound/middleware/banner_injector.rb +288 -0
- data/lib/newshound/que_reporter.rb +20 -10
- data/lib/newshound/railtie.rb +32 -36
- data/lib/newshound/version.rb +1 -1
- data/lib/newshound.rb +5 -43
- data/newshound.gemspec +34 -0
- metadata +12 -105
- data/lib/newshound/daily_report_job.rb +0 -19
- data/lib/newshound/scheduler.rb +0 -41
- data/lib/newshound/slack_notifier.rb +0 -61
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: newshound
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- salbanez
|
|
@@ -23,20 +23,6 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '6.0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: slack-ruby-client
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '2.0'
|
|
33
|
-
type: :runtime
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '2.0'
|
|
40
26
|
- !ruby/object:Gem::Dependency
|
|
41
27
|
name: que
|
|
42
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -51,20 +37,6 @@ dependencies:
|
|
|
51
37
|
- - ">="
|
|
52
38
|
- !ruby/object:Gem::Version
|
|
53
39
|
version: '1.0'
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: que-scheduler
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - ">="
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '4.0'
|
|
61
|
-
type: :runtime
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - ">="
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '4.0'
|
|
68
40
|
- !ruby/object:Gem::Dependency
|
|
69
41
|
name: exception-track
|
|
70
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -79,96 +51,31 @@ dependencies:
|
|
|
79
51
|
- - ">="
|
|
80
52
|
- !ruby/object:Gem::Version
|
|
81
53
|
version: '0.1'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '2.0'
|
|
89
|
-
type: :development
|
|
90
|
-
prerelease: false
|
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '2.0'
|
|
96
|
-
- !ruby/object:Gem::Dependency
|
|
97
|
-
name: rake
|
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '13.0'
|
|
103
|
-
type: :development
|
|
104
|
-
prerelease: false
|
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - "~>"
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '13.0'
|
|
110
|
-
- !ruby/object:Gem::Dependency
|
|
111
|
-
name: rspec
|
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '3.0'
|
|
117
|
-
type: :development
|
|
118
|
-
prerelease: false
|
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "~>"
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '3.0'
|
|
124
|
-
- !ruby/object:Gem::Dependency
|
|
125
|
-
name: rubocop
|
|
126
|
-
requirement: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - "~>"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '1.0'
|
|
131
|
-
type: :development
|
|
132
|
-
prerelease: false
|
|
133
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
-
requirements:
|
|
135
|
-
- - "~>"
|
|
136
|
-
- !ruby/object:Gem::Version
|
|
137
|
-
version: '1.0'
|
|
138
|
-
- !ruby/object:Gem::Dependency
|
|
139
|
-
name: pg
|
|
140
|
-
requirement: !ruby/object:Gem::Requirement
|
|
141
|
-
requirements:
|
|
142
|
-
- - ">="
|
|
143
|
-
- !ruby/object:Gem::Version
|
|
144
|
-
version: '0'
|
|
145
|
-
type: :development
|
|
146
|
-
prerelease: false
|
|
147
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
148
|
-
requirements:
|
|
149
|
-
- - ">="
|
|
150
|
-
- !ruby/object:Gem::Version
|
|
151
|
-
version: '0'
|
|
152
|
-
description: Newshound sniffs out exceptions and job statuses in your Rails app and
|
|
153
|
-
reports them daily to Slack
|
|
54
|
+
description: Newshound displays exceptions and job statuses in a collapsible banner
|
|
55
|
+
for authorized users in your Rails app
|
|
154
56
|
email:
|
|
155
57
|
- salbanez@example.com
|
|
156
58
|
executables: []
|
|
157
59
|
extensions: []
|
|
158
60
|
extra_rdoc_files: []
|
|
159
61
|
files:
|
|
62
|
+
- ".rspec"
|
|
63
|
+
- ".tool-versions"
|
|
160
64
|
- Gemfile
|
|
161
65
|
- README.md
|
|
162
66
|
- Rakefile
|
|
67
|
+
- TRANSPORT_USAGE.md
|
|
68
|
+
- lib/generators/newshound/install/install_generator.rb
|
|
69
|
+
- lib/generators/newshound/install/templates/newshound.rb
|
|
163
70
|
- lib/newshound.rb
|
|
71
|
+
- lib/newshound/authorization.rb
|
|
164
72
|
- lib/newshound/configuration.rb
|
|
165
|
-
- lib/newshound/daily_report_job.rb
|
|
166
73
|
- lib/newshound/exception_reporter.rb
|
|
74
|
+
- lib/newshound/middleware/banner_injector.rb
|
|
167
75
|
- lib/newshound/que_reporter.rb
|
|
168
76
|
- lib/newshound/railtie.rb
|
|
169
|
-
- lib/newshound/scheduler.rb
|
|
170
|
-
- lib/newshound/slack_notifier.rb
|
|
171
77
|
- lib/newshound/version.rb
|
|
78
|
+
- newshound.gemspec
|
|
172
79
|
homepage: https://github.com/salbanez/newshound
|
|
173
80
|
licenses:
|
|
174
81
|
- MIT
|
|
@@ -192,5 +99,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
192
99
|
requirements: []
|
|
193
100
|
rubygems_version: 3.6.9
|
|
194
101
|
specification_version: 4
|
|
195
|
-
summary:
|
|
102
|
+
summary: Real-time web UI banner for monitoring Que jobs and exception tracking
|
|
196
103
|
test_files: []
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Newshound
|
|
4
|
-
class DailyReportJob < ::Que::Job
|
|
5
|
-
def run
|
|
6
|
-
return unless Newshound.configuration.valid?
|
|
7
|
-
|
|
8
|
-
Newshound.report!
|
|
9
|
-
|
|
10
|
-
destroy
|
|
11
|
-
rescue StandardError => e
|
|
12
|
-
Rails.logger.error "Newshound::DailyReportJob failed: #{e.message}"
|
|
13
|
-
Rails.logger.error e.backtrace.join("\n")
|
|
14
|
-
|
|
15
|
-
# Re-raise to let Que handle retry logic
|
|
16
|
-
raise
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/newshound/scheduler.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Newshound
|
|
4
|
-
class Scheduler
|
|
5
|
-
def self.schedule_daily_report
|
|
6
|
-
return unless defined?(::Que::Scheduler)
|
|
7
|
-
|
|
8
|
-
config = Newshound.configuration
|
|
9
|
-
return unless config.valid?
|
|
10
|
-
|
|
11
|
-
# Schedule the job using que-scheduler
|
|
12
|
-
# This will be picked up by que-scheduler's configuration
|
|
13
|
-
schedule_config = {
|
|
14
|
-
"newshound_daily_report" => {
|
|
15
|
-
"class" => "Newshound::DailyReportJob",
|
|
16
|
-
"cron" => build_cron_expression(config.report_time),
|
|
17
|
-
"queue" => "default",
|
|
18
|
-
"args" => []
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
# Merge with existing schedule if any
|
|
23
|
-
if defined?(::Que::Scheduler.configuration)
|
|
24
|
-
::Que::Scheduler.configuration.merge!(schedule_config)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
schedule_config
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.build_cron_expression(time_string)
|
|
31
|
-
# Convert "09:00" format to cron expression
|
|
32
|
-
# Format: minute hour * * *
|
|
33
|
-
hour, minute = time_string.split(":").map(&:to_i)
|
|
34
|
-
"#{minute} #{hour} * * *"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.run_now!
|
|
38
|
-
Newshound::DailyReportJob.enqueue
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "slack-ruby-client"
|
|
4
|
-
|
|
5
|
-
module Newshound
|
|
6
|
-
class SlackNotifier
|
|
7
|
-
def initialize
|
|
8
|
-
configure_slack_client
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def post(message)
|
|
12
|
-
return unless valid_configuration?
|
|
13
|
-
|
|
14
|
-
if webhook_configured?
|
|
15
|
-
post_via_webhook(message)
|
|
16
|
-
elsif web_api_configured?
|
|
17
|
-
post_via_web_api(message)
|
|
18
|
-
else
|
|
19
|
-
Rails.logger.error "Newshound: No valid Slack configuration found"
|
|
20
|
-
end
|
|
21
|
-
rescue StandardError => e
|
|
22
|
-
Rails.logger.error "Newshound: Failed to send Slack notification: #{e.message}"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def configure_slack_client
|
|
28
|
-
Slack.configure do |config|
|
|
29
|
-
config.token = ENV["SLACK_API_TOKEN"] if ENV["SLACK_API_TOKEN"]
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def valid_configuration?
|
|
34
|
-
return false unless Newshound.configuration.valid?
|
|
35
|
-
|
|
36
|
-
webhook_configured? || web_api_configured?
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def webhook_configured?
|
|
40
|
-
Newshound.configuration.slack_webhook_url.present?
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def web_api_configured?
|
|
44
|
-
ENV["SLACK_API_TOKEN"].present?
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def post_via_webhook(message)
|
|
48
|
-
client = Slack::Incoming::Webhook.new(Newshound.configuration.slack_webhook_url)
|
|
49
|
-
client.post(message)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def post_via_web_api(message)
|
|
53
|
-
client = Slack::Web::Client.new
|
|
54
|
-
client.chat_postMessage(
|
|
55
|
-
channel: Newshound.configuration.slack_channel,
|
|
56
|
-
blocks: message[:blocks],
|
|
57
|
-
text: "Daily Newshound Report"
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|