Sha256: 798655d5877f067df9361a79627874a4795e4d72f30a74a90a537bc4c465f174

Contents?: true

Size: 779 Bytes

Versions: 3

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

module Jaeger
  class UdpSender
    class Transport
      FLAGS = 0

      def initialize(host, port)
        @socket = UDPSocket.new
        @host = host
        @port = port
        @buffer = ::Thrift::MemoryBufferTransport.new
      end

      def write(str)
        @buffer.write(str)
      end

      def flush
        data = @buffer.read(@buffer.available)
        send_bytes(data)
      end

      def open; end

      def close; end

      private

      def send_bytes(bytes)
        @socket.send(bytes, FLAGS, @host, @port)
        @socket.flush
      rescue Errno::ECONNREFUSED
        warn 'Unable to connect to Jaeger Agent'
      rescue StandardError => e
        warn "Unable to send spans: #{e.message}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jaeger-client-1.1.0 lib/jaeger/udp_sender/transport.rb
jaeger-client-1.0.0 lib/jaeger/udp_sender/transport.rb
jaeger-client-0.10.0 lib/jaeger/udp_sender/transport.rb