  We characterize the subsets $E$ of a metric space $X$ with doubling measure
whose distance function to some negative power
$\textrm{dist}(\cdot,E)^{-\alpha}$ belongs to the Muckenhoupt $A_1$ class of
weights in $X$. To this end, we introduce the weakly porous and dyadic weakly
porous sets in this setting, and show that, along with certain doubling-type
conditions for the sizes of the largest $E$-free holes, these sets provide the
mentioned $A_1$-characterization. We exhibit examples showing the optimality of
these conditions, and also see how they can be simplified in the particular
case where the underlying measure possesses certain qualitative version of the
annular decay property. Moreover, one of those examples gives rise to a new
family of doubling weights in $\mathbb{R}$ that do not belong to $A_\infty.$
