Sha256: 4dcef5b10b1c4f9437e81b99b54ab0b942d585ed89ddd757f18385921ad2578a

Contents?: true

Size: 649 Bytes

Versions: 3

Compression:

Stored size: 649 Bytes

Contents

module Pliny::Sidekiq::Middleware
  module Server
    class Log
      def initialize(_opts={})
      end

      def call(worker, job, queue)
        context = {
          sidekiq: true,
          job:     job['class'],
          job_id:  job['jid'],
        }

        Pliny.context(context) do
          count("worker.#{worker.class.to_s.gsub('::', '.')}")
          count("queue.#{queue}")

          Pliny.log(job: job['class'], job_retry: job['retry']) do
            yield
          end
        end
      end

      private

      def count(key, value=1)
        Pliny::Metrics.count("sidekiq.#{key}", value: value)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pliny-sidekiq-0.3.1 lib/pliny/sidekiq/middleware/server/log.rb
pliny-sidekiq-0.3.0 lib/pliny/sidekiq/middleware/server/log.rb
pliny-sidekiq-0.2.2 lib/pliny/sidekiq/middleware/server/log.rb