Module: Datadog::Core::Utils::AtForkMonkeyPatch::ProcessMonkeyPatch

Defined in:
lib/datadog/core/utils/at_fork_monkey_patch.rb

Overview

Adds ‘at_fork` behavior; see parent module for details.

Instance Method Summary collapse

Instance Method Details

#_forkObject

Hook provided by Ruby 3.1+ for observability libraries that want to know about fork, see github.com/ruby/ruby/pull/5017 and bugs.ruby-lang.org/issues/17795



80
81
82
83
84
85
86
# File 'lib/datadog/core/utils/at_fork_monkey_patch.rb', line 80

def _fork
  pid = super

  AtForkMonkeyPatch.run_at_fork_blocks(:child) if pid == 0

  pid
end

#daemon(*args) ⇒ Object

A call to Process.daemon ( rubyapi.org/3.1/o/process#method-c-daemon ) forks the current process and keeps executing code in the child process, killing off the parent, thus effectively replacing it. This is not covered by ‘_fork` and thus we have some extra code for it.



91
92
93
94
95
96
97
# File 'lib/datadog/core/utils/at_fork_monkey_patch.rb', line 91

def daemon(*args)
  result = super

  AtForkMonkeyPatch.run_at_fork_blocks(:child)

  result
end