  Let $X$ be a metric space equipped with a doubling measure. We consider
weights $w(x)=\operatorname{dist}(x,E)^{-\alpha}$, where $E$ is a closed set in
$X$ and $\alpha\in\mathbb R$. We establish sharp conditions, based on the
Assouad (co)dimension of $E$, for the inclusion of $w$ in Muckenhoupt's $A_p$
classes of weights, $1\le p<\infty$. With the help of general $A_p$-weighted
embedding results, we then prove (global) Hardy-Sobolev inequalities and also
fractional versions of such inequalities in the setting of metric spaces.
