Sha256: 9c1fbb6707da03511ffc3d6b4a9a5f8e0fd98627c880331a0a4c9a0dfddabe47
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Appsignal class Hooks # @api private class AtExit < Appsignal::Hooks::Hook register :at_exit def dependencies_present? true end def install return unless Appsignal.config[:enable_at_exit_reporter] Kernel.at_exit(&AtExitCallback.method(:call)) end # Report any unhandled errors and will crash the Ruby process. # # If this error was previously reported by any of our instrumentation, # the error will not also be reported here. This way we don't report an # error from a Rake task or instrumented script twice. class AtExitCallback def self.call error = $! # rubocop:disable Style/SpecialGlobalVars return if ignored_error?(error) return if Appsignal::Transaction.last_errors.include?(error) Appsignal.report_error(error) do |transaction| transaction.set_namespace("unhandled") end Appsignal.stop("at_exit") end IGNORED_ERRORS = [ # Normal exits from the application we do not need to report SystemExit ].freeze def self.ignored_error?(error) IGNORED_ERRORS.include?(error.class) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems