Class: ScoutApm::ServerIntegrations::Rainbows

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/server_integrations/rainbows.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Rainbows

Returns a new instance of Rainbows.



6
7
8
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 6

def initialize(logger)
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 4

def logger
  @logger
end

Instance Method Details

#forking?Boolean

Returns:

  • (Boolean)


14
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 14

def forking?; true; end

#found?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 35

def found?
  true
end

#installObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 23

def install
  logger.info "Installing Rainbows worker loop."

  Rainbows::HttpServer.class_eval do
    old = instance_method(:worker_loop)
    define_method(:worker_loop) do |worker|
      ScoutApm::Agent.instance.start_background_worker
      old.bind(self).call(worker)
    end
  end
end

#nameObject



10
11
12
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 10

def name
  :rainbows
end

#present?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/scout_apm/server_integrations/rainbows.rb', line 16

def present?
  if defined?(::Rainbows) && defined?(::Rainbows::HttpServer)
    ObjectSpace.each_object(::Rainbows::HttpServer) { |x| return true }
    false
  end
end