Class: Jaeger::UdpSender

Inherits:
Object
  • Object
show all
Defined in:
lib/jaeger/udp_sender.rb,
lib/jaeger/udp_sender/transport.rb

Defined Under Namespace

Classes: Transport

Instance Method Summary collapse

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, logger: logger)
  @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 => e
  @logger.error("Failure while sending a batch of spans: #{e}")
end