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.4.2 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.4.1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.4.0 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.7 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.6 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.5 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.4 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.3 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.2 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.0 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/agent/harvester.rb
oneapm_rpm-1.2.9 lib/one_apm/agent/harvester.rb