Class: ManageEngine::Instrumentation::SidekiqClient

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::ClientMiddleware
Defined in:
lib/agent/server/instrument/sidekiq_client.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, msg, queue, *_) ⇒ Object



9
10
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
# File 'lib/agent/server/instrument/sidekiq_client.rb', line 9

def call(worker, msg, queue, *_)
    tracker = nil
    result = nil
    begin
        # https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/chain.rb
        # Check comment section
      jobName = msg["class"]
      tracker = ManageEngine::Tracker::DefaultTracker.new("Sidekiq - " + msg["class"] + " - Job Id: " + msg["jid"])
      tracker = ManageEngine::Agent::TrackerHandler.invokeTracker(tracker)
    rescue Exception=>e
      ManageEngine::APMObjectHolder.instance.log.info "Exception while creating tracker for sidekiq_client #{e}"
    end
    begin
      result = yield
    rescue Exception=>e
      if (tracker != nil)
        tracker.setError(e)
      end
      raise e
    ensure
    if tracker != nil
      tracker.finish
      ManageEngine::Agent::TrackerHandler.exitTracker(tracker)
    end
  end
  result
end