def run_discovery
      discovered = {}

      ::Instana.logger.debug "#{__method__}: Running agent discovery..."

      # Try default location or manually configured (if so)
      uri = URI.parse("http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/")
      req = Net::HTTP::Get.new(uri)

      ::Instana.logger.debug "#{__method__}: Trying #{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}"

      response = make_host_agent_request(req)

      if response && (response.code.to_i == 200)
        discovered[:agent_host] = ::Instana.config[:agent_host]
        discovered[:agent_port] = ::Instana.config[:agent_port]
        ::Instana.logger.debug "#{__method__}: Found #{discovered[:agent_host]}:#{discovered[:agent_port]}"
        return discovered
      end

      return nil unless @is_linux

      # We are potentially running on Docker in bridged networking mode.
      # Attempt to contact default gateway
      uri = URI.parse("http://#{@default_gateway}:#{::Instana.config[:agent_port]}/")
      req = Net::HTTP::Get.new(uri)

      ::Instana.logger.debug "#{__method__}: Trying default gateway #{@default_gateway}:#{::Instana.config[:agent_port]}"

      response = make_host_agent_request(req)

      if response && (response.code.to_i == 200)
        discovered[:agent_host] = @default_gateway
        discovered[:agent_port] = ::Instana.config[:agent_port]
        ::Instana.logger.debug "#{__method__}: Found #{discovered[:agent_host]}:#{discovered[:agent_port]}"
        return discovered
      end

      nil
    end
def run_discovery
      discovered = {}

      ::Instana.logger.debug "#{__method__}: Running agent discovery..."

      # Try default location or manually configured (if so)
      uri = URI.parse("http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/")
      req = Net::HTTP::Get.new(uri)

      ::Instana.logger.debug "#{__method__}: Trying #{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}"

      response = make_host_agent_request(req)

      if response && (response.code.to_i == 200)
        discovered[:agent_host] = ::Instana.config[:agent_host]
        discovered[:agent_port] = ::Instana.config[:agent_port]
        ::Instana.logger.debug "#{__method__}: Found #{discovered[:agent_host]}:#{discovered[:agent_port]}"
        return discovered
      end

      return nil unless @is_linux

      # We are potentially running on Docker in bridged networking mode.
      # Attempt to contact default gateway
      uri = URI.parse("http://#{@default_gateway}:#{::Instana.config[:agent_port]}/")
      req = Net::HTTP::Get.new(uri)

      ::Instana.logger.debug "#{__method__}: Trying default gateway #{@default_gateway}:#{::Instana.config[:agent_port]}"

      response = make_host_agent_request(req)

      if response && (response.code.to_i == 200)
        discovered[:agent_host] = @default_gateway
        discovered[:agent_port] = ::Instana.config[:agent_port]
        ::Instana.logger.debug "#{__method__}: Found #{discovered[:agent_host]}:#{discovered[:agent_port]}"
        return discovered
      end

      nil
    end
Runs a discovery process to determine where we can contact the host agent.  This is usually just
 localhost but in docker can be found on the default gateway. Another option is the INSTANA_AGENT_HOST
 environment variable. This also allows for manual configuration via ::Instana.config[:agent_host/port].

 @return [Hash] a hash with :agent_host, :agent_port values or empty hash