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 PeriodicMetricReaderBuilder
builder
(MetricExporter exporter) Returns a newPeriodicMetricReaderBuilder
.io.opentelemetry.sdk.common.CompletableResultCode
flush()
Flushes metrics read by this reader.Return The preferred temporality for metrics.static MetricReaderFactory
newMetricReaderFactory
(MetricExporter exporter) Returns a newMetricReaderFactory
which can be registered to aSdkMeterProvider
to start aPeriodicMetricReader
exporting once every minute on a new daemon thread.io.opentelemetry.sdk.common.CompletableResultCode
shutdown()
Shuts down the metric reader.
-
Method Details
-
newMetricReaderFactory
Returns a newMetricReaderFactory
which can be registered to aSdkMeterProvider
to start aPeriodicMetricReader
exporting once every minute on a new daemon thread. -
builder
Returns a newPeriodicMetricReaderBuilder
. -
getPreferredTemporality
Description copied from interface:MetricReader
Return The preferred temporality for metrics.- Specified by:
getPreferredTemporality
in interfaceMetricReader
-
flush
public io.opentelemetry.sdk.common.CompletableResultCode flush()Description copied from interface:MetricReader
Flushes metrics read by this reader.In all scenarios, the associated
MetricProducer
should have itsMetricProducer.collectAllMetrics()
method called.For push endpoints, this should collect and report metrics as normal.
- Specified by:
flush
in interfaceMetricReader
- Returns:
- the result of the shutdown.
-
shutdown
public io.opentelemetry.sdk.common.CompletableResultCode shutdown()Description copied from interface:MetricReader
Shuts 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:
shutdown
in interfaceMetricReader
- Returns:
- the result of the shutdown.
-