Prometheus metrics are usually file-level global variables, registered with a global registry. While you could plumb around the registry to use, this would cause friction and decrease the number of useful metrics that'd end up being added. The global nature of metrics does not make them harder to unit test. In fact it reduces the chances that you'll miss a bit of plumbing, resulting in the metric and tests passing perfectly but not being exposed.