Class PrometheusMetricReader

java.lang.Object
io.opentelemetry.exporter.prometheus.PrometheusMetricReader
All Implemented Interfaces:
io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector, io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector, io.opentelemetry.sdk.metrics.export.MetricReader, io.prometheus.metrics.model.registry.MultiCollector, Closeable, AutoCloseable

public class PrometheusMetricReader extends Object implements io.opentelemetry.sdk.metrics.export.MetricReader, io.prometheus.metrics.model.registry.MultiCollector
This is the bridge between Prometheus and OpenTelemetry.

The PrometheusMetricReader is a Prometheus MultiCollector and can be registered with the PrometheusRegistry. It's also an OpenTelemetry MetricReader and can be registered with a SdkMeterProvider.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PrometheusMetricReader(boolean otelScopeEnabled)
    See Otel2PrometheusConverter(boolean).
  • Method Summary

    Modifier and Type
    Method
    Description
    io.prometheus.metrics.model.snapshots.MetricSnapshots
     
    io.opentelemetry.sdk.common.CompletableResultCode
     
    io.opentelemetry.sdk.metrics.data.AggregationTemporality
    getAggregationTemporality(io.opentelemetry.sdk.metrics.InstrumentType instrumentType)
     
    void
    register(io.opentelemetry.sdk.metrics.export.CollectionRegistration registration)
     
    io.opentelemetry.sdk.common.CompletableResultCode
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector

    with

    Methods inherited from interface io.opentelemetry.sdk.metrics.export.MetricReader

    close, getDefaultAggregation, getMemoryMode

    Methods inherited from interface io.prometheus.metrics.model.registry.MultiCollector

    collect, collect, collect, getPrometheusNames
  • Constructor Details

    • PrometheusMetricReader

      public PrometheusMetricReader(boolean otelScopeEnabled)
      See Otel2PrometheusConverter(boolean).
  • Method Details

    • getAggregationTemporality

      public io.opentelemetry.sdk.metrics.data.AggregationTemporality getAggregationTemporality(io.opentelemetry.sdk.metrics.InstrumentType instrumentType)
      Specified by:
      getAggregationTemporality in interface io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector
    • register

      public void register(io.opentelemetry.sdk.metrics.export.CollectionRegistration registration)
      Specified by:
      register in interface io.opentelemetry.sdk.metrics.export.MetricReader
    • forceFlush

      public io.opentelemetry.sdk.common.CompletableResultCode forceFlush()
      Specified by:
      forceFlush in interface io.opentelemetry.sdk.metrics.export.MetricReader
    • shutdown

      public io.opentelemetry.sdk.common.CompletableResultCode shutdown()
      Specified by:
      shutdown in interface io.opentelemetry.sdk.metrics.export.MetricReader
    • collect

      public io.prometheus.metrics.model.snapshots.MetricSnapshots collect()
      Specified by:
      collect in interface io.prometheus.metrics.model.registry.MultiCollector