Sha256: aceb9c5185c3bc7fb15cb0ebed46b74310751da2b4378f4cb8add21b299dcce8
Contents?: true
Size: 1.39 KB
Versions: 7
Compression:
Stored size: 1.39 KB
Contents
module PlainApm module Hooks # Rails 7 error notification mechanism class ErrorReporter IGNORED_EXCEPTIONS = [ "Sidekiq::JobRetry::Skip" # Sidekiq uses exceptions for control flow. ].freeze def install begin require "active_support/error_reporter" require "active_support/lazy_load_hooks" rescue LoadError return end # Install the hook when the app is up. This might miss errors that # happen before that, but that's OK. ActiveSupport.on_load(:after_initialize, yield: self, run_once: true) do ::Rails.error.subscribe(self) end end def collect(e, handled:, severity:, context: {}) return if IGNORED_EXCEPTIONS.include?(e.class.name) event = { "source" => "error_subscriber", "name" => "exception", "class" => e.class.name, "message" => e.message, "backtrace" => e.backtrace, "handled" => handled, "severity" => severity, "context" => context } if e.cause event.merge!({ "cause_class" => e.cause.class.name, "cause_message" => e.cause.message, "cause_backtrace" => e.cause.backtrace }) end PlainApm::Agent.collect(event) end alias_method :report, :collect end end end
Version data entries
7 entries across 7 versions & 1 rubygems