lib/jaeger/client/udp_sender.rb in jaeger-client-0.4.1 vs lib/jaeger/client/udp_sender.rb in jaeger-client-0.4.2
- old
+ new
@@ -1,17 +1,39 @@
require_relative './udp_sender/transport'
require 'jaeger/thrift/agent'
+require 'socket'
require 'thread'
module Jaeger
module Client
class UdpSender
def initialize(service_name:, host:, port:, collector:, flush_interval:)
@service_name = service_name
@collector = collector
@flush_interval = flush_interval
+ @tags = [
+ Jaeger::Thrift::Tag.new(
+ 'key' => 'jaeger.version',
+ 'vType' => Jaeger::Thrift::TagType::STRING,
+ 'vStr' => 'Ruby-' + Jaeger::Client::VERSION
+ ),
+ Jaeger::Thrift::Tag.new(
+ 'key' => 'hostname',
+ 'vType' => Jaeger::Thrift::TagType::STRING,
+ 'vStr' => Socket.gethostname
+ )
+ ]
+ ipv4 = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }
+ unless ipv4.nil?
+ @tags << Jaeger::Thrift::Tag.new(
+ 'key' => 'ip',
+ 'vType' => Jaeger::Thrift::TagType::STRING,
+ 'vStr' => ipv4.ip_address
+ )
+ end
+
transport = Transport.new(host, port)
protocol = ::Thrift::CompactProtocol.new(transport)
@client = Jaeger::Thrift::Agent::Client.new(protocol)
end
@@ -36,10 +58,10 @@
return if thrift_spans.empty?
batch = Jaeger::Thrift::Batch.new(
'process' => Jaeger::Thrift::Process.new(
'serviceName' => @service_name,
- 'tags' => [],
+ 'tags' => @tags
),
'spans' => thrift_spans
)
@client.emitBatch(batch)