Aggiunge monitoraggio ops: health check, log scanner, dashboard e notifiche.
Introduce incidenti con dedup, job Sidekiq ogni 3 min, scan log cron, /up/deep, dashboard /admin/ops e push ntfy; include Sentry opzionale e fix test suite. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
21
backend/config/initializers/ops_log_subscriber.rb
Normal file
21
backend/config/initializers/ops_log_subscriber.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
if Rails.env.production? && ENV["OPS_LOG_SUBSCRIBER"] == "true"
|
||||
ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*args|
|
||||
event = ActiveSupport::Notifications::Event.new(*args)
|
||||
next unless event.payload[:status].to_i >= 500
|
||||
|
||||
Ops::IncidentRecorder.record(
|
||||
kind: "log_pattern",
|
||||
severity: "warning",
|
||||
title: "HTTP 500 in Rails",
|
||||
message: "#{event.payload[:method]} #{event.payload[:path]} → #{event.payload[:status]}",
|
||||
metadata: {
|
||||
"controller" => event.payload[:controller],
|
||||
"action" => event.payload[:action],
|
||||
"status" => event.payload[:status]
|
||||
},
|
||||
fingerprint: "rails_500:#{event.payload[:controller]}##{event.payload[:action]}"
|
||||
)
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn("[Ops::LogSubscriber] #{e.message}")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user