Module: RailsPodKit::ErrorReporter
- Defined in:
- lib/rails_pod_kit/error_reporter.rb
Overview
Where the gem's background work (the SolidQueue scheduler supervisor, the scrape-time metric collectors) sends the errors it swallows. Those errors must never propagate — one would kill the supervising timer or fail the whole /metrics response — but they must not vanish either.
Always logs, and additionally hands the error to the Rails error reporter
when there is one, so the host's Rollbar / Sentry / Datadog subscriber picks
it up. The log line is not redundant: Rails.error.report only fans out to
subscribers, so on an app with none — or with one that is not wired in a
given environment — the failure would otherwise leave no trace at all, and
the only symptom of a broken collector is a gauge quietly serving a stale
value.
Class Method Summary collapse
Class Method Details
.logger ⇒ Object
26 27 28 |
# File 'lib/rails_pod_kit/error_reporter.rb', line 26 def logger ::Rails.logger if defined?(::Rails) && ::Rails.respond_to?(:logger) end |
.rails_reporter ⇒ Object
30 31 32 |
# File 'lib/rails_pod_kit/error_reporter.rb', line 30 def rails_reporter ::Rails.error if defined?(::Rails) && ::Rails.respond_to?(:error) end |
.report(error, source:) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rails_pod_kit/error_reporter.rb', line 19 def report(error, source:) = "[#{source}] #{error.class}: #{error.}" logger ? logger.error() : warn() rails_reporter&.report(error, handled: true, source: source) end |