Class PrometheusStatsCollector

java.lang.Object
io.prometheus.client.Collector
io.opencensus.exporter.stats.prometheus.PrometheusStatsCollector
All Implemented Interfaces:
io.prometheus.client.Collector.Describable

public final class PrometheusStatsCollector extends io.prometheus.client.Collector implements io.prometheus.client.Collector.Describable
OpenCensus Metrics Collector for Prometheus.
Since:
0.12
  • Field Details

    • logger

      private static final Logger logger
    • tracer

      private static final Tracer tracer
    • DESCRIBE_METRICS_FOR_PROMETHEUS

      private static final String DESCRIBE_METRICS_FOR_PROMETHEUS
      See Also:
    • EXPORT_METRICS_TO_PROMETHEUS

      private static final String EXPORT_METRICS_TO_PROMETHEUS
      See Also:
    • collectMetricReader

      private final MetricReader collectMetricReader
    • describeMetricReader

      private final MetricReader describeMetricReader
    • namespace

      private final String namespace
  • Constructor Details

  • Method Details

    • createAndRegister

      public static void createAndRegister()
      Creates a PrometheusStatsCollector and registers it to Prometheus CollectorRegistry.defaultRegistry.

      This is equivalent with:

      
       PrometheusStatsCollector.createAndRegister(PrometheusStatsConfiguration.builder().build());
       
      Throws:
      IllegalArgumentException - if a PrometheusStatsCollector has already been created and registered.
      Since:
      0.12
    • createAndRegister

      public static void createAndRegister(PrometheusStatsConfiguration configuration)
      Creates a PrometheusStatsCollector and registers it to the given Prometheus CollectorRegistry in the PrometheusStatsConfiguration.

      If CollectorRegistry of the configuration is not set, the collector will use CollectorRegistry.defaultRegistry.

      Throws:
      IllegalArgumentException - if a PrometheusStatsCollector has already been created and registered.
      Since:
      0.13
    • collect

      public List<io.prometheus.client.Collector.MetricFamilySamples> collect()
      Specified by:
      collect in class io.prometheus.client.Collector
    • describe

      public List<io.prometheus.client.Collector.MetricFamilySamples> describe()
      Specified by:
      describe in interface io.prometheus.client.Collector.Describable
    • exceptionMessage

      private static String exceptionMessage(Throwable e)