Sha256: 2afb74e387d2f4aabd1196cff7720e754519ff5bf1c3a074000915d628fbb1c1

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

module Sidekiq
  module Middleware
    module Server
      class HarnessInstrumentation
        def call(worker_class, item, queue)
          if instrument? worker_class
            options = {}
            options[:gauge] = "#{worker_class.class.to_s.underscore}.sidekiq"
            options[:counter] = "#{worker_class.class.to_s.pluralize.underscore}.sidekiq"

            ActiveSupport::Notifications.instrument "#{worker_class.class.to_s.underscore}.sidekiq", options do
              yield
            end

            ActiveSupport::Notifications.instrument "job.sidekiq", :counter => true
          else
            yield
          end
        end

        private
        def instrument?(worker_class)
          worker_class.to_s !~ /^harness/i
        end
      end
    end
  end
end

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add Sidekiq::Middleware::Server::HarnessInstrumentation
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harness-0.2.11 lib/harness/integration/sidekiq.rb