Class PeriodicMetricReader
java.lang.Object
io.opentelemetry.sdk.metrics.export.PeriodicMetricReader
- All Implemented Interfaces:
AggregationTemporalitySelector,DefaultAggregationSelector,MetricReader,Closeable,AutoCloseable
A
MetricReader which wraps a MetricExporter and automatically reads and exports
the metrics every export interval.
Register with SdkMeterProvider via SdkMeterProviderBuilder.registerMetricReader(MetricReader).
- Since:
- 1.14.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic PeriodicMetricReaderBuilderbuilder(MetricExporter exporter) Returns a newPeriodicMetricReaderBuilder.static PeriodicMetricReadercreate(MetricExporter exporter) Returns a newPeriodicMetricReaderwhich exports to theexporteronce every minute.io.opentelemetry.sdk.common.CompletableResultCodeForces a flush of all metrics.getAggregationTemporality(InstrumentType instrumentType) Return the aggregation temporality for theInstrumentType.getDefaultAggregation(InstrumentType instrumentType) Return the default aggregation for theInstrumentType.io.opentelemetry.sdk.common.export.MemoryModeReturns the memory mode used by this reader.voidregister(CollectionRegistration collectionRegistration) Called bySdkMeterProvideron initialization to supply theMetricReaderwithMetricProducers used to collect metrics.io.opentelemetry.sdk.common.CompletableResultCodeshutdown()Shuts down the metric reader.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector
withMethods inherited from interface io.opentelemetry.sdk.metrics.export.MetricReader
close
-
Method Details
-
create
Returns a newPeriodicMetricReaderwhich exports to theexporteronce every minute. -
builder
Returns a newPeriodicMetricReaderBuilder. -
getAggregationTemporality
Description copied from interface:AggregationTemporalitySelectorReturn the aggregation temporality for theInstrumentType.- Specified by:
getAggregationTemporalityin interfaceAggregationTemporalitySelector
-
getDefaultAggregation
Description copied from interface:MetricReaderReturn the default aggregation for theInstrumentType.- Specified by:
getDefaultAggregationin interfaceDefaultAggregationSelector- Specified by:
getDefaultAggregationin interfaceMetricReader- See Also:
-
getMemoryMode
public io.opentelemetry.sdk.common.export.MemoryMode getMemoryMode()Description copied from interface:MetricReaderReturns the memory mode used by this reader.- Specified by:
getMemoryModein interfaceMetricReader- Returns:
- The
MemoryModeused by this instance
-
forceFlush
public io.opentelemetry.sdk.common.CompletableResultCode forceFlush()Forces a flush of all metrics.If an export is already in progress, the flush will be skipped and the returned result will be completed exceptionally with an
IllegalStateException. Callers can inspect the cause viaCompletableResultCode.getFailureThrowable().- Specified by:
forceFlushin interfaceMetricReader- Returns:
- the result of the flush.
-
shutdown
public io.opentelemetry.sdk.common.CompletableResultCode shutdown()Description copied from interface:MetricReaderShuts 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.- Specified by:
shutdownin interfaceMetricReader- Returns:
- the result of the shutdown.
-
register
Description copied from interface:MetricReaderCalled bySdkMeterProvideron initialization to supply theMetricReaderwithMetricProducers used to collect metrics.MetricReaderimplementations callCollectionRegistration.collectAllMetrics()to read metrics.- Specified by:
registerin interfaceMetricReader
-
toString
-