Sha256: 1c8eda3cf9bfab6a244c95c988ced8fc6487ada17aaa14409ac1f888dcc8dcc6

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Karafka
  module Extensions
    # Additional methods for listener that listen on instrumentation related to the Sidekiq
    # backend of Karafka
    module StdoutListener
      # Logs info about scheduling of a certain dataset with a Sidekiq backend
      # @param event [Dry::Events::Event] event details including payload
      def on_backends_sidekiq_process(event)
        count = event[:caller].send(:params_batch).to_a.size
        topic = event[:caller].topic.name
        time = event[:time]
        info "Scheduling of #{count} messages to Sidekiq on topic #{topic} took #{time} ms"
      end

      # Logs ino about processing certain events with a given Sidekiq worker
      # @param event [Dry::Events::Event] event details including payload
      def on_backends_sidekiq_base_worker_perform(event)
        count = event[:consumer].send(:params_batch).to_a.size
        topic = event[:consumer].topic.name
        time = event[:time]
        info "Sidekiq processing of topic #{topic} with #{count} messages took #{time} ms"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
karafka-sidekiq-backend-1.3.1 lib/karafka/extensions/stdout_listener.rb
karafka-sidekiq-backend-1.3.0 lib/karafka/extensions/stdout_listener.rb
karafka-sidekiq-backend-1.3.0.rc1 lib/karafka/extensions/stdout_listener.rb