lib/instrumental/agent.rb in instrumental_agent-0.12.5 vs lib/instrumental/agent.rb in instrumental_agent-0.12.6
- old
+ new
@@ -11,10 +11,11 @@
MAX_RECONNECT_DELAY = 15
MAX_BUFFER = 5000
REPLY_TIMEOUT = 10
CONNECT_TIMEOUT = 20
EXIT_FLUSH_TIMEOUT = 5
+ HOSTNAME = Socket.gethostbyname(Socket.gethostname).first rescue Socket.gethostname
attr_accessor :host, :port, :synchronous, :queue
attr_reader :connection, :enabled
def self.logger=(l)
@@ -331,10 +332,18 @@
@socket = Socket.new(Socket::PF_INET, Socket::SOCK_STREAM, 0)
with_timeout(CONNECT_TIMEOUT) do
@socket.connect Socket.pack_sockaddr_in(port, ipv4_address_for_host(host, port))
end
logger.info "connected to collector at #{host}:#{port}"
- send_with_reply_timeout "hello version #{Instrumental::VERSION} hostname #{Socket.gethostname} pid #{Process.pid}"
+ hello_options = {
+ "version" => "ruby/instrumental_agent/#{VERSION}",
+ "hostname" => HOSTNAME,
+ "pid" => Process.pid,
+ "runtime" => "#{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}",
+ "platform" => RUBY_PLATFORM
+ }.to_a.flatten.map { |v| v.to_s.gsub(/\s+/, "_") }.join(" ")
+
+ send_with_reply_timeout "hello #{hello_options}"
send_with_reply_timeout "authenticate #{@api_key}"
@failures = 0
loop do
command_and_args, command_options = @queue.pop
sync_resource = command_options && command_options[:sync_resource]