Module: OneApm::Probe::InstanceMethods

Included in:
OneApm::Probe
Defined in:
lib/one_apm/probe/instance_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#env=(value) ⇒ Object (writeonly)

Sets the attribute env

Parameters:

  • value

    the value to set the attribute env to.



11
12
13
# File 'lib/one_apm/probe/instance_methods.rb', line 11

def env=(value)
  @env = value
end

#local_envObject (readonly)

Returns the value of attribute local_env.



12
13
14
# File 'lib/one_apm/probe/instance_methods.rb', line 12

def local_env
  @local_env
end

Instance Method Details

#appObject



69
70
71
# File 'lib/one_apm/probe/instance_methods.rb', line 69

def app
  OneApm::Manager.config[:framework]
end

#configure_agent(env, options) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/one_apm/probe/instance_methods.rb', line 52

def configure_agent(env, options)
  manual = OneApm::Configuration::ManualSource.new(options)
  OneApm::Manager.config.replace_or_add_config(manual)
  config_file_path = @config_file_override || OneApm::Manager.config[:config_path]
  OneApm::Manager.config.replace_or_add_config(OneApm::Configuration::YamlSource.new(config_file_path, env))

  if OneApm::Manager.config[:high_security]
    OneApm::Manager.logger.info("Installing high security configuration based on local configuration")
    OneApm::Manager.config.replace_or_add_config(OneApm::Configuration::HighSecuritySource.new(Manager.config))
  end
end

#dispatcherObject



81
82
83
# File 'lib/one_apm/probe/instance_methods.rb', line 81

def dispatcher
  OneApm::Manager.config[:dispatcher]
end

#frameworkObject



73
74
75
# File 'lib/one_apm/probe/instance_methods.rb', line 73

def framework
  OneApm::Manager.config[:framework]
end

#init_plugin(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/one_apm/probe/instance_methods.rb', line 14

def init_plugin(options = {})
  env = options[:env] || self.env

  OneApm::Manager.logger.info("Starting the OneAPM Agent (#{OneApm::VERSION::STRING}) in #{env.inspect} environment.")

  configure_agent(env, options)

  # Be sure to only create once! RUBY-1020
  if OneApm::Manager.logger.is_startup_logger?
    OneApm::Manager.logger = OneApm::Logger::AgentLogger.new(root, options.delete(:log))
  end

  # Merge the stringified options into the config as overrides:
  environment_name = options.delete(:env) and self.env = environment_name

  OneApm::Support::ForkedProcessChannel.listener.start if options.delete(:start_channel_listener)

  # An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
  # methods in the module methods.
  Module.send :include, OneApm::Support::MethodTracer::ClassMethods
  Module.send :include, OneApm::Support::MethodTracer

  init_config(options)

  # initialize agent
  OneApm::Manager.agent = OneApm::Agent::Agent.instance
  OneApm::Manager.agent.start_service

  if OneApm::Manager.config[:agent_enabled] && !OneApm::Manager.agent.started?
    start_agent
    install_instrumentation
  elsif !Manager.config[:agent_enabled]
    install_shim
  else
    detect_dependencies
  end
end

#oneapm_rootObject



85
86
87
# File 'lib/one_apm/probe/instance_methods.rb', line 85

def oneapm_root
  OneApm::Probe.oneapm_root
end

#settingsObject



77
78
79
# File 'lib/one_apm/probe/instance_methods.rb', line 77

def settings
  OneApm::Manager.config.to_collector_hash
end

#start_agentObject

Install the real agent into the Agent module, and issue the start command.



65
66
67
# File 'lib/one_apm/probe/instance_methods.rb', line 65

def start_agent
  OneApm::Manager.agent.start
end