$\newcommand{\bR}{\mathbb{R}}$ $\newcommand{\pa}{\partial}$

This questions has some nebulous roots in Morse theory. The most general   version  goes as follows. Fix an integer $n\geq 2$. Suppose that we have a smooth function  $f$ defined on an open neighborhood $U$ of $0$ in $\bR^n$. To a smooth Riemannian metric $g$ defined on  $U$  we associated the gradient $\nabla^g f$.  

> For which smooth functions functions $f$ is the correspondence 
> 
> $$g\mapsto \nabla^g f $$
> 
> injective, i.e., from the  knowledge that $\nabla^{g_0} f=\nabla^{g_1} f$
> on $U$ we can conclude that $g_0=g_1$ on some neighborhood $V$ of
> $0$ in $\bR^n$, $V\subset U$.


Clearly, the above correspondence is not injective if $f\equiv const$, or $f(x)$ is linear in $x$.

The next interesting case is when $q$ is quadratic.  Suppose that

$$
f(x)=q(x):=\frac{1}{2}(x_1^2+\cdots +x_n^2).
 $$

Denote by $g_0$ the canonical Euclidean metric on $\bR^n$ so that

$$\nabla^{g_0}q =\sum_i x_i\pa_{x_i}. $$

The special case of the question goes as follows. 

> If $g$ is a real analytic Riemann metric defined on a neighborhood $U$
> of $0$ and  $\nabla^g q(x)= \nabla^{g_0} q(x)$, $\forall x\in U$, can
> we conclude that  $g=g_0$ in a neighborhood of $0$?


I was not able to track results of this kind in the literature, and  I would appreciate any   pointers.