Change MetricsRegistryImpl constructor to "@VisibleForTesting public".

This enables registry isolation in tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173426040
This commit is contained in:
jianglai 2017-10-25 11:33:46 -07:00
parent f59c3daf6d
commit 0573560a6c

View file

@ -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<String, Metric<?>> 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;