Class: XRay::DefaultEmitter
- Inherits:
-
Object
- Object
- XRay::DefaultEmitter
- Defined in:
- lib/aws-xray-sdk/emitter/default_emitter.rb
Overview
The default emitter the X-Ray recorder uses to send segments/subsegments to the X-Ray daemon over UDP using a non-blocking socket.
Constant Summary
Constants included from Emitter
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Instance Method Summary collapse
- #daemon_address=(v) ⇒ Object
-
#initialize ⇒ DefaultEmitter
constructor
A new instance of DefaultEmitter.
-
#send_entity(entity:) ⇒ Object
Serializes a segment/subsegment and sends it to the X-Ray daemon over UDP.
Methods included from Logging
Constructor Details
#initialize ⇒ DefaultEmitter
Returns a new instance of DefaultEmitter.
15 16 17 18 19 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 15 def initialize @socket = UDPSocket.new @address = ENV[DAEMON_ADDRESS_KEY] || '127.0.0.1:2000' configure_socket(@address) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
13 14 15 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 13 def address @address end |
Instance Method Details
#daemon_address=(v) ⇒ Object
35 36 37 38 39 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 35 def daemon_address=(v) v = ENV[DAEMON_ADDRESS_KEY] || v @address = v configure_socket(v) end |
#send_entity(entity:) ⇒ Object
Serializes a segment/subsegment and sends it to the X-Ray daemon over UDP. It is no-op for non-sampled entity.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 24 def send_entity(entity:) return nil unless entity.sampled begin payload = %(#{@@protocol_header}#{@@protocol_delimiter}#{entity.to_json}) logger.debug %(sending payload #{payload} to daemon at #{address}.) @socket.send payload, 0 rescue StandardError => e logger.warn %(failed to send payload due to #{e.}) end end |