module OneApm::Agent::Agent::ForkableDispatcherFunctions

Public Instance Methods

after_fork(options={}) click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 8
def after_fork(options={})
  needs_restart = false
  @after_fork_lock.synchronize do
    needs_restart = @harvester.needs_restart?
    @harvester.mark_started
  end

  return if !needs_restart ||
    !Manager.config[:agent_enabled] ||
    !Manager.config[:monitor_mode] ||
    disconnected?

  OneApm::Manager.logger.debug "Starting the worker thread in #{Process.pid} (parent #{Process.ppid}) after forking."

  channel_id = options[:report_to_channel]
  install_pipe_service(channel_id) if channel_id

  reset_objects_with_locks
  drop_buffered_data

  setup_and_start_agent(options)
end
flush_pipe_data() click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 59
def flush_pipe_data
  if connected? && @service.is_a?(::OneApm::Collector::ForkedProcessService)
    transmit_data
    transmit_event_data
  end
end
install_pipe_service(channel_id) click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 31
def install_pipe_service(channel_id)
  @service = OneApm::Collector::ForkedProcessService.new(channel_id)
  if connected?
    @connected_pid = Process.pid
  else
    OneApm::Manager.logger.debug("Child process #{Process.pid} not reporting to non-connected parent (process #{Process.ppid}).")
    @service.shutdown(Time.now)
    disconnect
  end
end
reset_harvest_locks() click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 53
def reset_harvest_locks
  return if harvest_lock.nil?

  harvest_lock.unlock if harvest_lock.locked?
end
reset_objects_with_locks() click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 48
def reset_objects_with_locks
  @stats_engine = OneApm::Collector::StatsEngine.new
  reset_harvest_locks
end
synchronize_with_harvest() { || ... } click to toggle source
# File lib/one_apm/agent/agent/forkable_dispatcher_functions.rb, line 42
def synchronize_with_harvest
  harvest_lock.synchronize do
    yield
  end
end