Interface MetricReader
- All Superinterfaces:
AggregationTemporalitySelector, AutoCloseable, Closeable, DefaultAggregationSelector
- All Known Implementing Classes:
PeriodicMetricReader
public interface MetricReader
extends AggregationTemporalitySelector, DefaultAggregationSelector, Closeable
A metric reader reads metrics from an
SdkMeterProvider.- Since:
- 1.14.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Close thisMetricReader, releasing any resources.Read and export the metrics.default AggregationgetDefaultAggregation(InstrumentType instrumentType) Return the default aggregation for theInstrumentType.default MemoryModeReturns the memory mode used by this reader.voidregister(CollectionRegistration registration) Called bySdkMeterProvideron initialization to supply theMetricReaderwithMetricProducers used to collect metrics.shutdown()Shuts down the metric reader.Methods inherited from interface AggregationTemporalitySelector
getAggregationTemporalityMethods inherited from interface DefaultAggregationSelector
with
-
Method Details
-
register
Called bySdkMeterProvideron initialization to supply theMetricReaderwithMetricProducers used to collect metrics.MetricReaderimplementations callCollectionRegistration.collectAllMetrics()to read metrics. -
getDefaultAggregation
Return the default aggregation for theInstrumentType.- Specified by:
getDefaultAggregationin interfaceDefaultAggregationSelector- Since:
- 1.16.0
- See Also:
-
getMemoryMode
Returns the memory mode used by this reader.- Returns:
- The
MemoryModeused by this instance - Since:
- 1.31.0
-
forceFlush
CompletableResultCode forceFlush()Read and export the metrics.Called when
SdkMeterProvider.forceFlush()is called.- Returns:
- the result of the flush.
-
shutdown
CompletableResultCode shutdown()Shuts down the metric reader.Called when
SdkMeterProvider.shutdown()is called.For pull based readers like prometheus, this should shut down the metric hosting endpoint or server doing such a job.
For push based readers like
MetricExporter, this should shut down any scheduler threads.- Returns:
- the result of the shutdown.
-
close
Close thisMetricReader, releasing any resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-