Sha256: 43bdecea1c3103bb8b6b043bb4b8079dd95408340e10c54c69a615ec7928ab56

Contents?: true

Size: 940 Bytes

Versions: 3

Compression:

Stored size: 940 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 !~ /^Harness/
        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

3 entries across 3 versions & 1 rubygems

Version Path
harness-0.2.8 lib/harness/integration/sidekiq.rb
harness-0.2.7 lib/harness/integration/sidekiq.rb
harness-0.2.6 lib/harness/integration/sidekiq.rb