Class PeriodicMetricReader
java.lang.Object
io.opentelemetry.sdk.metrics.export.PeriodicMetricReader
- All Implemented Interfaces:
MetricReader
Wraps a
MetricExporter and automatically reads and exports the metrics every export
interval. Metrics may also be dropped when it becomes time to export again, and there is an
export in progress.-
Method Summary
Modifier and TypeMethodDescriptionstatic PeriodicMetricReaderBuilderbuilder(MetricExporter exporter) Returns a newPeriodicMetricReaderBuilder.io.opentelemetry.sdk.common.CompletableResultCodeflush()Flushes metrics read by this reader.Return The preferred temporality for metrics.static MetricReaderFactorynewMetricReaderFactory(MetricExporter exporter) Returns a newMetricReaderFactorywhich can be registered to aSdkMeterProviderto start aPeriodicMetricReaderexporting once every minute on a new daemon thread.io.opentelemetry.sdk.common.CompletableResultCodeshutdown()Shuts down the metric reader.
-
Method Details
-
newMetricReaderFactory
Returns a newMetricReaderFactorywhich can be registered to aSdkMeterProviderto start aPeriodicMetricReaderexporting once every minute on a new daemon thread. -
builder
Returns a newPeriodicMetricReaderBuilder. -
getPreferredTemporality
Description copied from interface:MetricReaderReturn The preferred temporality for metrics.- Specified by:
getPreferredTemporalityin interfaceMetricReader
-
flush
public io.opentelemetry.sdk.common.CompletableResultCode flush()Description copied from interface:MetricReaderFlushes metrics read by this reader.In all scenarios, the associated
MetricProducershould have itsMetricProducer.collectAllMetrics()method called.For push endpoints, this should collect and report metrics as normal.
- Specified by:
flushin interfaceMetricReader- Returns:
- the result of the shutdown.
-
shutdown
public io.opentelemetry.sdk.common.CompletableResultCode shutdown()Description copied from interface:MetricReaderShuts down the metric reader.For pull endpoints, like prometheus, this should shut down the metric hosting endpoint or server doing such a job.
For push endpoints, this should shut down any scheduler threads.
- Specified by:
shutdownin interfaceMetricReader- Returns:
- the result of the shutdown.
-