According to Frankel's book "The Geometry of Physics", the components of a contravariant gradient vector can be obtained from the inverse of the metric tensor as follows (in section 2.1d, Page 73):
$$ (\nabla f)^i = \sum_j g^{ij} \frac{\partial f}{\partial x^j}, $$
while the metric sensor is:
$$ g_{ij} = \bigg\langle \frac{\partial}{\partial x^i}, \frac{\partial}{\partial x^j} \bigg\rangle. $$
Take the spherical coordinate as example,
\begin{align} x &= r\sin\theta\cos\phi \\ y &= r\sin\theta\sin\phi \\ z &= r\cos\theta \end{align}
and let $J$ be the Jacobi matrix
$$ J = \begin{pmatrix} \sin\theta\cos\phi & -r\sin\phi\sin\theta & r\cos\phi\cos\theta \\ \sin\theta\sin\phi & r\cos\phi\sin\theta & r\sin\phi\cos\theta \\ \cos\theta & 0 & -r\sin\theta \end{pmatrix}, $$
the metric tensor can be obtained as
$$ \left( g_{ij} \right) = J^TJ = \begin{pmatrix} 1 & 0 & 0 \\ 0 & r^2\sin^2\theta & 0 \\ 0 & 0 & r^2 \end{pmatrix}. $$
Finally, the contravariant gradient vector can be obtained as follows according to the first equation:
$$ \nabla f = \begin{pmatrix}\displaystyle{ \frac{\partial f}{\partial r} \\ \frac{1}{r^2\sin^2\theta} \frac{\partial f}{\partial \phi} \\ \frac{1}{r^2} \frac{\partial f}{\partial \theta}} \end{pmatrix}. $$
However, the correct answer is
$$ \nabla f = \begin{pmatrix}\displaystyle{ \frac{\partial f}{\partial r} \\ \frac{1}{r\sin\theta} \frac{\partial f}{\partial \phi} \\ \frac{1}{r} \frac{\partial f}{\partial \theta}} \end{pmatrix}. $$
I don't know why I cannot get the correct answer using metric tensor. Could you please help me figure it out? Thank you!