Class: XRay::DaemonConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-xray-sdk/daemon_config.rb

Overview

The class that stores X-Ray daemon configuration about the ip address and port for UDP and TCP port. It gets the address string from ‘AWS_XRAY_DAEMON_ADDRESS` and then from recorder’s configuration for ‘daemon_address`. A notation of `127.0.0.1:2000` or `tcp:127.0.0.1:2000 udp:127.0.0.2:2001` are both acceptable. The former one means UDP and TCP are running at the same address. By default it assumes a X-Ray daemon running at `127.0.0.1:2000` listening to both UDP and TCP traffic.

Constant Summary collapse

DAEMON_ADDRESS_KEY =
'AWS_XRAY_DAEMON_ADDRESS'.freeze
@@dafault_addr =
'127.0.0.1:2000'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addr: @@dafault_addr) ⇒ DaemonConfig

Returns a new instance of DaemonConfig.



17
18
19
# File 'lib/aws-xray-sdk/daemon_config.rb', line 17

def initialize(addr: @@dafault_addr)
  update_address(addr)
end

Instance Attribute Details

#tcp_ipObject (readonly)

Returns the value of attribute tcp_ip.



14
15
16
# File 'lib/aws-xray-sdk/daemon_config.rb', line 14

def tcp_ip
  @tcp_ip
end

#tcp_portObject (readonly)

Returns the value of attribute tcp_port.



14
15
16
# File 'lib/aws-xray-sdk/daemon_config.rb', line 14

def tcp_port
  @tcp_port
end

#udp_ipObject (readonly)

Returns the value of attribute udp_ip.



14
15
16
# File 'lib/aws-xray-sdk/daemon_config.rb', line 14

def udp_ip
  @udp_ip
end

#udp_portObject (readonly)

Returns the value of attribute udp_port.



14
15
16
# File 'lib/aws-xray-sdk/daemon_config.rb', line 14

def udp_port
  @udp_port
end

Instance Method Details

#update_address(v) ⇒ Object



21
22
23
24
25
26
# File 'lib/aws-xray-sdk/daemon_config.rb', line 21

def update_address(v)
  v = ENV[DAEMON_ADDRESS_KEY] || v
  update_addr(v)
rescue StandardError
  raise InvalidDaemonAddressError, %(Invalid X-Ray daemon address specified: #{v}.)
end