diff --git a/java/google/registry/monitoring/metrics/MetricRegistryImpl.java b/java/google/registry/monitoring/metrics/MetricRegistryImpl.java index f341b6df9..0bb695f05 100644 --- a/java/google/registry/monitoring/metrics/MetricRegistryImpl.java +++ b/java/google/registry/monitoring/metrics/MetricRegistryImpl.java @@ -36,7 +36,14 @@ public final class MetricRegistryImpl implements MetricRegistry { /** The canonical registry for metrics. The map key is the metric name. */ private final ConcurrentHashMap> registeredMetrics = new ConcurrentHashMap<>(); - private MetricRegistryImpl() {} + + /** + * Production code must use {@link getDefault}, since this returns the {@link MetricRegistry} + * that {@link MetricReporter} uses. Test code that does not use {@link MetricReporter} can + * use this constructor to get an isolated instance of the registry. + */ + @VisibleForTesting + public MetricRegistryImpl() {} public static MetricRegistryImpl getDefault() { return INSTANCE;