mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 17:37:13 +02: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:
parent
b0e062d725
commit
d3254eaaeb
2 changed files with 11 additions and 12 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue