For a certain class of discrete metric spaces, we provide a formula for the density of states. This formula involves Dixmier traces and is proven using recent advances in operator theory. Various examples are given of metric spaces for which this formula holds, including crystals, quasicrystals and the infinite cluster resulting from super-critical bond percolation on Z d .