Sha256: 74dd267d4e4791f9325b84b9e5cd8bc4d4c628553c0dce4b8688ace7c159548b

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Karafka
  # Namespace for extensions of Karafka core framework instrumentation
  module Instrumentation
    # Additional methods for listener that listen on instrumentation related to the Sidekiq
    # backend of Karafka
    module Listener
      class << self
        # 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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
karafka-sidekiq-backend-1.2.0 lib/karafka/instrumentation/listener.rb
karafka-sidekiq-backend-1.2.0.beta4 lib/karafka/instrumentation/listener.rb
karafka-sidekiq-backend-1.2.0.beta3 lib/karafka/instrumentation/listener.rb
karafka-sidekiq-backend-1.2.0.beta2 lib/karafka/instrumentation/listener.rb
karafka-sidekiq-backend-1.2.0.beta1 lib/karafka/instrumentation/listener.rb