Class: StackifyRubyAPM::Spies::SidekiqClientSpy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/spies/sidekiq.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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, **kwargs, &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, **kwargs, &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