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



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

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

#configure_agent(env, options) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# 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



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

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

#frameworkObject



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

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



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

def oneapm_root
  OneApm::Probe.oneapm_root
end

#settingsObject



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

def settings
  OneApm::Manager.config.to_collector_hash
end

#start_agentObject

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



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

def start_agent
  OneApm::Manager.agent.start
end