Module: Datadog::Core::Utils::Forking
- Included in:
 - Environment::Identity, Environment::Socket, Telemetry::Component, Telemetry::Emitter, Telemetry::Event, Datadog::Core::Utils, Profiling::Profiler, Profiling::SequenceTracker, Tracing::Context, Tracing::Utils
 
- Defined in:
 - lib/datadog/core/utils/forking.rb
 
Overview
Helper methods for managing forking behavior
Defined Under Namespace
Modules: ClassExtensions
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
      12 13 14 15 16 17 18  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 12 def self.extended(base) # Explicitly update PID here because there's a case where # the code path that lazily updates the PID may not be exercised # until after a fork occurs, thus causing the event to be missed. # By eagerly setting this, we avoid this scenario. base.update_fork_pid! end  | 
  
.included(base) ⇒ Object
      8 9 10  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 8 def self.included(base) base.prepend(ClassExtensions) if base.is_a?(Class) end  | 
  
Instance Method Details
#after_fork! ⇒ Object
      20 21 22 23 24 25 26 27 28  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 20 def after_fork! if forked? yield update_fork_pid! true else false end end  | 
  
#fork_pid ⇒ Object
      38 39 40  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 38 def fork_pid @fork_pid ||= Process.pid end  | 
  
#forked? ⇒ Boolean
      30 31 32  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 30 def forked? Process.pid != fork_pid end  | 
  
#update_fork_pid! ⇒ Object
      34 35 36  | 
    
      # File 'lib/datadog/core/utils/forking.rb', line 34 def update_fork_pid! @fork_pid = Process.pid end  |