mirror of
https://github.com/google/nomulus
synced 2026-01-09 15:43:52 +00:00
Add a convenience method to clear all registered metrics
Also making these methods public so that other test methods can use them. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174074038
This commit is contained in:
@@ -36,11 +36,10 @@ 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<>();
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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() {}
|
||||
@@ -144,11 +143,16 @@ public final class MetricRegistryImpl implements MetricRegistry {
|
||||
* write intervals.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void unregisterMetric(String name) {
|
||||
public void unregisterMetric(String name) {
|
||||
registeredMetrics.remove(name);
|
||||
logger.info("Unregistered metric: " + name);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void unregisterAllMetrics() {
|
||||
registeredMetrics.clear();
|
||||
}
|
||||
|
||||
/** Registers a metric. */
|
||||
@VisibleForTesting
|
||||
void registerMetric(String name, Metric<?> metric) {
|
||||
|
||||
Reference in New Issue
Block a user