Class PeriodicMetricReader
java.lang.Object
io.opentelemetry.sdk.metrics.export.PeriodicMetricReader
- All Implemented Interfaces:
MetricReader
A
MetricReader which 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.static PeriodicMetricReadercreate(MetricExporter exporter) Returns a newPeriodicMetricReaderwhich can be registered to aSdkMeterProviderto start aPeriodicMetricReaderexporting once every minute on a new daemon thread.io.opentelemetry.sdk.common.CompletableResultCodeflush()Flushes metrics read by this reader.getAggregationTemporality(InstrumentType instrumentType) Return the default aggregation temporality for theInstrumentType.voidregister(CollectionRegistration registration) Called bySdkMeterProviderand supplies theMetricReaderwith a handle to collect metrics.io.opentelemetry.sdk.common.CompletableResultCodeshutdown()Shuts down the metric reader.
-
Method Details
-
create
Returns a newPeriodicMetricReaderwhich can be registered to aSdkMeterProviderto start aPeriodicMetricReaderexporting once every minute on a new daemon thread. -
builder
Returns a newPeriodicMetricReaderBuilder. -
getAggregationTemporality
Description copied from interface:MetricReaderReturn the default aggregation temporality for theInstrumentType.- Specified by:
getAggregationTemporalityin interfaceMetricReader
-
flush
public io.opentelemetry.sdk.common.CompletableResultCode flush()Description copied from interface:MetricReaderFlushes metrics read by this reader.In all scenarios, the trigger a metrics collection.
For readers associated with push
MetricExporters, this shouldMetricExporter.export(Collection)the collected metrics.- Specified by:
flushin interfaceMetricReader- Returns:
- the result of the flush.
-
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.
-
register
Description copied from interface:MetricReaderCalled bySdkMeterProviderand supplies theMetricReaderwith a handle to collect metrics.CollectionRegistrationis currently an empty interface because custom implementations ofMetricReaderare not currently supported.- Specified by:
registerin interfaceMetricReader
-