Search in sources :

Example 31 with MetricFamilySamples

use of io.prometheus.client.Collector.MetricFamilySamples in project instrumentation-java by census-instrumentation.

the class PrometheusStatsCollectorTest method testCollect.

@Test
public void testCollect() {
    PrometheusStatsCollector collector = new PrometheusStatsCollector(mockMetricProducerManager, "");
    assertThat(collector.collect()).containsExactly(new MetricFamilySamples(METRIC_NAME, Type.HISTOGRAM, METRIC_DESCRIPTION, Arrays.asList(new Sample(METRIC_NAME + "_bucket", Arrays.asList("k1", "k2", "le"), Arrays.asList("v1", "v2", "1.0"), 0), new Sample(METRIC_NAME + "_bucket", Arrays.asList("k1", "k2", "le"), Arrays.asList("v1", "v2", "2.0"), 2), new Sample(METRIC_NAME + "_bucket", Arrays.asList("k1", "k2", "le"), Arrays.asList("v1", "v2", "5.0"), 4), new Sample(METRIC_NAME + "_bucket", Arrays.asList("k1", "k2", "le"), Arrays.asList("v1", "v2", "+Inf"), 5), new Sample(METRIC_NAME + "_count", Arrays.asList("k1", "k2"), Arrays.asList("v1", "v2"), 5), new Sample(METRIC_NAME + "_sum", Arrays.asList("k1", "k2"), Arrays.asList("v1", "v2"), 22.0))));
}
Also used : Sample(io.prometheus.client.Collector.MetricFamilySamples.Sample) MetricFamilySamples(io.prometheus.client.Collector.MetricFamilySamples) Test(org.junit.Test)

Aggregations

MetricFamilySamples (io.prometheus.client.Collector.MetricFamilySamples)31 Sample (io.prometheus.client.Collector.MetricFamilySamples.Sample)17 Test (org.junit.Test)15 HashMap (java.util.HashMap)9 LinkedList (java.util.LinkedList)8 MergableMetricFamilySamples (org.cloudfoundry.promregator.rewrite.MergableMetricFamilySamples)4 IOException (java.io.IOException)3 Collector (io.prometheus.client.Collector)2 Type (io.prometheus.client.Collector.Type)2 Collector.doubleToGoString (io.prometheus.client.Collector.doubleToGoString)2 StringWriter (java.io.StringWriter)2 Writer (java.io.Writer)2 Future (java.util.concurrent.Future)2 CFMetricsFetcher (org.cloudfoundry.promregator.fetcher.CFMetricsFetcher)2 MetricsFetcher (org.cloudfoundry.promregator.fetcher.MetricsFetcher)2 MetricDescriptor (io.opencensus.metrics.export.MetricDescriptor)1 Timer (io.prometheus.client.Histogram.Timer)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 ExecutionException (java.util.concurrent.ExecutionException)1