Class: Rookout::ComWs::Information

Inherits:
Object
  • Object
show all
Includes:
Git
Defined in:
lib/rookout/com_ws/information.rb

Constant Summary

Constants included from Git

Git::GIT_CONFIG, Git::GIT_FOLDER, Git::GIT_HEAD, Git::REMOTE_ORIGINS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Git

#find_root, #follow_sym_links, #git?, #remote_origin, #revision

Constructor Details

#initialize(labels, k8s_file_path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace") ⇒ Information

Returns a new instance of Information.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rookout/com_ws/information.rb', line 14

def initialize labels, k8s_file_path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
  @agent_id = nil
  @labels = labels.clone
  @labels["rookout_debug"] = "on" if Config.debug

  k8_namespace = create_cluster_namespace k8s_file_path
  unless k8_namespace == "" || @labels.key?("k8s_namespace")
    @labels["k8s_namespace"] = k8_namespace
  end

  collect_serverless_labels

  @ip_addr = local_ip

  @scm_info = create_scm_information
end

Instance Attribute Details

#agent_idObject

Returns the value of attribute agent_id.



59
60
61
# File 'lib/rookout/com_ws/information.rb', line 59

def agent_id
  @agent_id
end

#labelsObject

Returns the value of attribute labels.



60
61
62
# File 'lib/rookout/com_ws/information.rb', line 60

def labels
  @labels
end

Instance Method Details

#packObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rookout/com_ws/information.rb', line 31

def pack
  version_info = Com::Rookout::VersionInformation.new version: Config.rookout_version,
                                                      commit: Config.rookout_commit

  network_info = Com::Rookout::NetworkInformation.new ip_addr: @ip_addr

  system_info = Com::Rookout::SystemInformation.new hostname: Socket.gethostname,
                                                    os: RUBY_PLATFORM,
                                                    os_version: "",
                                                    distro: "",
                                                    arch: ""

  platform_info = Com::Rookout::PlatformInformation.new platform: "ruby",
                                                        version: RUBY_VERSION,
                                                        variant: RUBY_ENGINE

  Com::Rookout::AgentInformation.new agent_id: @agent_id,
                                     version: version_info,
                                     network: network_info,
                                     system: system_info,
                                     platform: platform_info,
                                     executable: $PROGRAM_NAME,
                                     command_arguments: ARGV,
                                     process_id: Process.pid,
                                     labels: @labels,
                                     scm: @scm_info
end