Sha256: 1d096c5ca5e80c500139c6d6f211771689d7a20e2cd7b82ed7b440bf674fd6d2
Contents?: true
Size: 1.34 KB
Versions: 14
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Karafka module Web module Tracking # Triggers reporters to report in an async mode in a separate thread # We report this way to prevent any potential dead-locks in cases we would be emitting # statistics during transactions. # # We should never use the notifications thread for sensitive IO bound operations. class Scheduler include ::Karafka::Helpers::Async private # Reports the process state once in a while def call # We won't track more often anyhow but want to try frequently not to miss a window # We need to convert the sleep interval into seconds for sleep sleep_time = ::Karafka::Web.config.tracking.interval.to_f / 1_000 / 10 loop do # Not every reporter may be active at a given stage or in a context of a given process # We select only those that decided that they are active. reporters.select(&:active?).each(&:report) sleep(sleep_time) end end # @return [Array] consumers and producers reporters def reporters @reporters ||= [ ::Karafka::Web.config.tracking.consumers.reporter, ::Karafka::Web.config.tracking.producers.reporter ].freeze end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems