@Test public void richGaugePublicMetrics() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class, PublicMetricsAutoConfiguration.class); RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class); assertThat(richGaugeReader).isNotNull(); given(richGaugeReader.findAll()) .willReturn(Collections.singletonList(new RichGauge("bar", 3.7d))); RichGaugeReaderPublicMetrics publicMetrics = context .getBean(RichGaugeReaderPublicMetrics.class); assertThat(publicMetrics).isNotNull(); Collection<Metric<?>> metrics = publicMetrics.metrics(); assertThat(metrics).isNotNull(); assertThat(6).isEqualTo(metrics.size()); assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d)); assertHasMetric(metrics, new Metric<Long>("bar.count", 1L)); context.close(); }
@Test public void richGaugePublicMetrics() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class, PublicMetricsAutoConfiguration.class); RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class); assertNotNull(richGaugeReader); given(richGaugeReader.findAll()) .willReturn(Collections.singletonList(new RichGauge("bar", 3.7d))); RichGaugeReaderPublicMetrics publicMetrics = context .getBean(RichGaugeReaderPublicMetrics.class); assertNotNull(publicMetrics); Collection<Metric<?>> metrics = publicMetrics.metrics(); assertNotNull(metrics); assertEquals(metrics.size(), 6); assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d)); assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d)); assertHasMetric(metrics, new Metric<Long>("bar.count", 1L)); context.close(); }
public MetricsListener(GaugeService gaugeService, RichGaugeReader richGaugeReader, MetricReader metricReader, List<Exporter> exporters) { this.gaugeService = gaugeService; this.richGaugeReader = richGaugeReader; this.metricReader = metricReader; this.exporters = exporters; }
public RichGaugeExporter(RichGaugeReader reader, PrefixMetricWriter writer) { this(reader, writer, ""); }
public RichGaugeExporter(RichGaugeReader reader, PrefixMetricWriter writer, String prefix) { super(prefix); this.reader = reader; this.writer = writer; }
@Bean @ConditionalOnBean(RichGaugeReader.class) public RichGaugeReaderPublicMetrics richGaugePublicMetrics( RichGaugeReader richGaugeReader) { return new RichGaugeReaderPublicMetrics(richGaugeReader); }
public RichGaugeReaderPublicMetrics(RichGaugeReader richGaugeReader) { Assert.notNull(richGaugeReader, "RichGaugeReader must not be null"); this.richGaugeReader = richGaugeReader; }
@Bean public RichGaugeReader richGaugeReader() { return mock(RichGaugeReader.class); }