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 MetricsCollector
for Prometheus.- Since:
- 0.12
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PrometheusStatsCollector.DescribeMetricExporter
private static class
PrometheusStatsCollector.ExportMetricExporter
-
Field Summary
Fields Modifier and Type Field Description private MetricReader
collectMetricReader
private static java.lang.String
DESCRIBE_METRICS_FOR_PROMETHEUS
private MetricReader
describeMetricReader
private static java.lang.String
EXPORT_METRICS_TO_PROMETHEUS
private static java.util.logging.Logger
logger
private java.lang.String
namespace
private static Tracer
tracer
-
Constructor Summary
Constructors Constructor Description PrometheusStatsCollector(MetricProducerManager metricProducerManager, java.lang.String namespace)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<io.prometheus.client.Collector.MetricFamilySamples>
collect()
static void
createAndRegister()
Creates aPrometheusStatsCollector
and registers it to PrometheusCollectorRegistry.defaultRegistry
.static void
createAndRegister(PrometheusStatsConfiguration configuration)
Creates aPrometheusStatsCollector
and registers it to the given PrometheusCollectorRegistry
in thePrometheusStatsConfiguration
.java.util.List<io.prometheus.client.Collector.MetricFamilySamples>
describe()
private static java.lang.String
exceptionMessage(java.lang.Throwable e)
-
-
-
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 aPrometheusStatsCollector
and registers it to PrometheusCollectorRegistry.defaultRegistry
.This is equivalent with:
PrometheusStatsCollector.createAndRegister(PrometheusStatsConfiguration.builder().build());
- Throws:
java.lang.IllegalArgumentException
- if aPrometheusStatsCollector
has already been created and registered.- Since:
- 0.12
-
createAndRegister
public static void createAndRegister(PrometheusStatsConfiguration configuration)
Creates aPrometheusStatsCollector
and registers it to the given PrometheusCollectorRegistry
in thePrometheusStatsConfiguration
.If
CollectorRegistry
of the configuration is not set, the collector will useCollectorRegistry.defaultRegistry
.- Throws:
java.lang.IllegalArgumentException
- if aPrometheusStatsCollector
has already been created and registered.- Since:
- 0.13
-
collect
public java.util.List<io.prometheus.client.Collector.MetricFamilySamples> collect()
- Specified by:
collect
in classio.prometheus.client.Collector
-
describe
public java.util.List<io.prometheus.client.Collector.MetricFamilySamples> describe()
- Specified by:
describe
in interfaceio.prometheus.client.Collector.Describable
-
exceptionMessage
private static java.lang.String exceptionMessage(java.lang.Throwable e)
-
-