Sha256: d2ac5c2f5af8fe5996901deb0db04a060a0b06dea02adfb74cb329fb0c214429

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

if defined?(::Sidekiq)
  module Appsignal
    module Integrations
      class SidekiqPlugin
        def call(worker, item, queue)
          Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)

          ActiveSupport::Notifications.instrument(
            'perform_job.sidekiq',
            :class => item['class'],
            :method => 'perform',
            :attempts => item['retry_count'],
            :queue => item['queue'],
            :queue_time => (Time.now.to_f - item['enqueued_at'].to_f) * 1000
          ) do
            yield
          end
        rescue Exception => exception
          unless Appsignal.is_ignored_exception?(exception)
            Appsignal::Transaction.current.add_exception(exception)
          end
          raise exception
        ensure
          Appsignal::Transaction.current.complete!
        end
      end
    end
  end

  Sidekiq.configure_server do |config|
    config.server_middleware do |chain|
      chain.add Appsignal::Integrations::SidekiqPlugin
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appsignal-0.8.0.alpha.0 lib/appsignal/integrations/sidekiq.rb