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