Class 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 Detail

      • logger

        private static final java.util.logging.Logger logger
      • tracer

        private static final Tracer tracer
      • DESCRIBE_METRICS_FOR_PROMETHEUS

        private static final java.lang.String DESCRIBE_METRICS_FOR_PROMETHEUS
        See Also:
        Constant Field Values
      • EXPORT_METRICS_TO_PROMETHEUS

        private static final java.lang.String EXPORT_METRICS_TO_PROMETHEUS
        See Also:
        Constant Field Values
      • collectMetricReader

        private final MetricReader collectMetricReader
      • describeMetricReader

        private final MetricReader describeMetricReader
      • namespace

        private final java.lang.String namespace
    • Constructor Detail

      • PrometheusStatsCollector

        PrometheusStatsCollector​(MetricProducerManager metricProducerManager,
                                 java.lang.String namespace)
    • Method Detail

      • 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:
        java.lang.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:
        java.lang.IllegalArgumentException - if a PrometheusStatsCollector has already been created and registered.
        Since:
        0.13
      • collect

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

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

        private static java.lang.String exceptionMessage​(java.lang.Throwable e)