class StackifyRubyAPM::Spies::SidekiqClientSpy

@api private

Public Instance Methods

install() click to toggle source
# File lib/stackify_apm/spies/sidekiq.rb, line 11
def install
  Sidekiq::Processor.class_eval do
    alias_method 'process_without_apm', 'process'

    def process(work, *args, &block)
      ret = nil
      begin
        job = nil
        if defined? work.message
          job = work.message
        else
          job = work.job
        end
        job_hash = JSON.parse job
        name = job_hash["class"]
        transaction = StackifyRubyAPM.transaction name, 'TASK'
        ret = process_without_apm(work, *args, &block)
      rescue StackifyRubyAPM::InternalError
        raise # Don't report StackifyRubyAPM errors
      rescue StandardError => e
        StackifyRubyAPM.report e
        raise e
      ensure
        transaction.submit()
      end
      ret
    end
  end
end
process(work, *args, &block) click to toggle source
# File lib/stackify_apm/spies/sidekiq.rb, line 15
def process(work, *args, &block)
  ret = nil
  begin
    job = nil
    if defined? work.message
      job = work.message
    else
      job = work.job
    end
    job_hash = JSON.parse job
    name = job_hash["class"]
    transaction = StackifyRubyAPM.transaction name, 'TASK'
    ret = process_without_apm(work, *args, &block)
  rescue StackifyRubyAPM::InternalError
    raise # Don't report StackifyRubyAPM errors
  rescue StandardError => e
    StackifyRubyAPM.report e
    raise e
  ensure
    transaction.submit()
  end
  ret
end