def make_host_agent_request(req)
      req['Accept'] = MIME_JSON
      req['Content-Type'] = MIME_JSON

      if @state == :unannounced
        @httpclient = Net::HTTP.new(req.uri.hostname, req.uri.port)
        @httpclient.open_timeout = 1
        @httpclient.read_timeout = 1
      end

      response = @httpclient.request(req)
      # ::Instana.logger.debug "#{req.method}->#{req.uri} body:(#{req.body}) Response:#{response} body:(#{response.body})"

      response
    rescue Errno::ECONNREFUSED
      return nil
    rescue => e
      Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
      Instana.logger.debug e.backtrace.join("\r\n") unless ::Instana.test?
      return nil
    end
def make_host_agent_request(req)
      req['Accept'] = MIME_JSON
      req['Content-Type'] = MIME_JSON

      if @state == :unannounced
        @httpclient = Net::HTTP.new(req.uri.hostname, req.uri.port)
        @httpclient.open_timeout = 1
        @httpclient.read_timeout = 1
      end

      response = @httpclient.request(req)
      # ::Instana.logger.debug "#{req.method}->#{req.uri} body:(#{req.body}) Response:#{response} body:(#{response.body})"

      response
    rescue Errno::ECONNREFUSED
      return nil
    rescue => e
      Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
      Instana.logger.debug e.backtrace.join("\r\n") unless ::Instana.test?
      return nil
    end
Centralization of the net/http communications
 with the host agent. Pass in a prepared <req>
 of type Net::HTTP::Get|Put|Head

 @param req [Net::HTTP::Req] A prepared Net::HTTP request object of the type
  you wish to make (Get, Put, Post etc.)