Class: Skywalking::Agent Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skywalking/agent.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

LOCK =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Mutex.new

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Agent

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Agent.



69
70
71
72
73
74
# File 'lib/skywalking/agent.rb', line 69

def initialize(config)
  @plugins = Plugins::PluginsManager.new(config)
  @reporter = Reporter::Report.new(config)

  add_shutdown_hook
end

Class Attribute Details

.agent_configObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



64
65
66
# File 'lib/skywalking/agent.rb', line 64

def agent_config
  @agent_config
end

.loggerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



64
65
66
# File 'lib/skywalking/agent.rb', line 64

def logger
  @logger
end

Instance Attribute Details

#pluginsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



67
68
69
# File 'lib/skywalking/agent.rb', line 67

def plugins
  @plugins
end

#reporterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



67
68
69
# File 'lib/skywalking/agent.rb', line 67

def reporter
  @reporter
end

Class Method Details

.agentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/skywalking/agent.rb', line 31

def agent
  defined?(@agent) && @agent
end

.start(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/skywalking/agent.rb', line 35

def start(config)
  return @agent if @agent

  LOCK.synchronize do
    return @agent if @agent

    config ||= {}
    config = Configuration.new(config) unless config.is_a?(Configuration)

    @logger = config.logger
    @agent_config = config.agent_config
    @agent = new(@agent_config).start!
    config.freeze
  end
end

.started?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


60
61
62
# File 'lib/skywalking/agent.rb', line 60

def started?
  !!(defined?(@agent) && @agent)
end

.stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
54
55
56
57
58
# File 'lib/skywalking/agent.rb', line 51

def stop
  LOCK.synchronize do
    return unless @agent

    @agent&.shutdown
    @agent = nil
  end
end

Instance Method Details

#add_shutdown_hookObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



90
91
92
93
94
95
96
# File 'lib/skywalking/agent.rb', line 90

def add_shutdown_hook
  return unless environment.shutdown_handler_supported?

  at_exit do
    shutdown
  end
end

#environmentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
# File 'lib/skywalking/agent.rb', line 76

def environment
  @environment ||= Skywalking::Environment.instance
end

#shutdownObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
# File 'lib/skywalking/agent.rb', line 86

def shutdown
  @reporter.stop
end

#start!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



80
81
82
83
84
# File 'lib/skywalking/agent.rb', line 80

def start!
  @plugins.init_plugins
  @reporter.init_reporter
  self
end