Class: ScoutApm::ServerIntegrations::Puma

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Puma

Returns a new instance of Puma.



6
7
8
# File 'lib/scout_apm/server_integrations/puma.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/puma.rb', line 4

def logger
  @logger
end

Instance Method Details

#forking?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/scout_apm/server_integrations/puma.rb', line 14

def forking?
  return false unless defined?(::Puma)
  options = ::Puma.cli_config.instance_variable_get(:@options)
  options[:preload_app]
rescue
  false
end

#found?Boolean

Returns:

  • (Boolean)


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

def found?
  true
end

#installObject



26
27
28
29
30
31
32
33
# File 'lib/scout_apm/server_integrations/puma.rb', line 26

def install
  ::Puma.cli_config.options[:before_worker_boot] << Proc.new do
    logger.info "Installing Puma worker loop."
    ScoutApm::Agent.instance.start_background_worker
  end
rescue
  logger.warn "Unable to install Puma worker loop: #{$!.message}"
end

#nameObject



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

def name
  :puma
end

#present?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/scout_apm/server_integrations/puma.rb', line 22

def present?
  defined?(::Puma) && (File.basename($0) =~ /\Apuma/)
end