Module: Contrast::Agent::AtExitHook
- Includes:
- Components::Interface
- Defined in:
- lib/contrast/agent/at_exit_hook.rb
Overview
This module adds an at_exit hook for us to send messages that may be lost at process exit
Class Method Summary collapse
- .exit_hook ⇒ Object
-
.on_exit ⇒ Object
Actions to take when a process exits.
Methods included from Components::Interface
Class Method Details
.exit_hook ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/contrast/agent/at_exit_hook.rb', line 12 def self.exit_hook @_exit_hook ||= begin at_exit do on_exit end true end end |
.on_exit ⇒ Object
Actions to take when a process exits. Typically called from our exit_hook, but exposed here for other process terminations, like those in Kernel#exec
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/contrast/agent/at_exit_hook.rb', line 24 def self.on_exit logger.debug('at_exit invoked, host application terminating', p_id: @pid, pp_id: @ppid, process_pid: Process.pid, process_pp_id: Process.ppid) context = Contrast::Agent::REQUEST_TRACKER.current return unless context Contrast::Agent.messaging_queue.send_event_immediately(context.activity) end |