Class PeriodicMetricReader
java.lang.Object
io.opentelemetry.sdk.metrics.export.PeriodicMetricReader
- All Implemented Interfaces:
AggregationTemporalitySelector
,DefaultAggregationSelector
,MetricReader
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 PeriodicMetricReaderBuilder
builder
(MetricExporter exporter) Returns a newPeriodicMetricReaderBuilder
.static PeriodicMetricReader
create
(MetricExporter exporter) Returns a newPeriodicMetricReader
which exports to theexporter
once every minute.io.opentelemetry.sdk.common.CompletableResultCode
Read and export the metrics.getAggregationTemporality
(InstrumentType instrumentType) Return the aggregation temporality for theInstrumentType
.getDefaultAggregation
(InstrumentType instrumentType) Return the default aggregation for theInstrumentType
.void
register
(CollectionRegistration registration) Called bySdkMeterProvider
and supplies theMetricReader
with a handle to collect metrics.io.opentelemetry.sdk.common.CompletableResultCode
shutdown()
Shuts down the metric reader.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector
with
-
Method Details
-
create
Returns a newPeriodicMetricReader
which exports to theexporter
once every minute. -
builder
Returns a newPeriodicMetricReaderBuilder
. -
getAggregationTemporality
Description copied from interface:AggregationTemporalitySelector
Return the aggregation temporality for theInstrumentType
.- Specified by:
getAggregationTemporality
in interfaceAggregationTemporalitySelector
-
getDefaultAggregation
Description copied from interface:MetricReader
Return the default aggregation for theInstrumentType
.- Specified by:
getDefaultAggregation
in interfaceDefaultAggregationSelector
- Specified by:
getDefaultAggregation
in interfaceMetricReader
- See Also:
-
forceFlush
public io.opentelemetry.sdk.common.CompletableResultCode forceFlush()Description copied from interface:MetricReader
Read and export the metrics.Called when
SdkMeterProvider.forceFlush()
is called.- Specified by:
forceFlush
in interfaceMetricReader
- Returns:
- the result of the flush.
-
shutdown
public io.opentelemetry.sdk.common.CompletableResultCode shutdown()Description copied from interface:MetricReader
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.- Specified by:
shutdown
in interfaceMetricReader
- Returns:
- the result of the shutdown.
-
register
Description copied from interface:MetricReader
Called bySdkMeterProvider
and supplies theMetricReader
with a handle to collect metrics.CollectionRegistration
is currently an empty interface because custom implementations ofMetricReader
are not currently supported.- Specified by:
register
in interfaceMetricReader
-
toString
-