Sha256: d41510b7a4f1a7462514e04d285ec834a47fca1ed5fe1f139075c25b426782d7

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    module Tracking
      # Namespace for all the things related to tracking producers
      module Producers
        # Samples for collecting producers related data we're interested in
        class Sampler < Tracking::Sampler
          include ::Karafka::Core::Helpers::Time

          attr_reader :errors

          # Current schema version
          # This can be used in the future for detecting incompatible changes and writing
          # migrations
          SCHEMA_VERSION = '1.0.0'

          def initialize
            super

            @errors = []
            @started_at = float_now
          end

          # We cannot report and track the same time, that is why we use mutex here. To make sure
          # that samples aggregations and counting does not interact with reporter flushing.
          def track
            Reporter::MUTEX.synchronize do
              yield(self)
            end
          end

          # Clears the sampler (for use after data dispatch)
          def clear
            @errors.clear
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
karafka-web-0.7.7 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.6 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.5 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.4 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.3 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.2 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.1 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.7.0 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.6.3 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.6.2 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.6.1 lib/karafka/web/tracking/producers/sampler.rb
karafka-web-0.6.0 lib/karafka/web/tracking/producers/sampler.rb