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.
Instance Attribute Summary collapse
-
#daemon_config ⇒ Object
Returns the value of attribute daemon_config.
Instance Method Summary collapse
-
#initialize(daemon_config: DaemonConfig.new) ⇒ 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(daemon_config: DaemonConfig.new) ⇒ DefaultEmitter
Returns a new instance of DefaultEmitter.
16 17 18 19 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 16 def initialize(daemon_config: DaemonConfig.new) @socket = UDPSocket.new self.daemon_config = daemon_config end |
Instance Attribute Details
#daemon_config ⇒ Object
Returns the value of attribute daemon_config.
14 15 16 |
# File 'lib/aws-xray-sdk/emitter/default_emitter.rb', line 14 def daemon_config @daemon_config end |
Instance Method Details
#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 |