Sha256: 3a1486494ec9963231adf33a2fd1a9362c4b5b2fe49202ae53de0e50861dd9c7

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

cs__scoped_require 'contrast/components/interface'

module Contrast
  module Agent
    # This module adds an at_exit hook for us to send messages that may be lost at process exit
    module AtExitHook
      include Contrast::Components::Interface
      access_component :logging, :contrast_service

      TERMINATION_NOTICE = 'at_exit invoked, host application terminating'

      def self.exit_hook
        @_exit_hook ||= begin
                          at_exit do
                            logger.debug(TERMINATION_NOTICE)

                            context = Contrast::Agent::REQUEST_TRACKER.current
                            CONTRAST_SERVICE.send_message(context.activity) if context

                            logger.debug(" - current PID  #{ @pid  }")
                            logger.debug(" - current PPID #{ @ppid }")
                            logger.debug(" - process PID  #{ Process.pid  }")
                            logger.debug(" - process PPID #{ Process.ppid }")
                          end
                          true
                        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contrast-agent-3.10.2 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.10.1 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.10.0 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.9.1 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.9.0 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.8.5 lib/contrast/agent/at_exit_hook.rb
contrast-agent-3.8.4 lib/contrast/agent/at_exit_hook.rb