class Stackify::UnixSocketSender
Public Instance Methods
send_request(log_group)
click to toggle source
send_request
() This function will send http request via unix domain socket @msgs {Object} log group message return {Object} Return an object {status, message}
# File lib/stackify/unix_socket_sender.rb, line 13 def send_request log_group begin client = NetX::HTTPUnix.new('unix://' + Stackify.configuration.unix_socket_path) req = Net::HTTP::Post.new(Stackify.configuration.agent_log_url) req.set_content_type('application/json') req.body = log_group response = client.request(req) Stackify.internal_log :debug, "[UnixSocketSender] status_code = #{response.code}" if response.code.to_i == 200 Stackify.internal_log :debug, "[UnixSocketSender]: Successfully send message via unix domain socket." return OpenStruct.new({status: 200, msg: 'OK'}) else Stackify.internal_log :debug, "[UnixSocketSender] Sending failed." return OpenStruct.new({status: 500, msg: 'Not OK'}) end rescue => exception Stackify.log_internal_error "[UnixSocketSender] send_logs() Error: #{exception}" return OpenStruct.new({status: 500, msg: exception}) end end