This is the exersise 13-16 of Lee's Introduction to Smooth Manifolds.
Let $\mathbb R$ be a riemannian manifold equiped with the metric $g = f(t) dt^2$. I want to show that $(\mathbb{R},g)$ is complete (in the sens that every Cauchy sequence converge for the distance induced by $g$) if and only if $$ \int_0^\infty \sqrt{f(t)}\,dt~ \text{and}~ \int_{-\infty}^0 \sqrt{f(t)}\, dt $$ diverge.
The only thing I wrote is length of a piecewise smooth curve (a function in this case) $\gamma: J \rightarrow \mathbb{R}$ : $$ L_g(\gamma) = \int_J \lVert \gamma'(t) \rVert\, dt = \int_J \sqrt{f(\gamma(t))} | \gamma'(t) |\, dt. $$ Then my guess is to break $J$ in two parts with one where $\gamma'>0$ and the other one where $\gamma'<0$ and do a variable change to make $\sqrt{f(t)}$ appear in the integrand. Once here I know that I need to use the definition of Cauchy sequence but I don't know how.
Define a metric
$$ d : \mathbb{R} \times \mathbb{R} \rightarrow [0,\infty), \ \ d(x,y) := \left|\int_x^y \sqrt{f(t)}dt\right|.$$
This is the metric induces by your Riemannian metric $g$. Let's first show that if the integrals diverge, then $(\mathbb{R}, d)$ is complete. Let $(x_n) \subseteq \mathbb{R}$ be a Cauchy sequence with respect to $d$. This means that for all $\epsilon > 0$ there is an $N_\epsilon$ so that for all $n,m \geq N_\epsilon$ we have
$$ d(x_n, x_m) = \left|\int_{x_n}^{x_m} \sqrt{f(t)} dt\right| < \epsilon.$$
In particular, for $\epsilon = 1$, if we let $n := N_1$ then we see that for all $m \geq N_1$ we have
$$d(x_n, x_m) = \left|\int_{x_n}^{x_m} \sqrt{f(t)} dt\right| < 1.$$
Observe that we cannot have $|x_m| \rightarrow \infty$ as $m \rightarrow \infty$ by the divergence assumption, so in particular there exists an $M$ so that for all $m \geq N_1$ we have $|x_m| \leq M$. Moreover, we can choose $M$ sufficiently large so that for all $n$ we have $|x_n| \leq M$. Thus our sequence is bounded. If we restrict $\sqrt{f}$ to the domain $[-M, M]$, we see that it is going to be uniformly continuous, hence bounded. Let $D$ be such that $\sqrt{f} \leq D$ on $[-M,M]$. Notice we now have
$$ d(x_n, x_m) = \left|\int_{x_n}^{x_m} \sqrt{f(t)}dt\right| \leq D |x_n - x_m|.$$
We have a bounded sequence, so there is a convergent subsequence with respect to the Euclidean distance function. This implies that $(x_n)$ has a convergent subsequence with respect to the metric $d$. A Cauchy sequence with a convergent subsequence is convergent, so our sequence converges. Hence $(\mathbb{R}, d)$ is complete.
Suppose that $(\mathbb{R},d)$ is complete. Suppose for contradiction that $$\int_0^\infty \sqrt{f(t)}dt < \infty.$$ Consider the sequence $x_n := n$. Then we have that
$$ d(n, m) = \int_n^m \sqrt{f(t)}dt \leq \int_n^\infty \sqrt{f(t)}dt.$$
Since the integral converges, for $\epsilon > 0$ we can find $N$ sufficiently large so that
$$ \int_N^\infty \sqrt{f(t)}dt < \epsilon.$$
This implies that for all $n,m \geq N$ we have
$$ d(n, m) \leq \int_N^\infty \sqrt{f(t)}dt < \epsilon.$$
So our sequence is Cauchy. Notice our sequence doesn't converge to any $x \in \mathbb{R}$, so we've reached a contradiction (the argument for the other integral converging is similar).