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:
2026-06-12 08:16:47 +02:00
parent ce8939fffb
commit 52cfffb83f
44 changed files with 1396 additions and 24 deletions

View File

@@ -0,0 +1,33 @@
if ENV["SENTRY_DSN"].present? && !Rails.env.test?
begin
require "sentry-ruby"
require "sentry-rails"
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.breadcrumbs_logger = %i[active_support_logger http_logger]
config.traces_sample_rate = ENV.fetch("SENTRY_TRACES_SAMPLE_RATE", "0.1").to_f
config.environment = Rails.env
config.before_send = lambda do |event, _hint|
Ops::IncidentRecorder.record(
kind: "log_pattern",
severity: "warning",
title: "Sentry: #{event.message}",
message: event.message,
metadata: {
"sentry_event_id" => event.event_id,
"level" => event.level
},
fingerprint: "sentry:#{event.fingerprint&.first || event.event_id}"
)
event
rescue StandardError => e
Rails.logger.warn("[Sentry] ops incident hook: #{e.message}")
event
end
end
rescue LoadError
Rails.logger.warn("[Sentry] gem non installata — imposta SENTRY_DSN dopo bundle add sentry-ruby sentry-rails")
end
end