Interface MetricReader
-
- All Superinterfaces:
AggregationTemporalitySelector
,java.lang.AutoCloseable
,java.io.Closeable
,DefaultAggregationSelector
- All Known Implementing Classes:
PeriodicMetricReader
public interface MetricReader extends AggregationTemporalitySelector, DefaultAggregationSelector, java.io.Closeable
A metric reader reads metrics from anSdkMeterProvider
.- Since:
- 1.14.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Close thisMetricReader
, releasing any resources.CompletableResultCode
forceFlush()
Read and export the metrics.default Aggregation
getDefaultAggregation(InstrumentType instrumentType)
Return the default aggregation for theInstrumentType
.default MemoryMode
getMemoryMode()
Returns the memory mode used by this reader.void
register(CollectionRegistration registration)
Called bySdkMeterProvider
on initialization to supply theMetricReader
withMetricProducer
s used to collect metrics.CompletableResultCode
shutdown()
Shuts down the metric reader.-
Methods inherited from interface io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector
getAggregationTemporality
-
Methods inherited from interface io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector
with
-
-
-
-
Method Detail
-
register
void register(CollectionRegistration registration)
Called bySdkMeterProvider
on initialization to supply theMetricReader
withMetricProducer
s used to collect metrics.MetricReader
implementations callCollectionRegistration.collectAllMetrics()
to read metrics.
-
getDefaultAggregation
default Aggregation getDefaultAggregation(InstrumentType instrumentType)
Return the default aggregation for theInstrumentType
.- Specified by:
getDefaultAggregation
in interfaceDefaultAggregationSelector
- Since:
- 1.16.0
- See Also:
DefaultAggregationSelector.getDefaultAggregation(InstrumentType)
-
getMemoryMode
default MemoryMode getMemoryMode()
Returns the memory mode used by this reader.- Returns:
- The
MemoryMode
used 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
default void close() throws java.io.IOException
Close thisMetricReader
, releasing any resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-