Class: ScoutApm::BackgroundJobIntegrations::Sidekiq

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/background_job_integrations/sidekiq.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 4

def logger
  @logger
end

Instance Method Details

#add_middlewareObject



31
32
33
34
35
36
37
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 31

def add_middleware
  ::Sidekiq.configure_server do |config|
    config.server_middleware do |chain|
      chain.add SidekiqMiddleware
    end
  end
end

#forking?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 14

def forking?
  false
end

#installObject



18
19
20
21
22
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 18

def install
  install_tracer
  add_middleware
  install_processor
end

#install_processorObject



39
40
41
42
43
44
45
46
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 39

def install_processor
  ::Sidekiq.configure_server do |config|
    config.on(:startup) do
      agent = ::ScoutApm::Agent.instance
      agent.start
    end
  end
end

#install_tracerObject



24
25
26
27
28
29
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 24

def install_tracer
  # ScoutApm::Tracer is not available when this class is defined
  SidekiqMiddleware.class_eval do
    include ScoutApm::Tracer
  end
end

#nameObject



6
7
8
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 6

def name
  :sidekiq
end

#present?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/scout_apm/background_job_integrations/sidekiq.rb', line 10

def present?
  defined?(::Sidekiq) && File.basename($PROGRAM_NAME).start_with?('sidekiq')
end