I used the fact that $\nabla_X X=0$, which implies that the integral curves of $X$ are geodesics, to find the Christoffel symbols(the non-zero ones are $\Gamma_{22}^1=1/x,\Gamma_{11}^2=1/y$). I then used $\nabla g=0$ to find the metric from the connection, but I get a singular metric, which cannot happen.
But I hoped I'd get the metric of a cylinder as the solution, as if the metric is that of a cylinder, this vector field corresponds to revolutions around the cylinder, which are geodesics. What is wrong with what I'm doing or with the interpretation?
The simplest approach is to use polar coordinates.
The geodesics of the metric $$\tag{1} ds^2=dr^2+d\theta^2 $$ are straight lines in $(r,\theta)$ because the Christoffel symbols all vanish. Among those geodesics are
rays going through the origin $r\mapsto (r,\theta)\,,$ where the angle $\theta$ is fixed, and
circles $\theta\mapsto (r,\theta)\,$ where the radius $r$ is fixed.
To see how this metric looks like in Cartesian coordinates we start from \begin{align}\tag{2} dx&=\cos\theta\,dr-r\sin\theta\,d\theta\,,&dy=\sin\theta\,dr+r\cos\theta\,d\theta \end{align} and get \begin{align}\tag{3} \begin{pmatrix}dr\\r\,d\theta\end{pmatrix}=\begin{pmatrix}\cos\theta&\sin\theta\\-\sin\theta&\cos\theta\end{pmatrix}\begin{pmatrix}dx\\dy\end{pmatrix}\,, \end{align} which can be written as \begin{align}\tag{4} dr&=\cos\theta\,dx+\sin\theta\,dy\,,&d\theta=\frac{-\sin\theta\,dx+\cos\theta\,dy}{r}\,. \end{align} Therefore, the metric in Cartesian coordinates is \begin{align} ds^2&=\Big(\cos^2\theta+\frac{\sin^2\theta}{r^2}\Big)\,dx^2+\Big(\sin^2\theta+\frac{\cos^2\theta}{r^2}\Big)\,dy^2 +2\sin\theta\cos\theta\Big(1-\frac{1}{r^2}\Big)\,dx\,dy\nonumber\\ &=\frac{x^2r^2+y^2}{r^4}\,dx^2+\frac{y^2r^2+x^2}{r^4}\,dy^2+2xy\frac{r^2-1}{r^4}\,dx\,dy\tag{5} \end{align} where the abbreviation $r^2=x^2+y^2$ is used.
With
sympyI calculated the Christoffel symbols: \begin{align*} {\Gamma^x}_{xx} &= - \frac{x y^2}{r^4}\,,&{\Gamma^x}_{xy} &={\Gamma^x}_{yx}= - \frac{y^3}{r^4}\,,&{\Gamma^x}_{yy} &= \frac{(x^2 + 2 y^2) x}{r^4}\,,\\ {\Gamma^y}_{xx} &= \frac{(2 x^2 + y^2) y}{r^4}\,,&{\Gamma^y}_{xy} &={\Gamma^y}_{yx}= - \frac{x^3}{r^4}\,,&{\Gamma^y}_{yy} &= - \frac{x^2 y}{r^4}\,. \end{align*} To check that circles are geodesics lets parametrize them by $$\tag{6} x(\theta)=r\cos(\theta)\,,\quad y(\theta)=r\sin(\theta) $$ and observe that the equations of motion are $$\tag{7} \ddot x=-x\,,\quad \ddot y=-y\,. $$ The geodesic equation are, as we know: \begin{align*} 0&=\ddot x+{\Gamma^x}_{xx}\,\dot x^2+{\Gamma^x}_{yy}\,\dot y^2+{\Gamma^x}_{xy}\,\dot x\dot y+{\Gamma^x}_{yx}\,\dot x\dot y\,,\tag{8}\\[2mm] 0&=\ddot y+{\Gamma^y}_{xx}\,\dot x^2+{\Gamma^y}_{yy}\,\dot y^2+{\Gamma^y}_{xy}\,\dot x\dot y+{\Gamma^y}_{yx}\,\dot x\dot y\,.\tag{9} \end{align*} Since \begin{align*} \dot x=-y\,,\quad \dot y =x\tag{10} \end{align*} we get \begin{align} 0&=\ddot x+{\Gamma^x}_{xx}\,y^2+{\Gamma^x}_{yy}\,x^2-{\Gamma^x}_{xy}\,xy-{\Gamma^x}_{yx}\,xy\,,\tag{11}\\[2mm] 0&=\ddot y+{\Gamma^y}_{xx}\,y^2+{\Gamma^y}_{yy}\,x^2-{\Gamma^y}_{xy}\,xy-{\Gamma^y}_{yx}\,xy\,.\tag{12} \end{align}Plugging the Christoffel symbols into (11) and (12) gives \begin{align*} 0&=\ddot x+\frac{-xy^4+x^5+2x^3y^2+2xy^4}{r^4}=\ddot x+x\frac{(x^2+y^2)^2}{r^4}=\ddot x+x\,,\tag{13}\\ 0&=\ddot y+\frac{2x^2y^3+y^5-x^4y+2x^4y}{r^4}=\ddot y+y\frac{(x^2+y^2)^2}{r^4}=\ddot y+y\,.\tag{14} \end{align*} which are the equations of motion (7) as it should be.
Again with
sympyI also checked that the Riemann tensor of the metric (5) vanishes as it must.A pseudo Riemannian Metric
The pseudo Riemannian metric $$\tag{15} g=\begin{pmatrix}xy^{-1}&0\\0&-yx^{-1}\end{pmatrix} $$ leads to \begin{align*} {\Gamma^x}_{xx}&=\frac{1}{2x}\,, &{\Gamma^x}_{yy}&=-\frac{y^2}{2x^3}\,,&{\Gamma^x}_{xy}&=-\frac{1}{2y}\,,&{\Gamma^x}_{yx}&=-\frac{1}{2y}\,,\\[2mm] {\Gamma^y}_{xx}&=-\frac{x^2}{2y^3}\,, &{\Gamma^y}_{yy}&=\frac{1}{2y}\,,&{\Gamma^y}_{xy}&=-\frac{1}{2x}\,,&{\Gamma^x}_{yx}&=-\frac{1}{2x}\,. \end{align*} Then the geodesic equations collapse again to the equations of motion (7) that the circles satisfy.