Sha256: 2bf385466324b5b3ae23222c1016449ad6e70ba9b3b50ff2375ec060d6491ffe

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2018

module AgentHooks
  # Used post fork to re-initialize state and restart communications with
  # the host agent.
  #
  def after_fork
    ::Instana.logger.debug "after_fork hook called. Falling back to unannounced state and spawning a new background agent thread."

    @timers.cancel

    # Reseed the random number generator for this
    # new thread.
    srand

    transition_to(:unannounced)

    setup
    spawn_background_thread
  end

  def before_resque_fork
    ::Instana.logger.debug "before_resque_fork hook called. pid/ppid: #{Process.pid}/#{Process.ppid}"
    @is_resque_worker = true
  end

  def after_resque_fork
    ::Instana.logger.debug "after_resque_fork hook called. pid/ppid: #{Process.pid}/#{Process.ppid}"

    @timers.cancel

    # Reseed the random number generator for this
    # new thread.
    srand

    ::Instana.config[:metrics][:enabled] = false

    @process[:pid] = Process.pid

    setup
    spawn_background_thread
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
instana-1.195.4 lib/instana/agent/hooks.rb
instana-1.195.3 lib/instana/agent/hooks.rb
instana-1.195.2 lib/instana/agent/hooks.rb
instana-1.195.1 lib/instana/agent/hooks.rb
instana-1.195.0 lib/instana/agent/hooks.rb
instana-1.193.6 lib/instana/agent/hooks.rb
instana-1.193.5 lib/instana/agent/hooks.rb