Module: Langfuse::ExitHook Private

Defined in:
lib/langfuse/exit_hook.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Flushes SDK telemetry during normal process exit.

Class Method Summary collapse

Class Method Details

.disablevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Disable the callback after an explicit shutdown or reset.



34
35
36
# File 'lib/langfuse/exit_hook.rb', line 34

def disable
  mutex.synchronize { @active = false }
end

.enablevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Enable the installed callback for the current SDK lifecycle.



27
28
29
# File 'lib/langfuse/exit_hook.rb', line 27

def enable
  mutex.synchronize { @active = true }
end

.install!void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Install the process callback once and enable it.



14
15
16
17
18
19
20
21
22
# File 'lib/langfuse/exit_hook.rb', line 14

def install!
  mutex.synchronize do
    return if @installed

    Kernel.at_exit { run }
    @installed = true
    @active = false
  end
end

.runvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Run the callback once without allowing shutdown errors to escape.



41
42
43
44
45
46
47
# File 'lib/langfuse/exit_hook.rb', line 41

def run
  return unless consume_active_hook

  Langfuse.shutdown
rescue StandardError => e
  warn_failure(e)
end