Consider a smooth metric measure space in which the integral of a gradient is meaningful. For example in the sense of upper gradients of Heinonen, or on a riemannian manifold with the associated measure. Therefore, one can define Sobolev spaces $W^{1,p}$. In the case of a compact riemannian metric, and in particular a domain in the euclidean space, one has the Rellich's theorem which guarantees compactness of the inclusion $W^{1,p} \hookrightarrow L^q$ for $q< p^*$, where $p^{*}$ is the exponent in the Sobolev embedding theorem.
My question is whether sufficient conditions are known which may guarantee the same compactness property for Sobolev spaces defined in more abstract measure spaces. As a particular example, I'd like to know if anything is known about the conditions on the weight function $w(x)$ when the measure $d \nu$ is defined as $d \nu= w (x) d \mu$, wherein $d \mu$ is the Lebesgue measure on $\mathbb{R}^n$. Another example is the case of riemannian manifolds with possibly degenerate metrics.