Class MetricStorageRegistry
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.state.MetricStorageRegistry
-
public class MetricStorageRegistry extends java.lang.ObjectResponsible for storing metrics byMetricDescriptorand returning access to input pipeline for instrument measurements.Each descriptor in the registry results in an exported metric stream. Under normal circumstances each descriptor shares a unique
MetricDescriptor.getName(). When multiple descriptors share the same name, but have some difference in identifying fields, an identity conflict has occurred. The registry detects identity conflicts onregister(MetricStorage)and logs diagnostic information when they occur. SeeMetricDescriptor.equals(Object)for definition of identity equality.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Objectlockprivate static java.util.logging.Loggerloggerprivate java.util.Map<MetricDescriptor,MetricStorage>registry
-
Constructor Summary
Constructors Constructor Description MetricStorageRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<MetricStorage>getStorages()Returns aCollectionof the registeredMetricStorage.<I extends MetricStorage>
Iregister(I newStorage)Registers the metricnewStorageto this registry.voidresetForTest()Reset the storage registry, clearing all storages.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
lock
private final java.lang.Object lock
-
registry
private final java.util.Map<MetricDescriptor,MetricStorage> registry
-
-
Method Detail
-
getStorages
public java.util.Collection<MetricStorage> getStorages()
Returns aCollectionof the registeredMetricStorage.
-
register
public <I extends MetricStorage> I register(I newStorage)
Registers the metricnewStorageto this registry. If a metric with compatible identity was previously registered, returns the previously registered storage. If a metric with the same name (case-insensitive) but incompatibleMetricDescriptorwas previously registered, logs a diagnostic warning and returns thenewStorage.- Parameters:
newStorage- the metric storage to use or discard.- Returns:
- the
newStorageif no compatible metric is already registered, otherwise the previously registered storage.
-
resetForTest
public void resetForTest()
Reset the storage registry, clearing all storages.
-
-