debian-mirror-gitlab/debian/gems-compat/jaeger-client-0.10.0/lib/jaeger/udp_sender.rb
2019-03-14 13:21:19 +05:30

24 lines
613 B
Ruby

# frozen_string_literal: true
require_relative './udp_sender/transport'
require 'socket'
module Jaeger
class UdpSender
def initialize(host:, port:, encoder:, logger:)
@encoder = encoder
@logger = logger
transport = Transport.new(host, port)
protocol = ::Thrift::CompactProtocol.new(transport)
@client = Jaeger::Thrift::Agent::Client.new(protocol)
end
def send_spans(spans)
batch = @encoder.encode(spans)
@client.emitBatch(batch)
rescue StandardError => error
@logger.error("Failure while sending a batch of spans: #{error}")
end
end
end