Module: Contrast::Components::AppContextExtend

Included in:
Contrast::Components::AppContext::Interface
Defined in:
lib/contrast/components/app_context_extend.rb

Overview

A wrapper build around the Common Agent Configuration project to allow for access of the values contained in its parent_configuration_spec.yaml. Specifically, this allows for querying the state of the Application, including the Client, Process, and Server information.

Constant Summary collapse

SUPPORTED_FRAMEWORKS =
%w[rails sinatra grape rack].cs__freeze
SUPPORTED_SERVERS =
%w[passenger puma thin unicorn].cs__freeze

Instance Method Summary collapse

Instance Method Details

#app_and_server_informationObject



23
24
25
26
27
28
# File 'lib/contrast/components/app_context_extend.rb', line 23

def app_and_server_information
  {
      application_info: find_gem_information(SUPPORTED_FRAMEWORKS),
      server_info: find_gem_information(SUPPORTED_SERVERS)
  }
end

#disabled_agent_rake_tasksObject



48
49
50
# File 'lib/contrast/components/app_context_extend.rb', line 48

def disabled_agent_rake_tasks
  ::Contrast::CONFIG.agent.ruby.disabled_agent_rake_tasks
end

#find_gem_information(arr) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/contrast/components/app_context_extend.rb', line 30

def find_gem_information arr
  arr.each do |framework|
    next unless Gem.loaded_specs.key?(framework)

    loaded = Gem.loaded_specs[framework]
    next unless loaded

    name = loaded.instance_variable_get(:@name)
    version = loaded.instance_variable_get(:@version).to_s
    return [name, version].join(' ')
  end
  nil
end

#instrument_middleware_stack?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/contrast/components/app_context_extend.rb', line 44

def instrument_middleware_stack?
  !Contrast::Utils::JobServersRunning.job_servers_running?
end

#pidObject



15
16
17
# File 'lib/contrast/components/app_context_extend.rb', line 15

def pid
  Process.pid
end

#ppidObject



19
20
21
# File 'lib/contrast/components/app_context_extend.rb', line 19

def ppid
  Process.ppid
end