Class AsynchronousMetricStorage<T extends PointData,U extends ExemplarData>
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.state.AsynchronousMetricStorage<T,U>
-
- All Implemented Interfaces:
MetricStorage
public final class AsynchronousMetricStorage<T extends PointData,U extends ExemplarData> extends java.lang.Object implements MetricStorage
Stores aggregatedMetricData
for asynchronous instruments.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 AggregationTemporality
aggregationTemporality
private Aggregator<T,U>
aggregator
private AttributesProcessor
attributesProcessor
private java.util.Map<Attributes,T>
lastPoints
private static java.util.logging.Logger
logger
private int
maxCardinality
This field is set to 1 less than the actual intended cardinality limit, allowing the last slot to be filled by theMetricStorage.CARDINALITY_OVERFLOW
series.private MemoryMode
memoryMode
private MetricDescriptor
metricDescriptor
private java.util.Map<Attributes,T>
points
private RegisteredReader
registeredReader
private ObjectPool<T>
reusablePointsPool
private java.util.ArrayList<T>
reusableResultList
private ThrottlingLogger
throttlingLogger
-
Fields inherited from interface io.opentelemetry.sdk.metrics.internal.state.MetricStorage
CARDINALITY_OVERFLOW, DEFAULT_MAX_CARDINALITY
-
-
Constructor Summary
Constructors Modifier Constructor Description private
AsynchronousMetricStorage(RegisteredReader registeredReader, MetricDescriptor metricDescriptor, Aggregator<T,U> aggregator, AttributesProcessor attributesProcessor, int maxCardinality)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MetricData
collect(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, long startEpochNanos, long epochNanos)
Collects the metrics from this storage.static <T extends PointData,U extends ExemplarData>
AsynchronousMetricStorage<T,U>create(RegisteredReader registeredReader, RegisteredView registeredView, InstrumentDescriptor instrumentDescriptor)
Create an asynchronous storage instance for theView
andInstrumentDescriptor
.MetricDescriptor
getMetricDescriptor()
Returns a description of the metric produced in this storage.RegisteredReader
getRegisteredReader()
Returns the registered reader this storage is associated with.boolean
isEmpty()
Determines whether this storage is an empty metric storage.(package private) void
record(Measurement measurement)
Record callback measurement fromObservableLongMeasurement
orObservableDoubleMeasurement
.private void
recordPoint(Attributes attributes, Measurement measurement)
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
throttlingLogger
private final ThrottlingLogger throttlingLogger
-
registeredReader
private final RegisteredReader registeredReader
-
metricDescriptor
private final MetricDescriptor metricDescriptor
-
aggregationTemporality
private final AggregationTemporality aggregationTemporality
-
aggregator
private final Aggregator<T extends PointData,U extends ExemplarData> aggregator
-
attributesProcessor
private final AttributesProcessor attributesProcessor
-
maxCardinality
private final int maxCardinality
This field is set to 1 less than the actual intended cardinality limit, allowing the last slot to be filled by theMetricStorage.CARDINALITY_OVERFLOW
series.
-
points
private java.util.Map<Attributes,T extends PointData> points
-
lastPoints
private java.util.Map<Attributes,T extends PointData> lastPoints
-
reusablePointsPool
private final ObjectPool<T extends PointData> reusablePointsPool
-
memoryMode
private final MemoryMode memoryMode
-
-
Constructor Detail
-
AsynchronousMetricStorage
private AsynchronousMetricStorage(RegisteredReader registeredReader, MetricDescriptor metricDescriptor, Aggregator<T,U> aggregator, AttributesProcessor attributesProcessor, int maxCardinality)
-
-
Method Detail
-
create
public static <T extends PointData,U extends ExemplarData> AsynchronousMetricStorage<T,U> create(RegisteredReader registeredReader, RegisteredView registeredView, InstrumentDescriptor instrumentDescriptor)
Create an asynchronous storage instance for theView
andInstrumentDescriptor
.
-
record
void record(Measurement measurement)
Record callback measurement fromObservableLongMeasurement
orObservableDoubleMeasurement
.
-
recordPoint
private void recordPoint(Attributes attributes, Measurement measurement)
-
getMetricDescriptor
public MetricDescriptor getMetricDescriptor()
Description copied from interface:MetricStorage
Returns a description of the metric produced in this storage.- Specified by:
getMetricDescriptor
in interfaceMetricStorage
-
getRegisteredReader
public RegisteredReader getRegisteredReader()
Returns the registered reader this storage is associated with.
-
collect
public MetricData collect(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, long startEpochNanos, long epochNanos)
Description copied from interface:MetricStorage
Collects the metrics from this storage. If storingAggregationTemporality.DELTA
metrics, reset for the next collection period.Note: This is a stateful operation and will reset any interval-related state for the
collector
.- Specified by:
collect
in interfaceMetricStorage
- Parameters:
resource
- The resource associated with the metrics.instrumentationScopeInfo
- The instrumentation scope generating the metrics.startEpochNanos
- The start timestamp for this SDK.epochNanos
- The timestamp for this collection.- Returns:
- The
MetricData
from this collection period.
-
isEmpty
public boolean isEmpty()
Description copied from interface:MetricStorage
Determines whether this storage is an empty metric storage.Uses the reference comparison since
EmptyMetricStorage
is singleton.- Specified by:
isEmpty
in interfaceMetricStorage
- Returns:
- true if is empty.
-
-