Class PrometheusExportUtils
- java.lang.Object
-
- io.opencensus.exporter.stats.prometheus.PrometheusExportUtils
-
final class PrometheusExportUtils extends java.lang.Object
Util methods to convert OpenCensus Metrics data models to Prometheus data models.Each OpenCensus
MetricDescriptor
will be converted to a PrometheusCollector.MetricFamilySamples
with noCollector.MetricFamilySamples.Sample
s, and is used for registering PrometheusMetric
s.Each OpenCensus
Metric
will be converted to a PrometheusCollector.MetricFamilySamples
, and eachPoint
of theMetric
will be converted to PrometheusCollector.MetricFamilySamples.Sample
s.io.opencensus.metrics.export.Value.ValueDouble
,io.opencensus.metrics.export.Value.ValueLong
will be converted to a singleCollector.MetricFamilySamples.Sample
.io.opencensus.metrics.export.Value.ValueSummary
will be converted to twoSample
s sum and count.io.opencensus.metrics.export.Value.ValueDistribution
will be converted to a list ofCollector.MetricFamilySamples.Sample
s that have the sum, count and histogram buckets.LabelKey
andLabelValue
will be converted to PrometheusLabelName
andLabelValue
.Null
LabelValue
will be converted to an empty string.Please note that Prometheus Metric and Label name can only have alphanumeric characters and underscore. All other characters will be sanitized by underscores.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
LABEL_NAME_BUCKET_BOUND
(package private) static java.lang.String
LABEL_NAME_QUANTILE
(package private) static java.lang.String
SAMPLE_SUFFIX_BUCKET
(package private) static java.lang.String
SAMPLE_SUFFIX_COUNT
(package private) static java.lang.String
SAMPLE_SUFFIX_SUM
-
Constructor Summary
Constructors Modifier Constructor Description private
PrometheusExportUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static boolean
containsDisallowedLeLabelForHistogram(java.util.List<java.lang.String> labelNames, io.prometheus.client.Collector.Type type)
(package private) static boolean
containsDisallowedQuantileLabelForSummary(java.util.List<java.lang.String> labelNames, io.prometheus.client.Collector.Type type)
(package private) static java.util.List<java.lang.String>
convertToLabelNames(java.util.List<LabelKey> labelKeys)
(package private) static io.prometheus.client.Collector.MetricFamilySamples
createDescribableMetricFamilySamples(MetricDescriptor metricDescriptor, java.lang.String namespace)
(package private) static io.prometheus.client.Collector.MetricFamilySamples
createMetricFamilySamples(Metric metric, java.lang.String namespace)
private static java.lang.String
getNamespacedName(java.lang.String metricName, java.lang.String namespace)
(package private) static java.util.List<io.prometheus.client.Collector.MetricFamilySamples.Sample>
getSamples(java.lang.String name, java.util.List<java.lang.String> labelNames, java.util.List<LabelValue> labelValuesList, Value value)
(package private) static io.prometheus.client.Collector.Type
getType(MetricDescriptor.Type type)
-
-
-
Field Detail
-
SAMPLE_SUFFIX_BUCKET
static final java.lang.String SAMPLE_SUFFIX_BUCKET
- See Also:
- Constant Field Values
-
SAMPLE_SUFFIX_COUNT
static final java.lang.String SAMPLE_SUFFIX_COUNT
- See Also:
- Constant Field Values
-
SAMPLE_SUFFIX_SUM
static final java.lang.String SAMPLE_SUFFIX_SUM
- See Also:
- Constant Field Values
-
LABEL_NAME_BUCKET_BOUND
static final java.lang.String LABEL_NAME_BUCKET_BOUND
- See Also:
- Constant Field Values
-
LABEL_NAME_QUANTILE
static final java.lang.String LABEL_NAME_QUANTILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
createMetricFamilySamples
static io.prometheus.client.Collector.MetricFamilySamples createMetricFamilySamples(Metric metric, java.lang.String namespace)
-
createDescribableMetricFamilySamples
static io.prometheus.client.Collector.MetricFamilySamples createDescribableMetricFamilySamples(MetricDescriptor metricDescriptor, java.lang.String namespace)
-
getNamespacedName
private static java.lang.String getNamespacedName(java.lang.String metricName, java.lang.String namespace)
-
getType
static io.prometheus.client.Collector.Type getType(MetricDescriptor.Type type)
-
getSamples
static java.util.List<io.prometheus.client.Collector.MetricFamilySamples.Sample> getSamples(java.lang.String name, java.util.List<java.lang.String> labelNames, java.util.List<LabelValue> labelValuesList, Value value)
-
convertToLabelNames
static java.util.List<java.lang.String> convertToLabelNames(java.util.List<LabelKey> labelKeys)
-
containsDisallowedLeLabelForHistogram
static boolean containsDisallowedLeLabelForHistogram(java.util.List<java.lang.String> labelNames, io.prometheus.client.Collector.Type type)
-
containsDisallowedQuantileLabelForSummary
static boolean containsDisallowedQuantileLabelForSummary(java.util.List<java.lang.String> labelNames, io.prometheus.client.Collector.Type type)
-
-