Class: ManageEngine::Instrumentation::SidekiqServer

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

Instance Method Summary collapse

Instance Method Details

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



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/agent/server/instrument/sidekiq_server.rb', line 36

def call(worker, msg, queue, *_)
    tracker = nil
    begin
        # https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/chain.rb
        # Check comment section
      jobName = msg["class"]+".perform"
      tracker = ManageEngine::Tracker::RootTracker.new(jobName + " jid: " + msg["jid"])
      tracker.url = jobName
      tracker.setTxnType(ManageEngine::APMObjectHolder.instance.constants.mf_bckgrnd)
      #tracker.addAdditionalInfo(msg)
      tracker = ManageEngine::Agent::TrackerHandler.invokeTracker(tracker)
    rescue Exception=>e
      ManageEngine::APMObjectHolder.instance.log.info "Exception while creating tracker for sidekiq_server #{e}"
    end
    begin
      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
end

#instrumentObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/agent/server/instrument/sidekiq_server.rb', line 22

def instrument
  ::Sidekiq.configure_server do |config|            
    config.server_middleware do |chain|
      chain.add(ManageEngine::Instrumentation::SidekiqServer)
    end
  end
  ::Sidekiq.configure_client do |config|            
      config.client_middleware do |chain|
        chain.add(ManageEngine::Instrumentation::SidekiqClient)
      end
    end
  ManageEngine::APMObjectHolder.instance.log.info "Instrumenting #{name}  Version: #{version}"
end

#nameObject



18
19
20
# File 'lib/agent/server/instrument/sidekiq_server.rb', line 18

def name
  'Sidekiq'
end

#present?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/agent/server/instrument/sidekiq_server.rb', line 10

def present?
 defined?(::Sidekiq::ServerMiddleware)
end

#versionObject



14
15
16
# File 'lib/agent/server/instrument/sidekiq_server.rb', line 14

def version
 Sidekiq::VERSION
end