Sha256: 1638c0c973b5932268500fe6b5246c68ede2b74e6bd6a65cd8387182c392f0de

Contents?: true

Size: 1010 Bytes

Versions: 39

Compression:

Stored size: 1010 Bytes

Contents

# encoding: utf-8

module OneApm
  module Agent
    class Harvester

      attr_accessor :starting_pid

      def initialize(events, after_forker = OneApm::Manager)
        @starting_pid = nil
        @after_forker = after_forker

        if events
          events.subscribe(:start_transaction, &method(:on_transaction))
        end
      end

      def on_transaction(*_)
        return unless restart_in_children_enabled? && needs_restart? && harvest_thread_enabled?

        restart_harvest_thread
      end

      def mark_started(pid = Process.pid)
        @starting_pid = pid
      end

      def needs_restart?(pid = Process.pid)
        @starting_pid != pid
      end

      def restart_in_children_enabled?
        OneApm::Manager.config[:restart_thread_in_children]
      end

      def harvest_thread_enabled?
        !OneApm::Manager.config[:disable_harvest_thread]
      end

      def restart_harvest_thread
        @after_forker.after_fork(:force_reconnect => true)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
oneapm_rpm-1.2.9.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.8 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.7 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.6 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.6.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.5 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.5.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.4 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.4.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.3 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.3.rc2 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.2 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.2.rc lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.1.rc lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.0 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.1.3 lib/one_apm/agent/harvester.rb