Sha256: 72dec1c0436c66c721d826240a6a9118d3bdb777edb1cd2654dba364a7e728b2

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 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 Appsignal::Transaction.last_errors.include?(error)

          Appsignal.report_error(error) do |transaction|
            transaction.set_namespace("unhandled")
          end
          Appsignal.stop("at_exit")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
appsignal-4.0.0-java lib/appsignal/hooks/at_exit.rb
appsignal-4.0.0 lib/appsignal/hooks/at_exit.rb
appsignal-4.0.0.beta.2-java lib/appsignal/hooks/at_exit.rb
appsignal-4.0.0.beta.2 lib/appsignal/hooks/at_exit.rb
appsignal-4.0.0.beta.1-java lib/appsignal/hooks/at_exit.rb
appsignal-4.0.0.beta.1 lib/appsignal/hooks/at_exit.rb