Class: Jaeger::UdpSender
- Inherits:
-
Object
- Object
- Jaeger::UdpSender
- Defined in:
- lib/jaeger/udp_sender.rb,
lib/jaeger/udp_sender/transport.rb
Defined Under Namespace
Classes: Transport
Instance Method Summary collapse
-
#initialize(host:, port:, encoder:, logger:, max_packet_size: 65_000) ⇒ UdpSender
constructor
A new instance of UdpSender.
- #send_spans(spans) ⇒ Object
Constructor Details
#initialize(host:, port:, encoder:, logger:, max_packet_size: 65_000) ⇒ UdpSender
Returns a new instance of UdpSender.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jaeger/udp_sender.rb', line 8 def initialize(host:, port:, encoder:, logger:, max_packet_size: 65_000) @encoder = encoder @logger = logger transport = Transport.new(host, port) @protocol_class = ::Thrift::CompactProtocol protocol = @protocol_class.new(transport) @client = Jaeger::Thrift::Agent::Client.new(protocol) @max_packet_size = max_packet_size end |
Instance Method Details
#send_spans(spans) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/jaeger/udp_sender.rb', line 19 def send_spans(spans) batches = @encoder.encode_limited_size(spans, @protocol_class, @max_packet_size) batches.each { |batch| @client.emitBatch(batch) } rescue StandardError => error @logger.error("Failure while sending a batch of spans: #{error}") end |